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

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

Issue 536753003: Add recommended extension installation support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ext-3
Patch Set: rebase Created 6 years, 2 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
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/saved_files_service.h" 8 #include "apps/saved_files_service.h"
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 should_do_verification_check_ = true; 231 should_do_verification_check_ = true;
232 232
233 bool corrupt_install = 233 bool corrupt_install =
234 (disable_reasons & Extension::DISABLE_CORRUPTED) != 0; 234 (disable_reasons & Extension::DISABLE_CORRUPTED) != 0;
235 extension_data->SetBoolean("corruptInstall", corrupt_install); 235 extension_data->SetBoolean("corruptInstall", corrupt_install);
236 236
237 bool managed_install = 237 bool managed_install =
238 !management_policy_->UserMayModifySettings(extension, NULL); 238 !management_policy_->UserMayModifySettings(extension, NULL);
239 extension_data->SetBoolean("managedInstall", managed_install); 239 extension_data->SetBoolean("managedInstall", managed_install);
240 240
241 bool recommended_install =
242 !managed_install &&
243 management_policy_->MustRemainInstalled(extension, NULL);
244 extension_data->SetBoolean("recommendedInstall", recommended_install);
245
241 // We should not get into a state where both are true. 246 // We should not get into a state where both are true.
Finnur 2014/10/06 14:01:42 Nit: This comment is now out of date. Perhaps: //
binjin 2014/10/06 18:48:47 Done.
242 DCHECK(!managed_install || !suspicious_install); 247 DCHECK(!(managed_install || recommended_install) || !suspicious_install);
243 248
244 GURL icon = 249 GURL icon =
245 ExtensionIconSource::GetIconURL(extension, 250 ExtensionIconSource::GetIconURL(extension,
246 extension_misc::EXTENSION_ICON_MEDIUM, 251 extension_misc::EXTENSION_ICON_MEDIUM,
247 ExtensionIconSet::MATCH_BIGGER, 252 ExtensionIconSet::MATCH_BIGGER,
248 !enabled, NULL); 253 !enabled, NULL);
249 if (Manifest::IsUnpackedLocation(extension->location())) { 254 if (Manifest::IsUnpackedLocation(extension->location())) {
250 extension_data->SetString("path", extension->path().value()); 255 extension_data->SetString("path", extension->path().value());
251 extension_data->SetString( 256 extension_data->SetString(
252 "prettifiedPath", 257 "prettifiedPath",
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 util::AllowedScriptingOnAllUrls( 311 util::AllowedScriptingOnAllUrls(
307 extension->id(), extension_service_->GetBrowserContext())); 312 extension->id(), extension_service_->GetBrowserContext()));
308 extension_data->SetBoolean("wantsAllUrls", wants_all_urls); 313 extension_data->SetBoolean("wantsAllUrls", wants_all_urls);
309 extension_data->SetBoolean( 314 extension_data->SetBoolean(
310 "allowAllUrls", 315 "allowAllUrls",
311 util::AllowedScriptingOnAllUrls( 316 util::AllowedScriptingOnAllUrls(
312 extension->id(), 317 extension->id(),
313 extension_service_->GetBrowserContext())); 318 extension_service_->GetBrowserContext()));
314 319
315 base::string16 location_text; 320 base::string16 location_text;
316 if (Manifest::IsPolicyLocation(extension->location())) { 321 if (Manifest::IsPolicyLocation(extension->location()) ||
322 (extension->location() == Manifest::EXTERNAL_PREF_DOWNLOAD &&
323 recommended_install)) {
317 location_text = l10n_util::GetStringUTF16( 324 location_text = l10n_util::GetStringUTF16(
318 IDS_OPTIONS_INSTALL_LOCATION_ENTERPRISE); 325 IDS_OPTIONS_INSTALL_LOCATION_ENTERPRISE);
319 } else if (extension->location() == Manifest::INTERNAL && 326 } else if (extension->location() == Manifest::INTERNAL &&
320 !ManifestURL::UpdatesFromGallery(extension)) { 327 !ManifestURL::UpdatesFromGallery(extension)) {
321 location_text = l10n_util::GetStringUTF16( 328 location_text = l10n_util::GetStringUTF16(
322 IDS_OPTIONS_INSTALL_LOCATION_UNKNOWN); 329 IDS_OPTIONS_INSTALL_LOCATION_UNKNOWN);
323 } else if (extension->location() == Manifest::EXTERNAL_REGISTRY) { 330 } else if (extension->location() == Manifest::EXTERNAL_REGISTRY) {
324 location_text = l10n_util::GetStringUTF16( 331 location_text = l10n_util::GetStringUTF16(
325 IDS_OPTIONS_INSTALL_LOCATION_3RD_PARTY); 332 IDS_OPTIONS_INSTALL_LOCATION_3RD_PARTY);
326 } else if (extension->is_shared_module()) { 333 } else if (extension->is_shared_module()) {
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 source->AddString("extensionSettingsOptions", 532 source->AddString("extensionSettingsOptions",
526 l10n_util::GetStringUTF16(IDS_EXTENSIONS_OPTIONS_LINK)); 533 l10n_util::GetStringUTF16(IDS_EXTENSIONS_OPTIONS_LINK));
527 source->AddString("extensionSettingsPermissions", 534 source->AddString("extensionSettingsPermissions",
528 l10n_util::GetStringUTF16(IDS_EXTENSIONS_PERMISSIONS_LINK)); 535 l10n_util::GetStringUTF16(IDS_EXTENSIONS_PERMISSIONS_LINK));
529 source->AddString("extensionSettingsVisitWebsite", 536 source->AddString("extensionSettingsVisitWebsite",
530 l10n_util::GetStringUTF16(IDS_EXTENSIONS_VISIT_WEBSITE)); 537 l10n_util::GetStringUTF16(IDS_EXTENSIONS_VISIT_WEBSITE));
531 source->AddString("extensionSettingsVisitWebStore", 538 source->AddString("extensionSettingsVisitWebStore",
532 l10n_util::GetStringUTF16(IDS_EXTENSIONS_VISIT_WEBSTORE)); 539 l10n_util::GetStringUTF16(IDS_EXTENSIONS_VISIT_WEBSTORE));
533 source->AddString("extensionSettingsPolicyControlled", 540 source->AddString("extensionSettingsPolicyControlled",
534 l10n_util::GetStringUTF16(IDS_EXTENSIONS_POLICY_CONTROLLED)); 541 l10n_util::GetStringUTF16(IDS_EXTENSIONS_POLICY_CONTROLLED));
542 source->AddString("extensionSettingsPolicyRecommeneded",
543 l10n_util::GetStringUTF16(IDS_EXTENSIONS_POLICY_RECOMMENDED));
535 source->AddString("extensionSettingsDependentExtensions", 544 source->AddString("extensionSettingsDependentExtensions",
536 l10n_util::GetStringUTF16(IDS_EXTENSIONS_DEPENDENT_EXTENSIONS)); 545 l10n_util::GetStringUTF16(IDS_EXTENSIONS_DEPENDENT_EXTENSIONS));
537 source->AddString("extensionSettingsSupervisedUser", 546 source->AddString("extensionSettingsSupervisedUser",
538 l10n_util::GetStringUTF16(IDS_EXTENSIONS_LOCKED_SUPERVISED_USER)); 547 l10n_util::GetStringUTF16(IDS_EXTENSIONS_LOCKED_SUPERVISED_USER));
539 source->AddString("extensionSettingsCorruptInstall", 548 source->AddString("extensionSettingsCorruptInstall",
540 l10n_util::GetStringUTF16( 549 l10n_util::GetStringUTF16(
541 IDS_EXTENSIONS_CORRUPTED_EXTENSION)); 550 IDS_EXTENSIONS_CORRUPTED_EXTENSION));
542 source->AddString("extensionSettingsSuspiciousInstall", 551 source->AddString("extensionSettingsSuspiciousInstall",
543 l10n_util::GetStringFUTF16( 552 l10n_util::GetStringFUTF16(
544 IDS_EXTENSIONS_ADDED_WITHOUT_KNOWLEDGE, 553 IDS_EXTENSIONS_ADDED_WITHOUT_KNOWLEDGE,
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 void ExtensionSettingsHandler::HandleUninstallMessage( 1134 void ExtensionSettingsHandler::HandleUninstallMessage(
1126 const base::ListValue* args) { 1135 const base::ListValue* args) {
1127 CHECK_EQ(1U, args->GetSize()); 1136 CHECK_EQ(1U, args->GetSize());
1128 std::string extension_id; 1137 std::string extension_id;
1129 CHECK(args->GetString(0, &extension_id)); 1138 CHECK(args->GetString(0, &extension_id));
1130 const Extension* extension = 1139 const Extension* extension =
1131 extension_service_->GetInstalledExtension(extension_id); 1140 extension_service_->GetInstalledExtension(extension_id);
1132 if (!extension) 1141 if (!extension)
1133 return; 1142 return;
1134 1143
1135 if (!management_policy_->UserMayModifySettings(extension, NULL)) { 1144 if (!management_policy_->UserMayModifySettings(extension, NULL)) {
Finnur 2014/10/06 14:01:42 We could at some point get the css wrong or the us
binjin 2014/10/06 18:48:47 Done.
1136 LOG(ERROR) << "An attempt was made to uninstall an extension that is " 1145 LOG(ERROR) << "An attempt was made to uninstall an extension that is "
1137 << "non-usermanagable. Extension id : " << extension->id(); 1146 << "non-usermanagable. Extension id : " << extension->id();
1138 return; 1147 return;
1139 } 1148 }
1140 1149
1141 if (!extension_id_prompting_.empty()) 1150 if (!extension_id_prompting_.empty())
1142 return; // Only one prompt at a time. 1151 return; // Only one prompt at a time.
1143 1152
1144 extension_id_prompting_ = extension_id; 1153 extension_id_prompting_ = extension_id;
1145 1154
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
1450 extension_service_->EnableExtension(extension_id); 1459 extension_service_->EnableExtension(extension_id);
1451 } else { 1460 } else {
1452 ExtensionErrorReporter::GetInstance()->ReportError( 1461 ExtensionErrorReporter::GetInstance()->ReportError(
1453 base::UTF8ToUTF16(JoinString(requirement_errors, ' ')), 1462 base::UTF8ToUTF16(JoinString(requirement_errors, ' ')),
1454 true); // Be noisy. 1463 true); // Be noisy.
1455 } 1464 }
1456 requirements_checker_.reset(); 1465 requirements_checker_.reset();
1457 } 1466 }
1458 1467
1459 } // namespace extensions 1468 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698