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

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 // We should not get into a state where both are true. 241 bool recommended_install =
242 DCHECK(!managed_install || !suspicious_install); 242 !managed_install &&
243 management_policy_->MustRemainInstalled(extension, NULL);
244 extension_data->SetBoolean("recommendedInstall", recommended_install);
245
246 // Suspicious install should always be mutually exclusive to managed and/or
247 // recommended install.
248 DCHECK(!(managed_install || recommended_install) || !suspicious_install);
243 249
244 GURL icon = 250 GURL icon =
245 ExtensionIconSource::GetIconURL(extension, 251 ExtensionIconSource::GetIconURL(extension,
246 extension_misc::EXTENSION_ICON_MEDIUM, 252 extension_misc::EXTENSION_ICON_MEDIUM,
247 ExtensionIconSet::MATCH_BIGGER, 253 ExtensionIconSet::MATCH_BIGGER,
248 !enabled, NULL); 254 !enabled, NULL);
249 if (Manifest::IsUnpackedLocation(extension->location())) { 255 if (Manifest::IsUnpackedLocation(extension->location())) {
250 extension_data->SetString("path", extension->path().value()); 256 extension_data->SetString("path", extension->path().value());
251 extension_data->SetString( 257 extension_data->SetString(
252 "prettifiedPath", 258 "prettifiedPath",
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 util::AllowedScriptingOnAllUrls( 312 util::AllowedScriptingOnAllUrls(
307 extension->id(), extension_service_->GetBrowserContext())); 313 extension->id(), extension_service_->GetBrowserContext()));
308 extension_data->SetBoolean("wantsAllUrls", wants_all_urls); 314 extension_data->SetBoolean("wantsAllUrls", wants_all_urls);
309 extension_data->SetBoolean( 315 extension_data->SetBoolean(
310 "allowAllUrls", 316 "allowAllUrls",
311 util::AllowedScriptingOnAllUrls( 317 util::AllowedScriptingOnAllUrls(
312 extension->id(), 318 extension->id(),
313 extension_service_->GetBrowserContext())); 319 extension_service_->GetBrowserContext()));
314 320
315 base::string16 location_text; 321 base::string16 location_text;
316 if (Manifest::IsPolicyLocation(extension->location())) { 322 if (Manifest::IsPolicyLocation(extension->location()) ||
323 (extension->location() == Manifest::EXTERNAL_PREF_DOWNLOAD &&
324 recommended_install)) {
317 location_text = l10n_util::GetStringUTF16( 325 location_text = l10n_util::GetStringUTF16(
318 IDS_OPTIONS_INSTALL_LOCATION_ENTERPRISE); 326 IDS_OPTIONS_INSTALL_LOCATION_ENTERPRISE);
319 } else if (extension->location() == Manifest::INTERNAL && 327 } else if (extension->location() == Manifest::INTERNAL &&
320 !ManifestURL::UpdatesFromGallery(extension)) { 328 !ManifestURL::UpdatesFromGallery(extension)) {
321 location_text = l10n_util::GetStringUTF16( 329 location_text = l10n_util::GetStringUTF16(
322 IDS_OPTIONS_INSTALL_LOCATION_UNKNOWN); 330 IDS_OPTIONS_INSTALL_LOCATION_UNKNOWN);
323 } else if (extension->location() == Manifest::EXTERNAL_REGISTRY) { 331 } else if (extension->location() == Manifest::EXTERNAL_REGISTRY) {
324 location_text = l10n_util::GetStringUTF16( 332 location_text = l10n_util::GetStringUTF16(
325 IDS_OPTIONS_INSTALL_LOCATION_3RD_PARTY); 333 IDS_OPTIONS_INSTALL_LOCATION_3RD_PARTY);
326 } else if (extension->is_shared_module()) { 334 } else if (extension->is_shared_module()) {
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 source->AddString("extensionSettingsOptions", 533 source->AddString("extensionSettingsOptions",
526 l10n_util::GetStringUTF16(IDS_EXTENSIONS_OPTIONS_LINK)); 534 l10n_util::GetStringUTF16(IDS_EXTENSIONS_OPTIONS_LINK));
527 source->AddString("extensionSettingsPermissions", 535 source->AddString("extensionSettingsPermissions",
528 l10n_util::GetStringUTF16(IDS_EXTENSIONS_PERMISSIONS_LINK)); 536 l10n_util::GetStringUTF16(IDS_EXTENSIONS_PERMISSIONS_LINK));
529 source->AddString("extensionSettingsVisitWebsite", 537 source->AddString("extensionSettingsVisitWebsite",
530 l10n_util::GetStringUTF16(IDS_EXTENSIONS_VISIT_WEBSITE)); 538 l10n_util::GetStringUTF16(IDS_EXTENSIONS_VISIT_WEBSITE));
531 source->AddString("extensionSettingsVisitWebStore", 539 source->AddString("extensionSettingsVisitWebStore",
532 l10n_util::GetStringUTF16(IDS_EXTENSIONS_VISIT_WEBSTORE)); 540 l10n_util::GetStringUTF16(IDS_EXTENSIONS_VISIT_WEBSTORE));
533 source->AddString("extensionSettingsPolicyControlled", 541 source->AddString("extensionSettingsPolicyControlled",
534 l10n_util::GetStringUTF16(IDS_EXTENSIONS_POLICY_CONTROLLED)); 542 l10n_util::GetStringUTF16(IDS_EXTENSIONS_POLICY_CONTROLLED));
543 source->AddString("extensionSettingsPolicyRecommeneded",
544 l10n_util::GetStringUTF16(IDS_EXTENSIONS_POLICY_RECOMMENDED));
535 source->AddString("extensionSettingsDependentExtensions", 545 source->AddString("extensionSettingsDependentExtensions",
536 l10n_util::GetStringUTF16(IDS_EXTENSIONS_DEPENDENT_EXTENSIONS)); 546 l10n_util::GetStringUTF16(IDS_EXTENSIONS_DEPENDENT_EXTENSIONS));
537 source->AddString("extensionSettingsSupervisedUser", 547 source->AddString("extensionSettingsSupervisedUser",
538 l10n_util::GetStringUTF16(IDS_EXTENSIONS_LOCKED_SUPERVISED_USER)); 548 l10n_util::GetStringUTF16(IDS_EXTENSIONS_LOCKED_SUPERVISED_USER));
539 source->AddString("extensionSettingsCorruptInstall", 549 source->AddString("extensionSettingsCorruptInstall",
540 l10n_util::GetStringUTF16( 550 l10n_util::GetStringUTF16(
541 IDS_EXTENSIONS_CORRUPTED_EXTENSION)); 551 IDS_EXTENSIONS_CORRUPTED_EXTENSION));
542 source->AddString("extensionSettingsSuspiciousInstall", 552 source->AddString("extensionSettingsSuspiciousInstall",
543 l10n_util::GetStringFUTF16( 553 l10n_util::GetStringFUTF16(
544 IDS_EXTENSIONS_ADDED_WITHOUT_KNOWLEDGE, 554 IDS_EXTENSIONS_ADDED_WITHOUT_KNOWLEDGE,
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 void ExtensionSettingsHandler::HandleUninstallMessage( 1135 void ExtensionSettingsHandler::HandleUninstallMessage(
1126 const base::ListValue* args) { 1136 const base::ListValue* args) {
1127 CHECK_EQ(1U, args->GetSize()); 1137 CHECK_EQ(1U, args->GetSize());
1128 std::string extension_id; 1138 std::string extension_id;
1129 CHECK(args->GetString(0, &extension_id)); 1139 CHECK(args->GetString(0, &extension_id));
1130 const Extension* extension = 1140 const Extension* extension =
1131 extension_service_->GetInstalledExtension(extension_id); 1141 extension_service_->GetInstalledExtension(extension_id);
1132 if (!extension) 1142 if (!extension)
1133 return; 1143 return;
1134 1144
1135 if (!management_policy_->UserMayModifySettings(extension, NULL)) { 1145 if (!management_policy_->UserMayModifySettings(extension, NULL) ||
1146 management_policy_->MustRemainInstalled(extension, NULL)) {
1136 LOG(ERROR) << "An attempt was made to uninstall an extension that is " 1147 LOG(ERROR) << "An attempt was made to uninstall an extension that is "
1137 << "non-usermanagable. Extension id : " << extension->id(); 1148 << "non-usermanagable. Extension id : " << extension->id();
1138 return; 1149 return;
1139 } 1150 }
1140 1151
1141 if (!extension_id_prompting_.empty()) 1152 if (!extension_id_prompting_.empty())
1142 return; // Only one prompt at a time. 1153 return; // Only one prompt at a time.
1143 1154
1144 extension_id_prompting_ = extension_id; 1155 extension_id_prompting_ = extension_id;
1145 1156
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
1450 extension_service_->EnableExtension(extension_id); 1461 extension_service_->EnableExtension(extension_id);
1451 } else { 1462 } else {
1452 ExtensionErrorReporter::GetInstance()->ReportError( 1463 ExtensionErrorReporter::GetInstance()->ReportError(
1453 base::UTF8ToUTF16(JoinString(requirement_errors, ' ')), 1464 base::UTF8ToUTF16(JoinString(requirement_errors, ' ')),
1454 true); // Be noisy. 1465 true); // Be noisy.
1455 } 1466 }
1456 requirements_checker_.reset(); 1467 requirements_checker_.reset();
1457 } 1468 }
1458 1469
1459 } // namespace extensions 1470 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698