| 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_LOADED, | 36 this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, |
| 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_LOADED: { | 81 case chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING: { |
| 82 Extension* extension = content::Details<Extension>(details).ptr(); | 82 extensions::ExtensionHost* host = |
| 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; |
| 83 std::map<std::string, PostReloadAction>::iterator it = | 88 std::map<std::string, PostReloadAction>::iterator it = |
| 84 post_reload_actions_.find(extension->id()); | 89 post_reload_actions_.find(extension->id()); |
| 85 if (it == post_reload_actions_.end()) | 90 if (it == post_reload_actions_.end()) |
| 86 break; | 91 break; |
| 87 | 92 |
| 88 switch (it->second.action_type) { | 93 switch (it->second.action_type) { |
| 89 case LAUNCH: | 94 case LAUNCH: |
| 90 LaunchPlatformApp(profile_, extension); | 95 LaunchPlatformApp(profile_, extension); |
| 91 break; | 96 break; |
| 92 case RESTART: | 97 case RESTART: |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 Extension::DISABLE_RELOAD) != 0; | 140 Extension::DISABLE_RELOAD) != 0; |
| 136 } | 141 } |
| 137 return false; | 142 return false; |
| 138 } | 143 } |
| 139 | 144 |
| 140 bool AppLoadService::HasPostReloadAction(const std::string& extension_id) { | 145 bool AppLoadService::HasPostReloadAction(const std::string& extension_id) { |
| 141 return post_reload_actions_.find(extension_id) != post_reload_actions_.end(); | 146 return post_reload_actions_.find(extension_id) != post_reload_actions_.end(); |
| 142 } | 147 } |
| 143 | 148 |
| 144 } // namespace apps | 149 } // namespace apps |
| OLD | NEW |