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

Side by Side Diff: chrome/browser/extensions/extension_service.h

Issue 10834078: Cleanup: Constify more ExtensionService methods, and IWYU. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rebase Created 8 years, 4 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 | Annotate | Revision Log
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_EXTENSIONS_EXTENSION_SERVICE_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <set>
11 #include <string> 10 #include <string>
12 #include <vector> 11 #include <vector>
13 12
14 #include "base/command_line.h"
15 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
16 #include "base/file_path.h" 14 #include "base/file_path.h"
17 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
18 #include "base/memory/linked_ptr.h" 16 #include "base/memory/linked_ptr.h"
19 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
20 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
21 #include "base/property_bag.h" 19 #include "base/property_bag.h"
22 #include "base/string16.h" 20 #include "base/string16.h"
23 #include "base/time.h" 21 #include "base/time.h"
24 #include "base/tuple.h" 22 #include "base/tuple.h"
(...skipping 14 matching lines...) Expand all
39 #include "chrome/common/extensions/extension.h" 37 #include "chrome/common/extensions/extension.h"
40 #include "chrome/common/extensions/extension_constants.h" 38 #include "chrome/common/extensions/extension_constants.h"
41 #include "chrome/common/extensions/extension_set.h" 39 #include "chrome/common/extensions/extension_set.h"
42 #include "content/public/browser/browser_thread.h" 40 #include "content/public/browser/browser_thread.h"
43 #include "content/public/browser/notification_observer.h" 41 #include "content/public/browser/notification_observer.h"
44 #include "content/public/browser/notification_registrar.h" 42 #include "content/public/browser/notification_registrar.h"
45 #include "sync/api/sync_change.h" 43 #include "sync/api/sync_change.h"
46 #include "sync/api/syncable_service.h" 44 #include "sync/api/syncable_service.h"
47 45
48 class BookmarkExtensionEventRouter; 46 class BookmarkExtensionEventRouter;
47 class CommandLine;
49 class ExtensionErrorUI; 48 class ExtensionErrorUI;
50 class ExtensionFontSettingsEventRouter; 49 class ExtensionFontSettingsEventRouter;
51 class ExtensionManagementEventRouter; 50 class ExtensionManagementEventRouter;
52 class ExtensionPreferenceEventRouter; 51 class ExtensionPreferenceEventRouter;
53 class ExtensionSyncData; 52 class ExtensionSyncData;
54 class ExtensionToolbarModel; 53 class ExtensionToolbarModel;
55 class HistoryExtensionEventRouter; 54 class HistoryExtensionEventRouter;
56 class GURL; 55 class GURL;
57 class Profile; 56 class Profile;
58 class Version; 57 class Version;
(...skipping 19 matching lines...) Expand all
78 class ExtensionSyncData; 77 class ExtensionSyncData;
79 class ExtensionSystem; 78 class ExtensionSystem;
80 class ExtensionUpdater; 79 class ExtensionUpdater;
81 class PendingExtensionManager; 80 class PendingExtensionManager;
82 class SettingsFrontend; 81 class SettingsFrontend;
83 class WebNavigationEventRouter; 82 class WebNavigationEventRouter;
84 class WindowEventRouter; 83 class WindowEventRouter;
85 } 84 }
86 85
87 namespace syncer { 86 namespace syncer {
88 class SyncData;
89 class SyncErrorFactory; 87 class SyncErrorFactory;
90 } 88 }
91 89
92 // This is an interface class to encapsulate the dependencies that 90 // This is an interface class to encapsulate the dependencies that
93 // various classes have on ExtensionService. This allows easy mocking. 91 // various classes have on ExtensionService. This allows easy mocking.
94 class ExtensionServiceInterface : public syncer::SyncableService { 92 class ExtensionServiceInterface : public syncer::SyncableService {
95 public: 93 public:
96 // A function that returns true if the given extension should be 94 // A function that returns true if the given extension should be
97 // included and false if it should be filtered out. Identical to 95 // included and false if it should be filtered out. Identical to
98 // PendingExtensionInfo::ShouldAllowInstallPredicate. 96 // PendingExtensionInfo::ShouldAllowInstallPredicate.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 166
169 // The name of the directory inside the profile where per-extension synced 167 // The name of the directory inside the profile where per-extension synced
170 // settings are stored. 168 // settings are stored.
171 static const char* kSyncExtensionSettingsDirectoryName; 169 static const char* kSyncExtensionSettingsDirectoryName;
172 170
173 // The name of the database inside the profile where chrome-internal 171 // The name of the database inside the profile where chrome-internal
174 // extension state resides. 172 // extension state resides.
175 static const char* kStateStoreName; 173 static const char* kStateStoreName;
176 174
177 // Returns the Extension of hosted or packaged apps, NULL otherwise. 175 // Returns the Extension of hosted or packaged apps, NULL otherwise.
178 const extensions::Extension* GetInstalledApp(const GURL& url); 176 const extensions::Extension* GetInstalledApp(const GURL& url) const;
179 177
180 // Returns whether the URL is from either a hosted or packaged app. 178 // Returns whether the URL is from either a hosted or packaged app.
181 bool IsInstalledApp(const GURL& url); 179 bool IsInstalledApp(const GURL& url) const;
182 180
183 // Associates a renderer process with the given installed app. 181 // Associates a renderer process with the given installed app.
184 void SetInstalledAppForRenderer(int renderer_child_id, 182 void SetInstalledAppForRenderer(int renderer_child_id,
185 const extensions::Extension* app); 183 const extensions::Extension* app);
186 184
187 // If the renderer is hosting an installed app, returns it, otherwise returns 185 // If the renderer is hosting an installed app, returns it, otherwise returns
188 // NULL. 186 // NULL.
189 const extensions::Extension* GetInstalledAppForRenderer( 187 const extensions::Extension* GetInstalledAppForRenderer(
190 int renderer_child_id); 188 int renderer_child_id) const;
191 189
192 // Attempts to uninstall an extension from a given ExtensionService. Returns 190 // Attempts to uninstall an extension from a given ExtensionService. Returns
193 // true iff the target extension exists. 191 // true iff the target extension exists.
194 static bool UninstallExtensionHelper(ExtensionService* extensions_service, 192 static bool UninstallExtensionHelper(ExtensionService* extensions_service,
195 const std::string& extension_id); 193 const std::string& extension_id);
196 194
197 // Constructor stores pointers to |profile| and |extension_prefs| but 195 // Constructor stores pointers to |profile| and |extension_prefs| but
198 // ownership remains at caller. 196 // ownership remains at caller.
199 ExtensionService(Profile* profile, 197 ExtensionService(Profile* profile,
200 const CommandLine* command_line, 198 const CommandLine* command_line,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 // Updates the app launcher value for the moved extension so that it is now 237 // Updates the app launcher value for the moved extension so that it is now
240 // located after the given predecessor and before the successor. This will 238 // located after the given predecessor and before the successor. This will
241 // trigger a sync if needed. Empty strings are used to indicate no successor 239 // trigger a sync if needed. Empty strings are used to indicate no successor
242 // or predecessor. 240 // or predecessor.
243 void OnExtensionMoved(const std::string& moved_extension_id, 241 void OnExtensionMoved(const std::string& moved_extension_id,
244 const std::string& predecessor_extension_id, 242 const std::string& predecessor_extension_id,
245 const std::string& successor_extension_id); 243 const std::string& successor_extension_id);
246 244
247 // Returns true if the given extension can see events and data from another 245 // Returns true if the given extension can see events and data from another
248 // sub-profile (incognito to original profile, or vice versa). 246 // sub-profile (incognito to original profile, or vice versa).
249 bool CanCrossIncognito(const extensions::Extension* extension); 247 bool CanCrossIncognito(const extensions::Extension* extension) const;
250 248
251 // Returns true if the given extension can be loaded in incognito. 249 // Returns true if the given extension can be loaded in incognito.
252 bool CanLoadInIncognito(const extensions::Extension* extension) const; 250 bool CanLoadInIncognito(const extensions::Extension* extension) const;
253 251
254 // Whether this extension can inject scripts into pages with file URLs. 252 // Whether this extension can inject scripts into pages with file URLs.
255 bool AllowFileAccess(const extensions::Extension* extension); 253 bool AllowFileAccess(const extensions::Extension* extension) const;
256 // Will reload the extension since this permission is applied at loading time 254 // Will reload the extension since this permission is applied at loading time
257 // only. 255 // only.
258 void SetAllowFileAccess(const extensions::Extension* extension, bool allow); 256 void SetAllowFileAccess(const extensions::Extension* extension, bool allow);
259 257
260 // Whether the persistent background page, if any, is ready. We don't load 258 // Whether the persistent background page, if any, is ready. We don't load
261 // other components until then. If there is no background page, or if it is 259 // other components until then. If there is no background page, or if it is
262 // non-persistent (lazy), we consider it to be ready. 260 // non-persistent (lazy), we consider it to be ready.
263 bool IsBackgroundPageReady(const extensions::Extension* extension); 261 bool IsBackgroundPageReady(const extensions::Extension* extension) const;
264 void SetBackgroundPageReady(const extensions::Extension* extension); 262 void SetBackgroundPageReady(const extensions::Extension* extension);
265 263
266 // Getter and setter for the flag that specifies whether the extension is 264 // Getter and setter for the flag that specifies whether the extension is
267 // being upgraded. 265 // being upgraded.
268 bool IsBeingUpgraded(const extensions::Extension* extension); 266 bool IsBeingUpgraded(const extensions::Extension* extension) const;
269 void SetBeingUpgraded(const extensions::Extension* extension, bool value); 267 void SetBeingUpgraded(const extensions::Extension* extension, bool value);
270 268
271 // Getter and setter for the flag that specifies if the extension has used 269 // Getter and setter for the flag that specifies if the extension has used
272 // the webrequest API. 270 // the webrequest API.
273 // TODO(mpcomplete): remove. http://crbug.com/100411 271 // TODO(mpcomplete): remove. http://crbug.com/100411
274 bool HasUsedWebRequest(const extensions::Extension* extension); 272 bool HasUsedWebRequest(const extensions::Extension* extension) const;
275 void SetHasUsedWebRequest(const extensions::Extension* extension, bool value); 273 void SetHasUsedWebRequest(const extensions::Extension* extension, bool value);
276 274
277 // Getter for the extension's runtime data PropertyBag. 275 // Getter for the extension's runtime data PropertyBag.
278 base::PropertyBag* GetPropertyBag(const extensions::Extension* extension); 276 base::PropertyBag* GetPropertyBag(const extensions::Extension* extension);
279 277
280 // Initialize and start all installed extensions. 278 // Initialize and start all installed extensions.
281 void Init(); 279 void Init();
282 280
283 // To delay some initialization until after import has finished, register 281 // To delay some initialization until after import has finished, register
284 // for the notification. 282 // for the notification.
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 #endif 866 #endif
869 867
870 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, 868 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
871 InstallAppsWithUnlimtedStorage); 869 InstallAppsWithUnlimtedStorage);
872 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, 870 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
873 InstallAppsAndCheckStorageProtection); 871 InstallAppsAndCheckStorageProtection);
874 DISALLOW_COPY_AND_ASSIGN(ExtensionService); 872 DISALLOW_COPY_AND_ASSIGN(ExtensionService);
875 }; 873 };
876 874
877 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ 875 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/convert_web_app_browsertest.cc ('k') | chrome/browser/extensions/extension_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698