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. |
| 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 if (extensions::util::IsExtensionSupervised(extension_, |
| 376 service_->profile())) { | 365 service_->profile())) { |
| 377 // For custodian-installed extensions, this button should only exist if the | 366 // For custodian-installed extensions, this button should only exist if the |
| 378 // supervised user can approve the update. Otherwise there is only an "OK" | 367 // supervised user can approve the update. Otherwise there is only an "OK" |
| 379 // button. | 368 // button. |
|
Marc Treib
2016/10/05 19:48:04
Now this whole "if" should never happen (you essen
| |
| 380 DCHECK(!extensions::util::NeedCustodianApprovalForPermissionIncrease( | |
| 381 service_->profile())); | |
| 382 // Supervised users may never remove custodian-installed extensions. | 369 // Supervised users may never remove custodian-installed extensions. |
| 383 return; | 370 return; |
| 384 } | 371 } |
| 385 | 372 |
| 386 uninstall_dialog_.reset(extensions::ExtensionUninstallDialog::Create( | 373 uninstall_dialog_.reset(extensions::ExtensionUninstallDialog::Create( |
| 387 service_->profile(), browser->window()->GetNativeWindow(), this)); | 374 service_->profile(), browser->window()->GetNativeWindow(), this)); |
| 388 // Delay showing the uninstall dialog, so that this function returns | 375 // Delay showing the uninstall dialog, so that this function returns |
| 389 // immediately, to close the bubble properly. See crbug.com/121544. | 376 // immediately, to close the bubble properly. See crbug.com/121544. |
| 390 base::ThreadTaskRunnerHandle::Get()->PostTask( | 377 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 391 FROM_HERE, | 378 FROM_HERE, |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 492 content::WebContents* web_contents, | 479 content::WebContents* web_contents, |
| 493 const Extension* extension) { | 480 const Extension* extension) { |
| 494 std::unique_ptr<ExtensionInstallPrompt> install_ui( | 481 std::unique_ptr<ExtensionInstallPrompt> install_ui( |
| 495 new ExtensionInstallPrompt(web_contents)); | 482 new ExtensionInstallPrompt(web_contents)); |
| 496 // This object manages its own lifetime. | 483 // This object manages its own lifetime. |
| 497 new ExtensionDisabledDialogDelegate(service, std::move(install_ui), | 484 new ExtensionDisabledDialogDelegate(service, std::move(install_ui), |
| 498 extension); | 485 extension); |
| 499 } | 486 } |
| 500 | 487 |
| 501 } // namespace extensions | 488 } // namespace extensions |
| OLD | NEW |