| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/webui/extensions/extension_settings_handler.h" | 5 #include "chrome/browser/ui/webui/extensions/extension_settings_handler.h" |
| 6 | 6 |
| 7 #include "apps/app_load_service.h" | 7 #include "apps/app_load_service.h" |
| 8 #include "apps/app_restore_service.h" | 8 #include "apps/app_restore_service.h" |
| 9 #include "apps/app_window.h" |
| 10 #include "apps/app_window_registry.h" |
| 9 #include "apps/saved_files_service.h" | 11 #include "apps/saved_files_service.h" |
| 10 #include "apps/shell_window.h" | |
| 11 #include "apps/shell_window_registry.h" | |
| 12 #include "base/auto_reset.h" | 12 #include "base/auto_reset.h" |
| 13 #include "base/base64.h" | 13 #include "base/base64.h" |
| 14 #include "base/bind.h" | 14 #include "base/bind.h" |
| 15 #include "base/bind_helpers.h" | 15 #include "base/bind_helpers.h" |
| 16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 17 #include "base/location.h" | 17 #include "base/location.h" |
| 18 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
| 19 #include "base/metrics/histogram.h" | 19 #include "base/metrics/histogram.h" |
| 20 #include "base/prefs/pref_service.h" | 20 #include "base/prefs/pref_service.h" |
| 21 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
| (...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1114 std::vector<ExtensionPage> result; | 1114 std::vector<ExtensionPage> result; |
| 1115 | 1115 |
| 1116 // Get the extension process's active views. | 1116 // Get the extension process's active views. |
| 1117 extensions::ProcessManager* process_manager = | 1117 extensions::ProcessManager* process_manager = |
| 1118 ExtensionSystem::Get(extension_service_->profile())->process_manager(); | 1118 ExtensionSystem::Get(extension_service_->profile())->process_manager(); |
| 1119 GetInspectablePagesForExtensionProcess( | 1119 GetInspectablePagesForExtensionProcess( |
| 1120 extension, | 1120 extension, |
| 1121 process_manager->GetRenderViewHostsForExtension(extension->id()), | 1121 process_manager->GetRenderViewHostsForExtension(extension->id()), |
| 1122 &result); | 1122 &result); |
| 1123 | 1123 |
| 1124 // Get shell window views | 1124 // Get app window views |
| 1125 GetShellWindowPagesForExtensionProfile(extension, | 1125 GetAppWindowPagesForExtensionProfile( |
| 1126 extension_service_->profile(), &result); | 1126 extension, extension_service_->profile(), &result); |
| 1127 | 1127 |
| 1128 // Include a link to start the lazy background page, if applicable. | 1128 // Include a link to start the lazy background page, if applicable. |
| 1129 if (BackgroundInfo::HasLazyBackgroundPage(extension) && | 1129 if (BackgroundInfo::HasLazyBackgroundPage(extension) && |
| 1130 extension_is_enabled && | 1130 extension_is_enabled && |
| 1131 !process_manager->GetBackgroundHostForExtension(extension->id())) { | 1131 !process_manager->GetBackgroundHostForExtension(extension->id())) { |
| 1132 result.push_back(ExtensionPage( | 1132 result.push_back(ExtensionPage( |
| 1133 BackgroundInfo::GetBackgroundURL(extension), | 1133 BackgroundInfo::GetBackgroundURL(extension), |
| 1134 -1, | 1134 -1, |
| 1135 -1, | 1135 -1, |
| 1136 false, | 1136 false, |
| 1137 BackgroundInfo::HasGeneratedBackgroundPage(extension))); | 1137 BackgroundInfo::HasGeneratedBackgroundPage(extension))); |
| 1138 } | 1138 } |
| 1139 | 1139 |
| 1140 // Repeat for the incognito process, if applicable. Don't try to get | 1140 // Repeat for the incognito process, if applicable. Don't try to get |
| 1141 // shell windows for incognito processes. | 1141 // app windows for incognito processes. |
| 1142 if (extension_service_->profile()->HasOffTheRecordProfile() && | 1142 if (extension_service_->profile()->HasOffTheRecordProfile() && |
| 1143 IncognitoInfo::IsSplitMode(extension) && | 1143 IncognitoInfo::IsSplitMode(extension) && |
| 1144 util::IsIncognitoEnabled(extension->id(), | 1144 util::IsIncognitoEnabled(extension->id(), |
| 1145 extension_service_->profile())) { | 1145 extension_service_->profile())) { |
| 1146 extensions::ProcessManager* process_manager = | 1146 extensions::ProcessManager* process_manager = |
| 1147 ExtensionSystem::Get(extension_service_->profile()-> | 1147 ExtensionSystem::Get(extension_service_->profile()-> |
| 1148 GetOffTheRecordProfile())->process_manager(); | 1148 GetOffTheRecordProfile())->process_manager(); |
| 1149 GetInspectablePagesForExtensionProcess( | 1149 GetInspectablePagesForExtensionProcess( |
| 1150 extension, | 1150 extension, |
| 1151 process_manager->GetRenderViewHostsForExtension(extension->id()), | 1151 process_manager->GetRenderViewHostsForExtension(extension->id()), |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1188 (url == BackgroundInfo::GetBackgroundURL(extension)); | 1188 (url == BackgroundInfo::GetBackgroundURL(extension)); |
| 1189 result->push_back( | 1189 result->push_back( |
| 1190 ExtensionPage(url, | 1190 ExtensionPage(url, |
| 1191 process->GetID(), | 1191 process->GetID(), |
| 1192 host->GetRoutingID(), | 1192 host->GetRoutingID(), |
| 1193 process->GetBrowserContext()->IsOffTheRecord(), | 1193 process->GetBrowserContext()->IsOffTheRecord(), |
| 1194 is_background_page && has_generated_background_page)); | 1194 is_background_page && has_generated_background_page)); |
| 1195 } | 1195 } |
| 1196 } | 1196 } |
| 1197 | 1197 |
| 1198 void ExtensionSettingsHandler::GetShellWindowPagesForExtensionProfile( | 1198 void ExtensionSettingsHandler::GetAppWindowPagesForExtensionProfile( |
| 1199 const Extension* extension, | 1199 const Extension* extension, |
| 1200 Profile* profile, | 1200 Profile* profile, |
| 1201 std::vector<ExtensionPage>* result) { | 1201 std::vector<ExtensionPage>* result) { |
| 1202 apps::ShellWindowRegistry* registry = apps::ShellWindowRegistry::Get(profile); | 1202 apps::AppWindowRegistry* registry = apps::AppWindowRegistry::Get(profile); |
| 1203 if (!registry) return; | 1203 if (!registry) return; |
| 1204 | 1204 |
| 1205 const apps::ShellWindowRegistry::ShellWindowList windows = | 1205 const apps::AppWindowRegistry::AppWindowList windows = |
| 1206 registry->GetShellWindowsForApp(extension->id()); | 1206 registry->GetAppWindowsForApp(extension->id()); |
| 1207 | 1207 |
| 1208 bool has_generated_background_page = | 1208 bool has_generated_background_page = |
| 1209 BackgroundInfo::HasGeneratedBackgroundPage(extension); | 1209 BackgroundInfo::HasGeneratedBackgroundPage(extension); |
| 1210 for (apps::ShellWindowRegistry::const_iterator it = windows.begin(); | 1210 for (apps::AppWindowRegistry::const_iterator it = windows.begin(); |
| 1211 it != windows.end(); ++it) { | 1211 it != windows.end(); |
| 1212 ++it) { |
| 1212 WebContents* web_contents = (*it)->web_contents(); | 1213 WebContents* web_contents = (*it)->web_contents(); |
| 1213 RenderViewHost* host = web_contents->GetRenderViewHost(); | 1214 RenderViewHost* host = web_contents->GetRenderViewHost(); |
| 1214 content::RenderProcessHost* process = host->GetProcess(); | 1215 content::RenderProcessHost* process = host->GetProcess(); |
| 1215 | 1216 |
| 1216 bool is_background_page = | 1217 bool is_background_page = |
| 1217 (web_contents->GetURL() == BackgroundInfo::GetBackgroundURL(extension)); | 1218 (web_contents->GetURL() == BackgroundInfo::GetBackgroundURL(extension)); |
| 1218 result->push_back( | 1219 result->push_back( |
| 1219 ExtensionPage(web_contents->GetURL(), | 1220 ExtensionPage(web_contents->GetURL(), |
| 1220 process->GetID(), | 1221 process->GetID(), |
| 1221 host->GetRoutingID(), | 1222 host->GetRoutingID(), |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1247 extension_service_->EnableExtension(extension_id); | 1248 extension_service_->EnableExtension(extension_id); |
| 1248 } else { | 1249 } else { |
| 1249 ExtensionErrorReporter::GetInstance()->ReportError( | 1250 ExtensionErrorReporter::GetInstance()->ReportError( |
| 1250 base::UTF8ToUTF16(JoinString(requirement_errors, ' ')), | 1251 base::UTF8ToUTF16(JoinString(requirement_errors, ' ')), |
| 1251 true /* be noisy */); | 1252 true /* be noisy */); |
| 1252 } | 1253 } |
| 1253 requirements_checker_.reset(); | 1254 requirements_checker_.reset(); |
| 1254 } | 1255 } |
| 1255 | 1256 |
| 1256 } // namespace extensions | 1257 } // namespace extensions |
| OLD | NEW |