| OLD | NEW |
| 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/launcher.h" | 8 #include "apps/launcher.h" |
| 9 #include "apps/shell_window_registry.h" | 9 #include "apps/shell_window_registry.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 namespace apps { | 26 namespace apps { |
| 27 | 27 |
| 28 AppLoadService::PostReloadAction::PostReloadAction() | 28 AppLoadService::PostReloadAction::PostReloadAction() |
| 29 : action_type(LAUNCH), | 29 : action_type(LAUNCH), |
| 30 command_line(CommandLine::NO_PROGRAM) { | 30 command_line(CommandLine::NO_PROGRAM) { |
| 31 } | 31 } |
| 32 | 32 |
| 33 AppLoadService::AppLoadService(Profile* profile) | 33 AppLoadService::AppLoadService(Profile* profile) |
| 34 : profile_(profile) { | 34 : profile_(profile) { |
| 35 registrar_.Add( | 35 registrar_.Add( |
| 36 this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, | 36 this, chrome::NOTIFICATION_EXTENSION_LOADED, |
| 37 content::NotificationService::AllSources()); | 37 content::NotificationService::AllSources()); |
| 38 registrar_.Add( | 38 registrar_.Add( |
| 39 this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 39 this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
| 40 content::NotificationService::AllSources()); | 40 content::NotificationService::AllSources()); |
| 41 } | 41 } |
| 42 | 42 |
| 43 AppLoadService::~AppLoadService() {} | 43 AppLoadService::~AppLoadService() {} |
| 44 | 44 |
| 45 void AppLoadService::RestartApplication(const std::string& extension_id) { | 45 void AppLoadService::RestartApplication(const std::string& extension_id) { |
| 46 post_reload_actions_[extension_id].action_type = RESTART; | 46 post_reload_actions_[extension_id].action_type = RESTART; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 71 | 71 |
| 72 // static | 72 // static |
| 73 AppLoadService* AppLoadService::Get(Profile* profile) { | 73 AppLoadService* AppLoadService::Get(Profile* profile) { |
| 74 return apps::AppLoadServiceFactory::GetForProfile(profile); | 74 return apps::AppLoadServiceFactory::GetForProfile(profile); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void AppLoadService::Observe(int type, | 77 void AppLoadService::Observe(int type, |
| 78 const content::NotificationSource& source, | 78 const content::NotificationSource& source, |
| 79 const content::NotificationDetails& details) { | 79 const content::NotificationDetails& details) { |
| 80 switch (type) { | 80 switch (type) { |
| 81 case chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING: { | 81 case chrome::NOTIFICATION_EXTENSION_LOADED: { |
| 82 extensions::ExtensionHost* host = | 82 Extension* extension = content::Details<Extension>(details).ptr(); |
| 83 content::Details<extensions::ExtensionHost>(details).ptr(); | |
| 84 const Extension* extension = host->extension(); | |
| 85 // It is possible for an extension to be unloaded before it stops loading. | |
| 86 if (!extension) | |
| 87 break; | |
| 88 std::map<std::string, PostReloadAction>::iterator it = | 83 std::map<std::string, PostReloadAction>::iterator it = |
| 89 post_reload_actions_.find(extension->id()); | 84 post_reload_actions_.find(extension->id()); |
| 90 if (it == post_reload_actions_.end()) | 85 if (it == post_reload_actions_.end()) |
| 91 break; | 86 break; |
| 92 | 87 |
| 93 switch (it->second.action_type) { | 88 switch (it->second.action_type) { |
| 94 case LAUNCH: | 89 case LAUNCH: |
| 95 LaunchPlatformApp(profile_, extension); | 90 LaunchPlatformApp(profile_, extension); |
| 96 break; | 91 break; |
| 97 case RESTART: | 92 case RESTART: |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 Extension::DISABLE_RELOAD) != 0; | 135 Extension::DISABLE_RELOAD) != 0; |
| 141 } | 136 } |
| 142 return false; | 137 return false; |
| 143 } | 138 } |
| 144 | 139 |
| 145 bool AppLoadService::HasPostReloadAction(const std::string& extension_id) { | 140 bool AppLoadService::HasPostReloadAction(const std::string& extension_id) { |
| 146 return post_reload_actions_.find(extension_id) != post_reload_actions_.end(); | 141 return post_reload_actions_.find(extension_id) != post_reload_actions_.end(); |
| 147 } | 142 } |
| 148 | 143 |
| 149 } // namespace apps | 144 } // namespace apps |
| OLD | NEW |