Avi Drissman | 60039d4 | 2022-09-13 21:49:05 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors |
[email protected] | c6463165 | 2009-04-29 22:24:31 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 22401dc | 2014-03-21 01:38:57 | [diff] [blame] | 5 | #ifndef EXTENSIONS_BROWSER_EXTENSION_HOST_H_ |
| 6 | #define EXTENSIONS_BROWSER_EXTENSION_HOST_H_ |
[email protected] | c6463165 | 2009-04-29 22:24:31 | [diff] [blame] | 7 | |
avi | c9cec10 | 2015-12-23 00:39:26 | [diff] [blame] | 8 | #include <stdint.h> |
| 9 | |
dcheng | f5d24108 | 2016-04-21 03:43:11 | [diff] [blame] | 10 | #include <memory> |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 11 | #include <string> |
David Bertoni | 3e1e9fa | 2018-08-29 20:39:30 | [diff] [blame] | 12 | #include <unordered_map> |
[email protected] | 8a17bd5 | 2009-06-06 08:19:49 | [diff] [blame] | 13 | |
Devlin Cronin | 36eecdae0 | 2022-07-07 18:15:08 | [diff] [blame] | 14 | #include "base/callback.h" |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 15 | #include "base/memory/raw_ptr.h" |
danakj | 62dd09e1 | 2021-02-05 04:23:35 | [diff] [blame] | 16 | #include "base/memory/weak_ptr.h" |
chirantan | 79788f6 | 2015-02-02 23:57:25 | [diff] [blame] | 17 | #include "base/observer_list.h" |
[email protected] | bd5a374 | 2013-09-29 18:06:13 | [diff] [blame] | 18 | #include "base/timer/elapsed_timer.h" |
Guido Urdaneta | 73fa663 | 2019-01-14 18:46:26 | [diff] [blame] | 19 | #include "content/public/browser/media_stream_request.h" |
[email protected] | 674bc59 | 2011-12-20 23:00:42 | [diff] [blame] | 20 | #include "content/public/browser/web_contents_delegate.h" |
[email protected] | d8c66043 | 2011-12-22 20:51:25 | [diff] [blame] | 21 | #include "content/public/browser/web_contents_observer.h" |
yoz | d61dfe19 | 2015-02-21 01:30:37 | [diff] [blame] | 22 | #include "extensions/browser/deferred_start_render_host.h" |
[email protected] | 0b9de03 | 2014-03-15 05:47:01 | [diff] [blame] | 23 | #include "extensions/browser/extension_function_dispatcher.h" |
limasdf | bbaa913d | 2015-03-02 23:52:33 | [diff] [blame] | 24 | #include "extensions/browser/extension_registry_observer.h" |
Julie Jeongeun Kim | 73c8cc3 | 2021-02-26 03:17:59 | [diff] [blame] | 25 | #include "extensions/common/mojom/view_type.mojom.h" |
[email protected] | 88b50b6 | 2013-09-01 23:05:06 | [diff] [blame] | 26 | #include "extensions/common/stack_frame.h" |
[email protected] | 5de63471 | 2011-03-02 00:20:19 | [diff] [blame] | 27 | |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 28 | namespace content { |
[email protected] | 9fe4204 | 2013-10-29 21:13:33 | [diff] [blame] | 29 | class BrowserContext; |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 30 | class RenderProcessHost; |
[email protected] | b658359 | 2012-01-25 19:52:33 | [diff] [blame] | 31 | class SiteInstance; |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 32 | } |
| 33 | |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 34 | namespace extensions { |
| 35 | class Extension; |
[email protected] | 6c0f179f | 2014-03-19 11:04:41 | [diff] [blame] | 36 | class ExtensionHostDelegate; |
chirantan | 79788f6 | 2015-02-02 23:57:25 | [diff] [blame] | 37 | class ExtensionHostObserver; |
kalman | fcece45 | 2015-02-18 18:20:42 | [diff] [blame] | 38 | class ExtensionHostQueue; |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 39 | |
danakj | 62dd09e1 | 2021-02-05 04:23:35 | [diff] [blame] | 40 | // This class is the browser component of an extension component's page. |
[email protected] | c6463165 | 2009-04-29 22:24:31 | [diff] [blame] | 41 | // It handles setting up the renderer process, if needed, with special |
| 42 | // privileges available to extensions. It may have a view to be shown in the |
[email protected] | 2d2f6cfc | 2011-05-06 21:09:33 | [diff] [blame] | 43 | // browser UI, or it may be hidden. |
[email protected] | 22401dc | 2014-03-21 01:38:57 | [diff] [blame] | 44 | // |
| 45 | // If you are adding code that only affects visible extension views (and not |
| 46 | // invisible background pages) you should add it to ExtensionViewHost. |
yoz | d61dfe19 | 2015-02-21 01:30:37 | [diff] [blame] | 47 | class ExtensionHost : public DeferredStartRenderHost, |
| 48 | public content::WebContentsDelegate, |
[email protected] | d8c66043 | 2011-12-22 20:51:25 | [diff] [blame] | 49 | public content::WebContentsObserver, |
[email protected] | e95ad33 | 2009-08-03 19:44:25 | [diff] [blame] | 50 | public ExtensionFunctionDispatcher::Delegate, |
limasdf | bbaa913d | 2015-03-02 23:52:33 | [diff] [blame] | 51 | public ExtensionRegistryObserver { |
[email protected] | c6463165 | 2009-04-29 22:24:31 | [diff] [blame] | 52 | public: |
Devlin Cronin | 36eecdae0 | 2022-07-07 18:15:08 | [diff] [blame] | 53 | using CloseHandler = base::OnceCallback<void(ExtensionHost*)>; |
| 54 | |
[email protected] | 3a1dc57 | 2012-07-31 22:25:13 | [diff] [blame] | 55 | ExtensionHost(const Extension* extension, |
[email protected] | b658359 | 2012-01-25 19:52:33 | [diff] [blame] | 56 | content::SiteInstance* site_instance, |
Julie Jeongeun Kim | 73c8cc3 | 2021-02-26 03:17:59 | [diff] [blame] | 57 | const GURL& url, |
| 58 | mojom::ViewType host_type); |
Peter Boström | 951cf77e | 2021-09-22 00:02:59 | [diff] [blame] | 59 | |
| 60 | ExtensionHost(const ExtensionHost&) = delete; |
| 61 | ExtensionHost& operator=(const ExtensionHost&) = delete; |
| 62 | |
dcheng | 9168b2f | 2014-10-21 12:38:24 | [diff] [blame] | 63 | ~ExtensionHost() override; |
[email protected] | c6463165 | 2009-04-29 22:24:31 | [diff] [blame] | 64 | |
Karan Bhatia | ee1e6a5 | 2017-11-09 21:32:51 | [diff] [blame] | 65 | // This may be null if the extension has been or is being unloaded. |
[email protected] | 3a1dc57 | 2012-07-31 22:25:13 | [diff] [blame] | 66 | const Extension* extension() const { return extension_; } |
Karan Bhatia | ee1e6a5 | 2017-11-09 21:32:51 | [diff] [blame] | 67 | |
[email protected] | 2d2f6cfc | 2011-05-06 21:09:33 | [diff] [blame] | 68 | const std::string& extension_id() const { return extension_id_; } |
[email protected] | 3a7d7d3 | 2012-01-05 17:44:01 | [diff] [blame] | 69 | content::WebContents* host_contents() const { return host_contents_.get(); } |
danakj | 62dd09e1 | 2021-02-05 04:23:35 | [diff] [blame] | 70 | content::RenderFrameHost* main_frame_host() const { return main_frame_host_; } |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 71 | content::RenderProcessHost* render_process_host() const; |
kalman | fd474fa | 2015-03-16 22:30:57 | [diff] [blame] | 72 | bool has_loaded_once() const { return has_loaded_once_; } |
rdevlin.cronin | b48a98e | 2015-05-01 00:00:28 | [diff] [blame] | 73 | const GURL& initial_url() const { return initial_url_; } |
[email protected] | e95ad33 | 2009-08-03 19:44:25 | [diff] [blame] | 74 | bool document_element_available() const { |
| 75 | return document_element_available_; |
| 76 | } |
[email protected] | 01f829a | 2010-03-17 18:20:31 | [diff] [blame] | 77 | |
[email protected] | 96e6a103 | 2013-11-28 06:58:03 | [diff] [blame] | 78 | content::BrowserContext* browser_context() { return browser_context_; } |
[email protected] | 9fe4204 | 2013-10-29 21:13:33 | [diff] [blame] | 79 | |
Julie Jeongeun Kim | 73c8cc3 | 2021-02-26 03:17:59 | [diff] [blame] | 80 | mojom::ViewType extension_host_type() const { return extension_host_type_; } |
Devlin Cronin | 3b8567d21 | 2020-07-30 16:31:47 | [diff] [blame] | 81 | |
Devlin Cronin | 36eecdae0 | 2022-07-07 18:15:08 | [diff] [blame] | 82 | // Sets the callback responsible for closing the ExtensionHost in response to |
| 83 | // a WebContents::CloseContents() call (which is triggered from e.g. |
| 84 | // calling `window.close()`). This is done separately from the constructor as |
| 85 | // some callsites create an ExtensionHost prior to the object that is |
| 86 | // responsible for later closing it, but must be done before `CloseContents()` |
| 87 | // can be called. |
| 88 | void SetCloseHandler(CloseHandler close_handler); |
| 89 | |
Devlin Cronin | 3b8567d21 | 2020-07-30 16:31:47 | [diff] [blame] | 90 | // Returns the last committed URL of the associated WebContents. |
| 91 | const GURL& GetLastCommittedURL() const; |
[email protected] | f8e55e7 | 2010-02-25 06:13:43 | [diff] [blame] | 92 | |
danakj | 62dd09e1 | 2021-02-05 04:23:35 | [diff] [blame] | 93 | // Returns true if the renderer main frame exists. |
| 94 | bool IsRendererLive() const; |
[email protected] | 7c6877d | 2009-06-19 13:56:25 | [diff] [blame] | 95 | |
danakj | 62dd09e1 | 2021-02-05 04:23:35 | [diff] [blame] | 96 | // Prepares to initializes our RenderFrameHost by creating the main frame and |
| 97 | // navigating `host_contents_` to the initial url. This happens delayed to |
| 98 | // avoid locking the UI. |
| 99 | void CreateRendererSoon(); |
[email protected] | bbc94554 | 2009-07-26 00:11:42 | [diff] [blame] | 100 | |
rdevlin.cronin | 42efb7dd | 2015-02-11 17:50:52 | [diff] [blame] | 101 | // Closes this host (results in [possibly asynchronous] deletion). |
| 102 | void Close(); |
| 103 | |
chirantan | 79788f6 | 2015-02-02 23:57:25 | [diff] [blame] | 104 | // Typical observer interface. |
| 105 | void AddObserver(ExtensionHostObserver* observer); |
| 106 | void RemoveObserver(ExtensionHostObserver* observer); |
| 107 | |
chirantan | 669993c | 2015-03-05 23:38:33 | [diff] [blame] | 108 | // Called when an event is dispatched to the event page associated with this |
| 109 | // ExtensionHost. |
| 110 | void OnBackgroundEventDispatched(const std::string& event_name, int event_id); |
chirantan | 79788f6 | 2015-02-02 23:57:25 | [diff] [blame] | 111 | |
| 112 | // Called by the ProcessManager when a network request is started by the |
| 113 | // extension corresponding to this ExtensionHost. |
avi | c9cec10 | 2015-12-23 00:39:26 | [diff] [blame] | 114 | void OnNetworkRequestStarted(uint64_t request_id); |
chirantan | 79788f6 | 2015-02-02 23:57:25 | [diff] [blame] | 115 | |
| 116 | // Called by the ProcessManager when a previously started network request is |
| 117 | // finished. |
avi | c9cec10 | 2015-12-23 00:39:26 | [diff] [blame] | 118 | void OnNetworkRequestDone(uint64_t request_id); |
chirantan | 79788f6 | 2015-02-02 23:57:25 | [diff] [blame] | 119 | |
Devlin Cronin | ccf3b9d | 2022-06-30 02:16:16 | [diff] [blame] | 120 | // Returns true if the ExtensionHost is allowed to be navigated. |
| 121 | bool ShouldAllowNavigations() const; |
| 122 | |
yoz | d61dfe19 | 2015-02-21 01:30:37 | [diff] [blame] | 123 | // content::WebContentsObserver: |
rdevlin.cronin | 6f42c252 | 2015-06-19 18:58:51 | [diff] [blame] | 124 | bool OnMessageReceived(const IPC::Message& message, |
| 125 | content::RenderFrameHost* host) override; |
danakj | 62dd09e1 | 2021-02-05 04:23:35 | [diff] [blame] | 126 | void RenderFrameCreated(content::RenderFrameHost* frame_host) override; |
Henrique Ferreiro | 2a6905f8 | 2022-02-09 10:14:50 | [diff] [blame] | 127 | void RenderFrameHostChanged(content::RenderFrameHost* old_host, |
| 128 | content::RenderFrameHost* new_host) override; |
Dave Tapuska | 7052b7c5 | 2021-10-18 17:30:53 | [diff] [blame] | 129 | void PrimaryMainFrameRenderProcessGone( |
| 130 | base::TerminationStatus status) override; |
Sreeja Kamishetty | 4978330 | 2022-01-28 17:52:25 | [diff] [blame] | 131 | void PrimaryMainDocumentElementAvailable() override; |
fdegans | 6ce28f5 | 2015-03-19 12:52:22 | [diff] [blame] | 132 | void DidStopLoading() override; |
[email protected] | 952a68e | 2011-11-17 00:36:10 | [diff] [blame] | 133 | |
yoz | d61dfe19 | 2015-02-21 01:30:37 | [diff] [blame] | 134 | // content::WebContentsDelegate: |
mathiash | 72a5e46 | 2014-11-19 08:18:50 | [diff] [blame] | 135 | content::JavaScriptDialogManager* GetJavaScriptDialogManager( |
| 136 | content::WebContents* source) override; |
dcheng | 9168b2f | 2014-10-21 12:38:24 | [diff] [blame] | 137 | void AddNewContents(content::WebContents* source, |
erikchen | bee5c962 | 2018-04-27 19:30:25 | [diff] [blame] | 138 | std::unique_ptr<content::WebContents> new_contents, |
Joel Hockey | 891e8806 | 2020-04-30 05:38:44 | [diff] [blame] | 139 | const GURL& target_url, |
dcheng | 9168b2f | 2014-10-21 12:38:24 | [diff] [blame] | 140 | WindowOpenDisposition disposition, |
Brad Triebwasser | 767c27a | 2022-08-25 22:56:05 | [diff] [blame] | 141 | const blink::mojom::WindowFeatures& window_features, |
dcheng | 9168b2f | 2014-10-21 12:38:24 | [diff] [blame] | 142 | bool user_gesture, |
| 143 | bool* was_blocked) override; |
| 144 | void CloseContents(content::WebContents* contents) override; |
| 145 | void RequestMediaAccessPermission( |
[email protected] | 0b9383a | 2012-10-26 00:58:16 | [diff] [blame] | 146 | content::WebContents* web_contents, |
[email protected] | 33662e5 | 2013-01-07 21:31:09 | [diff] [blame] | 147 | const content::MediaStreamRequest& request, |
Mark Pilgrim | 5749908 | 2018-06-12 12:38:30 | [diff] [blame] | 148 | content::MediaResponseCallback callback) override; |
Raymes Khoury | ad7c24a1 | 2018-03-05 23:22:58 | [diff] [blame] | 149 | bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host, |
dcheng | 9168b2f | 2014-10-21 12:38:24 | [diff] [blame] | 150 | const GURL& security_origin, |
Antonio Gomes | c8b734b | 2019-06-05 18:22:16 | [diff] [blame] | 151 | blink::mojom::MediaStreamType type) override; |
danakj | 77eb7e8 | 2020-01-09 19:38:46 | [diff] [blame] | 152 | bool IsNeverComposited(content::WebContents* web_contents) override; |
Becca Hughes | 112832e | 2019-06-11 17:19:02 | [diff] [blame] | 153 | content::PictureInPictureResult EnterPictureInPicture( |
François Beaufort | 1388f289 | 2022-01-29 08:22:47 | [diff] [blame] | 154 | content::WebContents* web_contents) override; |
François Beaufort | 48cf272 | 2018-08-28 09:33:52 | [diff] [blame] | 155 | void ExitPictureInPicture() override; |
Kuznetsov Alexey | 1a516bd | 2021-08-04 23:49:05 | [diff] [blame] | 156 | std::string GetTitleForMediaControls( |
| 157 | content::WebContents* web_contents) override; |
[email protected] | c6463165 | 2009-04-29 22:24:31 | [diff] [blame] | 158 | |
limasdf | bbaa913d | 2015-03-02 23:52:33 | [diff] [blame] | 159 | // ExtensionRegistryObserver: |
rockot | 494f007 | 2015-07-29 17:58:07 | [diff] [blame] | 160 | void OnExtensionReady(content::BrowserContext* browser_context, |
| 161 | const Extension* extension) override; |
limasdf | bbaa913d | 2015-03-02 23:52:33 | [diff] [blame] | 162 | void OnExtensionUnloaded(content::BrowserContext* browser_context, |
| 163 | const Extension* extension, |
limasdf | 0deef204 | 2017-05-03 19:17:17 | [diff] [blame] | 164 | UnloadedExtensionReason reason) override; |
[email protected] | e95ad33 | 2009-08-03 19:44:25 | [diff] [blame] | 165 | |
[email protected] | 45a73d5 | 2013-11-26 00:10:55 | [diff] [blame] | 166 | protected: |
kalman | fd474fa | 2015-03-16 22:30:57 | [diff] [blame] | 167 | // Called each time this ExtensionHost completes a load finishes loading, |
| 168 | // before any stop-loading notifications or observer methods are called. |
| 169 | virtual void OnDidStopFirstLoad(); |
[email protected] | 45a73d5 | 2013-11-26 00:10:55 | [diff] [blame] | 170 | |
[email protected] | 91abb92 | 2013-12-03 18:39:56 | [diff] [blame] | 171 | // Navigates to the initial page. |
| 172 | virtual void LoadInitialURL(); |
| 173 | |
[email protected] | 45a73d5 | 2013-11-26 00:10:55 | [diff] [blame] | 174 | // Returns true if we're hosting a background page. |
| 175 | virtual bool IsBackgroundPage() const; |
| 176 | |
[email protected] | c6463165 | 2009-04-29 22:24:31 | [diff] [blame] | 177 | private: |
yoz | d61dfe19 | 2015-02-21 01:30:37 | [diff] [blame] | 178 | // DeferredStartRenderHost: |
danakj | 62dd09e1 | 2021-02-05 04:23:35 | [diff] [blame] | 179 | void CreateRendererNow() override; |
yoz | d61dfe19 | 2015-02-21 01:30:37 | [diff] [blame] | 180 | |
[email protected] | 34f128d | 2011-01-25 19:07:44 | [diff] [blame] | 181 | // Message handlers. |
chirantan | 669993c | 2015-03-05 23:38:33 | [diff] [blame] | 182 | void OnEventAck(int event_id); |
[email protected] | 7042b68 | 2012-04-19 22:57:51 | [diff] [blame] | 183 | void OnIncrementLazyKeepaliveCount(); |
| 184 | void OnDecrementLazyKeepaliveCount(); |
[email protected] | 34f128d | 2011-01-25 19:07:44 | [diff] [blame] | 185 | |
Henrique Ferreiro | 2a6905f8 | 2022-02-09 10:14:50 | [diff] [blame] | 186 | void MaybeNotifyRenderProcessReady(); |
danakj | 62dd09e1 | 2021-02-05 04:23:35 | [diff] [blame] | 187 | void NotifyRenderProcessReady(); |
| 188 | |
kalman | fd474fa | 2015-03-16 22:30:57 | [diff] [blame] | 189 | // Records UMA for load events. |
| 190 | void RecordStopLoadingUMA(); |
| 191 | |
[email protected] | 6c0f179f | 2014-03-19 11:04:41 | [diff] [blame] | 192 | // Delegate for functionality that cannot exist in the extensions module. |
dcheng | f5d24108 | 2016-04-21 03:43:11 | [diff] [blame] | 193 | std::unique_ptr<ExtensionHostDelegate> delegate_; |
[email protected] | 6c0f179f | 2014-03-19 11:04:41 | [diff] [blame] | 194 | |
[email protected] | c6463165 | 2009-04-29 22:24:31 | [diff] [blame] | 195 | // The extension that we're hosting in this view. |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 196 | raw_ptr<const Extension> extension_; |
[email protected] | c6463165 | 2009-04-29 22:24:31 | [diff] [blame] | 197 | |
[email protected] | 2d2f6cfc | 2011-05-06 21:09:33 | [diff] [blame] | 198 | // Id of extension that we're hosting in this view. |
| 199 | const std::string extension_id_; |
| 200 | |
[email protected] | 96e6a103 | 2013-11-28 06:58:03 | [diff] [blame] | 201 | // The browser context that this host is tied to. |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 202 | raw_ptr<content::BrowserContext> browser_context_; |
[email protected] | 8a17bd5 | 2009-06-06 08:19:49 | [diff] [blame] | 203 | |
[email protected] | c6463165 | 2009-04-29 22:24:31 | [diff] [blame] | 204 | // The host for our HTML content. |
dcheng | f5d24108 | 2016-04-21 03:43:11 | [diff] [blame] | 205 | std::unique_ptr<content::WebContents> host_contents_; |
[email protected] | c6463165 | 2009-04-29 22:24:31 | [diff] [blame] | 206 | |
danakj | 62dd09e1 | 2021-02-05 04:23:35 | [diff] [blame] | 207 | // A pointer to the current or speculative main frame in `host_contents_`. We |
| 208 | // can't access this frame through the `host_contents_` directly as it does |
| 209 | // not expose the speculative main frame. While navigating to a still-loading |
| 210 | // speculative main frame, we want to send messages to it rather than the |
| 211 | // current frame. |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 212 | raw_ptr<content::RenderFrameHost> main_frame_host_; |
[email protected] | 4f4d42a | 2011-12-02 02:42:49 | [diff] [blame] | 213 | |
danakj | 62dd09e1 | 2021-02-05 04:23:35 | [diff] [blame] | 214 | // Whether CreateRendererNow was called before the extension was ready. |
| 215 | bool is_renderer_creation_pending_ = false; |
rockot | 494f007 | 2015-07-29 17:58:07 | [diff] [blame] | 216 | |
Devlin Cronin | 30eb24f | 2021-09-17 19:26:43 | [diff] [blame] | 217 | // Whether ExtensionHostCreated() event has been fired, since |
| 218 | // RenderFrameCreated is triggered by every main frame that is created, |
danakj | 62dd09e1 | 2021-02-05 04:23:35 | [diff] [blame] | 219 | // including during a cross-site navigation which uses a new main frame. |
Lukasz Anforowicz | d2cae304 | 2020-04-01 20:37:36 | [diff] [blame] | 220 | bool has_creation_notification_already_fired_ = false; |
| 221 | |
kalman | fd474fa | 2015-03-16 22:30:57 | [diff] [blame] | 222 | // Whether the ExtensionHost has finished loading some content at least once. |
| 223 | // There may be subsequent loads - such as reloads and navigations - and this |
| 224 | // will not affect its value (it will remain true). |
danakj | 62dd09e1 | 2021-02-05 04:23:35 | [diff] [blame] | 225 | bool has_loaded_once_ = false; |
[email protected] | c6463165 | 2009-04-29 22:24:31 | [diff] [blame] | 226 | |
[email protected] | e95ad33 | 2009-08-03 19:44:25 | [diff] [blame] | 227 | // True if the main frame has finished parsing. |
danakj | 62dd09e1 | 2021-02-05 04:23:35 | [diff] [blame] | 228 | bool document_element_available_ = false; |
[email protected] | e95ad33 | 2009-08-03 19:44:25 | [diff] [blame] | 229 | |
[email protected] | 952a68e | 2011-11-17 00:36:10 | [diff] [blame] | 230 | // The original URL of the page being hosted. |
| 231 | GURL initial_url_; |
[email protected] | e916901c | 2009-05-07 00:14:31 | [diff] [blame] | 232 | |
chirantan | 79788f6 | 2015-02-02 23:57:25 | [diff] [blame] | 233 | // Messages sent out to the renderer that have not been acknowledged yet. |
David Bertoni | 3e1e9fa | 2018-08-29 20:39:30 | [diff] [blame] | 234 | // Maps event ID to event name. |
| 235 | std::unordered_map<int, std::string> unacked_messages_; |
chirantan | 79788f6 | 2015-02-02 23:57:25 | [diff] [blame] | 236 | |
[email protected] | 720ad131 | 2012-02-27 23:07:36 | [diff] [blame] | 237 | // The type of view being hosted. |
Julie Jeongeun Kim | 73c8cc3 | 2021-02-26 03:17:59 | [diff] [blame] | 238 | mojom::ViewType extension_host_type_; |
[email protected] | 7b291f9 | 2009-08-14 05:43:53 | [diff] [blame] | 239 | |
kalman | 0f101ac | 2015-05-06 01:23:17 | [diff] [blame] | 240 | // Measures how long since the ExtensionHost object was created. This can be |
| 241 | // used to measure the responsiveness of UI. For example, it's important to |
| 242 | // keep this as low as possible for popups. Contrast this to |load_start_|, |
| 243 | // for which a low value does not necessarily mean a responsive UI, as |
| 244 | // ExtensionHosts may sit in an ExtensionHostQueue for a long time. |
| 245 | base::ElapsedTimer create_start_; |
| 246 | |
| 247 | // Measures how long since the initial URL started loading. This timer is |
| 248 | // started only once the ExtensionHost has exited the ExtensionHostQueue. |
dcheng | f5d24108 | 2016-04-21 03:43:11 | [diff] [blame] | 249 | std::unique_ptr<base::ElapsedTimer> load_start_; |
[email protected] | cc2c343 | 2009-11-06 17:24:36 | [diff] [blame] | 250 | |
Devlin Cronin | 36eecdae0 | 2022-07-07 18:15:08 | [diff] [blame] | 251 | CloseHandler close_handler_; |
| 252 | // Whether the close handler has been previously invoked. |
| 253 | bool called_close_handler_ = false; |
| 254 | |
Trent Apted | a250ec3ab | 2018-08-19 08:52:19 | [diff] [blame] | 255 | base::ObserverList<ExtensionHostObserver>::Unchecked observer_list_; |
chirantan | 79788f6 | 2015-02-02 23:57:25 | [diff] [blame] | 256 | |
danakj | 62dd09e1 | 2021-02-05 04:23:35 | [diff] [blame] | 257 | base::WeakPtrFactory<ExtensionHost> weak_ptr_factory_{this}; |
[email protected] | c6463165 | 2009-04-29 22:24:31 | [diff] [blame] | 258 | }; |
| 259 | |
[email protected] | 3a1dc57 | 2012-07-31 22:25:13 | [diff] [blame] | 260 | } // namespace extensions |
| 261 | |
[email protected] | 22401dc | 2014-03-21 01:38:57 | [diff] [blame] | 262 | #endif // EXTENSIONS_BROWSER_EXTENSION_HOST_H_ |