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

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

Issue 10375021: Move Extension into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Take 2 Created 8 years, 7 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_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 #pragma once 7 #pragma once
8 8
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 71
72 namespace chromeos { 72 namespace chromeos {
73 class ExtensionBluetoothEventRouter; 73 class ExtensionBluetoothEventRouter;
74 class ExtensionInputMethodEventRouter; 74 class ExtensionInputMethodEventRouter;
75 } 75 }
76 76
77 namespace extensions { 77 namespace extensions {
78 class APIResourceController; 78 class APIResourceController;
79 class AppSyncData; 79 class AppSyncData;
80 class ComponentLoader; 80 class ComponentLoader;
81 class Extension;
81 class ExtensionSyncData; 82 class ExtensionSyncData;
82 class ExtensionUpdater; 83 class ExtensionUpdater;
83 class SettingsFrontend; 84 class SettingsFrontend;
84 class WebNavigationEventRouter; 85 class WebNavigationEventRouter;
85 } 86 }
86 87
87 // This is an interface class to encapsulate the dependencies that 88 // This is an interface class to encapsulate the dependencies that
88 // various classes have on ExtensionService. This allows easy mocking. 89 // various classes have on ExtensionService. This allows easy mocking.
89 class ExtensionServiceInterface : public SyncableService { 90 class ExtensionServiceInterface : public SyncableService {
90 public: 91 public:
91 // A function that returns true if the given extension should be 92 // A function that returns true if the given extension should be
92 // included and false if it should be filtered out. Identical to 93 // included and false if it should be filtered out. Identical to
93 // PendingExtensionInfo::ShouldAllowInstallPredicate. 94 // PendingExtensionInfo::ShouldAllowInstallPredicate.
94 typedef bool (*ExtensionFilter)(const Extension&); 95 typedef bool (*ExtensionFilter)(const extensions::Extension&);
95 96
96 virtual ~ExtensionServiceInterface() {} 97 virtual ~ExtensionServiceInterface() {}
97 virtual const ExtensionSet* extensions() const = 0; 98 virtual const ExtensionSet* extensions() const = 0;
98 virtual const ExtensionSet* disabled_extensions() const = 0; 99 virtual const ExtensionSet* disabled_extensions() const = 0;
99 virtual PendingExtensionManager* pending_extension_manager() = 0; 100 virtual PendingExtensionManager* pending_extension_manager() = 0;
100 101
101 // Install an update. Return true if the install can be started. 102 // Install an update. Return true if the install can be started.
102 // Set out_crx_installer to the installer if one was started. 103 // Set out_crx_installer to the installer if one was started.
103 virtual bool UpdateExtension( 104 virtual bool UpdateExtension(
104 const std::string& id, 105 const std::string& id,
105 const FilePath& path, 106 const FilePath& path,
106 const GURL& download_url, 107 const GURL& download_url,
107 CrxInstaller** out_crx_installer) = 0; 108 CrxInstaller** out_crx_installer) = 0;
108 virtual const Extension* GetExtensionById(const std::string& id, 109 virtual const extensions::Extension* GetExtensionById(const std::string& id,
109 bool include_disabled) const = 0; 110 bool include_disabled) const = 0;
110 virtual const Extension* GetInstalledExtension( 111 virtual const extensions::Extension* GetInstalledExtension(
111 const std::string& id) const = 0; 112 const std::string& id) const = 0;
112 113
113 virtual bool IsExtensionEnabled(const std::string& extension_id) const = 0; 114 virtual bool IsExtensionEnabled(const std::string& extension_id) const = 0;
114 virtual bool IsExternalExtensionUninstalled( 115 virtual bool IsExternalExtensionUninstalled(
115 const std::string& extension_id) const = 0; 116 const std::string& extension_id) const = 0;
116 117
117 virtual void UpdateExtensionBlacklist( 118 virtual void UpdateExtensionBlacklist(
118 const std::vector<std::string>& blacklist) = 0; 119 const std::vector<std::string>& blacklist) = 0;
119 virtual void CheckAdminBlacklist() = 0; 120 virtual void CheckAdminBlacklist() = 0;
120 121
121 // Safe to call multiple times in a row. 122 // Safe to call multiple times in a row.
122 // 123 //
123 // TODO(akalin): Remove this method (and others) once we refactor 124 // TODO(akalin): Remove this method (and others) once we refactor
124 // themes sync to not use it directly. 125 // themes sync to not use it directly.
125 virtual void CheckForUpdatesSoon() = 0; 126 virtual void CheckForUpdatesSoon() = 0;
126 127
127 virtual void AddExtension(const Extension* extension) = 0; 128 virtual void AddExtension(const extensions::Extension* extension) = 0;
128 129
129 virtual void UnloadExtension( 130 virtual void UnloadExtension(
130 const std::string& extension_id, 131 const std::string& extension_id,
131 extension_misc::UnloadedExtensionReason reason) = 0; 132 extension_misc::UnloadedExtensionReason reason) = 0;
132 133
133 virtual void SyncExtensionChangeIfNeeded(const Extension& extension) = 0; 134 virtual void SyncExtensionChangeIfNeeded(
135 const extensions::Extension& extension) = 0;
134 136
135 virtual bool is_ready() = 0; 137 virtual bool is_ready() = 0;
136 }; 138 };
137 139
138 // Manages installed and running Chromium extensions. 140 // Manages installed and running Chromium extensions.
139 class ExtensionService 141 class ExtensionService
140 : public ExtensionServiceInterface, 142 : public ExtensionServiceInterface,
141 public ExternalExtensionProviderInterface::VisitorInterface, 143 public ExternalExtensionProviderInterface::VisitorInterface,
142 public base::SupportsWeakPtr<ExtensionService>, 144 public base::SupportsWeakPtr<ExtensionService>,
143 public content::NotificationObserver { 145 public content::NotificationObserver {
(...skipping 23 matching lines...) Expand all
167 // settings are stored. 169 // settings are stored.
168 static const char* kSyncExtensionSettingsDirectoryName; 170 static const char* kSyncExtensionSettingsDirectoryName;
169 171
170 // Determine if a given extension download should be treated as if it came 172 // Determine if a given extension download should be treated as if it came
171 // from the gallery. Note that this is requires *both* that the download_url 173 // from the gallery. Note that this is requires *both* that the download_url
172 // match and that the download was referred from a gallery page. 174 // match and that the download was referred from a gallery page.
173 bool IsDownloadFromGallery(const GURL& download_url, 175 bool IsDownloadFromGallery(const GURL& download_url,
174 const GURL& referrer_url); 176 const GURL& referrer_url);
175 177
176 // Returns the Extension of hosted or packaged apps, NULL otherwise. 178 // Returns the Extension of hosted or packaged apps, NULL otherwise.
177 const Extension* GetInstalledApp(const GURL& url); 179 const extensions::Extension* GetInstalledApp(const GURL& url);
178 180
179 // Returns whether the URL is from either a hosted or packaged app. 181 // Returns whether the URL is from either a hosted or packaged app.
180 bool IsInstalledApp(const GURL& url); 182 bool IsInstalledApp(const GURL& url);
181 183
182 // Associates a renderer process with the given installed app. 184 // Associates a renderer process with the given installed app.
183 void SetInstalledAppForRenderer(int renderer_child_id, const Extension* app); 185 void SetInstalledAppForRenderer(int renderer_child_id,
186 const extensions::Extension* app);
184 187
185 // If the renderer is hosting an installed app, returns it, otherwise returns 188 // If the renderer is hosting an installed app, returns it, otherwise returns
186 // NULL. 189 // NULL.
187 const Extension* GetInstalledAppForRenderer(int renderer_child_id); 190 const extensions::Extension* GetInstalledAppForRenderer(
191 int renderer_child_id);
188 192
189 // Attempts to uninstall an extension from a given ExtensionService. Returns 193 // Attempts to uninstall an extension from a given ExtensionService. Returns
190 // true iff the target extension exists. 194 // true iff the target extension exists.
191 static bool UninstallExtensionHelper(ExtensionService* extensions_service, 195 static bool UninstallExtensionHelper(ExtensionService* extensions_service,
192 const std::string& extension_id); 196 const std::string& extension_id);
193 197
194 // Constructor stores pointers to |profile| and |extension_prefs| but 198 // Constructor stores pointers to |profile| and |extension_prefs| but
195 // ownership remains at caller. 199 // ownership remains at caller.
196 ExtensionService(Profile* profile, 200 ExtensionService(Profile* profile,
197 const CommandLine* command_line, 201 const CommandLine* command_line,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 // Updates the app launcher value for the moved extension so that it is now 241 // Updates the app launcher value for the moved extension so that it is now
238 // located after the given predecessor and before the successor. This will 242 // located after the given predecessor and before the successor. This will
239 // trigger a sync if needed. Empty strings are used to indicate no successor 243 // trigger a sync if needed. Empty strings are used to indicate no successor
240 // or predecessor. 244 // or predecessor.
241 void OnExtensionMoved(const std::string& moved_extension_id, 245 void OnExtensionMoved(const std::string& moved_extension_id,
242 const std::string& predecessor_extension_id, 246 const std::string& predecessor_extension_id,
243 const std::string& successor_extension_id); 247 const std::string& successor_extension_id);
244 248
245 // Returns true if the given extension can see events and data from another 249 // Returns true if the given extension can see events and data from another
246 // sub-profile (incognito to original profile, or vice versa). 250 // sub-profile (incognito to original profile, or vice versa).
247 bool CanCrossIncognito(const Extension* extension); 251 bool CanCrossIncognito(const extensions::Extension* extension);
248 252
249 // Returns true if the given extension can be loaded in incognito. 253 // Returns true if the given extension can be loaded in incognito.
250 bool CanLoadInIncognito(const Extension* extension) const; 254 bool CanLoadInIncognito(const extensions::Extension* extension) const;
251 255
252 // Whether this extension can inject scripts into pages with file URLs. 256 // Whether this extension can inject scripts into pages with file URLs.
253 bool AllowFileAccess(const Extension* extension); 257 bool AllowFileAccess(const extensions::Extension* extension);
254 // Will reload the extension since this permission is applied at loading time 258 // Will reload the extension since this permission is applied at loading time
255 // only. 259 // only.
256 void SetAllowFileAccess(const Extension* extension, bool allow); 260 void SetAllowFileAccess(const extensions::Extension* extension, bool allow);
257 261
258 // Getter and setter for the Browser Action visibility in the toolbar. 262 // Getter and setter for the Browser Action visibility in the toolbar.
259 bool GetBrowserActionVisibility(const Extension* extension); 263 bool GetBrowserActionVisibility(const extensions::Extension* extension);
260 void SetBrowserActionVisibility(const Extension* extension, bool visible); 264 void SetBrowserActionVisibility(const extensions::Extension* extension,
265 bool visible);
261 266
262 // Whether the persistent background page, if any, is ready. We don't load 267 // Whether the persistent background page, if any, is ready. We don't load
263 // other components until then. If there is no background page, or if it is 268 // other components until then. If there is no background page, or if it is
264 // non-persistent (lazy), we consider it to be ready. 269 // non-persistent (lazy), we consider it to be ready.
265 bool IsBackgroundPageReady(const Extension* extension); 270 bool IsBackgroundPageReady(const extensions::Extension* extension);
266 void SetBackgroundPageReady(const Extension* extension); 271 void SetBackgroundPageReady(const extensions::Extension* extension);
267 272
268 // Getter and setter for the flag that specifies whether the extension is 273 // Getter and setter for the flag that specifies whether the extension is
269 // being upgraded. 274 // being upgraded.
270 bool IsBeingUpgraded(const Extension* extension); 275 bool IsBeingUpgraded(const extensions::Extension* extension);
271 void SetBeingUpgraded(const Extension* extension, bool value); 276 void SetBeingUpgraded(const extensions::Extension* extension, bool value);
272 277
273 // Getter and setter for the flag that specifies if the extension has used 278 // Getter and setter for the flag that specifies if the extension has used
274 // the webrequest API. 279 // the webrequest API.
275 // TODO(mpcomplete): remove. http://crbug.com/100411 280 // TODO(mpcomplete): remove. http://crbug.com/100411
276 bool HasUsedWebRequest(const Extension* extension); 281 bool HasUsedWebRequest(const extensions::Extension* extension);
277 void SetHasUsedWebRequest(const Extension* extension, bool value); 282 void SetHasUsedWebRequest(const extensions::Extension* extension, bool value);
278 283
279 // Getter for the extension's runtime data PropertyBag. 284 // Getter for the extension's runtime data PropertyBag.
280 base::PropertyBag* GetPropertyBag(const Extension* extension); 285 base::PropertyBag* GetPropertyBag(const extensions::Extension* extension);
281 286
282 // Initialize and start all installed extensions. 287 // Initialize and start all installed extensions.
283 void Init(); 288 void Init();
284 289
285 // To delay some initialization until after import has finished, register 290 // To delay some initialization until after import has finished, register
286 // for the notification. 291 // for the notification.
287 // TODO(yoz): remove InitEventRoutersAterImport. 292 // TODO(yoz): remove InitEventRoutersAterImport.
288 void InitEventRoutersAfterImport(); 293 void InitEventRoutersAfterImport();
289 void RegisterForImportFinished(); 294 void RegisterForImportFinished();
290 295
291 // Complete some initialization after being notified that import has finished. 296 // Complete some initialization after being notified that import has finished.
292 void InitAfterImport(); 297 void InitAfterImport();
293 298
294 // Start up the extension event routers. 299 // Start up the extension event routers.
295 void InitEventRouters(); 300 void InitEventRouters();
296 301
297 // Look up an extension by ID. Does not include terminated 302 // Look up an extension by ID. Does not include terminated
298 // extensions. 303 // extensions.
299 virtual const Extension* GetExtensionById( 304 virtual const extensions::Extension* GetExtensionById(
300 const std::string& id, bool include_disabled) const OVERRIDE; 305 const std::string& id, bool include_disabled) const OVERRIDE;
301 306
302 // Looks up a terminated (crashed) extension by ID. 307 // Looks up a terminated (crashed) extension by ID.
303 const Extension* GetTerminatedExtension(const std::string& id) const; 308 const extensions::Extension*
309 GetTerminatedExtension(const std::string& id) const;
304 310
305 // Looks up an extension by ID, regardless of whether it's enabled, 311 // Looks up an extension by ID, regardless of whether it's enabled,
306 // disabled, or terminated. 312 // disabled, or terminated.
307 virtual const Extension* GetInstalledExtension( 313 virtual const extensions::Extension* GetInstalledExtension(
308 const std::string& id) const OVERRIDE; 314 const std::string& id) const OVERRIDE;
309 315
310 // Updates a currently-installed extension with the contents from 316 // Updates a currently-installed extension with the contents from
311 // |extension_path|. 317 // |extension_path|.
312 // TODO(aa): This method can be removed. ExtensionUpdater could use 318 // TODO(aa): This method can be removed. ExtensionUpdater could use
313 // CrxInstaller directly instead. 319 // CrxInstaller directly instead.
314 virtual bool UpdateExtension( 320 virtual bool UpdateExtension(
315 const std::string& id, 321 const std::string& id,
316 const FilePath& extension_path, 322 const FilePath& extension_path,
317 const GURL& download_url, 323 const GURL& download_url,
(...skipping 22 matching lines...) Expand all
340 virtual bool IsExternalExtensionUninstalled( 346 virtual bool IsExternalExtensionUninstalled(
341 const std::string& extension_id) const OVERRIDE; 347 const std::string& extension_id) const OVERRIDE;
342 348
343 // Enables the extension. If the extension is already enabled, does 349 // Enables the extension. If the extension is already enabled, does
344 // nothing. 350 // nothing.
345 virtual void EnableExtension(const std::string& extension_id); 351 virtual void EnableExtension(const std::string& extension_id);
346 352
347 // Disables the extension. If the extension is already disabled, or 353 // Disables the extension. If the extension is already disabled, or
348 // cannot be disabled, does nothing. 354 // cannot be disabled, does nothing.
349 virtual void DisableExtension(const std::string& extension_id, 355 virtual void DisableExtension(const std::string& extension_id,
350 Extension::DisableReason disable_reason); 356 extensions::Extension::DisableReason disable_reason);
351 357
352 // Updates the |extension|'s granted permissions lists to include all 358 // Updates the |extension|'s granted permissions lists to include all
353 // permissions in the |extension|'s manifest and re-enables the 359 // permissions in the |extension|'s manifest and re-enables the
354 // extension. 360 // extension.
355 void GrantPermissionsAndEnableExtension(const Extension* extension); 361 void GrantPermissionsAndEnableExtension(
362 const extensions::Extension* extension);
356 363
357 // Check for updates (or potentially new extensions from external providers) 364 // Check for updates (or potentially new extensions from external providers)
358 void CheckForExternalUpdates(); 365 void CheckForExternalUpdates();
359 366
360 // Unload the specified extension. 367 // Unload the specified extension.
361 virtual void UnloadExtension( 368 virtual void UnloadExtension(
362 const std::string& extension_id, 369 const std::string& extension_id,
363 extension_misc::UnloadedExtensionReason reason) OVERRIDE; 370 extension_misc::UnloadedExtensionReason reason) OVERRIDE;
364 371
365 // Unload all extensions. This is currently only called on shutdown, and 372 // Unload all extensions. This is currently only called on shutdown, and
366 // does not send notifications. 373 // does not send notifications.
367 void UnloadAllExtensions(); 374 void UnloadAllExtensions();
368 375
369 // Called only by testing. 376 // Called only by testing.
370 void ReloadExtensions(); 377 void ReloadExtensions();
371 378
372 // Scan the extension directory and clean up the cruft. 379 // Scan the extension directory and clean up the cruft.
373 void GarbageCollectExtensions(); 380 void GarbageCollectExtensions();
374 381
375 // Notifies Sync (if needed) of a newly-installed extension or a change to 382 // Notifies Sync (if needed) of a newly-installed extension or a change to
376 // an existing extension. 383 // an existing extension.
377 virtual void SyncExtensionChangeIfNeeded(const Extension& extension) OVERRIDE; 384 virtual void SyncExtensionChangeIfNeeded(
385 const extensions::Extension& extension) OVERRIDE;
378 386
379 // The App that represents the web store. 387 // The App that represents the web store.
380 const Extension* GetWebStoreApp(); 388 const extensions::Extension* GetWebStoreApp();
381 389
382 // Returns true if |url| should get extension api bindings and be permitted 390 // Returns true if |url| should get extension api bindings and be permitted
383 // to make api calls. Note that this is independent of what extension 391 // to make api calls. Note that this is independent of what extension
384 // permissions the given extension has been granted. 392 // permissions the given extension has been granted.
385 bool ExtensionBindingsAllowed(const GURL& url); 393 bool ExtensionBindingsAllowed(const GURL& url);
386 394
387 // Returns the icon to display in the omnibox for the given extension. 395 // Returns the icon to display in the omnibox for the given extension.
388 const SkBitmap& GetOmniboxIcon(const std::string& extension_id); 396 const SkBitmap& GetOmniboxIcon(const std::string& extension_id);
389 397
390 // Returns the icon to display in the omnibox popup window for the given 398 // Returns the icon to display in the omnibox popup window for the given
391 // extension. 399 // extension.
392 const SkBitmap& GetOmniboxPopupIcon(const std::string& extension_id); 400 const SkBitmap& GetOmniboxPopupIcon(const std::string& extension_id);
393 401
394 // Called when the initial extensions load has completed. 402 // Called when the initial extensions load has completed.
395 virtual void OnLoadedInstalledExtensions(); 403 virtual void OnLoadedInstalledExtensions();
396 404
397 // Adds |extension| to this ExtensionService and notifies observers than an 405 // Adds |extension| to this ExtensionService and notifies observers than an
398 // extension has been loaded. Called by the backend after an extension has 406 // extension has been loaded. Called by the backend after an extension has
399 // been loaded from a file and installed. 407 // been loaded from a file and installed.
400 virtual void AddExtension(const Extension* extension) OVERRIDE; 408 virtual void AddExtension(const extensions::Extension* extension) OVERRIDE;
401 409
402 // Called by the backend when an extension has been installed. 410 // Called by the backend when an extension has been installed.
403 void OnExtensionInstalled( 411 void OnExtensionInstalled(
404 const Extension* extension, 412 const extensions::Extension* extension,
405 bool from_webstore, 413 bool from_webstore,
406 const StringOrdinal& page_ordinal); 414 const StringOrdinal& page_ordinal);
407 415
408 // Initializes the |extension|'s active permission set and disables the 416 // Initializes the |extension|'s active permission set and disables the
409 // extension if the privilege level has increased (e.g., due to an upgrade). 417 // extension if the privilege level has increased (e.g., due to an upgrade).
410 void InitializePermissions(const Extension* extension); 418 void InitializePermissions(const extensions::Extension* extension);
411 419
412 // Go through each extensions in pref, unload blacklisted extensions 420 // Go through each extensions in pref, unload blacklisted extensions
413 // and update the blacklist state in pref. 421 // and update the blacklist state in pref.
414 virtual void UpdateExtensionBlacklist( 422 virtual void UpdateExtensionBlacklist(
415 const std::vector<std::string>& blacklist) OVERRIDE; 423 const std::vector<std::string>& blacklist) OVERRIDE;
416 424
417 // Go through each extension and unload those that the network admin has 425 // Go through each extension and unload those that the network admin has
418 // put on the blacklist (not to be confused with the Google managed blacklist 426 // put on the blacklist (not to be confused with the Google managed blacklist
419 // set of extensions. 427 // set of extensions.
420 virtual void CheckAdminBlacklist() OVERRIDE; 428 virtual void CheckAdminBlacklist() OVERRIDE;
421 429
422 virtual void CheckForUpdatesSoon() OVERRIDE; 430 virtual void CheckForUpdatesSoon() OVERRIDE;
423 431
424 // SyncableService implementation. 432 // SyncableService implementation.
425 virtual SyncError MergeDataAndStartSyncing( 433 virtual SyncError MergeDataAndStartSyncing(
426 syncable::ModelType type, 434 syncable::ModelType type,
427 const SyncDataList& initial_sync_data, 435 const SyncDataList& initial_sync_data,
428 scoped_ptr<SyncChangeProcessor> sync_processor, 436 scoped_ptr<SyncChangeProcessor> sync_processor,
429 scoped_ptr<SyncErrorFactory> sync_error_factory) OVERRIDE; 437 scoped_ptr<SyncErrorFactory> sync_error_factory) OVERRIDE;
430 virtual void StopSyncing(syncable::ModelType type) OVERRIDE; 438 virtual void StopSyncing(syncable::ModelType type) OVERRIDE;
431 virtual SyncDataList GetAllSyncData(syncable::ModelType type) const OVERRIDE; 439 virtual SyncDataList GetAllSyncData(syncable::ModelType type) const OVERRIDE;
432 virtual SyncError ProcessSyncChanges( 440 virtual SyncError ProcessSyncChanges(
433 const tracked_objects::Location& from_here, 441 const tracked_objects::Location& from_here,
434 const SyncChangeList& change_list) OVERRIDE; 442 const SyncChangeList& change_list) OVERRIDE;
435 443
436 // Gets the sync data for the given extension, assuming that the extension is 444 // Gets the sync data for the given extension, assuming that the extension is
437 // syncable. 445 // syncable.
438 extensions::ExtensionSyncData GetExtensionSyncData( 446 extensions::ExtensionSyncData GetExtensionSyncData(
439 const Extension& extension) const; 447 const extensions::Extension& extension) const;
440 448
441 // Gets the sync data for the given app, assuming that the app is 449 // Gets the sync data for the given app, assuming that the app is
442 // syncable. 450 // syncable.
443 extensions::AppSyncData GetAppSyncData(const Extension& extension) const; 451 extensions::AppSyncData GetAppSyncData(
452 const extensions::Extension& extension) const;
444 453
445 // Gets the ExtensionSyncData for all extensions. 454 // Gets the ExtensionSyncData for all extensions.
446 std::vector<extensions::ExtensionSyncData> GetExtensionSyncDataList() const; 455 std::vector<extensions::ExtensionSyncData> GetExtensionSyncDataList() const;
447 456
448 // Gets the AppSyncData for all extensions. 457 // Gets the AppSyncData for all extensions.
449 std::vector<extensions::AppSyncData> GetAppSyncDataList() const; 458 std::vector<extensions::AppSyncData> GetAppSyncDataList() const;
450 459
451 // Applies the change specified passed in by either ExtensionSyncData or 460 // Applies the change specified passed in by either ExtensionSyncData or
452 // AppSyncData to the current system. 461 // AppSyncData to the current system.
453 // Returns false if the changes were not completely applied and were added 462 // Returns false if the changes were not completely applied and were added
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 void CheckExternalUninstall(const std::string& id); 538 void CheckExternalUninstall(const std::string& id);
530 539
531 // Clear all ExternalExtensionProviders. 540 // Clear all ExternalExtensionProviders.
532 void ClearProvidersForTesting(); 541 void ClearProvidersForTesting();
533 542
534 // Adds an ExternalExtensionProviderInterface for the service to use during 543 // Adds an ExternalExtensionProviderInterface for the service to use during
535 // testing. Takes ownership of |test_provider|. 544 // testing. Takes ownership of |test_provider|.
536 void AddProviderForTesting(ExternalExtensionProviderInterface* test_provider); 545 void AddProviderForTesting(ExternalExtensionProviderInterface* test_provider);
537 546
538 // ExternalExtensionProvider::Visitor implementation. 547 // ExternalExtensionProvider::Visitor implementation.
539 virtual bool OnExternalExtensionFileFound(const std::string& id, 548 virtual bool OnExternalExtensionFileFound(
540 const Version* version, 549 const std::string& id,
541 const FilePath& path, 550 const Version* version,
542 Extension::Location location, 551 const FilePath& path,
543 int creation_flags, 552 extensions::Extension::Location location,
544 bool mark_acknowledged) 553 int creation_flags,
545 OVERRIDE; 554 bool mark_acknowledged) OVERRIDE;
546 555
547 virtual bool OnExternalExtensionUpdateUrlFound(const std::string& id, 556 virtual bool OnExternalExtensionUpdateUrlFound(
548 const GURL& update_url, 557 const std::string& id,
549 Extension::Location location) 558 const GURL& update_url,
550 OVERRIDE; 559 extensions::Extension::Location location) OVERRIDE;
551 560
552 virtual void OnExternalProviderReady( 561 virtual void OnExternalProviderReady(
553 const ExternalExtensionProviderInterface* provider) OVERRIDE; 562 const ExternalExtensionProviderInterface* provider) OVERRIDE;
554 563
555 // Returns true when all the external extension providers are ready. 564 // Returns true when all the external extension providers are ready.
556 bool AreAllExternalProvidersReady() const; 565 bool AreAllExternalProvidersReady() const;
557 566
558 void OnAllExternalProvidersReady(); 567 void OnAllExternalProvidersReady();
559 568
560 // Once all external providers are done, generates any needed alerts about 569 // Once all external providers are done, generates any needed alerts about
(...skipping 25 matching lines...) Expand all
586 595
587 // content::NotificationObserver 596 // content::NotificationObserver
588 virtual void Observe(int type, 597 virtual void Observe(int type,
589 const content::NotificationSource& source, 598 const content::NotificationSource& source,
590 const content::NotificationDetails& details) OVERRIDE; 599 const content::NotificationDetails& details) OVERRIDE;
591 600
592 // Whether there are any apps installed. Component apps are not included. 601 // Whether there are any apps installed. Component apps are not included.
593 bool HasApps() const; 602 bool HasApps() const;
594 603
595 // Gets the set of loaded app ids. Component apps are not included. 604 // Gets the set of loaded app ids. Component apps are not included.
596 ExtensionIdSet GetAppIds() const; 605 extensions::ExtensionIdSet GetAppIds() const;
597 606
598 // Record a histogram using the PermissionMessage enum values for each 607 // Record a histogram using the PermissionMessage enum values for each
599 // permission in |e|. 608 // permission in |e|.
600 // NOTE: If this is ever called with high frequency, the implementation may 609 // NOTE: If this is ever called with high frequency, the implementation may
601 // need to be made more efficient. 610 // need to be made more efficient.
602 static void RecordPermissionMessagesHistogram( 611 static void RecordPermissionMessagesHistogram(
603 const Extension* e, const char* histogram); 612 const extensions::Extension* e, const char* histogram);
604 613
605 #if defined(UNIT_TEST) 614 #if defined(UNIT_TEST)
606 void TrackTerminatedExtensionForTest(const Extension* extension) { 615 void TrackTerminatedExtensionForTest(const extensions::Extension* extension) {
607 TrackTerminatedExtension(extension); 616 TrackTerminatedExtension(extension);
608 } 617 }
609 #endif 618 #endif
610 619
611 ExtensionWarningSet* extension_warnings() { 620 ExtensionWarningSet* extension_warnings() {
612 return &extension_warnings_; 621 return &extension_warnings_;
613 } 622 }
614 623
615 // Call only from IO thread. 624 // Call only from IO thread.
616 extensions::APIResourceController* api_resource_controller(); 625 extensions::APIResourceController* api_resource_controller();
(...skipping 24 matching lines...) Expand all
641 struct NaClModuleInfo { 650 struct NaClModuleInfo {
642 NaClModuleInfo(); 651 NaClModuleInfo();
643 ~NaClModuleInfo(); 652 ~NaClModuleInfo();
644 653
645 GURL url; 654 GURL url;
646 std::string mime_type; 655 std::string mime_type;
647 }; 656 };
648 typedef std::list<NaClModuleInfo> NaClModuleInfoList; 657 typedef std::list<NaClModuleInfo> NaClModuleInfoList;
649 658
650 // Return true if the sync type of |extension| matches |type|. 659 // Return true if the sync type of |extension| matches |type|.
651 bool IsCorrectSyncType(const Extension& extension, syncable::ModelType type) 660 bool IsCorrectSyncType(const extensions::Extension& extension,
661 syncable::ModelType type)
652 const; 662 const;
653 663
654 // Handles setting the extension specific values in |extension_sync_data| to 664 // Handles setting the extension specific values in |extension_sync_data| to
655 // the current system. 665 // the current system.
656 // Returns false if the changes were not completely applied and need to be 666 // Returns false if the changes were not completely applied and need to be
657 // tried again later. 667 // tried again later.
658 bool ProcessExtensionSyncDataHelper( 668 bool ProcessExtensionSyncDataHelper(
659 const extensions::ExtensionSyncData& extension_sync_data, 669 const extensions::ExtensionSyncData& extension_sync_data,
660 syncable::ModelType type); 670 syncable::ModelType type);
661 671
662 // Look up an extension by ID, optionally including either or both of enabled 672 // Look up an extension by ID, optionally including either or both of enabled
663 // and disabled extensions. 673 // and disabled extensions.
664 const Extension* GetExtensionByIdInternal(const std::string& id, 674 const extensions::Extension* GetExtensionByIdInternal(
665 bool include_enabled, 675 const std::string& id,
666 bool include_disabled, 676 bool include_enabled,
667 bool include_terminated) const; 677 bool include_disabled,
678 bool include_terminated) const;
668 679
669 // Adds the given extension to the list of terminated extensions if 680 // Adds the given extension to the list of terminated extensions if
670 // it is not already there and unloads it. 681 // it is not already there and unloads it.
671 void TrackTerminatedExtension(const Extension* extension); 682 void TrackTerminatedExtension(const extensions::Extension* extension);
672 683
673 // Removes the extension with the given id from the list of 684 // Removes the extension with the given id from the list of
674 // terminated extensions if it is there. 685 // terminated extensions if it is there.
675 void UntrackTerminatedExtension(const std::string& id); 686 void UntrackTerminatedExtension(const std::string& id);
676 687
677 // Handles sending notification that |extension| was loaded. 688 // Handles sending notification that |extension| was loaded.
678 void NotifyExtensionLoaded(const Extension* extension); 689 void NotifyExtensionLoaded(const extensions::Extension* extension);
679 690
680 // Handles sending notification that |extension| was unloaded. 691 // Handles sending notification that |extension| was unloaded.
681 void NotifyExtensionUnloaded(const Extension* extension, 692 void NotifyExtensionUnloaded(const extensions::Extension* extension,
682 extension_misc::UnloadedExtensionReason reason); 693 extension_misc::UnloadedExtensionReason reason);
683 694
684 // Helper that updates the active extension list used for crash reporting. 695 // Helper that updates the active extension list used for crash reporting.
685 void UpdateActiveExtensionsInCrashReporter(); 696 void UpdateActiveExtensionsInCrashReporter();
686 697
687 // We implement some Pepper plug-ins using NaCl to take advantage of NaCl's 698 // We implement some Pepper plug-ins using NaCl to take advantage of NaCl's
688 // strong sandbox. Typically, these NaCl modules are stored in extensions 699 // strong sandbox. Typically, these NaCl modules are stored in extensions
689 // and registered here. Not all NaCl modules need to register for a MIME 700 // and registered here. Not all NaCl modules need to register for a MIME
690 // type, just the ones that are responsible for rendering a particular MIME 701 // type, just the ones that are responsible for rendering a particular MIME
691 // type, like application/pdf. Note: We only register NaCl modules in the 702 // type, like application/pdf. Note: We only register NaCl modules in the
(...skipping 29 matching lines...) Expand all
721 ExtensionSet terminated_extensions_; 732 ExtensionSet terminated_extensions_;
722 733
723 // Hold the set of pending extensions. 734 // Hold the set of pending extensions.
724 PendingExtensionManager pending_extension_manager_; 735 PendingExtensionManager pending_extension_manager_;
725 736
726 // The map of extension IDs to their runtime data. 737 // The map of extension IDs to their runtime data.
727 ExtensionRuntimeDataMap extension_runtime_data_; 738 ExtensionRuntimeDataMap extension_runtime_data_;
728 739
729 // Holds a map between renderer process IDs that are associated with an 740 // Holds a map between renderer process IDs that are associated with an
730 // installed app and their app. 741 // installed app and their app.
731 typedef std::map<int, scoped_refptr<const Extension> > InstalledAppMap; 742 typedef std::map<int, scoped_refptr<const extensions::Extension> >
743 InstalledAppMap;
732 InstalledAppMap installed_app_hosts_; 744 InstalledAppMap installed_app_hosts_;
733 745
734 // The full path to the directory where extensions are installed. 746 // The full path to the directory where extensions are installed.
735 FilePath install_directory_; 747 FilePath install_directory_;
736 748
737 // Whether or not extensions are enabled. 749 // Whether or not extensions are enabled.
738 bool extensions_enabled_; 750 bool extensions_enabled_;
739 751
740 // Whether to notify users when they attempt to install an extension. 752 // Whether to notify users when they attempt to install an extension.
741 bool show_extensions_prompts_; 753 bool show_extensions_prompts_;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 scoped_ptr<ExtensionGlobalError> extension_global_error_; 859 scoped_ptr<ExtensionGlobalError> extension_global_error_;
848 860
849 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, 861 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
850 InstallAppsWithUnlimtedStorage); 862 InstallAppsWithUnlimtedStorage);
851 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, 863 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
852 InstallAppsAndCheckStorageProtection); 864 InstallAppsAndCheckStorageProtection);
853 DISALLOW_COPY_AND_ASSIGN(ExtensionService); 865 DISALLOW_COPY_AND_ASSIGN(ExtensionService);
854 }; 866 };
855 867
856 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ 868 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698