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

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: rebase 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 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 } 726 }
728 727
729 path = current_extension->path(); 728 path = current_extension->path();
730 DisableExtension(extension_id, Extension::DISABLE_RELOAD); 729 DisableExtension(extension_id, Extension::DISABLE_RELOAD);
731 reloading_extensions_.insert(extension_id); 730 reloading_extensions_.insert(extension_id);
732 } else { 731 } else {
733 path = unloaded_extension_paths_[extension_id]; 732 path = unloaded_extension_paths_[extension_id];
734 } 733 }
735 734
736 on_load_events_[extension_id] = events; 735 on_load_events_[extension_id] = events;
737 if (events & EVENT_RESTARTED) {
738 extensions::app_file_handler_util::GetSavedFileEntries(
739 extension_prefs_,
740 extension_id,
741 &on_restart_file_entries_[extension_id]);
742 }
743
744 736
745 if (delayed_updates_for_idle_.Contains(extension_id)) { 737 if (delayed_updates_for_idle_.Contains(extension_id)) {
746 FinishDelayedInstallation(extension_id); 738 FinishDelayedInstallation(extension_id);
747 return; 739 return;
748 } 740 }
749 741
750 // If we're reloading a component extension, use the component extension 742 // If we're reloading a component extension, use the component extension
751 // loader's reloader. 743 // loader's reloader.
752 if (component_loader_->Exists(extension_id)) { 744 if (component_loader_->Exists(extension_id)) {
753 component_loader_->Reload(extension_id); 745 component_loader_->Reload(extension_id);
(...skipping 2146 matching lines...) Expand 10 before | Expand all | Expand 10 after
2900 return; 2892 return;
2901 2893
2902 int events_to_fire = it->second; 2894 int events_to_fire = it->second;
2903 extensions::LazyBackgroundTaskQueue* queue = 2895 extensions::LazyBackgroundTaskQueue* queue =
2904 system_->lazy_background_task_queue(); 2896 system_->lazy_background_task_queue();
2905 if (queue->ShouldEnqueueTask(profile(), extension)) { 2897 if (queue->ShouldEnqueueTask(profile(), extension)) {
2906 if (events_to_fire & EVENT_LAUNCHED) 2898 if (events_to_fire & EVENT_LAUNCHED)
2907 queue->AddPendingTask(profile(), extension->id(), 2899 queue->AddPendingTask(profile(), extension->id(),
2908 base::Bind(&ExtensionService::LaunchApplication)); 2900 base::Bind(&ExtensionService::LaunchApplication));
2909 if (events_to_fire & EVENT_RESTARTED) { 2901 if (events_to_fire & EVENT_RESTARTED) {
2910 SavedFileEntryMap::iterator it =
2911 on_restart_file_entries_.find(extension->id());
2912 if (it == on_restart_file_entries_.end())
2913 NOTREACHED();
2914 queue->AddPendingTask(profile(), extension->id(), 2902 queue->AddPendingTask(profile(), extension->id(),
2915 base::Bind(&ExtensionService::RestartApplication, 2903 base::Bind(&ExtensionService::RestartApplication));
2916 it->second));
2917 on_restart_file_entries_.erase(it);
2918 } 2904 }
2919 } 2905 }
2920 2906
2921 on_load_events_.erase(it); 2907 on_load_events_.erase(it);
2922 } 2908 }
2923 2909
2924 // static 2910 // static
2925 void ExtensionService::LaunchApplication( 2911 void ExtensionService::LaunchApplication(
2926 extensions::ExtensionHost* extension_host) { 2912 extensions::ExtensionHost* extension_host) {
2927 if (!extension_host) 2913 if (!extension_host)
2928 return; 2914 return;
2929 2915
2930 #if !defined(OS_ANDROID) 2916 #if !defined(OS_ANDROID)
2931 extensions::LaunchPlatformApp(extension_host->profile(), 2917 extensions::LaunchPlatformApp(extension_host->profile(),
2932 extension_host->extension(), 2918 extension_host->extension(),
2933 NULL, base::FilePath()); 2919 NULL, base::FilePath());
2934 #endif 2920 #endif
2935 } 2921 }
2936 2922
2937 // static 2923 // static
2938 void ExtensionService::RestartApplication( 2924 void ExtensionService::RestartApplication(
2939 std::vector<extensions::app_file_handler_util::SavedFileEntry> file_entries,
2940 extensions::ExtensionHost* extension_host) { 2925 extensions::ExtensionHost* extension_host) {
2941 if (!extension_host) 2926 if (!extension_host)
2942 return; 2927 return;
2943 2928
2944 #if !defined(OS_ANDROID) 2929 #if !defined(OS_ANDROID)
2945 extensions::RestartPlatformAppWithFileEntries( 2930 extensions::RestartPlatformApp(
2946 extension_host->profile(), extension_host->extension(), file_entries); 2931 extension_host->profile(), extension_host->extension());
2947 #endif 2932 #endif
2948 } 2933 }
2949 2934
2950 bool ExtensionService::HasShellWindows(const std::string& extension_id) { 2935 bool ExtensionService::HasShellWindows(const std::string& extension_id) {
2951 const Extension* current_extension = GetExtensionById(extension_id, false); 2936 const Extension* current_extension = GetExtensionById(extension_id, false);
2952 return current_extension && current_extension->is_platform_app() && 2937 return current_extension && current_extension->is_platform_app() &&
2953 !extensions::ShellWindowRegistry::Get(profile_)-> 2938 !extensions::ShellWindowRegistry::Get(profile_)->
2954 GetShellWindowsForApp(extension_id).empty(); 2939 GetShellWindowsForApp(extension_id).empty();
2955 } 2940 }
2956 2941
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
3112 } 3097 }
3113 3098
3114 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { 3099 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) {
3115 update_observers_.AddObserver(observer); 3100 update_observers_.AddObserver(observer);
3116 } 3101 }
3117 3102
3118 void ExtensionService::RemoveUpdateObserver( 3103 void ExtensionService::RemoveUpdateObserver(
3119 extensions::UpdateObserver* observer) { 3104 extensions::UpdateObserver* observer) {
3120 update_observers_.RemoveObserver(observer); 3105 update_observers_.RemoveObserver(observer);
3121 } 3106 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | chrome/browser/extensions/platform_app_launcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698