[email protected] | 46a32b9 | 2012-03-22 13:04:48 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 398206c | 2010-06-21 01:46:08 | [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] | a07676b2 | 2011-06-17 16:36:53 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_SERVICE_H_ |
| 6 | #define CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_SERVICE_H_ |
[email protected] | 398206c | 2010-06-21 01:46:08 | [diff] [blame] | 7 | |
avi | e4d7b6f | 2015-12-26 00:59:18 | [diff] [blame] | 8 | #include <stdint.h> |
| 9 | |
[email protected] | 398206c | 2010-06-21 01:46:08 | [diff] [blame] | 10 | #include <map> |
[email protected] | bb95acab | 2011-11-16 22:22:27 | [diff] [blame] | 11 | #include <string> |
[email protected] | da58f5b1 | 2010-11-10 19:31:12 | [diff] [blame] | 12 | #include <vector> |
[email protected] | 398206c | 2010-06-21 01:46:08 | [diff] [blame] | 13 | |
[email protected] | 19118d5 | 2010-07-26 22:13:42 | [diff] [blame] | 14 | #include "base/gtest_prod_util.h" |
avi | e4d7b6f | 2015-12-26 00:59:18 | [diff] [blame] | 15 | #include "base/macros.h" |
[email protected] | 2c4fb7b | 2011-04-02 06:33:29 | [diff] [blame] | 16 | #include "base/memory/ref_counted.h" |
apacible | 1c232911 | 2016-09-08 16:49:44 | [diff] [blame] | 17 | #include "base/memory/weak_ptr.h" |
Sigurdur Asgeirsson | c2d58ce | 2021-05-10 19:13:02 | [diff] [blame] | 18 | #include "base/scoped_observation.h" |
avi | 71d0f76 | 2014-12-15 16:08:47 | [diff] [blame] | 19 | #include "chrome/browser/background/background_contents.h" |
[email protected] | 95003d52 | 2014-03-13 20:22:31 | [diff] [blame] | 20 | #include "components/keyed_service/core/keyed_service.h" |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 21 | #include "content/public/browser/notification_observer.h" |
| 22 | #include "content/public/browser/notification_registrar.h" |
Jose Dapena Paz | 56b99b40 | 2019-07-18 14:13:14 | [diff] [blame] | 23 | #include "extensions/browser/extension_registry.h" |
[email protected] | 7cf8286 | 2014-07-25 18:52:52 | [diff] [blame] | 24 | #include "extensions/browser/extension_registry_observer.h" |
apacible | fb3b9fa | 2016-08-31 04:28:15 | [diff] [blame] | 25 | #include "net/base/backoff_entry.h" |
[email protected] | f47621b | 2013-01-22 20:50:33 | [diff] [blame] | 26 | #include "ui/base/window_open_disposition.h" |
[email protected] | 761fa470 | 2013-07-02 15:25:15 | [diff] [blame] | 27 | #include "url/gurl.h" |
[email protected] | 398206c | 2010-06-21 01:46:08 | [diff] [blame] | 28 | |
[email protected] | 398206c | 2010-06-21 01:46:08 | [diff] [blame] | 29 | class PrefService; |
| 30 | class Profile; |
[email protected] | bc09387 | 2010-08-16 21:49:08 | [diff] [blame] | 31 | |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 32 | namespace base { |
[email protected] | 2f3b1cc | 2014-03-17 23:07:15 | [diff] [blame] | 33 | class CommandLine; |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 34 | class DictionaryValue; |
Nigel Tao | 28338b8 | 2018-11-27 21:40:37 | [diff] [blame] | 35 | } // namespace base |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 36 | |
[email protected] | dd673041 | 2013-08-14 15:03:37 | [diff] [blame] | 37 | namespace content { |
| 38 | class SessionStorageNamespace; |
| 39 | } |
| 40 | |
[email protected] | cca7d54 | 2013-09-20 07:16:41 | [diff] [blame] | 41 | namespace extensions { |
| 42 | class Extension; |
Nigel Tao | 28338b8 | 2018-11-27 21:40:37 | [diff] [blame] | 43 | } // namespace extensions |
[email protected] | cca7d54 | 2013-09-20 07:16:41 | [diff] [blame] | 44 | |
[email protected] | bc09387 | 2010-08-16 21:49:08 | [diff] [blame] | 45 | namespace gfx { |
| 46 | class Rect; |
| 47 | } |
| 48 | |
Evan Stade | 6670c33 | 2019-06-18 20:56:12 | [diff] [blame] | 49 | class BackgroundContentsServiceObserver; |
[email protected] | 398206c | 2010-06-21 01:46:08 | [diff] [blame] | 50 | |
| 51 | // BackgroundContentsService is owned by the profile, and is responsible for |
| 52 | // managing the lifetime of BackgroundContents (tracking the set of background |
| 53 | // urls, loading them at startup, and keeping the browser process alive as long |
| 54 | // as there are BackgroundContents loaded). |
| 55 | // |
| 56 | // It is also responsible for tracking the association between |
| 57 | // BackgroundContents and their parent app, and shutting them down when the |
| 58 | // parent app is unloaded. |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 59 | class BackgroundContentsService : private content::NotificationObserver, |
[email protected] | 7cf8286 | 2014-07-25 18:52:52 | [diff] [blame] | 60 | public extensions::ExtensionRegistryObserver, |
[email protected] | d2fad14 | 2011-04-15 10:18:44 | [diff] [blame] | 61 | public BackgroundContents::Delegate, |
[email protected] | 95003d52 | 2014-03-13 20:22:31 | [diff] [blame] | 62 | public KeyedService { |
[email protected] | 398206c | 2010-06-21 01:46:08 | [diff] [blame] | 63 | public: |
[email protected] | 2f3b1cc | 2014-03-17 23:07:15 | [diff] [blame] | 64 | BackgroundContentsService(Profile* profile, |
| 65 | const base::CommandLine* command_line); |
Peter Boström | 53c6c595 | 2021-09-17 09:41:26 | [diff] [blame^] | 66 | |
| 67 | BackgroundContentsService(const BackgroundContentsService&) = delete; |
| 68 | BackgroundContentsService& operator=(const BackgroundContentsService&) = |
| 69 | delete; |
| 70 | |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 71 | ~BackgroundContentsService() override; |
[email protected] | 398206c | 2010-06-21 01:46:08 | [diff] [blame] | 72 | |
[email protected] | 6b9dafc | 2013-08-30 15:41:59 | [diff] [blame] | 73 | // Allows tests to reduce the time between a force-installed app/extension |
[email protected] | cca7d54 | 2013-09-20 07:16:41 | [diff] [blame] | 74 | // crashing and when we reload it. |
| 75 | static void SetRestartDelayForForceInstalledAppsAndExtensionsForTesting( |
| 76 | int restart_delay_in_ms); |
[email protected] | 6b9dafc | 2013-08-30 15:41:59 | [diff] [blame] | 77 | |
juyik | 048931af | 2014-10-06 17:56:30 | [diff] [blame] | 78 | // Get the crash notification's delegate id for the extension. |
| 79 | static std::string GetNotificationDelegateIdForExtensionForTesting( |
[email protected] | 84695f2 | 2014-02-18 02:29:32 | [diff] [blame] | 80 | const std::string& extension_id); |
| 81 | |
| 82 | // Show a popup notification balloon with a crash message for a given app/ |
| 83 | // extension. |
| 84 | static void ShowBalloonForTesting(const extensions::Extension* extension, |
| 85 | Profile* profile); |
| 86 | |
skyostil | 0becb33 | 2015-04-27 17:59:37 | [diff] [blame] | 87 | // Disable closing the crash notification balloon for tests. |
| 88 | static void DisableCloseBalloonForTesting( |
| 89 | bool disable_close_balloon_for_testing); |
| 90 | |
Evan Stade | 6670c33 | 2019-06-18 20:56:12 | [diff] [blame] | 91 | void AddObserver(BackgroundContentsServiceObserver* observer); |
| 92 | void RemoveObserver(BackgroundContentsServiceObserver* observer); |
| 93 | |
[email protected] | 398206c | 2010-06-21 01:46:08 | [diff] [blame] | 94 | // Returns the BackgroundContents associated with the passed application id, |
| 95 | // or NULL if none. |
Evan Stade | 092530b | 2017-11-21 17:17:05 | [diff] [blame] | 96 | BackgroundContents* GetAppBackgroundContents(const std::string& appid); |
[email protected] | 398206c | 2010-06-21 01:46:08 | [diff] [blame] | 97 | |
[email protected] | 88ea00f | 2012-05-04 01:17:27 | [diff] [blame] | 98 | // Returns true if there's a registered BackgroundContents for this app. It |
| 99 | // is possible for this routine to return true when GetAppBackgroundContents() |
| 100 | // returns false, if the BackgroundContents closed due to the render process |
| 101 | // crashing. |
Evan Stade | 092530b | 2017-11-21 17:17:05 | [diff] [blame] | 102 | bool HasRegisteredBackgroundContents(const std::string& appid); |
[email protected] | 88ea00f | 2012-05-04 01:17:27 | [diff] [blame] | 103 | |
[email protected] | da58f5b1 | 2010-11-10 19:31:12 | [diff] [blame] | 104 | // Returns all currently opened BackgroundContents (used by the task manager). |
| 105 | std::vector<BackgroundContents*> GetBackgroundContents() const; |
| 106 | |
[email protected] | bc09387 | 2010-08-16 21:49:08 | [diff] [blame] | 107 | // BackgroundContents::Delegate implementation. |
erikchen | bee5c962 | 2018-04-27 19:30:25 | [diff] [blame] | 108 | void AddWebContents(std::unique_ptr<content::WebContents> new_contents, |
Joel Hockey | 891e8806 | 2020-04-30 05:38:44 | [diff] [blame] | 109 | const GURL& target_url, |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 110 | WindowOpenDisposition disposition, |
bokan | 107a47f | 2015-02-03 23:23:39 | [diff] [blame] | 111 | const gfx::Rect& initial_rect, |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 112 | bool* was_blocked) override; |
Evan Stade | 6670c33 | 2019-06-18 20:56:12 | [diff] [blame] | 113 | void OnBackgroundContentsNavigated(BackgroundContents* contents) override; |
| 114 | void OnBackgroundContentsTerminated(BackgroundContents* contents) override; |
| 115 | void OnBackgroundContentsClosed(BackgroundContents* contents) override; |
Evan Stade | ce3af4f | 2019-10-07 17:04:20 | [diff] [blame] | 116 | |
| 117 | // KeyedService implementation. |
| 118 | void Shutdown() override; |
[email protected] | bc09387 | 2010-08-16 21:49:08 | [diff] [blame] | 119 | |
[email protected] | da58f5b1 | 2010-11-10 19:31:12 | [diff] [blame] | 120 | // Gets the parent application id for the passed BackgroundContents. Returns |
| 121 | // an empty string if no parent application found (e.g. passed |
| 122 | // BackgroundContents has already shut down). |
Evan Stade | 092530b | 2017-11-21 17:17:05 | [diff] [blame] | 123 | const std::string& GetParentApplicationId(BackgroundContents* contents) const; |
[email protected] | da58f5b1 | 2010-11-10 19:31:12 | [diff] [blame] | 124 | |
| 125 | // Creates a new BackgroundContents using the passed |site| and |
Albert J. Wong | 1ceccef9 | 2019-10-08 08:25:20 | [diff] [blame] | 126 | // begins tracking the object internally so it can be shutdown if the parent |
| 127 | // application is uninstalled. |
Evan Stade | ae2652f | 2019-10-01 14:53:50 | [diff] [blame] | 128 | // Observers will receive a OnBackgroundContentsOpened call. |
[email protected] | dd673041 | 2013-08-14 15:03:37 | [diff] [blame] | 129 | BackgroundContents* CreateBackgroundContents( |
dcheng | bccd6b8 | 2016-03-30 16:24:19 | [diff] [blame] | 130 | scoped_refptr<content::SiteInstance> site, |
lukasza | 6f8ac62 | 2017-06-06 03:10:20 | [diff] [blame] | 131 | content::RenderFrameHost* opener, |
Albert J. Wong | 1ceccef9 | 2019-10-08 08:25:20 | [diff] [blame] | 132 | bool is_new_browsing_instance, |
nasko | 48321ca3 | 2015-07-02 20:44:12 | [diff] [blame] | 133 | const std::string& frame_name, |
Evan Stade | 092530b | 2017-11-21 17:17:05 | [diff] [blame] | 134 | const std::string& application_id, |
Aaron Colwell | f3b316e | 2021-03-11 20:17:05 | [diff] [blame] | 135 | const content::StoragePartitionId& partition_id, |
[email protected] | dd673041 | 2013-08-14 15:03:37 | [diff] [blame] | 136 | content::SessionStorageNamespace* session_storage_namespace); |
[email protected] | da58f5b1 | 2010-11-10 19:31:12 | [diff] [blame] | 137 | |
Evan Stade | ce3af4f | 2019-10-07 17:04:20 | [diff] [blame] | 138 | // Removes |contents| from |contents_map_|, deleting it. |
| 139 | void DeleteBackgroundContents(BackgroundContents* contents); |
| 140 | |
[email protected] | 41619a9a | 2011-04-13 20:07:32 | [diff] [blame] | 141 | // Load the manifest-specified background page for the specified hosted app. |
| 142 | // If the manifest doesn't specify one, then load the BackgroundContents |
| 143 | // registered in the pref. This is typically used to reload a crashed |
| 144 | // background page. |
Evan Stade | ae2652f | 2019-10-01 14:53:50 | [diff] [blame] | 145 | void LoadBackgroundContentsForExtension(const std::string& extension_id); |
[email protected] | 2c4fb7b | 2011-04-02 06:33:29 | [diff] [blame] | 146 | |
[email protected] | 398206c | 2010-06-21 01:46:08 | [diff] [blame] | 147 | private: |
| 148 | friend class BackgroundContentsServiceTest; |
[email protected] | da58f5b1 | 2010-11-10 19:31:12 | [diff] [blame] | 149 | friend class MockBackgroundContents; |
[email protected] | 2c4fb7b | 2011-04-02 06:33:29 | [diff] [blame] | 150 | |
[email protected] | 19118d5 | 2010-07-26 22:13:42 | [diff] [blame] | 151 | FRIEND_TEST_ALL_PREFIXES(BackgroundContentsServiceTest, |
| 152 | BackgroundContentsCreateDestroy); |
| 153 | FRIEND_TEST_ALL_PREFIXES(BackgroundContentsServiceTest, |
| 154 | TestApplicationIDLinkage); |
[email protected] | 398206c | 2010-06-21 01:46:08 | [diff] [blame] | 155 | |
| 156 | // Registers for various notifications. |
Evan Stade | 6670c33 | 2019-06-18 20:56:12 | [diff] [blame] | 157 | void StartObserving(); |
[email protected] | 398206c | 2010-06-21 01:46:08 | [diff] [blame] | 158 | |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 159 | // content::NotificationObserver implementation. |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 160 | void Observe(int type, |
| 161 | const content::NotificationSource& source, |
| 162 | const content::NotificationDetails& details) override; |
[email protected] | 398206c | 2010-06-21 01:46:08 | [diff] [blame] | 163 | |
limasdf | a845ec3 | 2016-11-01 03:33:27 | [diff] [blame] | 164 | // Called when ExtensionSystem is ready. |
Evan Stade | 6670c33 | 2019-06-18 20:56:12 | [diff] [blame] | 165 | void OnExtensionSystemReady(); |
limasdf | a845ec3 | 2016-11-01 03:33:27 | [diff] [blame] | 166 | |
[email protected] | 7cf8286 | 2014-07-25 18:52:52 | [diff] [blame] | 167 | // extensions::ExtensionRegistryObserver implementation. |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 168 | void OnExtensionLoaded(content::BrowserContext* browser_context, |
| 169 | const extensions::Extension* extension) override; |
limasdf | 0deef204 | 2017-05-03 19:17:17 | [diff] [blame] | 170 | void OnExtensionUnloaded(content::BrowserContext* browser_context, |
| 171 | const extensions::Extension* extension, |
| 172 | extensions::UnloadedExtensionReason reason) override; |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 173 | void OnExtensionUninstalled(content::BrowserContext* browser_context, |
| 174 | const extensions::Extension* extension, |
| 175 | extensions::UninstallReason reason) override; |
[email protected] | 7cf8286 | 2014-07-25 18:52:52 | [diff] [blame] | 176 | |
[email protected] | cca7d54 | 2013-09-20 07:16:41 | [diff] [blame] | 177 | // Restarts a force-installed app/extension after a crash. |
[email protected] | 6b9dafc | 2013-08-30 15:41:59 | [diff] [blame] | 178 | void RestartForceInstalledExtensionOnCrash( |
Evan Stade | ae2652f | 2019-10-01 14:53:50 | [diff] [blame] | 179 | const extensions::Extension* extension); |
[email protected] | 6b9dafc | 2013-08-30 15:41:59 | [diff] [blame] | 180 | |
[email protected] | 398206c | 2010-06-21 01:46:08 | [diff] [blame] | 181 | // Loads all registered BackgroundContents at startup. |
Evan Stade | ae2652f | 2019-10-01 14:53:50 | [diff] [blame] | 182 | void LoadBackgroundContentsFromPrefs(); |
[email protected] | 398206c | 2010-06-21 01:46:08 | [diff] [blame] | 183 | |
[email protected] | 2c4fb7b | 2011-04-02 06:33:29 | [diff] [blame] | 184 | // Load a BackgroundContent; the settings are read from the provided |
| 185 | // dictionary. |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 186 | void LoadBackgroundContentsFromDictionary( |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 187 | const std::string& extension_id, |
| 188 | const base::DictionaryValue* contents); |
[email protected] | 2c4fb7b | 2011-04-02 06:33:29 | [diff] [blame] | 189 | |
[email protected] | 41619a9a | 2011-04-13 20:07:32 | [diff] [blame] | 190 | // Load the manifest-specified BackgroundContents for all apps for the |
| 191 | // profile. |
Evan Stade | ae2652f | 2019-10-01 14:53:50 | [diff] [blame] | 192 | void LoadBackgroundContentsFromManifests(); |
[email protected] | 41619a9a | 2011-04-13 20:07:32 | [diff] [blame] | 193 | |
[email protected] | da58f5b1 | 2010-11-10 19:31:12 | [diff] [blame] | 194 | // Creates a single BackgroundContents associated with the specified |appid|, |
| 195 | // creates an associated RenderView with the name specified by |frame_name|, |
| 196 | // and navigates to the passed |url|. |
Evan Stade | ae2652f | 2019-10-01 14:53:50 | [diff] [blame] | 197 | void LoadBackgroundContents(const GURL& url, |
nasko | 48321ca3 | 2015-07-02 20:44:12 | [diff] [blame] | 198 | const std::string& frame_name, |
Evan Stade | 092530b | 2017-11-21 17:17:05 | [diff] [blame] | 199 | const std::string& appid); |
[email protected] | 398206c | 2010-06-21 01:46:08 | [diff] [blame] | 200 | |
| 201 | // Invoked when a new BackgroundContents is opened. |
Evan Stade | ce3af4f | 2019-10-07 17:04:20 | [diff] [blame] | 202 | void AddBackgroundContents(std::unique_ptr<BackgroundContents> contents, |
| 203 | const std::string& application_id, |
| 204 | const std::string& frame_name); |
[email protected] | 398206c | 2010-06-21 01:46:08 | [diff] [blame] | 205 | |
[email protected] | 398206c | 2010-06-21 01:46:08 | [diff] [blame] | 206 | // Registers the |contents->GetURL()| to be run at startup. Only happens for |
| 207 | // the first navigation after window.open() (future calls to |
| 208 | // RegisterBackgroundContents() for the same BackgroundContents will do |
| 209 | // nothing). |
| 210 | void RegisterBackgroundContents(BackgroundContents* contents); |
| 211 | |
| 212 | // Stops loading the passed BackgroundContents on startup. |
| 213 | void UnregisterBackgroundContents(BackgroundContents* contents); |
| 214 | |
| 215 | // Unregisters and deletes the BackgroundContents associated with the |
| 216 | // passed extension. |
Evan Stade | 092530b | 2017-11-21 17:17:05 | [diff] [blame] | 217 | void ShutdownAssociatedBackgroundContents(const std::string& appid); |
[email protected] | 398206c | 2010-06-21 01:46:08 | [diff] [blame] | 218 | |
| 219 | // Returns true if this BackgroundContents is in the contents_list_. |
| 220 | bool IsTracked(BackgroundContents* contents) const; |
| 221 | |
[email protected] | 88ea00f | 2012-05-04 01:17:27 | [diff] [blame] | 222 | // Sends out a notification when our association of background contents with |
| 223 | // apps may have changed (used by BackgroundApplicationListModel to update the |
| 224 | // set of background apps as new background contents are opened/closed). |
Evan Stade | 6670c33 | 2019-06-18 20:56:12 | [diff] [blame] | 225 | void SendChangeNotification(); |
[email protected] | 88ea00f | 2012-05-04 01:17:27 | [diff] [blame] | 226 | |
apacible | 1c232911 | 2016-09-08 16:49:44 | [diff] [blame] | 227 | // Checks whether there has been additional |extension_id| failures. If not, |
| 228 | // delete the BackoffEntry corresponding to |extension_id|, if exists. |
| 229 | void MaybeClearBackoffEntry(const std::string extension_id, |
| 230 | int expected_failure_count); |
| 231 | |
Evan Stade | 6670c33 | 2019-06-18 20:56:12 | [diff] [blame] | 232 | void HandleExtensionCrashed(const extensions::Extension* extension); |
| 233 | |
[email protected] | 6b9dafc | 2013-08-30 15:41:59 | [diff] [blame] | 234 | // Delay (in ms) before restarting a force-installed extension that crashed. |
| 235 | static int restart_delay_in_ms_; |
| 236 | |
Evan Stade | 6670c33 | 2019-06-18 20:56:12 | [diff] [blame] | 237 | Profile* profile_; |
| 238 | |
| 239 | base::ObserverList<BackgroundContentsServiceObserver> observers_; |
| 240 | |
[email protected] | 398206c | 2010-06-21 01:46:08 | [diff] [blame] | 241 | // PrefService used to store list of background pages (or NULL if this is |
[email protected] | 2c910b7 | 2011-03-08 21:16:32 | [diff] [blame] | 242 | // running under an incognito profile). |
Evan Stade | 6670c33 | 2019-06-18 20:56:12 | [diff] [blame] | 243 | PrefService* prefs_ = nullptr; |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 244 | content::NotificationRegistrar registrar_; |
[email protected] | 398206c | 2010-06-21 01:46:08 | [diff] [blame] | 245 | |
| 246 | // Information we track about each BackgroundContents. |
| 247 | struct BackgroundContentsInfo { |
Evan Stade | ce3af4f | 2019-10-07 17:04:20 | [diff] [blame] | 248 | BackgroundContentsInfo(); |
| 249 | ~BackgroundContentsInfo(); |
| 250 | |
[email protected] | 398206c | 2010-06-21 01:46:08 | [diff] [blame] | 251 | // The BackgroundContents whose information we are tracking. |
Evan Stade | ce3af4f | 2019-10-07 17:04:20 | [diff] [blame] | 252 | std::unique_ptr<BackgroundContents> contents; |
[email protected] | 398206c | 2010-06-21 01:46:08 | [diff] [blame] | 253 | // The name of the top level frame for this BackgroundContents. |
nasko | 48321ca3 | 2015-07-02 20:44:12 | [diff] [blame] | 254 | std::string frame_name; |
[email protected] | 398206c | 2010-06-21 01:46:08 | [diff] [blame] | 255 | }; |
| 256 | |
| 257 | // Map associating currently loaded BackgroundContents with their parent |
| 258 | // applications. |
| 259 | // Key: application id |
| 260 | // Value: BackgroundContentsInfo for the BC associated with that application |
Evan Stade | 092530b | 2017-11-21 17:17:05 | [diff] [blame] | 261 | typedef std::map<std::string, BackgroundContentsInfo> BackgroundContentsMap; |
[email protected] | 398206c | 2010-06-21 01:46:08 | [diff] [blame] | 262 | BackgroundContentsMap contents_map_; |
| 263 | |
apacible | fb3b9fa | 2016-08-31 04:28:15 | [diff] [blame] | 264 | // Map associating component extensions that have attempted to reload with a |
| 265 | // BackoffEntry keeping track of retry timing. |
| 266 | typedef std::map<extensions::ExtensionId, std::unique_ptr<net::BackoffEntry>> |
apacible | 1c232911 | 2016-09-08 16:49:44 | [diff] [blame] | 267 | ComponentExtensionBackoffEntryMap; |
| 268 | ComponentExtensionBackoffEntryMap component_backoff_map_; |
apacible | fb3b9fa | 2016-08-31 04:28:15 | [diff] [blame] | 269 | |
Sigurdur Asgeirsson | c2d58ce | 2021-05-10 19:13:02 | [diff] [blame] | 270 | base::ScopedObservation<extensions::ExtensionRegistry, |
| 271 | extensions::ExtensionRegistryObserver> |
| 272 | extension_registry_observation_{this}; |
[email protected] | 7cf8286 | 2014-07-25 18:52:52 | [diff] [blame] | 273 | |
Evan Stade | 6670c33 | 2019-06-18 20:56:12 | [diff] [blame] | 274 | base::WeakPtrFactory<BackgroundContentsService> weak_ptr_factory_{this}; |
[email protected] | 398206c | 2010-06-21 01:46:08 | [diff] [blame] | 275 | }; |
| 276 | |
[email protected] | a07676b2 | 2011-06-17 16:36:53 | [diff] [blame] | 277 | #endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_SERVICE_H_ |