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

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

Powered by Google App Engine
This is Rietveld 408576698