| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/perftimer.h" | 13 #include "base/perftimer.h" |
| 14 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 14 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
| 15 #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" | 15 #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" |
| 16 #include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h" | 16 #include "content/browser/javascript_dialogs.h" |
| 17 #include "content/browser/renderer_host/render_view_host_delegate.h" | 17 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 18 #include "content/common/notification_observer.h" |
| 18 #include "content/common/notification_registrar.h" | 19 #include "content/common/notification_registrar.h" |
| 19 | 20 |
| 20 #if defined(TOOLKIT_VIEWS) | 21 #if defined(TOOLKIT_VIEWS) |
| 21 #include "chrome/browser/ui/views/extensions/extension_view.h" | 22 #include "chrome/browser/ui/views/extensions/extension_view.h" |
| 22 #elif defined(OS_MACOSX) | 23 #elif defined(OS_MACOSX) |
| 23 #include "chrome/browser/ui/cocoa/extensions/extension_view_mac.h" | 24 #include "chrome/browser/ui/cocoa/extensions/extension_view_mac.h" |
| 24 #elif defined(TOOLKIT_GTK) | 25 #elif defined(TOOLKIT_GTK) |
| 25 #include "chrome/browser/ui/gtk/extensions/extension_view_gtk.h" | 26 #include "chrome/browser/ui/gtk/extensions/extension_view_gtk.h" |
| 26 #endif | 27 #endif |
| 27 | 28 |
| 28 class Browser; | 29 class Browser; |
| 29 class Extension; | 30 class Extension; |
| 30 class FileSelectHelper; | 31 class FileSelectHelper; |
| 31 class RenderProcessHost; | 32 class RenderProcessHost; |
| 32 class RenderWidgetHostView; | 33 class RenderWidgetHostView; |
| 33 class TabContents; | 34 class TabContents; |
| 34 struct ViewHostMsg_RunFileChooser_Params; | 35 struct ViewHostMsg_RunFileChooser_Params; |
| 35 struct WebPreferences; | 36 struct WebPreferences; |
| 36 | 37 |
| 37 // This class is the browser component of an extension component's RenderView. | 38 // This class is the browser component of an extension component's RenderView. |
| 38 // It handles setting up the renderer process, if needed, with special | 39 // It handles setting up the renderer process, if needed, with special |
| 39 // privileges available to extensions. It may have a view to be shown in the | 40 // privileges available to extensions. It may have a view to be shown in the |
| 40 // browser UI, or it may be hidden. | 41 // browser UI, or it may be hidden. |
| 41 class ExtensionHost : public RenderViewHostDelegate, | 42 class ExtensionHost : public RenderViewHostDelegate, |
| 42 public RenderViewHostDelegate::View, | 43 public RenderViewHostDelegate::View, |
| 43 public ExtensionFunctionDispatcher::Delegate, | 44 public ExtensionFunctionDispatcher::Delegate, |
| 44 public NotificationObserver, | 45 public NotificationObserver, |
| 45 public JavaScriptAppModalDialogDelegate { | 46 public content::JavaScriptDialogDelegate { |
| 46 public: | 47 public: |
| 47 class ProcessCreationQueue; | 48 class ProcessCreationQueue; |
| 48 | 49 |
| 49 // Enable DOM automation in created render view hosts. | 50 // Enable DOM automation in created render view hosts. |
| 50 static void EnableDOMAutomation() { enable_dom_automation_ = true; } | 51 static void EnableDOMAutomation() { enable_dom_automation_ = true; } |
| 51 | 52 |
| 52 ExtensionHost(const Extension* extension, SiteInstance* site_instance, | 53 ExtensionHost(const Extension* extension, SiteInstance* site_instance, |
| 53 const GURL& url, ViewType::Type host_type); | 54 const GURL& url, ViewType::Type host_type); |
| 54 virtual ~ExtensionHost(); | 55 virtual ~ExtensionHost(); |
| 55 | 56 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 virtual void UpdatePreferredSize(const gfx::Size& new_size); | 181 virtual void UpdatePreferredSize(const gfx::Size& new_size); |
| 181 virtual void UpdateInspectorSetting(const std::string& key, | 182 virtual void UpdateInspectorSetting(const std::string& key, |
| 182 const std::string& value); | 183 const std::string& value); |
| 183 virtual void ClearInspectorSettings(); | 184 virtual void ClearInspectorSettings(); |
| 184 | 185 |
| 185 // NotificationObserver | 186 // NotificationObserver |
| 186 virtual void Observe(NotificationType type, | 187 virtual void Observe(NotificationType type, |
| 187 const NotificationSource& source, | 188 const NotificationSource& source, |
| 188 const NotificationDetails& details); | 189 const NotificationDetails& details); |
| 189 | 190 |
| 190 // Overridden from JavaScriptAppModalDialogDelegate: | 191 // Overridden from content::JavaScriptDialogDelegate: |
| 191 virtual void OnMessageBoxClosed(IPC::Message* reply_msg, | 192 virtual void OnDialogClosed(IPC::Message* reply_msg, |
| 192 bool success, | 193 bool success, |
| 193 const std::wstring& user_input); | 194 const string16& user_input) OVERRIDE; |
| 194 virtual void SetSuppressMessageBoxes(bool suppress_message_boxes); | 195 virtual gfx::NativeWindow GetDialogRootWindow() OVERRIDE; |
| 195 virtual gfx::NativeWindow GetMessageBoxRootWindow(); | 196 virtual TabContents* AsTabContents() OVERRIDE; |
| 196 virtual TabContents* AsTabContents(); | 197 virtual ExtensionHost* AsExtensionHost() OVERRIDE; |
| 197 virtual ExtensionHost* AsExtensionHost(); | |
| 198 | 198 |
| 199 protected: | 199 protected: |
| 200 // Internal functions used to support the CreateNewWidget() method. If a | 200 // Internal functions used to support the CreateNewWidget() method. If a |
| 201 // platform requires plugging into widget creation at a lower level, then a | 201 // platform requires plugging into widget creation at a lower level, then a |
| 202 // subclass might want to override these functions, but otherwise they should | 202 // subclass might want to override these functions, but otherwise they should |
| 203 // be fine just implementing RenderWidgetHostView::InitAsPopup(). | 203 // be fine just implementing RenderWidgetHostView::InitAsPopup(). |
| 204 // | 204 // |
| 205 // The Create function returns the newly created widget so it can be | 205 // The Create function returns the newly created widget so it can be |
| 206 // associated with the given route. When the widget needs to be shown later, | 206 // associated with the given route. When the widget needs to be shown later, |
| 207 // we'll look it up again and pass the object to the Show functions rather | 207 // we'll look it up again and pass the object to the Show functions rather |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 | 284 |
| 285 // The relevant TabContents associated with this ExtensionHost, if any. | 285 // The relevant TabContents associated with this ExtensionHost, if any. |
| 286 TabContents* associated_tab_contents_; | 286 TabContents* associated_tab_contents_; |
| 287 | 287 |
| 288 // Used to measure how long it's been since the host was created. | 288 // Used to measure how long it's been since the host was created. |
| 289 PerfTimer since_created_; | 289 PerfTimer since_created_; |
| 290 | 290 |
| 291 // FileSelectHelper, lazily created. | 291 // FileSelectHelper, lazily created. |
| 292 scoped_ptr<FileSelectHelper> file_select_helper_; | 292 scoped_ptr<FileSelectHelper> file_select_helper_; |
| 293 | 293 |
| 294 // The time that the last javascript message was dismissed. | |
| 295 base::TimeTicks last_javascript_message_dismissal_; | |
| 296 | |
| 297 // Whether to suppress all javascript messages. | |
| 298 bool suppress_javascript_messages_; | |
| 299 | |
| 300 DISALLOW_COPY_AND_ASSIGN(ExtensionHost); | 294 DISALLOW_COPY_AND_ASSIGN(ExtensionHost); |
| 301 }; | 295 }; |
| 302 | 296 |
| 303 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ | 297 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ |
| OLD | NEW |