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 |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "base/threading/sequenced_worker_pool.h" | 16 #include "base/threading/sequenced_worker_pool.h" |
17 #include "base/threading/thread_restrictions.h" | 17 #include "base/threading/thread_restrictions.h" |
18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
19 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
20 #include "chrome/browser/chrome_notification_types.h" | 20 #include "chrome/browser/chrome_notification_types.h" |
21 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 21 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
22 #include "chrome/browser/extensions/component_loader.h" | 22 #include "chrome/browser/extensions/component_loader.h" |
23 #include "chrome/browser/extensions/crx_installer.h" | 23 #include "chrome/browser/extensions/crx_installer.h" |
24 #include "chrome/browser/extensions/data_deleter.h" | 24 #include "chrome/browser/extensions/data_deleter.h" |
25 #include "chrome/browser/extensions/extension_disabled_ui.h" | 25 #include "chrome/browser/extensions/extension_disabled_ui.h" |
26 #include "chrome/browser/extensions/extension_error_controller.h" | 26 #include "chrome/browser/extensions/extension_error_controller.h" |
27 #include "chrome/browser/extensions/extension_error_reporter.h" | |
28 #include "chrome/browser/extensions/extension_install_ui.h" | 27 #include "chrome/browser/extensions/extension_install_ui.h" |
29 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 28 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
30 #include "chrome/browser/extensions/extension_sync_service.h" | 29 #include "chrome/browser/extensions/extension_sync_service.h" |
31 #include "chrome/browser/extensions/extension_util.h" | 30 #include "chrome/browser/extensions/extension_util.h" |
32 #include "chrome/browser/extensions/external_install_ui.h" | 31 #include "chrome/browser/extensions/external_install_ui.h" |
33 #include "chrome/browser/extensions/external_provider_impl.h" | 32 #include "chrome/browser/extensions/external_provider_impl.h" |
34 #include "chrome/browser/extensions/install_verifier.h" | 33 #include "chrome/browser/extensions/install_verifier.h" |
35 #include "chrome/browser/extensions/installed_loader.h" | 34 #include "chrome/browser/extensions/installed_loader.h" |
36 #include "chrome/browser/extensions/pending_extension_manager.h" | 35 #include "chrome/browser/extensions/pending_extension_manager.h" |
37 #include "chrome/browser/extensions/permissions_updater.h" | 36 #include "chrome/browser/extensions/permissions_updater.h" |
(...skipping 2019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2057 | 2056 |
2058 // Depending on the source, a new external extension might not need a user | 2057 // Depending on the source, a new external extension might not need a user |
2059 // notification on installation. For such extensions, mark them acknowledged | 2058 // notification on installation. For such extensions, mark them acknowledged |
2060 // now to suppress the notification. | 2059 // now to suppress the notification. |
2061 if (mark_acknowledged) | 2060 if (mark_acknowledged) |
2062 AcknowledgeExternalExtension(id); | 2061 AcknowledgeExternalExtension(id); |
2063 | 2062 |
2064 return true; | 2063 return true; |
2065 } | 2064 } |
2066 | 2065 |
2067 void ExtensionService::ReportExtensionLoadError( | |
2068 const base::FilePath& extension_path, | |
2069 const std::string &error) { | |
2070 content::NotificationService::current()->Notify( | |
2071 chrome::NOTIFICATION_EXTENSION_LOAD_ERROR, | |
2072 content::Source<Profile>(profile_), | |
2073 content::Details<const std::string>(&error)); | |
2074 | |
2075 std::string path_str = base::UTF16ToUTF8(extension_path.LossyDisplayName()); | |
2076 base::string16 message = base::UTF8ToUTF16( | |
2077 base::StringPrintf("Could not load extension from '%s'. %s", | |
2078 path_str.c_str(), | |
2079 error.c_str())); | |
2080 ExtensionErrorReporter::GetInstance()->ReportError(message, false); | |
2081 } | |
2082 | |
2083 void ExtensionService::DidCreateRenderViewForBackgroundPage( | 2066 void ExtensionService::DidCreateRenderViewForBackgroundPage( |
2084 extensions::ExtensionHost* host) { | 2067 extensions::ExtensionHost* host) { |
2085 OrphanedDevTools::iterator iter = | 2068 OrphanedDevTools::iterator iter = |
2086 orphaned_dev_tools_.find(host->extension_id()); | 2069 orphaned_dev_tools_.find(host->extension_id()); |
2087 if (iter == orphaned_dev_tools_.end()) | 2070 if (iter == orphaned_dev_tools_.end()) |
2088 return; | 2071 return; |
2089 | 2072 |
2090 iter->second->ConnectRenderViewHost(host->render_view_host()); | 2073 iter->second->ConnectRenderViewHost(host->render_view_host()); |
2091 orphaned_dev_tools_.erase(iter); | 2074 orphaned_dev_tools_.erase(iter); |
2092 } | 2075 } |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2426 void ExtensionService::UnloadAllExtensionsInternal() { | 2409 void ExtensionService::UnloadAllExtensionsInternal() { |
2427 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); | 2410 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); |
2428 | 2411 |
2429 registry_->ClearAll(); | 2412 registry_->ClearAll(); |
2430 system_->runtime_data()->ClearAll(); | 2413 system_->runtime_data()->ClearAll(); |
2431 | 2414 |
2432 // TODO(erikkay) should there be a notification for this? We can't use | 2415 // TODO(erikkay) should there be a notification for this? We can't use |
2433 // EXTENSION_UNLOADED since that implies that the extension has been disabled | 2416 // EXTENSION_UNLOADED since that implies that the extension has been disabled |
2434 // or uninstalled. | 2417 // or uninstalled. |
2435 } | 2418 } |
OLD | NEW |