Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(278)

Side by Side Diff: chrome/browser/background/background_contents_service.h

Issue 648653003: Standardize usage of virtual/override/final in chrome/browser/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_BACKGROUND_BACKGROUND_CONTENTS_SERVICE_H_ 5 #ifndef CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_SERVICE_H_
6 #define CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_SERVICE_H_ 6 #define CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_SERVICE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 // It is also responsible for tracking the association between 52 // It is also responsible for tracking the association between
53 // BackgroundContents and their parent app, and shutting them down when the 53 // BackgroundContents and their parent app, and shutting them down when the
54 // parent app is unloaded. 54 // parent app is unloaded.
55 class BackgroundContentsService : private content::NotificationObserver, 55 class BackgroundContentsService : private content::NotificationObserver,
56 public extensions::ExtensionRegistryObserver, 56 public extensions::ExtensionRegistryObserver,
57 public BackgroundContents::Delegate, 57 public BackgroundContents::Delegate,
58 public KeyedService { 58 public KeyedService {
59 public: 59 public:
60 BackgroundContentsService(Profile* profile, 60 BackgroundContentsService(Profile* profile,
61 const base::CommandLine* command_line); 61 const base::CommandLine* command_line);
62 virtual ~BackgroundContentsService(); 62 ~BackgroundContentsService() override;
63 63
64 // Allows tests to reduce the time between a force-installed app/extension 64 // Allows tests to reduce the time between a force-installed app/extension
65 // crashing and when we reload it. 65 // crashing and when we reload it.
66 static void SetRestartDelayForForceInstalledAppsAndExtensionsForTesting( 66 static void SetRestartDelayForForceInstalledAppsAndExtensionsForTesting(
67 int restart_delay_in_ms); 67 int restart_delay_in_ms);
68 68
69 // Get the crash notification's delegate id for the extension. 69 // Get the crash notification's delegate id for the extension.
70 static std::string GetNotificationDelegateIdForExtensionForTesting( 70 static std::string GetNotificationDelegateIdForExtensionForTesting(
71 const std::string& extension_id); 71 const std::string& extension_id);
72 72
73 // Show a popup notification balloon with a crash message for a given app/ 73 // Show a popup notification balloon with a crash message for a given app/
74 // extension. 74 // extension.
75 static void ShowBalloonForTesting(const extensions::Extension* extension, 75 static void ShowBalloonForTesting(const extensions::Extension* extension,
76 Profile* profile); 76 Profile* profile);
77 77
78 // Returns the BackgroundContents associated with the passed application id, 78 // Returns the BackgroundContents associated with the passed application id,
79 // or NULL if none. 79 // or NULL if none.
80 BackgroundContents* GetAppBackgroundContents(const base::string16& appid); 80 BackgroundContents* GetAppBackgroundContents(const base::string16& appid);
81 81
82 // Returns true if there's a registered BackgroundContents for this app. It 82 // Returns true if there's a registered BackgroundContents for this app. It
83 // is possible for this routine to return true when GetAppBackgroundContents() 83 // is possible for this routine to return true when GetAppBackgroundContents()
84 // returns false, if the BackgroundContents closed due to the render process 84 // returns false, if the BackgroundContents closed due to the render process
85 // crashing. 85 // crashing.
86 bool HasRegisteredBackgroundContents(const base::string16& appid); 86 bool HasRegisteredBackgroundContents(const base::string16& appid);
87 87
88 // Returns all currently opened BackgroundContents (used by the task manager). 88 // Returns all currently opened BackgroundContents (used by the task manager).
89 std::vector<BackgroundContents*> GetBackgroundContents() const; 89 std::vector<BackgroundContents*> GetBackgroundContents() const;
90 90
91 // BackgroundContents::Delegate implementation. 91 // BackgroundContents::Delegate implementation.
92 virtual void AddWebContents(content::WebContents* new_contents, 92 void AddWebContents(content::WebContents* new_contents,
93 WindowOpenDisposition disposition, 93 WindowOpenDisposition disposition,
94 const gfx::Rect& initial_pos, 94 const gfx::Rect& initial_pos,
95 bool user_gesture, 95 bool user_gesture,
96 bool* was_blocked) override; 96 bool* was_blocked) override;
97 97
98 // Gets the parent application id for the passed BackgroundContents. Returns 98 // Gets the parent application id for the passed BackgroundContents. Returns
99 // an empty string if no parent application found (e.g. passed 99 // an empty string if no parent application found (e.g. passed
100 // BackgroundContents has already shut down). 100 // BackgroundContents has already shut down).
101 const base::string16& GetParentApplicationId(BackgroundContents* contents) con st; 101 const base::string16& GetParentApplicationId(BackgroundContents* contents) con st;
102 102
103 // Creates a new BackgroundContents using the passed |site| and 103 // Creates a new BackgroundContents using the passed |site| and
104 // the |route_id| and begins tracking the object internally so it can be 104 // the |route_id| and begins tracking the object internally so it can be
105 // shutdown if the parent application is uninstalled. 105 // shutdown if the parent application is uninstalled.
106 // A BACKGROUND_CONTENTS_OPENED notification will be generated with the passed 106 // A BACKGROUND_CONTENTS_OPENED notification will be generated with the passed
(...skipping 26 matching lines...) Expand all
133 TestApplicationIDLinkage); 133 TestApplicationIDLinkage);
134 FRIEND_TEST_ALL_PREFIXES(TaskManagerNoShowBrowserTest, 134 FRIEND_TEST_ALL_PREFIXES(TaskManagerNoShowBrowserTest,
135 NoticeBGContentsChanges); 135 NoticeBGContentsChanges);
136 FRIEND_TEST_ALL_PREFIXES(TaskManagerNoShowBrowserTest, 136 FRIEND_TEST_ALL_PREFIXES(TaskManagerNoShowBrowserTest,
137 KillBGContents); 137 KillBGContents);
138 138
139 // Registers for various notifications. 139 // Registers for various notifications.
140 void StartObserving(Profile* profile); 140 void StartObserving(Profile* profile);
141 141
142 // content::NotificationObserver implementation. 142 // content::NotificationObserver implementation.
143 virtual void Observe(int type, 143 void Observe(int type,
144 const content::NotificationSource& source, 144 const content::NotificationSource& source,
145 const content::NotificationDetails& details) override; 145 const content::NotificationDetails& details) override;
146 146
147 // extensions::ExtensionRegistryObserver implementation. 147 // extensions::ExtensionRegistryObserver implementation.
148 virtual void OnExtensionLoaded( 148 void OnExtensionLoaded(content::BrowserContext* browser_context,
149 content::BrowserContext* browser_context, 149 const extensions::Extension* extension) override;
150 const extensions::Extension* extension) override; 150 void OnExtensionUnloaded(
151 virtual void OnExtensionUnloaded(
152 content::BrowserContext* browser_context, 151 content::BrowserContext* browser_context,
153 const extensions::Extension* extension, 152 const extensions::Extension* extension,
154 extensions::UnloadedExtensionInfo::Reason reason) override; 153 extensions::UnloadedExtensionInfo::Reason reason) override;
155 virtual void OnExtensionUninstalled( 154 void OnExtensionUninstalled(content::BrowserContext* browser_context,
156 content::BrowserContext* browser_context, 155 const extensions::Extension* extension,
157 const extensions::Extension* extension, 156 extensions::UninstallReason reason) override;
158 extensions::UninstallReason reason) override;
159 157
160 // Restarts a force-installed app/extension after a crash. 158 // Restarts a force-installed app/extension after a crash.
161 void RestartForceInstalledExtensionOnCrash( 159 void RestartForceInstalledExtensionOnCrash(
162 const extensions::Extension* extension, 160 const extensions::Extension* extension,
163 Profile* profile); 161 Profile* profile);
164 162
165 // Loads all registered BackgroundContents at startup. 163 // Loads all registered BackgroundContents at startup.
166 void LoadBackgroundContentsFromPrefs(Profile* profile); 164 void LoadBackgroundContentsFromPrefs(Profile* profile);
167 165
168 // Load a BackgroundContent; the settings are read from the provided 166 // Load a BackgroundContent; the settings are read from the provided
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 BackgroundContentsMap contents_map_; 235 BackgroundContentsMap contents_map_;
238 236
239 ScopedObserver<extensions::ExtensionRegistry, 237 ScopedObserver<extensions::ExtensionRegistry,
240 extensions::ExtensionRegistryObserver> 238 extensions::ExtensionRegistryObserver>
241 extension_registry_observer_; 239 extension_registry_observer_;
242 240
243 DISALLOW_COPY_AND_ASSIGN(BackgroundContentsService); 241 DISALLOW_COPY_AND_ASSIGN(BackgroundContentsService);
244 }; 242 };
245 243
246 #endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_SERVICE_H_ 244 #endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698