jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 1 | #ifndef _H_ExternalWrapper |
| 2 | #define _H_ExternalWrapper |
| 3 | /* |
| 4 | * Copyright 2008 Google Inc. |
jat@google.com | 2318196 | 2009-09-03 22:22:56 +0000 | [diff] [blame] | 5 | * |
jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 6 | * 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.com | 2318196 | 2009-09-03 22:22:56 +0000 | [diff] [blame] | 9 | * |
jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
jat@google.com | 2318196 | 2009-09-03 22:22:56 +0000 | [diff] [blame] | 11 | * |
jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 12 | * 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.com | 2318196 | 2009-09-03 22:22:56 +0000 | [diff] [blame] | 25 | #include "Preferences.h" |
jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 26 | #include "FFSessionHandler.h" |
| 27 | #include "Debug.h" |
| 28 | #include "scoped_ptr/scoped_ptr.h" |
jat@google.com | 2318196 | 2009-09-03 22:22:56 +0000 | [diff] [blame] | 29 | |
| 30 | #include "nsCOMPtr.h" |
jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 31 | #include "nsISecurityCheckedComponent.h" |
| 32 | #include "nsStringAPI.h" |
jat@google.com | 2318196 | 2009-09-03 22:22:56 +0000 | [diff] [blame] | 33 | #include "nsIWindowWatcher.h" |
| 34 | #include "nsIDOMWindow.h" |
jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 35 | |
| 36 | class 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.com | 268f998 | 2009-11-06 21:34:25 +0000 | [diff] [blame] | 44 | #define OOPHM_CLASSNAME "GWT DevMode component" |
jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 45 | |
| 46 | class ExternalWrapper : public IOOPHM, |
| 47 | public nsISecurityCheckedComponent { |
| 48 | NS_DECL_ISUPPORTS |
| 49 | NS_DECL_IOOPHM |
| 50 | NS_DECL_NSISECURITYCHECKEDCOMPONENT |
| 51 | |
| 52 | ExternalWrapper(); |
jat@google.com | 2318196 | 2009-09-03 22:22:56 +0000 | [diff] [blame] | 53 | virtual ~ExternalWrapper(); |
| 54 | |
jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 55 | private: |
jat@google.com | 2318196 | 2009-09-03 22:22:56 +0000 | [diff] [blame] | 56 | nsCOMPtr<nsIDOMWindow> domWindow; |
jat@google.com | 268f998 | 2009-11-06 21:34:25 +0000 | [diff] [blame] | 57 | nsCOMPtr<nsIDOMWindowInternal> topWindow; |
| 58 | nsString url; |
jat@google.com | 2318196 | 2009-09-03 22:22:56 +0000 | [diff] [blame] | 59 | nsCOMPtr<Preferences> preferences; |
jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 60 | scoped_ptr<FFSessionHandler> sessionHandler; |
jat@google.com | 2318196 | 2009-09-03 22:22:56 +0000 | [diff] [blame] | 61 | 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.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 77 | }; |
| 78 | |
jat@google.com | 268f998 | 2009-11-06 21:34:25 +0000 | [diff] [blame] | 79 | inline Debug::DebugStream& operator<<(Debug::DebugStream& dbg, |
| 80 | const nsACString& str) { |
jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 81 | nsCString copy(str); |
| 82 | dbg << copy.get(); |
| 83 | return dbg; |
| 84 | } |
| 85 | |
jat@google.com | 268f998 | 2009-11-06 21:34:25 +0000 | [diff] [blame] | 86 | inline 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.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 93 | #endif |