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

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, more fix 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 should_do_verification_check_ = true; 234 should_do_verification_check_ = true;
235 235
236 bool corrupt_install = 236 bool corrupt_install =
237 (disable_reasons & Extension::DISABLE_CORRUPTED) != 0; 237 (disable_reasons & Extension::DISABLE_CORRUPTED) != 0;
238 extension_data->SetBoolean("corruptInstall", corrupt_install); 238 extension_data->SetBoolean("corruptInstall", corrupt_install);
239 239
240 bool managed_install = 240 bool managed_install =
241 !management_policy_->UserMayModifySettings(extension, NULL); 241 !management_policy_->UserMayModifySettings(extension, NULL);
242 extension_data->SetBoolean("managedInstall", managed_install); 242 extension_data->SetBoolean("managedInstall", managed_install);
243 243
244 // We should not get into a state where both are true. 244 bool recommended_install =
245 DCHECK(!managed_install || !suspicious_install); 245 !managed_install &&
246 management_policy_->MustRemainInstalled(extension, NULL);
247 extension_data->SetBoolean("recommendedInstall", recommended_install);
248
249 // Suspicious install should always be mutually exclusive to managed and/or
250 // recommended install.
251 DCHECK(!(managed_install || recommended_install) || !suspicious_install);
246 252
247 GURL icon = 253 GURL icon =
248 ExtensionIconSource::GetIconURL(extension, 254 ExtensionIconSource::GetIconURL(extension,
249 extension_misc::EXTENSION_ICON_MEDIUM, 255 extension_misc::EXTENSION_ICON_MEDIUM,
250 ExtensionIconSet::MATCH_BIGGER, 256 ExtensionIconSet::MATCH_BIGGER,
251 !enabled, NULL); 257 !enabled, NULL);
252 if (Manifest::IsUnpackedLocation(extension->location())) { 258 if (Manifest::IsUnpackedLocation(extension->location())) {
253 extension_data->SetString("path", extension->path().value()); 259 extension_data->SetString("path", extension->path().value());
254 extension_data->SetString( 260 extension_data->SetString(
255 "prettifiedPath", 261 "prettifiedPath",
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 util::AllowedScriptingOnAllUrls( 315 util::AllowedScriptingOnAllUrls(
310 extension->id(), extension_service_->GetBrowserContext())); 316 extension->id(), extension_service_->GetBrowserContext()));
311 extension_data->SetBoolean("wantsAllUrls", wants_all_urls); 317 extension_data->SetBoolean("wantsAllUrls", wants_all_urls);
312 extension_data->SetBoolean( 318 extension_data->SetBoolean(
313 "allowAllUrls", 319 "allowAllUrls",
314 util::AllowedScriptingOnAllUrls( 320 util::AllowedScriptingOnAllUrls(
315 extension->id(), 321 extension->id(),
316 extension_service_->GetBrowserContext())); 322 extension_service_->GetBrowserContext()));
317 323
318 base::string16 location_text; 324 base::string16 location_text;
319 if (Manifest::IsPolicyLocation(extension->location())) { 325 if (Manifest::IsPolicyLocation(extension->location()) ||
326 (extension->location() == Manifest::EXTERNAL_PREF_DOWNLOAD &&
327 recommended_install)) {
320 location_text = l10n_util::GetStringUTF16( 328 location_text = l10n_util::GetStringUTF16(
321 IDS_OPTIONS_INSTALL_LOCATION_ENTERPRISE); 329 IDS_OPTIONS_INSTALL_LOCATION_ENTERPRISE);
322 } else if (extension->location() == Manifest::INTERNAL && 330 } else if (extension->location() == Manifest::INTERNAL &&
323 !ManifestURL::UpdatesFromGallery(extension)) { 331 !ManifestURL::UpdatesFromGallery(extension)) {
324 location_text = l10n_util::GetStringUTF16( 332 location_text = l10n_util::GetStringUTF16(
325 IDS_OPTIONS_INSTALL_LOCATION_UNKNOWN); 333 IDS_OPTIONS_INSTALL_LOCATION_UNKNOWN);
326 } else if (extension->location() == Manifest::EXTERNAL_REGISTRY) { 334 } else if (extension->location() == Manifest::EXTERNAL_REGISTRY) {
327 location_text = l10n_util::GetStringUTF16( 335 location_text = l10n_util::GetStringUTF16(
328 IDS_OPTIONS_INSTALL_LOCATION_3RD_PARTY); 336 IDS_OPTIONS_INSTALL_LOCATION_3RD_PARTY);
329 } else if (extension->is_shared_module()) { 337 } else if (extension->is_shared_module()) {
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 source->AddString( 543 source->AddString(
536 "extensionSettingsPermissions", 544 "extensionSettingsPermissions",
537 l10n_util::GetStringUTF16(IDS_EXTENSIONS_PERMISSIONS_LINK)); 545 l10n_util::GetStringUTF16(IDS_EXTENSIONS_PERMISSIONS_LINK));
538 } 546 }
539 source->AddString("extensionSettingsVisitWebsite", 547 source->AddString("extensionSettingsVisitWebsite",
540 l10n_util::GetStringUTF16(IDS_EXTENSIONS_VISIT_WEBSITE)); 548 l10n_util::GetStringUTF16(IDS_EXTENSIONS_VISIT_WEBSITE));
541 source->AddString("extensionSettingsVisitWebStore", 549 source->AddString("extensionSettingsVisitWebStore",
542 l10n_util::GetStringUTF16(IDS_EXTENSIONS_VISIT_WEBSTORE)); 550 l10n_util::GetStringUTF16(IDS_EXTENSIONS_VISIT_WEBSTORE));
543 source->AddString("extensionSettingsPolicyControlled", 551 source->AddString("extensionSettingsPolicyControlled",
544 l10n_util::GetStringUTF16(IDS_EXTENSIONS_POLICY_CONTROLLED)); 552 l10n_util::GetStringUTF16(IDS_EXTENSIONS_POLICY_CONTROLLED));
553 source->AddString("extensionSettingsPolicyRecommeneded",
554 l10n_util::GetStringUTF16(IDS_EXTENSIONS_POLICY_RECOMMENDED));
545 source->AddString("extensionSettingsDependentExtensions", 555 source->AddString("extensionSettingsDependentExtensions",
546 l10n_util::GetStringUTF16(IDS_EXTENSIONS_DEPENDENT_EXTENSIONS)); 556 l10n_util::GetStringUTF16(IDS_EXTENSIONS_DEPENDENT_EXTENSIONS));
547 source->AddString("extensionSettingsSupervisedUser", 557 source->AddString("extensionSettingsSupervisedUser",
548 l10n_util::GetStringUTF16(IDS_EXTENSIONS_LOCKED_SUPERVISED_USER)); 558 l10n_util::GetStringUTF16(IDS_EXTENSIONS_LOCKED_SUPERVISED_USER));
549 source->AddString("extensionSettingsCorruptInstall", 559 source->AddString("extensionSettingsCorruptInstall",
550 l10n_util::GetStringUTF16( 560 l10n_util::GetStringUTF16(
551 IDS_EXTENSIONS_CORRUPTED_EXTENSION)); 561 IDS_EXTENSIONS_CORRUPTED_EXTENSION));
552 source->AddString("extensionSettingsSuspiciousInstall", 562 source->AddString("extensionSettingsSuspiciousInstall",
553 l10n_util::GetStringFUTF16( 563 l10n_util::GetStringFUTF16(
554 IDS_EXTENSIONS_ADDED_WITHOUT_KNOWLEDGE, 564 IDS_EXTENSIONS_ADDED_WITHOUT_KNOWLEDGE,
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 void ExtensionSettingsHandler::HandleUninstallMessage( 1149 void ExtensionSettingsHandler::HandleUninstallMessage(
1140 const base::ListValue* args) { 1150 const base::ListValue* args) {
1141 CHECK_EQ(1U, args->GetSize()); 1151 CHECK_EQ(1U, args->GetSize());
1142 std::string extension_id; 1152 std::string extension_id;
1143 CHECK(args->GetString(0, &extension_id)); 1153 CHECK(args->GetString(0, &extension_id));
1144 const Extension* extension = 1154 const Extension* extension =
1145 extension_service_->GetInstalledExtension(extension_id); 1155 extension_service_->GetInstalledExtension(extension_id);
1146 if (!extension) 1156 if (!extension)
1147 return; 1157 return;
1148 1158
1149 if (!management_policy_->UserMayModifySettings(extension, NULL)) { 1159 if (!management_policy_->UserMayModifySettings(extension, NULL) ||
1160 management_policy_->MustRemainInstalled(extension, NULL)) {
1150 LOG(ERROR) << "An attempt was made to uninstall an extension that is " 1161 LOG(ERROR) << "An attempt was made to uninstall an extension that is "
1151 << "non-usermanagable. Extension id : " << extension->id(); 1162 << "non-usermanagable. Extension id : " << extension->id();
1152 return; 1163 return;
1153 } 1164 }
1154 1165
1155 if (!extension_id_prompting_.empty()) 1166 if (!extension_id_prompting_.empty())
1156 return; // Only one prompt at a time. 1167 return; // Only one prompt at a time.
1157 1168
1158 extension_id_prompting_ = extension_id; 1169 extension_id_prompting_ = extension_id;
1159 1170
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
1486 extension_service_->EnableExtension(extension_id); 1497 extension_service_->EnableExtension(extension_id);
1487 } else { 1498 } else {
1488 ExtensionErrorReporter::GetInstance()->ReportError( 1499 ExtensionErrorReporter::GetInstance()->ReportError(
1489 base::UTF8ToUTF16(JoinString(requirement_errors, ' ')), 1500 base::UTF8ToUTF16(JoinString(requirement_errors, ' ')),
1490 true); // Be noisy. 1501 true); // Be noisy.
1491 } 1502 }
1492 requirements_checker_.reset(); 1503 requirements_checker_.reset();
1493 } 1504 }
1494 1505
1495 } // namespace extensions 1506 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/resources/extensions/extension_list.js ('k') | extensions/browser/management_policy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698