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 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 extension_prefs_->GetSavedFileEntries( | |
|
benwells
2013/03/13 03:58:29
Should it just do this if events & RESTART?
koz (OOO until 15th September)
2013/03/13 05:01:13
Yes, good spot.
Done.
| |
| 747 extension_id, &on_restart_file_entries_[extension_id]); | |
| 748 | |
| 745 | 749 |
| 746 if (delayed_updates_for_idle_.Contains(extension_id)) { | 750 if (delayed_updates_for_idle_.Contains(extension_id)) { |
| 747 FinishDelayedInstallation(extension_id); | 751 FinishDelayedInstallation(extension_id); |
| 748 return; | 752 return; |
| 749 } | 753 } |
| 750 | 754 |
| 751 // If we're reloading a component extension, use the component extension | 755 // If we're reloading a component extension, use the component extension |
| 752 // loader's reloader. | 756 // loader's reloader. |
| 753 if (component_loader_->Exists(extension_id)) { | 757 if (component_loader_->Exists(extension_id)) { |
| 754 component_loader_->Reload(extension_id); | 758 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()) | 2898 if (it == on_load_events_.end()) |
| 2895 return; | 2899 return; |
| 2896 | 2900 |
| 2897 int events_to_fire = it->second; | 2901 int events_to_fire = it->second; |
| 2898 extensions::LazyBackgroundTaskQueue* queue = | 2902 extensions::LazyBackgroundTaskQueue* queue = |
| 2899 system_->lazy_background_task_queue(); | 2903 system_->lazy_background_task_queue(); |
| 2900 if (queue->ShouldEnqueueTask(profile(), extension)) { | 2904 if (queue->ShouldEnqueueTask(profile(), extension)) { |
| 2901 if (events_to_fire & EVENT_LAUNCHED) | 2905 if (events_to_fire & EVENT_LAUNCHED) |
| 2902 queue->AddPendingTask(profile(), extension->id(), | 2906 queue->AddPendingTask(profile(), extension->id(), |
| 2903 base::Bind(&ExtensionService::LaunchApplication)); | 2907 base::Bind(&ExtensionService::LaunchApplication)); |
| 2904 if (events_to_fire & EVENT_RESTARTED) | 2908 if (events_to_fire & EVENT_RESTARTED) { |
| 2909 SavedFileEntryMap::iterator it = | |
| 2910 on_restart_file_entries_.find(extension->id()); | |
| 2911 if (it == on_restart_file_entries_.end()) | |
| 2912 NOTREACHED(); | |
|
benwells
2013/03/13 03:58:29
I'm not quite sure about this NOTREACHED. It feels
koz (OOO until 15th September)
2013/03/13 05:01:13
Yeah, my rationale is that it'd be a programmer er
| |
| 2905 queue->AddPendingTask(profile(), extension->id(), | 2913 queue->AddPendingTask(profile(), extension->id(), |
| 2906 base::Bind(&ExtensionService::RestartApplication)); | 2914 base::Bind(&ExtensionService::RestartApplication, |
| 2915 it->second)); | |
| 2916 on_restart_file_entries_.erase(it); | |
| 2917 } | |
| 2907 } | 2918 } |
| 2908 | 2919 |
| 2909 on_load_events_.erase(it); | 2920 on_load_events_.erase(it); |
| 2910 } | 2921 } |
| 2911 | 2922 |
| 2912 // static | 2923 // static |
| 2913 void ExtensionService::LaunchApplication( | 2924 void ExtensionService::LaunchApplication( |
| 2914 extensions::ExtensionHost* extension_host) { | 2925 extensions::ExtensionHost* extension_host) { |
| 2915 if (!extension_host) | 2926 if (!extension_host) |
| 2916 return; | 2927 return; |
| 2917 | 2928 |
| 2918 #if !defined(OS_ANDROID) | 2929 #if !defined(OS_ANDROID) |
| 2919 extensions::LaunchPlatformApp(extension_host->profile(), | 2930 extensions::LaunchPlatformApp(extension_host->profile(), |
| 2920 extension_host->extension(), | 2931 extension_host->extension(), |
| 2921 NULL, base::FilePath()); | 2932 NULL, base::FilePath()); |
| 2922 #endif | 2933 #endif |
| 2923 } | 2934 } |
| 2924 | 2935 |
| 2925 // static | 2936 // static |
| 2926 void ExtensionService::RestartApplication( | 2937 void ExtensionService::RestartApplication( |
| 2938 std::vector<extensions::app_file_handler_util::SavedFileEntry> file_entries, | |
| 2927 extensions::ExtensionHost* extension_host) { | 2939 extensions::ExtensionHost* extension_host) { |
| 2928 if (!extension_host) | 2940 if (!extension_host) |
| 2929 return; | 2941 return; |
| 2930 | 2942 |
| 2931 #if !defined(OS_ANDROID) | 2943 #if !defined(OS_ANDROID) |
| 2932 extensions::AppEventRouter::DispatchOnRestartedEvent( | 2944 extensions::RestartPlatformAppWithFileEntries( |
| 2933 extension_host->profile(), extension_host->extension()); | 2945 extension_host->profile(), extension_host->extension(), file_entries); |
| 2934 #endif | 2946 #endif |
| 2935 } | 2947 } |
| 2936 | 2948 |
| 2937 bool ExtensionService::HasShellWindows(const std::string& extension_id) { | 2949 bool ExtensionService::HasShellWindows(const std::string& extension_id) { |
| 2938 const Extension* current_extension = GetExtensionById(extension_id, false); | 2950 const Extension* current_extension = GetExtensionById(extension_id, false); |
| 2939 return current_extension && current_extension->is_platform_app() && | 2951 return current_extension && current_extension->is_platform_app() && |
| 2940 !extensions::ShellWindowRegistry::Get(profile_)-> | 2952 !extensions::ShellWindowRegistry::Get(profile_)-> |
| 2941 GetShellWindowsForApp(extension_id).empty(); | 2953 GetShellWindowsForApp(extension_id).empty(); |
| 2942 } | 2954 } |
| 2943 | 2955 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3090 if (!extension) | 3102 if (!extension) |
| 3091 continue; | 3103 continue; |
| 3092 blacklisted_extensions_.Insert(extension); | 3104 blacklisted_extensions_.Insert(extension); |
| 3093 UnloadExtension(*it, extension_misc::UNLOAD_REASON_BLACKLIST); | 3105 UnloadExtension(*it, extension_misc::UNLOAD_REASON_BLACKLIST); |
| 3094 UMA_HISTOGRAM_ENUMERATION("ExtensionBlacklist.BlacklistInstalled", | 3106 UMA_HISTOGRAM_ENUMERATION("ExtensionBlacklist.BlacklistInstalled", |
| 3095 extension->location(), Manifest::NUM_LOCATIONS); | 3107 extension->location(), Manifest::NUM_LOCATIONS); |
| 3096 } | 3108 } |
| 3097 | 3109 |
| 3098 IdentifyAlertableExtensions(); | 3110 IdentifyAlertableExtensions(); |
| 3099 } | 3111 } |
| OLD | NEW |