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

Side by Side Diff: apps/app_load_service.cc

Issue 425303002: Move extension notifications to extensions/browser/notification_types.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: (extension-notifications) rebase Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « apps/app_lifetime_monitor.cc ('k') | apps/app_restore_service_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "apps/app_load_service.h" 5 #include "apps/app_load_service.h"
6 6
7 #include "apps/app_load_service_factory.h" 7 #include "apps/app_load_service_factory.h"
8 #include "apps/app_restore_service.h" 8 #include "apps/app_restore_service.h"
9 #include "apps/app_window_registry.h" 9 #include "apps/app_window_registry.h"
10 #include "apps/launcher.h" 10 #include "apps/launcher.h"
11 #include "chrome/browser/chrome_notification_types.h"
12 #include "chrome/browser/extensions/extension_service.h" 11 #include "chrome/browser/extensions/extension_service.h"
13 #include "chrome/browser/extensions/unpacked_installer.h" 12 #include "chrome/browser/extensions/unpacked_installer.h"
14 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
15 #include "content/public/browser/notification_details.h" 14 #include "content/public/browser/notification_details.h"
16 #include "content/public/browser/notification_service.h" 15 #include "content/public/browser/notification_service.h"
17 #include "content/public/browser/notification_types.h" 16 #include "content/public/browser/notification_types.h"
18 #include "extensions/browser/extension_host.h" 17 #include "extensions/browser/extension_host.h"
19 #include "extensions/browser/extension_prefs.h" 18 #include "extensions/browser/extension_prefs.h"
20 #include "extensions/browser/extension_system.h" 19 #include "extensions/browser/extension_system.h"
20 #include "extensions/browser/notification_types.h"
21 #include "extensions/common/extension.h" 21 #include "extensions/common/extension.h"
22 22
23 using extensions::Extension; 23 using extensions::Extension;
24 using extensions::ExtensionPrefs; 24 using extensions::ExtensionPrefs;
25 using extensions::ExtensionSystem; 25 using extensions::ExtensionSystem;
26 26
27 namespace apps { 27 namespace apps {
28 28
29 AppLoadService::PostReloadAction::PostReloadAction() 29 AppLoadService::PostReloadAction::PostReloadAction()
30 : action_type(LAUNCH), 30 : action_type(LAUNCH),
31 command_line(CommandLine::NO_PROGRAM) { 31 command_line(CommandLine::NO_PROGRAM) {
32 } 32 }
33 33
34 AppLoadService::AppLoadService(Profile* profile) 34 AppLoadService::AppLoadService(Profile* profile)
35 : profile_(profile) { 35 : profile_(profile) {
36 registrar_.Add( 36 registrar_.Add(this,
37 this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, 37 extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING,
38 content::NotificationService::AllSources()); 38 content::NotificationService::AllSources());
39 registrar_.Add( 39 registrar_.Add(this,
40 this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, 40 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
41 content::NotificationService::AllSources()); 41 content::NotificationService::AllSources());
42 } 42 }
43 43
44 AppLoadService::~AppLoadService() {} 44 AppLoadService::~AppLoadService() {}
45 45
46 void AppLoadService::RestartApplication(const std::string& extension_id) { 46 void AppLoadService::RestartApplication(const std::string& extension_id) {
47 post_reload_actions_[extension_id].action_type = RESTART; 47 post_reload_actions_[extension_id].action_type = RESTART;
48 ExtensionService* service = extensions::ExtensionSystem::Get(profile_)-> 48 ExtensionService* service = extensions::ExtensionSystem::Get(profile_)->
49 extension_service(); 49 extension_service();
50 DCHECK(service); 50 DCHECK(service);
51 service->ReloadExtension(extension_id); 51 service->ReloadExtension(extension_id);
(...skipping 26 matching lines...) Expand all
78 78
79 // static 79 // static
80 AppLoadService* AppLoadService::Get(Profile* profile) { 80 AppLoadService* AppLoadService::Get(Profile* profile) {
81 return apps::AppLoadServiceFactory::GetForProfile(profile); 81 return apps::AppLoadServiceFactory::GetForProfile(profile);
82 } 82 }
83 83
84 void AppLoadService::Observe(int type, 84 void AppLoadService::Observe(int type,
85 const content::NotificationSource& source, 85 const content::NotificationSource& source,
86 const content::NotificationDetails& details) { 86 const content::NotificationDetails& details) {
87 switch (type) { 87 switch (type) {
88 case chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING: { 88 case extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING: {
89 extensions::ExtensionHost* host = 89 extensions::ExtensionHost* host =
90 content::Details<extensions::ExtensionHost>(details).ptr(); 90 content::Details<extensions::ExtensionHost>(details).ptr();
91 const Extension* extension = host->extension(); 91 const Extension* extension = host->extension();
92 // It is possible for an extension to be unloaded before it stops loading. 92 // It is possible for an extension to be unloaded before it stops loading.
93 if (!extension) 93 if (!extension)
94 break; 94 break;
95 std::map<std::string, PostReloadAction>::iterator it = 95 std::map<std::string, PostReloadAction>::iterator it =
96 post_reload_actions_.find(extension->id()); 96 post_reload_actions_.find(extension->id());
97 if (it == post_reload_actions_.end()) 97 if (it == post_reload_actions_.end())
98 break; 98 break;
(...skipping 10 matching lines...) Expand all
109 profile_, extension, it->second.command_line, 109 profile_, extension, it->second.command_line,
110 it->second.current_dir); 110 it->second.current_dir);
111 break; 111 break;
112 default: 112 default:
113 NOTREACHED(); 113 NOTREACHED();
114 } 114 }
115 115
116 post_reload_actions_.erase(it); 116 post_reload_actions_.erase(it);
117 break; 117 break;
118 } 118 }
119 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { 119 case extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: {
120 const extensions::UnloadedExtensionInfo* unload_info = 120 const extensions::UnloadedExtensionInfo* unload_info =
121 content::Details<extensions::UnloadedExtensionInfo>(details).ptr(); 121 content::Details<extensions::UnloadedExtensionInfo>(details).ptr();
122 if (!unload_info->extension->is_platform_app()) 122 if (!unload_info->extension->is_platform_app())
123 break; 123 break;
124 124
125 extensions::ExtensionPrefs* extension_prefs = 125 extensions::ExtensionPrefs* extension_prefs =
126 extensions::ExtensionPrefs::Get(profile_); 126 extensions::ExtensionPrefs::Get(profile_);
127 if (WasUnloadedForReload(*unload_info) && 127 if (WasUnloadedForReload(*unload_info) &&
128 extension_prefs->IsActive(unload_info->extension->id()) && 128 extension_prefs->IsActive(unload_info->extension->id()) &&
129 !HasPostReloadAction(unload_info->extension->id())) { 129 !HasPostReloadAction(unload_info->extension->id())) {
(...skipping 14 matching lines...) Expand all
144 Extension::DISABLE_RELOAD) != 0; 144 Extension::DISABLE_RELOAD) != 0;
145 } 145 }
146 return false; 146 return false;
147 } 147 }
148 148
149 bool AppLoadService::HasPostReloadAction(const std::string& extension_id) { 149 bool AppLoadService::HasPostReloadAction(const std::string& extension_id) {
150 return post_reload_actions_.find(extension_id) != post_reload_actions_.end(); 150 return post_reload_actions_.find(extension_id) != post_reload_actions_.end();
151 } 151 }
152 152
153 } // namespace apps 153 } // namespace apps
OLDNEW
« no previous file with comments | « apps/app_lifetime_monitor.cc ('k') | apps/app_restore_service_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698