Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(463)

Side by Side Diff: chrome/browser/extensions/extension_service.cc

Issue 14607023: Add support for persistent file access in apps. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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"
36 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" 35 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
37 #include "chrome/browser/extensions/api/runtime/runtime_api.h" 36 #include "chrome/browser/extensions/api/runtime/runtime_api.h"
38 #include "chrome/browser/extensions/api/storage/settings_frontend.h" 37 #include "chrome/browser/extensions/api/storage/settings_frontend.h"
39 #include "chrome/browser/extensions/app_sync_data.h" 38 #include "chrome/browser/extensions/app_sync_data.h"
40 #include "chrome/browser/extensions/browser_event_router.h" 39 #include "chrome/browser/extensions/browser_event_router.h"
41 #include "chrome/browser/extensions/component_loader.h" 40 #include "chrome/browser/extensions/component_loader.h"
42 #include "chrome/browser/extensions/crx_installer.h" 41 #include "chrome/browser/extensions/crx_installer.h"
43 #include "chrome/browser/extensions/data_deleter.h" 42 #include "chrome/browser/extensions/data_deleter.h"
44 #include "chrome/browser/extensions/extension_disabled_ui.h" 43 #include "chrome/browser/extensions/extension_disabled_ui.h"
45 #include "chrome/browser/extensions/extension_error_reporter.h" 44 #include "chrome/browser/extensions/extension_error_reporter.h"
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 } 729 }
731 730
732 path = current_extension->path(); 731 path = current_extension->path();
733 DisableExtension(extension_id, Extension::DISABLE_RELOAD); 732 DisableExtension(extension_id, Extension::DISABLE_RELOAD);
734 reloading_extensions_.insert(extension_id); 733 reloading_extensions_.insert(extension_id);
735 } else { 734 } else {
736 path = unloaded_extension_paths_[extension_id]; 735 path = unloaded_extension_paths_[extension_id];
737 } 736 }
738 737
739 on_load_events_[extension_id] = events; 738 on_load_events_[extension_id] = events;
740 if (events & EVENT_RESTARTED) {
741 extensions::app_file_handler_util::GetSavedFileEntries(
742 extension_prefs_,
743 extension_id,
744 &on_restart_file_entries_[extension_id]);
745 }
746
747 739
748 if (delayed_updates_for_idle_.Contains(extension_id)) { 740 if (delayed_updates_for_idle_.Contains(extension_id)) {
749 FinishDelayedInstallation(extension_id); 741 FinishDelayedInstallation(extension_id);
750 return; 742 return;
751 } 743 }
752 744
753 // If we're reloading a component extension, use the component extension 745 // If we're reloading a component extension, use the component extension
754 // loader's reloader. 746 // loader's reloader.
755 if (component_loader_->Exists(extension_id)) { 747 if (component_loader_->Exists(extension_id)) {
756 component_loader_->Reload(extension_id); 748 component_loader_->Reload(extension_id);
(...skipping 2142 matching lines...) Expand 10 before | Expand all | Expand 10 after
2899 return; 2891 return;
2900 2892
2901 int events_to_fire = it->second; 2893 int events_to_fire = it->second;
2902 extensions::LazyBackgroundTaskQueue* queue = 2894 extensions::LazyBackgroundTaskQueue* queue =
2903 system_->lazy_background_task_queue(); 2895 system_->lazy_background_task_queue();
2904 if (queue->ShouldEnqueueTask(profile(), extension)) { 2896 if (queue->ShouldEnqueueTask(profile(), extension)) {
2905 if (events_to_fire & EVENT_LAUNCHED) 2897 if (events_to_fire & EVENT_LAUNCHED)
2906 queue->AddPendingTask(profile(), extension->id(), 2898 queue->AddPendingTask(profile(), extension->id(),
2907 base::Bind(&ExtensionService::LaunchApplication)); 2899 base::Bind(&ExtensionService::LaunchApplication));
2908 if (events_to_fire & EVENT_RESTARTED) { 2900 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();
2913 queue->AddPendingTask(profile(), extension->id(), 2901 queue->AddPendingTask(profile(), extension->id(),
2914 base::Bind(&ExtensionService::RestartApplication, 2902 base::Bind(&ExtensionService::RestartApplication));
2915 it->second));
2916 on_restart_file_entries_.erase(it);
2917 } 2903 }
2918 } 2904 }
2919 2905
2920 on_load_events_.erase(it); 2906 on_load_events_.erase(it);
2921 } 2907 }
2922 2908
2923 // static 2909 // static
2924 void ExtensionService::LaunchApplication( 2910 void ExtensionService::LaunchApplication(
2925 extensions::ExtensionHost* extension_host) { 2911 extensions::ExtensionHost* extension_host) {
2926 if (!extension_host) 2912 if (!extension_host)
2927 return; 2913 return;
2928 2914
2929 #if !defined(OS_ANDROID) 2915 #if !defined(OS_ANDROID)
2930 extensions::LaunchPlatformApp(extension_host->profile(), 2916 extensions::LaunchPlatformApp(extension_host->profile(),
2931 extension_host->extension(), 2917 extension_host->extension(),
2932 NULL, base::FilePath()); 2918 NULL, base::FilePath());
2933 #endif 2919 #endif
2934 } 2920 }
2935 2921
2936 // static 2922 // static
2937 void ExtensionService::RestartApplication( 2923 void ExtensionService::RestartApplication(
2938 std::vector<extensions::app_file_handler_util::SavedFileEntry> file_entries,
2939 extensions::ExtensionHost* extension_host) { 2924 extensions::ExtensionHost* extension_host) {
2940 if (!extension_host) 2925 if (!extension_host)
2941 return; 2926 return;
2942 2927
2943 #if !defined(OS_ANDROID) 2928 #if !defined(OS_ANDROID)
2944 extensions::RestartPlatformAppWithFileEntries( 2929 extensions::RestartPlatformApp(
2945 extension_host->profile(), extension_host->extension(), file_entries); 2930 extension_host->profile(), extension_host->extension());
2946 #endif 2931 #endif
2947 } 2932 }
2948 2933
2949 bool ExtensionService::HasShellWindows(const std::string& extension_id) { 2934 bool ExtensionService::HasShellWindows(const std::string& extension_id) {
2950 const Extension* current_extension = GetExtensionById(extension_id, false); 2935 const Extension* current_extension = GetExtensionById(extension_id, false);
2951 return current_extension && current_extension->is_platform_app() && 2936 return current_extension && current_extension->is_platform_app() &&
2952 !extensions::ShellWindowRegistry::Get(profile_)-> 2937 !extensions::ShellWindowRegistry::Get(profile_)->
2953 GetShellWindowsForApp(extension_id).empty(); 2938 GetShellWindowsForApp(extension_id).empty();
2954 } 2939 }
2955 2940
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
3111 } 3096 }
3112 3097
3113 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { 3098 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) {
3114 update_observers_.AddObserver(observer); 3099 update_observers_.AddObserver(observer);
3115 } 3100 }
3116 3101
3117 void ExtensionService::RemoveUpdateObserver( 3102 void ExtensionService::RemoveUpdateObserver(
3118 extensions::UpdateObserver* observer) { 3103 extensions::UpdateObserver* observer) {
3119 update_observers_.RemoveObserver(observer); 3104 update_observers_.RemoveObserver(observer);
3120 } 3105 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698