Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "chrome/browser/extensions/extension_service.h" | 5 #include "chrome/browser/extensions/extension_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 #include "chrome/browser/themes/theme_service_factory.h" | 71 #include "chrome/browser/themes/theme_service_factory.h" |
| 72 #include "chrome/browser/ui/webui/favicon_source.h" | 72 #include "chrome/browser/ui/webui/favicon_source.h" |
| 73 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" | 73 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" |
| 74 #include "chrome/browser/ui/webui/theme_source.h" | 74 #include "chrome/browser/ui/webui/theme_source.h" |
| 75 #include "chrome/common/child_process_logging.h" | 75 #include "chrome/common/child_process_logging.h" |
| 76 #include "chrome/common/chrome_notification_types.h" | 76 #include "chrome/common/chrome_notification_types.h" |
| 77 #include "chrome/common/chrome_paths.h" | 77 #include "chrome/common/chrome_paths.h" |
| 78 #include "chrome/common/chrome_switches.h" | 78 #include "chrome/common/chrome_switches.h" |
| 79 #include "chrome/common/chrome_version_info.h" | 79 #include "chrome/common/chrome_version_info.h" |
| 80 #include "chrome/common/extensions/api/plugins/plugins_handler.h" | 80 #include "chrome/common/extensions/api/plugins/plugins_handler.h" |
| 81 #include "chrome/common/extensions/api/url_handlers/url_handlers_parser.h" | |
| 81 #include "chrome/common/extensions/background_info.h" | 82 #include "chrome/common/extensions/background_info.h" |
| 82 #include "chrome/common/extensions/extension.h" | 83 #include "chrome/common/extensions/extension.h" |
| 83 #include "chrome/common/extensions/extension_file_util.h" | 84 #include "chrome/common/extensions/extension_file_util.h" |
| 84 #include "chrome/common/extensions/extension_manifest_constants.h" | 85 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 85 #include "chrome/common/extensions/extension_messages.h" | 86 #include "chrome/common/extensions/extension_messages.h" |
| 86 #include "chrome/common/extensions/feature_switch.h" | 87 #include "chrome/common/extensions/feature_switch.h" |
| 87 #include "chrome/common/extensions/features/feature.h" | 88 #include "chrome/common/extensions/features/feature.h" |
| 88 #include "chrome/common/extensions/incognito_handler.h" | 89 #include "chrome/common/extensions/incognito_handler.h" |
| 89 #include "chrome/common/extensions/manifest.h" | 90 #include "chrome/common/extensions/manifest.h" |
| 90 #include "chrome/common/extensions/manifest_handlers/app_isolation_info.h" | 91 #include "chrome/common/extensions/manifest_handlers/app_isolation_info.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 using extensions::CrxInstaller; | 125 using extensions::CrxInstaller; |
| 125 using extensions::Extension; | 126 using extensions::Extension; |
| 126 using extensions::ExtensionIdSet; | 127 using extensions::ExtensionIdSet; |
| 127 using extensions::ExtensionInfo; | 128 using extensions::ExtensionInfo; |
| 128 using extensions::FeatureSwitch; | 129 using extensions::FeatureSwitch; |
| 129 using extensions::Manifest; | 130 using extensions::Manifest; |
| 130 using extensions::PermissionMessage; | 131 using extensions::PermissionMessage; |
| 131 using extensions::PermissionMessages; | 132 using extensions::PermissionMessages; |
| 132 using extensions::PermissionSet; | 133 using extensions::PermissionSet; |
| 133 using extensions::UnloadedExtensionInfo; | 134 using extensions::UnloadedExtensionInfo; |
| 135 using extensions::AppEventRouter; | |
| 134 | 136 |
| 135 namespace errors = extension_manifest_errors; | 137 namespace errors = extension_manifest_errors; |
| 136 | 138 |
| 137 namespace { | 139 namespace { |
| 138 | 140 |
| 139 // Histogram values for logging events related to externally installed | 141 // Histogram values for logging events related to externally installed |
| 140 // extensions. | 142 // extensions. |
| 141 enum ExternalExtensionEvent { | 143 enum ExternalExtensionEvent { |
| 142 EXTERNAL_EXTENSION_INSTALLED = 0, | 144 EXTERNAL_EXTENSION_INSTALLED = 0, |
| 143 EXTERNAL_EXTENSION_IGNORED, | 145 EXTERNAL_EXTENSION_IGNORED, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 "Local Extension Settings"; | 194 "Local Extension Settings"; |
| 193 const char ExtensionService::kSyncAppSettingsDirectoryName[] = | 195 const char ExtensionService::kSyncAppSettingsDirectoryName[] = |
| 194 "Sync App Settings"; | 196 "Sync App Settings"; |
| 195 const char ExtensionService::kSyncExtensionSettingsDirectoryName[] = | 197 const char ExtensionService::kSyncExtensionSettingsDirectoryName[] = |
| 196 "Sync Extension Settings"; | 198 "Sync Extension Settings"; |
| 197 const char ExtensionService::kManagedSettingsDirectoryName[] = | 199 const char ExtensionService::kManagedSettingsDirectoryName[] = |
| 198 "Managed Extension Settings"; | 200 "Managed Extension Settings"; |
| 199 const char ExtensionService::kStateStoreName[] = "Extension State"; | 201 const char ExtensionService::kStateStoreName[] = "Extension State"; |
| 200 const char ExtensionService::kRulesStoreName[] = "Extension Rules"; | 202 const char ExtensionService::kRulesStoreName[] = "Extension Rules"; |
| 201 | 203 |
| 204 bool ExtensionService::OnMessageReceived(const IPC::Message& message) { | |
| 205 bool handled = true; | |
| 206 IPC_BEGIN_MESSAGE_MAP(ExtensionService, message) | |
| 207 IPC_MESSAGE_HANDLER(ExtensionHostMsg_OnRedirectUrlToApp, | |
| 208 OnRedirectUrlToApp) | |
| 209 IPC_MESSAGE_UNHANDLED(handled = false) | |
| 210 IPC_END_MESSAGE_MAP() | |
| 211 return handled; | |
| 212 } | |
| 213 | |
| 202 void ExtensionService::CheckExternalUninstall(const std::string& id) { | 214 void ExtensionService::CheckExternalUninstall(const std::string& id) { |
| 203 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 215 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 204 | 216 |
| 205 // Check if the providers know about this extension. | 217 // Check if the providers know about this extension. |
| 206 extensions::ProviderCollection::const_iterator i; | 218 extensions::ProviderCollection::const_iterator i; |
| 207 for (i = external_extension_providers_.begin(); | 219 for (i = external_extension_providers_.begin(); |
| 208 i != external_extension_providers_.end(); ++i) { | 220 i != external_extension_providers_.end(); ++i) { |
| 209 DCHECK(i->get()->IsReady()); | 221 DCHECK(i->get()->IsReady()); |
| 210 if (i->get()->HasExtension(id)) | 222 if (i->get()->HasExtension(id)) |
| 211 return; // Yup, known extension, don't uninstall. | 223 return; // Yup, known extension, don't uninstall. |
| (...skipping 2274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2486 const Extension* extension = extensions_.GetExtensionOrAppByURL( | 2498 const Extension* extension = extensions_.GetExtensionOrAppByURL( |
| 2487 ExtensionURLInfo(*url)); | 2499 ExtensionURLInfo(*url)); |
| 2488 if (extension && extension->is_platform_app()) { | 2500 if (extension && extension->is_platform_app()) { |
| 2489 *url = GURL(chrome::kExtensionInvalidRequestURL); | 2501 *url = GURL(chrome::kExtensionInvalidRequestURL); |
| 2490 return true; | 2502 return true; |
| 2491 } | 2503 } |
| 2492 | 2504 |
| 2493 return false; | 2505 return false; |
| 2494 } | 2506 } |
| 2495 | 2507 |
| 2508 bool ExtensionService::MaybeRedirectUrlToApp(const GURL& url, | |
| 2509 const GURL& referrer_url) { | |
| 2510 // NOTE: The current API spec enforces at most a single app matching a URL. | |
| 2511 // TODO: Actually implement the above-mentioned enforcement. | |
| 2512 const extensions::UrlHandlerInfo* handler = | |
| 2513 extensions_.GetHandlingAppForURL(url); | |
| 2514 if (handler) { | |
| 2515 CHECK(handler->app->is_platform_app()); | |
| 2516 extensions::AppEventRouter::DispatchOnLaunchedEventWithURL( | |
| 2517 profile_, handler->app, handler->id, url, referrer_url); | |
| 2518 return true; | |
| 2519 } | |
| 2520 | |
| 2521 return false; | |
| 2522 } | |
| 2523 | |
| 2524 void ExtensionService::OnRedirectUrlToApp(const std::string& app_id, | |
| 2525 const std::string& handler_id, | |
| 2526 const GURL& url, | |
| 2527 const GURL& referrer_url) { | |
| 2528 const Extension* app = GetExtensionById(app_id, true); | |
| 2529 if (app) { | |
| 2530 CHECK(app->is_platform_app()); | |
|
asargent_no_longer_on_chrome
2013/08/14 18:05:12
Note that a renderer process could be compromised,
sergeygs
2013/08/18 11:40:24
After more careful thinking, this should have been
| |
| 2531 extensions::AppEventRouter::DispatchOnLaunchedEventWithURL( | |
| 2532 profile_, app, handler_id, url, referrer_url); | |
| 2533 } | |
| 2534 } | |
| 2535 | |
| 2496 bool ExtensionService::OnExternalExtensionFileFound( | 2536 bool ExtensionService::OnExternalExtensionFileFound( |
| 2497 const std::string& id, | 2537 const std::string& id, |
| 2498 const Version* version, | 2538 const Version* version, |
| 2499 const base::FilePath& path, | 2539 const base::FilePath& path, |
| 2500 Manifest::Location location, | 2540 Manifest::Location location, |
| 2501 int creation_flags, | 2541 int creation_flags, |
| 2502 bool mark_acknowledged) { | 2542 bool mark_acknowledged) { |
| 2503 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2543 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 2504 CHECK(Extension::IdIsValid(id)); | 2544 CHECK(Extension::IdIsValid(id)); |
| 2505 if (extension_prefs_->IsExternalExtensionUninstalled(id)) | 2545 if (extension_prefs_->IsExternalExtensionUninstalled(id)) |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3084 } | 3124 } |
| 3085 | 3125 |
| 3086 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { | 3126 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { |
| 3087 update_observers_.AddObserver(observer); | 3127 update_observers_.AddObserver(observer); |
| 3088 } | 3128 } |
| 3089 | 3129 |
| 3090 void ExtensionService::RemoveUpdateObserver( | 3130 void ExtensionService::RemoveUpdateObserver( |
| 3091 extensions::UpdateObserver* observer) { | 3131 extensions::UpdateObserver* observer) { |
| 3092 update_observers_.RemoveObserver(observer); | 3132 update_observers_.RemoveObserver(observer); |
| 3093 } | 3133 } |
| OLD | NEW |