OLD | NEW |
---|---|
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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
299 if (is_remote_install_) { | 299 if (is_remote_install_) { |
300 messages.push_back(l10n_util::GetStringFUTF16( | 300 messages.push_back(l10n_util::GetStringFUTF16( |
301 extension_->is_app() | 301 extension_->is_app() |
302 ? IDS_APP_DISABLED_REMOTE_INSTALL_ERROR_LABEL | 302 ? IDS_APP_DISABLED_REMOTE_INSTALL_ERROR_LABEL |
303 : IDS_EXTENSION_DISABLED_REMOTE_INSTALL_ERROR_LABEL, | 303 : IDS_EXTENSION_DISABLED_REMOTE_INSTALL_ERROR_LABEL, |
304 base::UTF8ToUTF16(extension_->name()))); | 304 base::UTF8ToUTF16(extension_->name()))); |
305 if (!permission_warnings.empty()) | 305 if (!permission_warnings.empty()) |
306 messages.push_back( | 306 messages.push_back( |
307 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO)); | 307 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO)); |
308 } else { | 308 } else { |
309 // TODO(treib): Add an extra message for supervised users? | |
309 messages.push_back(l10n_util::GetStringFUTF16( | 310 messages.push_back(l10n_util::GetStringFUTF16( |
310 extension_->is_app() ? IDS_APP_DISABLED_ERROR_LABEL | 311 extension_->is_app() ? IDS_APP_DISABLED_ERROR_LABEL |
311 : IDS_EXTENSION_DISABLED_ERROR_LABEL, | 312 : IDS_EXTENSION_DISABLED_ERROR_LABEL, |
312 base::UTF8ToUTF16(extension_->name()))); | 313 base::UTF8ToUTF16(extension_->name()))); |
313 messages.push_back(l10n_util::GetStringUTF16( | 314 messages.push_back(l10n_util::GetStringUTF16( |
314 IDS_EXTENSION_PROMPT_WILL_NOW_HAVE_ACCESS_TO)); | 315 IDS_EXTENSION_PROMPT_WILL_NOW_HAVE_ACCESS_TO)); |
315 } | 316 } |
316 for (size_t i = 0; i < permission_warnings.size(); ++i) { | 317 for (size_t i = 0; i < permission_warnings.size(); ++i) { |
317 messages.push_back(l10n_util::GetStringFUTF16( | 318 messages.push_back(l10n_util::GetStringFUTF16( |
318 IDS_EXTENSION_PERMISSION_LINE, permission_warnings[i])); | 319 IDS_EXTENSION_PERMISSION_LINE, permission_warnings[i])); |
319 } | 320 } |
320 return messages; | 321 return messages; |
321 } | 322 } |
322 | 323 |
323 base::string16 ExtensionDisabledGlobalError::GetBubbleViewAcceptButtonLabel() { | 324 base::string16 ExtensionDisabledGlobalError::GetBubbleViewAcceptButtonLabel() { |
325 if (service_->profile()->IsSupervised() && | |
326 extension_->was_installed_by_custodian()) { | |
benwells
2015/02/24 07:33:47
This logic is repeated a few times. You should put
Marc Treib
2015/02/24 10:33:39
The "well-named" is the hard part ;)
Done (I hope)
| |
327 // TODO(treib): Probably use a new string here once we get UX design. | |
benwells
2015/02/24 07:33:47
These TODOs are a bit concerning. If this doesn't
Marc Treib
2015/02/24 10:33:39
There's currently no way for a user to trigger thi
| |
328 // For now, just re-use an existing string that says "OK". | |
329 return l10n_util::GetStringUTF16(IDS_EXTENSION_ALERT_ITEM_OK); | |
330 } | |
324 if (is_remote_install_) { | 331 if (is_remote_install_) { |
325 return l10n_util::GetStringUTF16( | 332 return l10n_util::GetStringUTF16( |
326 IDS_EXTENSION_PROMPT_REMOTE_INSTALL_BUTTON); | 333 IDS_EXTENSION_PROMPT_REMOTE_INSTALL_BUTTON); |
327 } else { | |
328 return l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_RE_ENABLE_BUTTON); | |
329 } | 334 } |
335 return l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_RE_ENABLE_BUTTON); | |
330 } | 336 } |
331 | 337 |
332 base::string16 ExtensionDisabledGlobalError::GetBubbleViewCancelButtonLabel() { | 338 base::string16 ExtensionDisabledGlobalError::GetBubbleViewCancelButtonLabel() { |
339 // For custodian-installed extensions, supervised users only get a single | |
340 // "acknowledge" button. | |
341 if (service_->profile()->IsSupervised() && | |
342 extension_->was_installed_by_custodian()) { | |
343 return base::string16(); | |
344 } | |
333 return l10n_util::GetStringUTF16(IDS_EXTENSIONS_UNINSTALL); | 345 return l10n_util::GetStringUTF16(IDS_EXTENSIONS_UNINSTALL); |
334 } | 346 } |
335 | 347 |
336 void ExtensionDisabledGlobalError::OnBubbleViewDidClose(Browser* browser) { | 348 void ExtensionDisabledGlobalError::OnBubbleViewDidClose(Browser* browser) { |
337 } | 349 } |
338 | 350 |
339 void ExtensionDisabledGlobalError::BubbleViewAcceptButtonPressed( | 351 void ExtensionDisabledGlobalError::BubbleViewAcceptButtonPressed( |
340 Browser* browser) { | 352 Browser* browser) { |
353 // Supervised users can't re-enable custodian-installed extensions, just | |
354 // acknowledge that they've been disabled. | |
355 if (service_->profile()->IsSupervised() && | |
356 extension_->was_installed_by_custodian()) { | |
357 return; | |
358 } | |
341 // Delay extension reenabling so this bubble closes properly. | 359 // Delay extension reenabling so this bubble closes properly. |
342 base::MessageLoop::current()->PostTask(FROM_HERE, | 360 base::MessageLoop::current()->PostTask(FROM_HERE, |
343 base::Bind(&ExtensionService::GrantPermissionsAndEnableExtension, | 361 base::Bind(&ExtensionService::GrantPermissionsAndEnableExtension, |
344 service_->AsWeakPtr(), extension_)); | 362 service_->AsWeakPtr(), extension_)); |
345 } | 363 } |
346 | 364 |
347 void ExtensionDisabledGlobalError::BubbleViewCancelButtonPressed( | 365 void ExtensionDisabledGlobalError::BubbleViewCancelButtonPressed( |
348 Browser* browser) { | 366 Browser* browser) { |
367 // This button shouldn't exist for custodian-installed extensions in a | |
368 // supervised profile. | |
369 DCHECK(!service_->profile()->IsSupervised() || | |
370 !extension_->was_installed_by_custodian()); | |
349 uninstall_dialog_.reset(extensions::ExtensionUninstallDialog::Create( | 371 uninstall_dialog_.reset(extensions::ExtensionUninstallDialog::Create( |
350 service_->profile(), browser->window()->GetNativeWindow(), this)); | 372 service_->profile(), browser->window()->GetNativeWindow(), this)); |
351 // Delay showing the uninstall dialog, so that this function returns | 373 // Delay showing the uninstall dialog, so that this function returns |
352 // immediately, to close the bubble properly. See crbug.com/121544. | 374 // immediately, to close the bubble properly. See crbug.com/121544. |
353 base::MessageLoop::current()->PostTask( | 375 base::MessageLoop::current()->PostTask( |
354 FROM_HERE, | 376 FROM_HERE, |
355 base::Bind(&extensions::ExtensionUninstallDialog::ConfirmUninstall, | 377 base::Bind(&extensions::ExtensionUninstallDialog::ConfirmUninstall, |
356 uninstall_dialog_->AsWeakPtr(), | 378 uninstall_dialog_->AsWeakPtr(), |
357 extension_)); | 379 extension_)); |
358 } | 380 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
437 void ShowExtensionDisabledDialog(ExtensionService* service, | 459 void ShowExtensionDisabledDialog(ExtensionService* service, |
438 content::WebContents* web_contents, | 460 content::WebContents* web_contents, |
439 const Extension* extension) { | 461 const Extension* extension) { |
440 scoped_ptr<ExtensionInstallPrompt> install_ui( | 462 scoped_ptr<ExtensionInstallPrompt> install_ui( |
441 new ExtensionInstallPrompt(web_contents)); | 463 new ExtensionInstallPrompt(web_contents)); |
442 // This object manages its own lifetime. | 464 // This object manages its own lifetime. |
443 new ExtensionDisabledDialogDelegate(service, install_ui.Pass(), extension); | 465 new ExtensionDisabledDialogDelegate(service, install_ui.Pass(), extension); |
444 } | 466 } |
445 | 467 |
446 } // namespace extensions | 468 } // namespace extensions |
OLD | NEW |