Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Side by Side Diff: chrome/browser/ui/webui/extensions/extension_settings_handler.cc

Issue 23535002: Fixed case where _generated_background_page.html was still showing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/webui/extensions/extension_settings_handler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/saved_files_service.h" 9 #include "apps/saved_files_service.h"
10 #include "apps/shell_window.h" 10 #include "apps/shell_window.h"
(...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 998
999 std::vector<ExtensionPage> 999 std::vector<ExtensionPage>
1000 ExtensionSettingsHandler::GetInspectablePagesForExtension( 1000 ExtensionSettingsHandler::GetInspectablePagesForExtension(
1001 const Extension* extension, bool extension_is_enabled) { 1001 const Extension* extension, bool extension_is_enabled) {
1002 std::vector<ExtensionPage> result; 1002 std::vector<ExtensionPage> result;
1003 1003
1004 // Get the extension process's active views. 1004 // Get the extension process's active views.
1005 ExtensionProcessManager* process_manager = 1005 ExtensionProcessManager* process_manager =
1006 ExtensionSystem::Get(extension_service_->profile())->process_manager(); 1006 ExtensionSystem::Get(extension_service_->profile())->process_manager();
1007 GetInspectablePagesForExtensionProcess( 1007 GetInspectablePagesForExtensionProcess(
1008 extension,
1008 process_manager->GetRenderViewHostsForExtension(extension->id()), 1009 process_manager->GetRenderViewHostsForExtension(extension->id()),
1009 &result); 1010 &result);
1010 1011
1011 // Get shell window views 1012 // Get shell window views
1012 GetShellWindowPagesForExtensionProfile(extension, 1013 GetShellWindowPagesForExtensionProfile(extension,
1013 extension_service_->profile(), &result); 1014 extension_service_->profile(), &result);
1014 1015
1015 // Include a link to start the lazy background page, if applicable. 1016 // Include a link to start the lazy background page, if applicable.
1016 if (BackgroundInfo::HasLazyBackgroundPage(extension) && 1017 if (BackgroundInfo::HasLazyBackgroundPage(extension) &&
1017 extension_is_enabled && 1018 extension_is_enabled &&
1018 !process_manager->GetBackgroundHostForExtension(extension->id())) { 1019 !process_manager->GetBackgroundHostForExtension(extension->id())) {
1019 result.push_back(ExtensionPage( 1020 result.push_back(ExtensionPage(
1020 BackgroundInfo::GetBackgroundURL(extension), 1021 BackgroundInfo::GetBackgroundURL(extension),
1021 -1, 1022 -1,
1022 -1, 1023 -1,
1023 false, 1024 false,
1024 BackgroundInfo::HasGeneratedBackgroundPage(extension))); 1025 BackgroundInfo::HasGeneratedBackgroundPage(extension)));
1025 } 1026 }
1026 1027
1027 // Repeat for the incognito process, if applicable. Don't try to get 1028 // Repeat for the incognito process, if applicable. Don't try to get
1028 // shell windows for incognito processes. 1029 // shell windows for incognito processes.
1029 if (extension_service_->profile()->HasOffTheRecordProfile() && 1030 if (extension_service_->profile()->HasOffTheRecordProfile() &&
1030 IncognitoInfo::IsSplitMode(extension)) { 1031 IncognitoInfo::IsSplitMode(extension)) {
1031 ExtensionProcessManager* process_manager = 1032 ExtensionProcessManager* process_manager =
1032 ExtensionSystem::Get(extension_service_->profile()-> 1033 ExtensionSystem::Get(extension_service_->profile()->
1033 GetOffTheRecordProfile())->process_manager(); 1034 GetOffTheRecordProfile())->process_manager();
1034 GetInspectablePagesForExtensionProcess( 1035 GetInspectablePagesForExtensionProcess(
1036 extension,
1035 process_manager->GetRenderViewHostsForExtension(extension->id()), 1037 process_manager->GetRenderViewHostsForExtension(extension->id()),
1036 &result); 1038 &result);
1037 1039
1038 if (BackgroundInfo::HasLazyBackgroundPage(extension) && 1040 if (BackgroundInfo::HasLazyBackgroundPage(extension) &&
1039 extension_is_enabled && 1041 extension_is_enabled &&
1040 !process_manager->GetBackgroundHostForExtension(extension->id())) { 1042 !process_manager->GetBackgroundHostForExtension(extension->id())) {
1041 result.push_back(ExtensionPage( 1043 result.push_back(ExtensionPage(
1042 BackgroundInfo::GetBackgroundURL(extension), 1044 BackgroundInfo::GetBackgroundURL(extension),
1043 -1, 1045 -1,
1044 -1, 1046 -1,
1045 true, 1047 true,
1046 BackgroundInfo::HasGeneratedBackgroundPage(extension))); 1048 BackgroundInfo::HasGeneratedBackgroundPage(extension)));
1047 } 1049 }
1048 } 1050 }
1049 1051
1050 return result; 1052 return result;
1051 } 1053 }
1052 1054
1053 void ExtensionSettingsHandler::GetInspectablePagesForExtensionProcess( 1055 void ExtensionSettingsHandler::GetInspectablePagesForExtensionProcess(
1056 const Extension* extension,
1054 const std::set<RenderViewHost*>& views, 1057 const std::set<RenderViewHost*>& views,
1055 std::vector<ExtensionPage>* result) { 1058 std::vector<ExtensionPage>* result) {
1059 bool has_generated_background_page =
1060 BackgroundInfo::HasGeneratedBackgroundPage(extension);
1056 for (std::set<RenderViewHost*>::const_iterator iter = views.begin(); 1061 for (std::set<RenderViewHost*>::const_iterator iter = views.begin();
1057 iter != views.end(); ++iter) { 1062 iter != views.end(); ++iter) {
1058 RenderViewHost* host = *iter; 1063 RenderViewHost* host = *iter;
1059 WebContents* web_contents = WebContents::FromRenderViewHost(host); 1064 WebContents* web_contents = WebContents::FromRenderViewHost(host);
1060 ViewType host_type = GetViewType(web_contents); 1065 ViewType host_type = GetViewType(web_contents);
1061 if (host == deleting_rvh_ || 1066 if (host == deleting_rvh_ ||
1062 VIEW_TYPE_EXTENSION_POPUP == host_type || 1067 VIEW_TYPE_EXTENSION_POPUP == host_type ||
1063 VIEW_TYPE_EXTENSION_DIALOG == host_type) 1068 VIEW_TYPE_EXTENSION_DIALOG == host_type)
1064 continue; 1069 continue;
1065 1070
1066 GURL url = web_contents->GetURL(); 1071 GURL url = web_contents->GetURL();
1067 content::RenderProcessHost* process = host->GetProcess(); 1072 content::RenderProcessHost* process = host->GetProcess();
1073 bool is_background_page =
1074 (url == BackgroundInfo::GetBackgroundURL(extension));
1068 result->push_back( 1075 result->push_back(
1069 ExtensionPage(url, process->GetID(), host->GetRoutingID(), 1076 ExtensionPage(url,
1070 process->GetBrowserContext()->IsOffTheRecord(), false)); 1077 process->GetID(),
1078 host->GetRoutingID(),
1079 process->GetBrowserContext()->IsOffTheRecord(),
1080 is_background_page && has_generated_background_page));
1071 } 1081 }
1072 } 1082 }
1073 1083
1074 void ExtensionSettingsHandler::GetShellWindowPagesForExtensionProfile( 1084 void ExtensionSettingsHandler::GetShellWindowPagesForExtensionProfile(
1075 const Extension* extension, 1085 const Extension* extension,
1076 Profile* profile, 1086 Profile* profile,
1077 std::vector<ExtensionPage>* result) { 1087 std::vector<ExtensionPage>* result) {
1078 apps::ShellWindowRegistry* registry = apps::ShellWindowRegistry::Get(profile); 1088 apps::ShellWindowRegistry* registry = apps::ShellWindowRegistry::Get(profile);
1079 if (!registry) return; 1089 if (!registry) return;
1080 1090
1081 const apps::ShellWindowRegistry::ShellWindowList windows = 1091 const apps::ShellWindowRegistry::ShellWindowList windows =
1082 registry->GetShellWindowsForApp(extension->id()); 1092 registry->GetShellWindowsForApp(extension->id());
1083 1093
1094 bool has_generated_background_page =
1095 BackgroundInfo::HasGeneratedBackgroundPage(extension);
1084 for (apps::ShellWindowRegistry::const_iterator it = windows.begin(); 1096 for (apps::ShellWindowRegistry::const_iterator it = windows.begin();
1085 it != windows.end(); ++it) { 1097 it != windows.end(); ++it) {
1086 WebContents* web_contents = (*it)->web_contents(); 1098 WebContents* web_contents = (*it)->web_contents();
1087 RenderViewHost* host = web_contents->GetRenderViewHost(); 1099 RenderViewHost* host = web_contents->GetRenderViewHost();
1088 content::RenderProcessHost* process = host->GetProcess(); 1100 content::RenderProcessHost* process = host->GetProcess();
1089 1101
1102 bool is_background_page =
1103 (web_contents->GetURL() == BackgroundInfo::GetBackgroundURL(extension));
1090 result->push_back( 1104 result->push_back(
1091 ExtensionPage(web_contents->GetURL(), process->GetID(), 1105 ExtensionPage(web_contents->GetURL(),
1106 process->GetID(),
1092 host->GetRoutingID(), 1107 host->GetRoutingID(),
1093 process->GetBrowserContext()->IsOffTheRecord(), false)); 1108 process->GetBrowserContext()->IsOffTheRecord(),
1109 is_background_page && has_generated_background_page));
1094 } 1110 }
1095 } 1111 }
1096 1112
1097 ExtensionUninstallDialog* 1113 ExtensionUninstallDialog*
1098 ExtensionSettingsHandler::GetExtensionUninstallDialog() { 1114 ExtensionSettingsHandler::GetExtensionUninstallDialog() {
1099 #if !defined(OS_ANDROID) 1115 #if !defined(OS_ANDROID)
1100 if (!extension_uninstall_dialog_.get()) { 1116 if (!extension_uninstall_dialog_.get()) {
1101 Browser* browser = chrome::FindBrowserWithWebContents( 1117 Browser* browser = chrome::FindBrowserWithWebContents(
1102 web_ui()->GetWebContents()); 1118 web_ui()->GetWebContents());
1103 extension_uninstall_dialog_.reset( 1119 extension_uninstall_dialog_.reset(
(...skipping 13 matching lines...) Expand all
1117 extension_service_->EnableExtension(extension_id); 1133 extension_service_->EnableExtension(extension_id);
1118 } else { 1134 } else {
1119 ExtensionErrorReporter::GetInstance()->ReportError( 1135 ExtensionErrorReporter::GetInstance()->ReportError(
1120 UTF8ToUTF16(JoinString(requirement_errors, ' ')), 1136 UTF8ToUTF16(JoinString(requirement_errors, ' ')),
1121 true /* be noisy */); 1137 true /* be noisy */);
1122 } 1138 }
1123 requirements_checker_.reset(); 1139 requirements_checker_.reset();
1124 } 1140 }
1125 1141
1126 } // namespace extensions 1142 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/extensions/extension_settings_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698