| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 EXTENSIONS_BROWSER_EXTENSION_HOST_H_ | 5 #ifndef EXTENSIONS_BROWSER_EXTENSION_HOST_H_ |
| 6 #define EXTENSIONS_BROWSER_EXTENSION_HOST_H_ | 6 #define EXTENSIONS_BROWSER_EXTENSION_HOST_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 class ExtensionHost : public content::WebContentsDelegate, | 43 class ExtensionHost : public content::WebContentsDelegate, |
| 44 public content::WebContentsObserver, | 44 public content::WebContentsObserver, |
| 45 public ExtensionFunctionDispatcher::Delegate, | 45 public ExtensionFunctionDispatcher::Delegate, |
| 46 public content::NotificationObserver { | 46 public content::NotificationObserver { |
| 47 public: | 47 public: |
| 48 class ProcessCreationQueue; | 48 class ProcessCreationQueue; |
| 49 | 49 |
| 50 ExtensionHost(const Extension* extension, | 50 ExtensionHost(const Extension* extension, |
| 51 content::SiteInstance* site_instance, | 51 content::SiteInstance* site_instance, |
| 52 const GURL& url, ViewType host_type); | 52 const GURL& url, ViewType host_type); |
| 53 virtual ~ExtensionHost(); | 53 ~ExtensionHost() override; |
| 54 | 54 |
| 55 const Extension* extension() const { return extension_; } | 55 const Extension* extension() const { return extension_; } |
| 56 const std::string& extension_id() const { return extension_id_; } | 56 const std::string& extension_id() const { return extension_id_; } |
| 57 content::WebContents* host_contents() const { return host_contents_.get(); } | 57 content::WebContents* host_contents() const { return host_contents_.get(); } |
| 58 content::RenderViewHost* render_view_host() const; | 58 content::RenderViewHost* render_view_host() const; |
| 59 content::RenderProcessHost* render_process_host() const; | 59 content::RenderProcessHost* render_process_host() const; |
| 60 bool did_stop_loading() const { return did_stop_loading_; } | 60 bool did_stop_loading() const { return did_stop_loading_; } |
| 61 bool document_element_available() const { | 61 bool document_element_available() const { |
| 62 return document_element_available_; | 62 return document_element_available_; |
| 63 } | 63 } |
| 64 | 64 |
| 65 content::BrowserContext* browser_context() { return browser_context_; } | 65 content::BrowserContext* browser_context() { return browser_context_; } |
| 66 | 66 |
| 67 ViewType extension_host_type() const { return extension_host_type_; } | 67 ViewType extension_host_type() const { return extension_host_type_; } |
| 68 const GURL& GetURL() const; | 68 const GURL& GetURL() const; |
| 69 | 69 |
| 70 // Returns true if the render view is initialized and didn't crash. | 70 // Returns true if the render view is initialized and didn't crash. |
| 71 bool IsRenderViewLive() const; | 71 bool IsRenderViewLive() const; |
| 72 | 72 |
| 73 // Prepares to initializes our RenderViewHost by creating its RenderView and | 73 // Prepares to initializes our RenderViewHost by creating its RenderView and |
| 74 // navigating to this host's url. Uses host_view for the RenderViewHost's view | 74 // navigating to this host's url. Uses host_view for the RenderViewHost's view |
| 75 // (can be NULL). This happens delayed to avoid locking the UI. | 75 // (can be NULL). This happens delayed to avoid locking the UI. |
| 76 void CreateRenderViewSoon(); | 76 void CreateRenderViewSoon(); |
| 77 | 77 |
| 78 // content::WebContentsObserver | 78 // content::WebContentsObserver |
| 79 virtual bool OnMessageReceived(const IPC::Message& message) override; | 79 bool OnMessageReceived(const IPC::Message& message) override; |
| 80 virtual void RenderViewCreated( | 80 void RenderViewCreated(content::RenderViewHost* render_view_host) override; |
| 81 content::RenderViewHost* render_view_host) override; | 81 void RenderViewDeleted(content::RenderViewHost* render_view_host) override; |
| 82 virtual void RenderViewDeleted( | 82 void RenderViewReady() override; |
| 83 content::RenderViewHost* render_view_host) override; | 83 void RenderProcessGone(base::TerminationStatus status) override; |
| 84 virtual void RenderViewReady() override; | 84 void DocumentAvailableInMainFrame() override; |
| 85 virtual void RenderProcessGone(base::TerminationStatus status) override; | 85 void DidStopLoading(content::RenderViewHost* render_view_host) override; |
| 86 virtual void DocumentAvailableInMainFrame() override; | |
| 87 virtual void DidStopLoading( | |
| 88 content::RenderViewHost* render_view_host) override; | |
| 89 | 86 |
| 90 // content::WebContentsDelegate | 87 // content::WebContentsDelegate |
| 91 virtual content::JavaScriptDialogManager* | 88 content::JavaScriptDialogManager* GetJavaScriptDialogManager() override; |
| 92 GetJavaScriptDialogManager() override; | 89 void AddNewContents(content::WebContents* source, |
| 93 virtual void AddNewContents(content::WebContents* source, | 90 content::WebContents* new_contents, |
| 94 content::WebContents* new_contents, | 91 WindowOpenDisposition disposition, |
| 95 WindowOpenDisposition disposition, | 92 const gfx::Rect& initial_pos, |
| 96 const gfx::Rect& initial_pos, | 93 bool user_gesture, |
| 97 bool user_gesture, | 94 bool* was_blocked) override; |
| 98 bool* was_blocked) override; | 95 void CloseContents(content::WebContents* contents) override; |
| 99 virtual void CloseContents(content::WebContents* contents) override; | 96 void RequestMediaAccessPermission( |
| 100 virtual void RequestMediaAccessPermission( | |
| 101 content::WebContents* web_contents, | 97 content::WebContents* web_contents, |
| 102 const content::MediaStreamRequest& request, | 98 const content::MediaStreamRequest& request, |
| 103 const content::MediaResponseCallback& callback) override; | 99 const content::MediaResponseCallback& callback) override; |
| 104 virtual bool CheckMediaAccessPermission( | 100 bool CheckMediaAccessPermission(content::WebContents* web_contents, |
| 105 content::WebContents* web_contents, | 101 const GURL& security_origin, |
| 106 const GURL& security_origin, | 102 content::MediaStreamType type) override; |
| 107 content::MediaStreamType type) override; | 103 bool IsNeverVisible(content::WebContents* web_contents) override; |
| 108 virtual bool IsNeverVisible(content::WebContents* web_contents) override; | |
| 109 | 104 |
| 110 // content::NotificationObserver | 105 // content::NotificationObserver |
| 111 virtual void Observe(int type, | 106 void Observe(int type, |
| 112 const content::NotificationSource& source, | 107 const content::NotificationSource& source, |
| 113 const content::NotificationDetails& details) override; | 108 const content::NotificationDetails& details) override; |
| 114 | 109 |
| 115 protected: | 110 protected: |
| 116 content::NotificationRegistrar* registrar() { return ®istrar_; } | 111 content::NotificationRegistrar* registrar() { return ®istrar_; } |
| 117 | 112 |
| 118 // Called after the extension page finishes loading but before the | 113 // Called after the extension page finishes loading but before the |
| 119 // EXTENSION_HOST_DID_STOP_LOADING notification is sent. | 114 // EXTENSION_HOST_DID_STOP_LOADING notification is sent. |
| 120 virtual void OnDidStopLoading(); | 115 virtual void OnDidStopLoading(); |
| 121 | 116 |
| 122 // Called once when the document first becomes available. | 117 // Called once when the document first becomes available. |
| 123 virtual void OnDocumentAvailable(); | 118 virtual void OnDocumentAvailable(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 176 |
| 182 // Used to measure how long it's been since the host was created. | 177 // Used to measure how long it's been since the host was created. |
| 183 base::ElapsedTimer since_created_; | 178 base::ElapsedTimer since_created_; |
| 184 | 179 |
| 185 DISALLOW_COPY_AND_ASSIGN(ExtensionHost); | 180 DISALLOW_COPY_AND_ASSIGN(ExtensionHost); |
| 186 }; | 181 }; |
| 187 | 182 |
| 188 } // namespace extensions | 183 } // namespace extensions |
| 189 | 184 |
| 190 #endif // EXTENSIONS_BROWSER_EXTENSION_HOST_H_ | 185 #endif // EXTENSIONS_BROWSER_EXTENSION_HOST_H_ |
| OLD | NEW |