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/app_window_registry.h" |
8 #include "apps/launcher.h" | 9 #include "apps/launcher.h" |
9 #include "apps/shell_window_registry.h" | |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
11 #include "chrome/browser/extensions/extension_host.h" | 11 #include "chrome/browser/extensions/extension_host.h" |
12 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
13 #include "chrome/browser/extensions/unpacked_installer.h" | 13 #include "chrome/browser/extensions/unpacked_installer.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "content/public/browser/notification_details.h" | 15 #include "content/public/browser/notification_details.h" |
16 #include "content/public/browser/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
17 #include "content/public/browser/notification_types.h" | 17 #include "content/public/browser/notification_types.h" |
18 #include "extensions/browser/extension_prefs.h" | 18 #include "extensions/browser/extension_prefs.h" |
19 #include "extensions/browser/extension_system.h" | 19 #include "extensions/browser/extension_system.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 post_reload_actions_.erase(it); | 109 post_reload_actions_.erase(it); |
110 break; | 110 break; |
111 } | 111 } |
112 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { | 112 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { |
113 const extensions::UnloadedExtensionInfo* unload_info = | 113 const extensions::UnloadedExtensionInfo* unload_info = |
114 content::Details<extensions::UnloadedExtensionInfo>(details).ptr(); | 114 content::Details<extensions::UnloadedExtensionInfo>(details).ptr(); |
115 if (!unload_info->extension->is_platform_app()) | 115 if (!unload_info->extension->is_platform_app()) |
116 break; | 116 break; |
117 | 117 |
118 if (WasUnloadedForReload(*unload_info) && | 118 if (WasUnloadedForReload(*unload_info) && |
119 HasShellWindows(unload_info->extension->id()) && | 119 HasAppWindows(unload_info->extension->id()) && |
120 !HasPostReloadAction(unload_info->extension->id())) { | 120 !HasPostReloadAction(unload_info->extension->id())) { |
121 post_reload_actions_[unload_info->extension->id()].action_type = LAUNCH; | 121 post_reload_actions_[unload_info->extension->id()].action_type = LAUNCH; |
122 } | 122 } |
123 break; | 123 break; |
124 } | 124 } |
125 default: | 125 default: |
126 NOTREACHED(); | 126 NOTREACHED(); |
127 } | 127 } |
128 } | 128 } |
129 | 129 |
130 bool AppLoadService::HasShellWindows(const std::string& extension_id) { | 130 bool AppLoadService::HasAppWindows(const std::string& extension_id) { |
131 return !ShellWindowRegistry::Get(profile_)-> | 131 return !AppWindowRegistry::Get(profile_) |
132 GetShellWindowsForApp(extension_id).empty(); | 132 ->GetAppWindowsForApp(extension_id) |
| 133 .empty(); |
133 } | 134 } |
134 | 135 |
135 bool AppLoadService::WasUnloadedForReload( | 136 bool AppLoadService::WasUnloadedForReload( |
136 const extensions::UnloadedExtensionInfo& unload_info) { | 137 const extensions::UnloadedExtensionInfo& unload_info) { |
137 if (unload_info.reason == extensions::UnloadedExtensionInfo::REASON_DISABLE) { | 138 if (unload_info.reason == extensions::UnloadedExtensionInfo::REASON_DISABLE) { |
138 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile_); | 139 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile_); |
139 return (prefs->GetDisableReasons(unload_info.extension->id()) & | 140 return (prefs->GetDisableReasons(unload_info.extension->id()) & |
140 Extension::DISABLE_RELOAD) != 0; | 141 Extension::DISABLE_RELOAD) != 0; |
141 } | 142 } |
142 return false; | 143 return false; |
143 } | 144 } |
144 | 145 |
145 bool AppLoadService::HasPostReloadAction(const std::string& extension_id) { | 146 bool AppLoadService::HasPostReloadAction(const std::string& extension_id) { |
146 return post_reload_actions_.find(extension_id) != post_reload_actions_.end(); | 147 return post_reload_actions_.find(extension_id) != post_reload_actions_.end(); |
147 } | 148 } |
148 | 149 |
149 } // namespace apps | 150 } // namespace apps |
OLD | NEW |