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 14 matching lines...) Expand all Loading... |
25 #include "base/threading/thread_restrictions.h" | 25 #include "base/threading/thread_restrictions.h" |
26 #include "base/time.h" | 26 #include "base/time.h" |
27 #include "base/utf_string_conversions.h" | 27 #include "base/utf_string_conversions.h" |
28 #include "base/values.h" | 28 #include "base/values.h" |
29 #include "base/version.h" | 29 #include "base/version.h" |
30 #include "chrome/browser/browser_process.h" | 30 #include "chrome/browser/browser_process.h" |
31 #include "chrome/browser/devtools/devtools_window.h" | 31 #include "chrome/browser/devtools/devtools_window.h" |
32 #include "chrome/browser/extensions/api/app_runtime/app_runtime_api.h" | 32 #include "chrome/browser/extensions/api/app_runtime/app_runtime_api.h" |
33 #include "chrome/browser/extensions/api/declarative/rules_registry_service.h" | 33 #include "chrome/browser/extensions/api/declarative/rules_registry_service.h" |
34 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 34 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
| 35 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h" |
35 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" | 36 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" |
36 #include "chrome/browser/extensions/api/runtime/runtime_api.h" | 37 #include "chrome/browser/extensions/api/runtime/runtime_api.h" |
37 #include "chrome/browser/extensions/api/storage/settings_frontend.h" | 38 #include "chrome/browser/extensions/api/storage/settings_frontend.h" |
38 #include "chrome/browser/extensions/app_sync_data.h" | 39 #include "chrome/browser/extensions/app_sync_data.h" |
39 #include "chrome/browser/extensions/browser_event_router.h" | 40 #include "chrome/browser/extensions/browser_event_router.h" |
40 #include "chrome/browser/extensions/component_loader.h" | 41 #include "chrome/browser/extensions/component_loader.h" |
41 #include "chrome/browser/extensions/crx_installer.h" | 42 #include "chrome/browser/extensions/crx_installer.h" |
42 #include "chrome/browser/extensions/data_deleter.h" | 43 #include "chrome/browser/extensions/data_deleter.h" |
43 #include "chrome/browser/extensions/extension_disabled_ui.h" | 44 #include "chrome/browser/extensions/extension_disabled_ui.h" |
44 #include "chrome/browser/extensions/extension_error_reporter.h" | 45 #include "chrome/browser/extensions/extension_error_reporter.h" |
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 } | 736 } |
736 | 737 |
737 path = current_extension->path(); | 738 path = current_extension->path(); |
738 DisableExtension(extension_id, Extension::DISABLE_RELOAD); | 739 DisableExtension(extension_id, Extension::DISABLE_RELOAD); |
739 disabled_extension_paths_[extension_id] = path; | 740 disabled_extension_paths_[extension_id] = path; |
740 } else { | 741 } else { |
741 path = unloaded_extension_paths_[extension_id]; | 742 path = unloaded_extension_paths_[extension_id]; |
742 } | 743 } |
743 | 744 |
744 on_load_events_[extension_id] = events; | 745 on_load_events_[extension_id] = events; |
| 746 if (events & EVENT_RESTARTED) { |
| 747 extension_prefs_->GetSavedFileEntries( |
| 748 extension_id, &on_restart_file_entries_[extension_id]); |
| 749 } |
| 750 |
745 | 751 |
746 if (delayed_updates_for_idle_.Contains(extension_id)) { | 752 if (delayed_updates_for_idle_.Contains(extension_id)) { |
747 FinishDelayedInstallation(extension_id); | 753 FinishDelayedInstallation(extension_id); |
748 return; | 754 return; |
749 } | 755 } |
750 | 756 |
751 // If we're reloading a component extension, use the component extension | 757 // If we're reloading a component extension, use the component extension |
752 // loader's reloader. | 758 // loader's reloader. |
753 if (component_loader_->Exists(extension_id)) { | 759 if (component_loader_->Exists(extension_id)) { |
754 component_loader_->Reload(extension_id); | 760 component_loader_->Reload(extension_id); |
(...skipping 2139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2894 if (it == on_load_events_.end()) | 2900 if (it == on_load_events_.end()) |
2895 return; | 2901 return; |
2896 | 2902 |
2897 int events_to_fire = it->second; | 2903 int events_to_fire = it->second; |
2898 extensions::LazyBackgroundTaskQueue* queue = | 2904 extensions::LazyBackgroundTaskQueue* queue = |
2899 system_->lazy_background_task_queue(); | 2905 system_->lazy_background_task_queue(); |
2900 if (queue->ShouldEnqueueTask(profile(), extension)) { | 2906 if (queue->ShouldEnqueueTask(profile(), extension)) { |
2901 if (events_to_fire & EVENT_LAUNCHED) | 2907 if (events_to_fire & EVENT_LAUNCHED) |
2902 queue->AddPendingTask(profile(), extension->id(), | 2908 queue->AddPendingTask(profile(), extension->id(), |
2903 base::Bind(&ExtensionService::LaunchApplication)); | 2909 base::Bind(&ExtensionService::LaunchApplication)); |
2904 if (events_to_fire & EVENT_RESTARTED) | 2910 if (events_to_fire & EVENT_RESTARTED) { |
| 2911 SavedFileEntryMap::iterator it = |
| 2912 on_restart_file_entries_.find(extension->id()); |
| 2913 if (it == on_restart_file_entries_.end()) |
| 2914 NOTREACHED(); |
2905 queue->AddPendingTask(profile(), extension->id(), | 2915 queue->AddPendingTask(profile(), extension->id(), |
2906 base::Bind(&ExtensionService::RestartApplication)); | 2916 base::Bind(&ExtensionService::RestartApplication, |
| 2917 it->second)); |
| 2918 on_restart_file_entries_.erase(it); |
| 2919 } |
2907 } | 2920 } |
2908 | 2921 |
2909 on_load_events_.erase(it); | 2922 on_load_events_.erase(it); |
2910 } | 2923 } |
2911 | 2924 |
2912 // static | 2925 // static |
2913 void ExtensionService::LaunchApplication( | 2926 void ExtensionService::LaunchApplication( |
2914 extensions::ExtensionHost* extension_host) { | 2927 extensions::ExtensionHost* extension_host) { |
2915 if (!extension_host) | 2928 if (!extension_host) |
2916 return; | 2929 return; |
2917 | 2930 |
2918 #if !defined(OS_ANDROID) | 2931 #if !defined(OS_ANDROID) |
2919 extensions::LaunchPlatformApp(extension_host->profile(), | 2932 extensions::LaunchPlatformApp(extension_host->profile(), |
2920 extension_host->extension(), | 2933 extension_host->extension(), |
2921 NULL, base::FilePath()); | 2934 NULL, base::FilePath()); |
2922 #endif | 2935 #endif |
2923 } | 2936 } |
2924 | 2937 |
2925 // static | 2938 // static |
2926 void ExtensionService::RestartApplication( | 2939 void ExtensionService::RestartApplication( |
| 2940 std::vector<extensions::app_file_handler_util::SavedFileEntry> file_entries, |
2927 extensions::ExtensionHost* extension_host) { | 2941 extensions::ExtensionHost* extension_host) { |
2928 if (!extension_host) | 2942 if (!extension_host) |
2929 return; | 2943 return; |
2930 | 2944 |
2931 #if !defined(OS_ANDROID) | 2945 #if !defined(OS_ANDROID) |
2932 extensions::AppEventRouter::DispatchOnRestartedEvent( | 2946 extensions::RestartPlatformAppWithFileEntries( |
2933 extension_host->profile(), extension_host->extension()); | 2947 extension_host->profile(), extension_host->extension(), file_entries); |
2934 #endif | 2948 #endif |
2935 } | 2949 } |
2936 | 2950 |
2937 bool ExtensionService::HasShellWindows(const std::string& extension_id) { | 2951 bool ExtensionService::HasShellWindows(const std::string& extension_id) { |
2938 const Extension* current_extension = GetExtensionById(extension_id, false); | 2952 const Extension* current_extension = GetExtensionById(extension_id, false); |
2939 return current_extension && current_extension->is_platform_app() && | 2953 return current_extension && current_extension->is_platform_app() && |
2940 !extensions::ShellWindowRegistry::Get(profile_)-> | 2954 !extensions::ShellWindowRegistry::Get(profile_)-> |
2941 GetShellWindowsForApp(extension_id).empty(); | 2955 GetShellWindowsForApp(extension_id).empty(); |
2942 } | 2956 } |
2943 | 2957 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3090 if (!extension) | 3104 if (!extension) |
3091 continue; | 3105 continue; |
3092 blacklisted_extensions_.Insert(extension); | 3106 blacklisted_extensions_.Insert(extension); |
3093 UnloadExtension(*it, extension_misc::UNLOAD_REASON_BLACKLIST); | 3107 UnloadExtension(*it, extension_misc::UNLOAD_REASON_BLACKLIST); |
3094 UMA_HISTOGRAM_ENUMERATION("ExtensionBlacklist.BlacklistInstalled", | 3108 UMA_HISTOGRAM_ENUMERATION("ExtensionBlacklist.BlacklistInstalled", |
3095 extension->location(), Manifest::NUM_LOCATIONS); | 3109 extension->location(), Manifest::NUM_LOCATIONS); |
3096 } | 3110 } |
3097 | 3111 |
3098 IdentifyAlertableExtensions(); | 3112 IdentifyAlertableExtensions(); |
3099 } | 3113 } |
OLD | NEW |