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