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

Side by Side Diff: chrome/browser/extensions/extension_disabled_ui.cc

Issue 925563002: Supervised users: Slightly relax restrictions around extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@test_ext_install_disable
Patch Set: fix Created 5 years, 10 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/extensions/extension_disabled_ui.h" 5 #include "chrome/browser/extensions/extension_disabled_ui.h"
6 6
7 #include <bitset> 7 #include <bitset>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } 129 }
130 130
131 void ExtensionDisabledDialogDelegate::InstallUIAbort(bool user_initiated) { 131 void ExtensionDisabledDialogDelegate::InstallUIAbort(bool user_initiated) {
132 std::string histogram_name = user_initiated 132 std::string histogram_name = user_initiated
133 ? "Extensions.Permissions_ReEnableCancel2" 133 ? "Extensions.Permissions_ReEnableCancel2"
134 : "Extensions.Permissions_ReEnableAbort2"; 134 : "Extensions.Permissions_ReEnableAbort2";
135 ExtensionService::RecordPermissionMessagesHistogram( 135 ExtensionService::RecordPermissionMessagesHistogram(
136 extension_, histogram_name.c_str()); 136 extension_, histogram_name.c_str());
137 137
138 // Do nothing. The extension will remain disabled. 138 // Do nothing. The extension will remain disabled.
139
139 Release(); 140 Release();
140 } 141 }
141 142
142 // ExtensionDisabledGlobalError ----------------------------------------------- 143 // ExtensionDisabledGlobalError -----------------------------------------------
143 144
144 class ExtensionDisabledGlobalError 145 class ExtensionDisabledGlobalError
145 : public GlobalErrorWithStandardBubble, 146 : public GlobalErrorWithStandardBubble,
146 public content::NotificationObserver, 147 public content::NotificationObserver,
147 public extensions::ExtensionUninstallDialog::Delegate { 148 public extensions::ExtensionUninstallDialog::Delegate {
148 public: 149 public:
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 if (is_remote_install_) { 300 if (is_remote_install_) {
300 messages.push_back(l10n_util::GetStringFUTF16( 301 messages.push_back(l10n_util::GetStringFUTF16(
301 extension_->is_app() 302 extension_->is_app()
302 ? IDS_APP_DISABLED_REMOTE_INSTALL_ERROR_LABEL 303 ? IDS_APP_DISABLED_REMOTE_INSTALL_ERROR_LABEL
303 : IDS_EXTENSION_DISABLED_REMOTE_INSTALL_ERROR_LABEL, 304 : IDS_EXTENSION_DISABLED_REMOTE_INSTALL_ERROR_LABEL,
304 base::UTF8ToUTF16(extension_->name()))); 305 base::UTF8ToUTF16(extension_->name())));
305 if (!permission_warnings.empty()) 306 if (!permission_warnings.empty())
306 messages.push_back( 307 messages.push_back(
307 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO)); 308 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO));
308 } else { 309 } else {
310 // TODO(treib): Add an extra message for supervised users?
Pam (message me for reviews) 2015/02/23 10:18:50 +1
Marc Treib 2015/02/23 12:07:38 I'd like to do that in a different CL, though.
309 messages.push_back(l10n_util::GetStringFUTF16( 311 messages.push_back(l10n_util::GetStringFUTF16(
310 extension_->is_app() ? IDS_APP_DISABLED_ERROR_LABEL 312 extension_->is_app() ? IDS_APP_DISABLED_ERROR_LABEL
311 : IDS_EXTENSION_DISABLED_ERROR_LABEL, 313 : IDS_EXTENSION_DISABLED_ERROR_LABEL,
312 base::UTF8ToUTF16(extension_->name()))); 314 base::UTF8ToUTF16(extension_->name())));
313 messages.push_back(l10n_util::GetStringUTF16( 315 messages.push_back(l10n_util::GetStringUTF16(
314 IDS_EXTENSION_PROMPT_WILL_NOW_HAVE_ACCESS_TO)); 316 IDS_EXTENSION_PROMPT_WILL_NOW_HAVE_ACCESS_TO));
315 } 317 }
316 for (size_t i = 0; i < permission_warnings.size(); ++i) { 318 for (size_t i = 0; i < permission_warnings.size(); ++i) {
317 messages.push_back(l10n_util::GetStringFUTF16( 319 messages.push_back(l10n_util::GetStringFUTF16(
318 IDS_EXTENSION_PERMISSION_LINE, permission_warnings[i])); 320 IDS_EXTENSION_PERMISSION_LINE, permission_warnings[i]));
319 } 321 }
320 return messages; 322 return messages;
321 } 323 }
322 324
323 base::string16 ExtensionDisabledGlobalError::GetBubbleViewAcceptButtonLabel() { 325 base::string16 ExtensionDisabledGlobalError::GetBubbleViewAcceptButtonLabel() {
326 if (service_->profile()->IsSupervised() &&
327 extension_->was_installed_by_custodian()) {
328 // TODO(treib): Probably use a new string here once we get UX design.
329 // For now, just re-use an existing string that says "OK".
330 return l10n_util::GetStringUTF16(IDS_EXTENSION_ALERT_ITEM_OK);
331 }
324 if (is_remote_install_) { 332 if (is_remote_install_) {
325 return l10n_util::GetStringUTF16( 333 return l10n_util::GetStringUTF16(
326 IDS_EXTENSION_PROMPT_REMOTE_INSTALL_BUTTON); 334 IDS_EXTENSION_PROMPT_REMOTE_INSTALL_BUTTON);
327 } else {
328 return l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_RE_ENABLE_BUTTON);
329 } 335 }
336 return l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_RE_ENABLE_BUTTON);
330 } 337 }
331 338
332 base::string16 ExtensionDisabledGlobalError::GetBubbleViewCancelButtonLabel() { 339 base::string16 ExtensionDisabledGlobalError::GetBubbleViewCancelButtonLabel() {
340 // For custodian-installed extensions, supervised users only get a single
341 // "acknowledge" button.
342 if (service_->profile()->IsSupervised() &&
343 extension_->was_installed_by_custodian()) {
344 return base::string16();
345 }
333 return l10n_util::GetStringUTF16(IDS_EXTENSIONS_UNINSTALL); 346 return l10n_util::GetStringUTF16(IDS_EXTENSIONS_UNINSTALL);
334 } 347 }
335 348
336 void ExtensionDisabledGlobalError::OnBubbleViewDidClose(Browser* browser) { 349 void ExtensionDisabledGlobalError::OnBubbleViewDidClose(Browser* browser) {
337 } 350 }
338 351
339 void ExtensionDisabledGlobalError::BubbleViewAcceptButtonPressed( 352 void ExtensionDisabledGlobalError::BubbleViewAcceptButtonPressed(
340 Browser* browser) { 353 Browser* browser) {
354 // Supervised users can't re-enable custodian-installed extensions, just
355 // acknowledge that they've been disabled.
356 if (service_->profile()->IsSupervised() &&
357 extension_->was_installed_by_custodian()) {
358 return;
359 }
341 // Delay extension reenabling so this bubble closes properly. 360 // Delay extension reenabling so this bubble closes properly.
342 base::MessageLoop::current()->PostTask(FROM_HERE, 361 base::MessageLoop::current()->PostTask(FROM_HERE,
343 base::Bind(&ExtensionService::GrantPermissionsAndEnableExtension, 362 base::Bind(&ExtensionService::GrantPermissionsAndEnableExtension,
344 service_->AsWeakPtr(), extension_)); 363 service_->AsWeakPtr(), extension_));
345 } 364 }
346 365
347 void ExtensionDisabledGlobalError::BubbleViewCancelButtonPressed( 366 void ExtensionDisabledGlobalError::BubbleViewCancelButtonPressed(
348 Browser* browser) { 367 Browser* browser) {
368 // This button shouldn't exist for custodian-installed extensions in a
369 // supervised profile.
Pam (message me for reviews) 2015/02/23 10:18:50 What other kind of extension in a supervised profi
Marc Treib 2015/02/23 12:07:38 Or if we decide to have an "allow everything, even
370 DCHECK(!service_->profile()->IsSupervised() ||
371 !extension_->was_installed_by_custodian());
349 uninstall_dialog_.reset(extensions::ExtensionUninstallDialog::Create( 372 uninstall_dialog_.reset(extensions::ExtensionUninstallDialog::Create(
350 service_->profile(), browser->window()->GetNativeWindow(), this)); 373 service_->profile(), browser->window()->GetNativeWindow(), this));
351 // Delay showing the uninstall dialog, so that this function returns 374 // Delay showing the uninstall dialog, so that this function returns
352 // immediately, to close the bubble properly. See crbug.com/121544. 375 // immediately, to close the bubble properly. See crbug.com/121544.
353 base::MessageLoop::current()->PostTask( 376 base::MessageLoop::current()->PostTask(
354 FROM_HERE, 377 FROM_HERE,
355 base::Bind(&extensions::ExtensionUninstallDialog::ConfirmUninstall, 378 base::Bind(&extensions::ExtensionUninstallDialog::ConfirmUninstall,
356 uninstall_dialog_->AsWeakPtr(), 379 uninstall_dialog_->AsWeakPtr(),
357 extension_)); 380 extension_));
358 } 381 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 void ShowExtensionDisabledDialog(ExtensionService* service, 460 void ShowExtensionDisabledDialog(ExtensionService* service,
438 content::WebContents* web_contents, 461 content::WebContents* web_contents,
439 const Extension* extension) { 462 const Extension* extension) {
440 scoped_ptr<ExtensionInstallPrompt> install_ui( 463 scoped_ptr<ExtensionInstallPrompt> install_ui(
441 new ExtensionInstallPrompt(web_contents)); 464 new ExtensionInstallPrompt(web_contents));
442 // This object manages its own lifetime. 465 // This object manages its own lifetime.
443 new ExtensionDisabledDialogDelegate(service, install_ui.Pass(), extension); 466 new ExtensionDisabledDialogDelegate(service, install_ui.Pass(), extension);
444 } 467 }
445 468
446 } // namespace extensions 469 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698