blob: 9d012e1ce0ca365cc825faf0f48f5d5df5905c6f [file] [log] [blame]
jat@google.com134be542009-08-03 15:30:11 +00001#ifndef _H_ExternalWrapper
2#define _H_ExternalWrapper
3/*
4 * Copyright 2008 Google Inc.
jat@google.com23181962009-09-03 22:22:56 +00005 *
jat@google.com134be542009-08-03 15:30:11 +00006 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
7 * use this file except in compliance with the License. You may obtain a copy of
8 * the License at
jat@google.com23181962009-09-03 22:22:56 +00009 *
jat@google.com134be542009-08-03 15:30:11 +000010 * http://www.apache.org/licenses/LICENSE-2.0
jat@google.com23181962009-09-03 22:22:56 +000011 *
jat@google.com134be542009-08-03 15:30:11 +000012 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15 * License for the specific language governing permissions and limitations under
16 * the License.
17 */
18
19#include <string>
20
21#include "mozincludes.h"
22
23#include "IOOPHM.h"
24
jat@google.com23181962009-09-03 22:22:56 +000025#include "Preferences.h"
jat@google.com134be542009-08-03 15:30:11 +000026#include "FFSessionHandler.h"
27#include "Debug.h"
28#include "scoped_ptr/scoped_ptr.h"
jat@google.com23181962009-09-03 22:22:56 +000029
30#include "nsCOMPtr.h"
jat@google.com134be542009-08-03 15:30:11 +000031#include "nsISecurityCheckedComponent.h"
32#include "nsStringAPI.h"
jat@google.com23181962009-09-03 22:22:56 +000033#include "nsIWindowWatcher.h"
34#include "nsIDOMWindow.h"
jat@google.com134be542009-08-03 15:30:11 +000035
36class nsIDOMWindow;
37
38// {028DD88B-6D65-401D-AAFD-17E497D15D09}
39#define OOPHM_CID \
40 { 0x028DD88B, 0x6D65, 0x401D, \
41 { 0xAA, 0xFD, 0x17, 0xE4, 0x97, 0xD1, 0x5D, 0x09 } }
42
43#define OOPHM_CONTRACTID "@gwt.google.com/oophm/ExternalWrapper;1"
jat@google.com268f9982009-11-06 21:34:25 +000044#define OOPHM_CLASSNAME "GWT DevMode component"
jat@google.com134be542009-08-03 15:30:11 +000045
46class ExternalWrapper : public IOOPHM,
47 public nsISecurityCheckedComponent {
48 NS_DECL_ISUPPORTS
49 NS_DECL_IOOPHM
50 NS_DECL_NSISECURITYCHECKEDCOMPONENT
51
52 ExternalWrapper();
jat@google.com23181962009-09-03 22:22:56 +000053 virtual ~ExternalWrapper();
54
jat@google.com134be542009-08-03 15:30:11 +000055private:
jat@google.com23181962009-09-03 22:22:56 +000056 nsCOMPtr<nsIDOMWindow> domWindow;
jat@google.com268f9982009-11-06 21:34:25 +000057 nsCOMPtr<nsIDOMWindowInternal> topWindow;
58 nsString url;
jat@google.com23181962009-09-03 22:22:56 +000059 nsCOMPtr<Preferences> preferences;
jat@google.com134be542009-08-03 15:30:11 +000060 scoped_ptr<FFSessionHandler> sessionHandler;
jat@google.com23181962009-09-03 22:22:56 +000061 nsCOMPtr<nsIWindowWatcher> windowWatcher;
62
63 /**
64 * Prompt the user whether a connection should be allowed, and optionally
65 * update the preferences.
66 */
67 bool askUserToAllow(const std::string& url);
68
69 /**
70 * Compute a stable tab identity value for the DOM window.
71 *
72 * @return a unique tab identifier which is stable across reloads, or an
73 * empty string if it cannot be computed
74 */
75 std::string computeTabIdentity();
76
jat@google.com134be542009-08-03 15:30:11 +000077};
78
jat@google.com268f9982009-11-06 21:34:25 +000079inline Debug::DebugStream& operator<<(Debug::DebugStream& dbg,
80 const nsACString& str) {
jat@google.com134be542009-08-03 15:30:11 +000081 nsCString copy(str);
82 dbg << copy.get();
83 return dbg;
84}
85
jat@google.com268f9982009-11-06 21:34:25 +000086inline Debug::DebugStream& operator<<(Debug::DebugStream& dbg,
87 const nsAString& str) {
88 NS_ConvertUTF16toUTF8 copy(str);
89 dbg << copy.get();
90 return dbg;
91}
92
jat@google.com134be542009-08-03 15:30:11 +000093#endif