Chromium Code Reviews| 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 25 matching lines...) Expand all Loading... | |
| 36 this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, | 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; | |
| 47 ExtensionService* service = extensions::ExtensionSystem::Get(profile_)-> | 46 ExtensionService* service = extensions::ExtensionSystem::Get(profile_)-> |
| 48 extension_service(); | 47 extension_service(); |
| 49 DCHECK(service); | 48 DCHECK(service); |
| 50 service->ReloadExtension(extension_id); | 49 service->ReloadExtension(extension_id); |
| 50 RestartPlatformApp(profile_, service->GetExtensionById(extension_id, false)); | |
|
tapted
2013/12/12 06:54:52
GetExtensionsById likes to return NULL a lot..
I
koz (OOO until 15th September)
2013/12/13 03:33:56
Ah, good spot! I've tried a different approach in
| |
| 51 } | 51 } |
| 52 | 52 |
| 53 bool AppLoadService::LoadAndLaunch(const base::FilePath& extension_path, | 53 bool AppLoadService::LoadAndLaunch(const base::FilePath& extension_path, |
| 54 const CommandLine& command_line, | 54 const CommandLine& command_line, |
| 55 const base::FilePath& current_dir) { | 55 const base::FilePath& current_dir) { |
| 56 ExtensionService* extension_service = | 56 ExtensionService* extension_service = |
| 57 ExtensionSystem::GetForBrowserContext(profile_)->extension_service(); | 57 ExtensionSystem::GetForBrowserContext(profile_)->extension_service(); |
| 58 std::string extension_id; | 58 std::string extension_id; |
| 59 if (!extensions::UnpackedInstaller::Create(extension_service)-> | 59 if (!extensions::UnpackedInstaller::Create(extension_service)-> |
| 60 LoadFromCommandLine(base::FilePath(extension_path), &extension_id)) { | 60 LoadFromCommandLine(base::FilePath(extension_path), &extension_id)) { |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 87 break; | 87 break; |
| 88 std::map<std::string, PostReloadAction>::iterator it = | 88 std::map<std::string, PostReloadAction>::iterator it = |
| 89 post_reload_actions_.find(extension->id()); | 89 post_reload_actions_.find(extension->id()); |
| 90 if (it == post_reload_actions_.end()) | 90 if (it == post_reload_actions_.end()) |
| 91 break; | 91 break; |
| 92 | 92 |
| 93 switch (it->second.action_type) { | 93 switch (it->second.action_type) { |
| 94 case LAUNCH: | 94 case LAUNCH: |
| 95 LaunchPlatformApp(profile_, extension); | 95 LaunchPlatformApp(profile_, extension); |
| 96 break; | 96 break; |
| 97 case RESTART: | |
| 98 RestartPlatformApp(profile_, extension); | |
| 99 break; | |
| 100 case LAUNCH_WITH_COMMAND_LINE: | 97 case LAUNCH_WITH_COMMAND_LINE: |
| 101 LaunchPlatformAppWithCommandLine( | 98 LaunchPlatformAppWithCommandLine( |
| 102 profile_, extension, &it->second.command_line, | 99 profile_, extension, &it->second.command_line, |
| 103 it->second.current_dir); | 100 it->second.current_dir); |
| 104 break; | 101 break; |
| 105 default: | 102 default: |
| 106 NOTREACHED(); | 103 NOTREACHED(); |
| 107 } | 104 } |
| 108 | 105 |
| 109 post_reload_actions_.erase(it); | 106 post_reload_actions_.erase(it); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 140 Extension::DISABLE_RELOAD) != 0; | 137 Extension::DISABLE_RELOAD) != 0; |
| 141 } | 138 } |
| 142 return false; | 139 return false; |
| 143 } | 140 } |
| 144 | 141 |
| 145 bool AppLoadService::HasPostReloadAction(const std::string& extension_id) { | 142 bool AppLoadService::HasPostReloadAction(const std::string& extension_id) { |
| 146 return post_reload_actions_.find(extension_id) != post_reload_actions_.end(); | 143 return post_reload_actions_.find(extension_id) != post_reload_actions_.end(); |
| 147 } | 144 } |
| 148 | 145 |
| 149 } // namespace apps | 146 } // namespace apps |
| OLD | NEW |