Chromium Code Reviews| 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 <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 312 } | 312 } |
| 313 for (const PermissionMessage& msg : permission_warnings) { | 313 for (const PermissionMessage& msg : permission_warnings) { |
| 314 messages.push_back(l10n_util::GetStringFUTF16(IDS_EXTENSION_PERMISSION_LINE, | 314 messages.push_back(l10n_util::GetStringFUTF16(IDS_EXTENSION_PERMISSION_LINE, |
| 315 msg.message())); | 315 msg.message())); |
| 316 } | 316 } |
| 317 return messages; | 317 return messages; |
| 318 } | 318 } |
| 319 | 319 |
| 320 base::string16 ExtensionDisabledGlobalError::GetBubbleViewAcceptButtonLabel() { | 320 base::string16 ExtensionDisabledGlobalError::GetBubbleViewAcceptButtonLabel() { |
| 321 if (extensions::util::IsExtensionSupervised(extension_, | 321 if (extensions::util::IsExtensionSupervised(extension_, |
| 322 service_->profile()) && | 322 service_->profile())) { |
| 323 extensions::util::NeedCustodianApprovalForPermissionIncrease( | |
| 324 service_->profile())) { | |
| 325 // TODO(treib): Probably use a new string here once we get UX design. | 323 // TODO(treib): Probably use a new string here once we get UX design. |
| 326 // For now, just use "OK". crbug.com/461261 | 324 // For now, just use "OK". crbug.com/461261 |
| 327 return l10n_util::GetStringUTF16(IDS_OK); | 325 return l10n_util::GetStringUTF16(IDS_OK); |
| 328 } | 326 } |
| 329 if (is_remote_install_) { | 327 if (is_remote_install_) { |
| 330 return l10n_util::GetStringUTF16( | 328 return l10n_util::GetStringUTF16( |
| 331 extension_->is_app() | 329 extension_->is_app() |
| 332 ? IDS_EXTENSION_PROMPT_REMOTE_INSTALL_BUTTON_APP | 330 ? IDS_EXTENSION_PROMPT_REMOTE_INSTALL_BUTTON_APP |
| 333 : IDS_EXTENSION_PROMPT_REMOTE_INSTALL_BUTTON_EXTENSION); | 331 : IDS_EXTENSION_PROMPT_REMOTE_INSTALL_BUTTON_EXTENSION); |
| 334 } | 332 } |
| 335 return l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_RE_ENABLE_BUTTON); | 333 return l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_RE_ENABLE_BUTTON); |
| 336 } | 334 } |
| 337 | 335 |
| 338 base::string16 ExtensionDisabledGlobalError::GetBubbleViewCancelButtonLabel() { | 336 base::string16 ExtensionDisabledGlobalError::GetBubbleViewCancelButtonLabel() { |
| 339 if (extensions::util::IsExtensionSupervised(extension_, | 337 if (extensions::util::IsExtensionSupervised(extension_, |
| 340 service_->profile())) { | 338 service_->profile())) { |
| 341 if (extensions::util::NeedCustodianApprovalForPermissionIncrease( | 339 // The supervised user can't approve the update, and hence there is no |
| 342 service_->profile())) { | 340 // "cancel" button. |
|
asargent_no_longer_on_chrome
2016/10/05 23:23:34
Can you clarify this a little bit? Do you mean tha
mamir
2016/10/06 09:09:23
It's the latter. We return an empty string which
| |
| 343 // If the supervised user can't approve the update, then there is no | 341 return base::string16(); |
| 344 // "cancel" button. | |
| 345 return base::string16(); | |
| 346 } else { | |
| 347 // Supervised users can not remove extensions, so use "cancel" here | |
| 348 // instead of "uninstall". | |
| 349 return l10n_util::GetStringUTF16(IDS_CANCEL); | |
| 350 } | |
| 351 } | 342 } |
| 352 return l10n_util::GetStringUTF16(IDS_EXTENSIONS_UNINSTALL); | 343 return l10n_util::GetStringUTF16(IDS_EXTENSIONS_UNINSTALL); |
| 353 } | 344 } |
| 354 | 345 |
| 355 void ExtensionDisabledGlobalError::OnBubbleViewDidClose(Browser* browser) { | 346 void ExtensionDisabledGlobalError::OnBubbleViewDidClose(Browser* browser) { |
| 356 } | 347 } |
| 357 | 348 |
| 358 void ExtensionDisabledGlobalError::BubbleViewAcceptButtonPressed( | 349 void ExtensionDisabledGlobalError::BubbleViewAcceptButtonPressed( |
| 359 Browser* browser) { | 350 Browser* browser) { |
| 360 if (extensions::util::IsExtensionSupervised(extension_, | 351 if (extensions::util::IsExtensionSupervised(extension_, |
| 361 service_->profile()) && | 352 service_->profile())) { |
| 362 extensions::util::NeedCustodianApprovalForPermissionIncrease( | |
| 363 service_->profile())) { | |
| 364 return; | 353 return; |
| 365 } | 354 } |
| 366 // Delay extension reenabling so this bubble closes properly. | 355 // Delay extension reenabling so this bubble closes properly. |
| 367 base::ThreadTaskRunnerHandle::Get()->PostTask( | 356 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 368 FROM_HERE, | 357 FROM_HERE, |
| 369 base::Bind(&ExtensionService::GrantPermissionsAndEnableExtension, | 358 base::Bind(&ExtensionService::GrantPermissionsAndEnableExtension, |
| 370 service_->AsWeakPtr(), extension_)); | 359 service_->AsWeakPtr(), extension_)); |
| 371 } | 360 } |
| 372 | 361 |
| 373 void ExtensionDisabledGlobalError::BubbleViewCancelButtonPressed( | 362 void ExtensionDisabledGlobalError::BubbleViewCancelButtonPressed( |
| 374 Browser* browser) { | 363 Browser* browser) { |
| 375 if (extensions::util::IsExtensionSupervised(extension_, | 364 // For custodian-installed extensions, this button should not exist because |
| 376 service_->profile())) { | 365 // there is only an "OK" button. |
| 377 // For custodian-installed extensions, this button should only exist if the | 366 // Supervised users may never remove custodian-installed extensions. |
| 378 // supervised user can approve the update. Otherwise there is only an "OK" | 367 DCHECK(!extensions::util::IsExtensionSupervised(extension_, |
| 379 // button. | 368 service_->profile())); |
| 380 DCHECK(!extensions::util::NeedCustodianApprovalForPermissionIncrease( | |
| 381 service_->profile())); | |
| 382 // Supervised users may never remove custodian-installed extensions. | |
| 383 return; | |
| 384 } | |
| 385 | 369 |
| 386 uninstall_dialog_.reset(extensions::ExtensionUninstallDialog::Create( | 370 uninstall_dialog_.reset(extensions::ExtensionUninstallDialog::Create( |
| 387 service_->profile(), browser->window()->GetNativeWindow(), this)); | 371 service_->profile(), browser->window()->GetNativeWindow(), this)); |
| 388 // Delay showing the uninstall dialog, so that this function returns | 372 // Delay showing the uninstall dialog, so that this function returns |
| 389 // immediately, to close the bubble properly. See crbug.com/121544. | 373 // immediately, to close the bubble properly. See crbug.com/121544. |
| 390 base::ThreadTaskRunnerHandle::Get()->PostTask( | 374 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 391 FROM_HERE, | 375 FROM_HERE, |
| 392 base::Bind(&extensions::ExtensionUninstallDialog::ConfirmUninstall, | 376 base::Bind(&extensions::ExtensionUninstallDialog::ConfirmUninstall, |
| 393 uninstall_dialog_->AsWeakPtr(), extension_, | 377 uninstall_dialog_->AsWeakPtr(), extension_, |
| 394 extensions::UNINSTALL_REASON_EXTENSION_DISABLED, | 378 extensions::UNINSTALL_REASON_EXTENSION_DISABLED, |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 492 content::WebContents* web_contents, | 476 content::WebContents* web_contents, |
| 493 const Extension* extension) { | 477 const Extension* extension) { |
| 494 std::unique_ptr<ExtensionInstallPrompt> install_ui( | 478 std::unique_ptr<ExtensionInstallPrompt> install_ui( |
| 495 new ExtensionInstallPrompt(web_contents)); | 479 new ExtensionInstallPrompt(web_contents)); |
| 496 // This object manages its own lifetime. | 480 // This object manages its own lifetime. |
| 497 new ExtensionDisabledDialogDelegate(service, std::move(install_ui), | 481 new ExtensionDisabledDialogDelegate(service, std::move(install_ui), |
| 498 extension); | 482 extension); |
| 499 } | 483 } |
| 500 | 484 |
| 501 } // namespace extensions | 485 } // namespace extensions |
| OLD | NEW |