| 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> |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 // Enable DOM automation in created render view hosts. | 47 // Enable DOM automation in created render view hosts. |
| 48 static void EnableDOMAutomation() { enable_dom_automation_ = true; } | 48 static void EnableDOMAutomation() { enable_dom_automation_ = true; } |
| 49 | 49 |
| 50 ExtensionHost(const Extension* extension, SiteInstance* site_instance, | 50 ExtensionHost(const Extension* extension, SiteInstance* site_instance, |
| 51 const GURL& url, ViewType::Type host_type); | 51 const GURL& url, ViewType::Type host_type); |
| 52 ~ExtensionHost(); | 52 ~ExtensionHost(); |
| 53 | 53 |
| 54 #if defined(TOOLKIT_VIEWS) | 54 #if defined(TOOLKIT_VIEWS) |
| 55 void set_view(ExtensionView* view) { view_.reset(view); } | 55 void set_view(ExtensionView* view) { view_.reset(view); } |
| 56 ExtensionView* view() const { return view_.get(); } | 56 const ExtensionView* view() const { return view_.get(); } |
| 57 ExtensionView* view() { return view_.get(); } |
| 57 #elif defined(OS_MACOSX) | 58 #elif defined(OS_MACOSX) |
| 58 ExtensionViewMac* view() const { return view_.get(); } | 59 const ExtensionViewMac* view() const { return view_.get(); } |
| 60 ExtensionViewMac* view() { return view_.get(); } |
| 59 #elif defined(TOOLKIT_GTK) | 61 #elif defined(TOOLKIT_GTK) |
| 60 ExtensionViewGtk* view() const { return view_.get(); } | 62 const ExtensionViewGtk* view() const { return view_.get(); } |
| 61 #else | 63 ExtensionViewGtk* view() { return view_.get(); } |
| 62 // TODO(port): implement | |
| 63 void* view() const { return NULL; } | |
| 64 #endif | 64 #endif |
| 65 | 65 |
| 66 // Create an ExtensionView and tie it to this host and |browser|. Note NULL | 66 // Create an ExtensionView and tie it to this host and |browser|. Note NULL |
| 67 // is a valid argument for |browser|. Extension views may be bound to | 67 // is a valid argument for |browser|. Extension views may be bound to |
| 68 // tab-contents hosted in ExternalTabContainer objects, which do not | 68 // tab-contents hosted in ExternalTabContainer objects, which do not |
| 69 // instantiate Browser objects. | 69 // instantiate Browser objects. |
| 70 void CreateView(Browser* browser); | 70 void CreateView(Browser* browser); |
| 71 | 71 |
| 72 const Extension* extension() { return extension_; } | 72 const Extension* extension() const { return extension_; } |
| 73 RenderViewHost* render_view_host() const { return render_view_host_; } | 73 RenderViewHost* render_view_host() const { return render_view_host_; } |
| 74 RenderProcessHost* render_process_host() const; | 74 RenderProcessHost* render_process_host() const; |
| 75 SiteInstance* site_instance() const; | 75 SiteInstance* site_instance() const; |
| 76 bool did_stop_loading() const { return did_stop_loading_; } | 76 bool did_stop_loading() const { return did_stop_loading_; } |
| 77 bool document_element_available() const { | 77 bool document_element_available() const { |
| 78 return document_element_available_; | 78 return document_element_available_; |
| 79 } | 79 } |
| 80 | 80 |
| 81 Profile* profile() const { return profile_; } | 81 Profile* profile() const { return profile_; } |
| 82 | 82 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 private: | 213 private: |
| 214 friend class ProcessCreationQueue; | 214 friend class ProcessCreationQueue; |
| 215 | 215 |
| 216 // Whether to allow DOM automation for created RenderViewHosts. This is used | 216 // Whether to allow DOM automation for created RenderViewHosts. This is used |
| 217 // for testing. | 217 // for testing. |
| 218 static bool enable_dom_automation_; | 218 static bool enable_dom_automation_; |
| 219 | 219 |
| 220 // Actually create the RenderView for this host. See CreateRenderViewSoon. | 220 // Actually create the RenderView for this host. See CreateRenderViewSoon. |
| 221 void CreateRenderViewNow(); | 221 void CreateRenderViewNow(); |
| 222 | 222 |
| 223 // Const version of below function. |
| 224 const Browser* GetBrowser() const; |
| 225 |
| 223 // ExtensionFunctionDispatcher::Delegate | 226 // ExtensionFunctionDispatcher::Delegate |
| 224 virtual Browser* GetBrowser() const; | 227 virtual Browser* GetBrowser(); |
| 225 virtual gfx::NativeView GetNativeViewOfHost(); | 228 virtual gfx::NativeView GetNativeViewOfHost(); |
| 226 | 229 |
| 227 // Handles keyboard events that were not handled by HandleKeyboardEvent(). | 230 // Handles keyboard events that were not handled by HandleKeyboardEvent(). |
| 228 // Platform specific implementation may override this method to handle the | 231 // Platform specific implementation may override this method to handle the |
| 229 // event in platform specific way. | 232 // event in platform specific way. |
| 230 virtual void UnhandledKeyboardEvent(const NativeWebKeyboardEvent& event) {} | 233 virtual void UnhandledKeyboardEvent(const NativeWebKeyboardEvent& event) {} |
| 231 | 234 |
| 232 // Returns true if we're hosting a background page. | 235 // Returns true if we're hosting a background page. |
| 233 // This isn't valid until CreateRenderView is called. | 236 // This isn't valid until CreateRenderView is called. |
| 234 bool is_background_page() const { return !view(); } | 237 bool is_background_page() const { return !view(); } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 // Used to measure how long it's been since the host was created. | 280 // Used to measure how long it's been since the host was created. |
| 278 PerfTimer since_created_; | 281 PerfTimer since_created_; |
| 279 | 282 |
| 280 // FileSelectHelper, lazily created. | 283 // FileSelectHelper, lazily created. |
| 281 scoped_ptr<FileSelectHelper> file_select_helper_; | 284 scoped_ptr<FileSelectHelper> file_select_helper_; |
| 282 | 285 |
| 283 DISALLOW_COPY_AND_ASSIGN(ExtensionHost); | 286 DISALLOW_COPY_AND_ASSIGN(ExtensionHost); |
| 284 }; | 287 }; |
| 285 | 288 |
| 286 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ | 289 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ |
| OLD | NEW |