| 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_install_prompt.h" | 5 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 ShowConfirmation(); | 523 ShowConfirmation(); |
| 524 } | 524 } |
| 525 | 525 |
| 526 void ExtensionInstallPrompt::ConfirmStandaloneInstall( | 526 void ExtensionInstallPrompt::ConfirmStandaloneInstall( |
| 527 Delegate* delegate, | 527 Delegate* delegate, |
| 528 const Extension* extension, | 528 const Extension* extension, |
| 529 SkBitmap* icon, | 529 SkBitmap* icon, |
| 530 const ExtensionInstallPrompt::Prompt& prompt) { | 530 const ExtensionInstallPrompt::Prompt& prompt) { |
| 531 DCHECK(ui_loop_ == base::MessageLoop::current()); | 531 DCHECK(ui_loop_ == base::MessageLoop::current()); |
| 532 extension_ = extension; | 532 extension_ = extension; |
| 533 permissions_ = extension->GetActivePermissions(); | 533 permissions_ = extension->permissions_data()->active_permissions(); |
| 534 delegate_ = delegate; | 534 delegate_ = delegate; |
| 535 prompt_ = prompt; | 535 prompt_ = prompt; |
| 536 | 536 |
| 537 SetIcon(icon); | 537 SetIcon(icon); |
| 538 ShowConfirmation(); | 538 ShowConfirmation(); |
| 539 } | 539 } |
| 540 | 540 |
| 541 void ExtensionInstallPrompt::ConfirmWebstoreInstall( | 541 void ExtensionInstallPrompt::ConfirmWebstoreInstall( |
| 542 Delegate* delegate, | 542 Delegate* delegate, |
| 543 const Extension* extension, | 543 const Extension* extension, |
| 544 const SkBitmap* icon, | 544 const SkBitmap* icon, |
| 545 const ShowDialogCallback& show_dialog_callback) { | 545 const ShowDialogCallback& show_dialog_callback) { |
| 546 // SetIcon requires |extension_| to be set. ConfirmInstall will setup the | 546 // SetIcon requires |extension_| to be set. ConfirmInstall will setup the |
| 547 // remaining fields. | 547 // remaining fields. |
| 548 extension_ = extension; | 548 extension_ = extension; |
| 549 SetIcon(icon); | 549 SetIcon(icon); |
| 550 ConfirmInstall(delegate, extension, show_dialog_callback); | 550 ConfirmInstall(delegate, extension, show_dialog_callback); |
| 551 } | 551 } |
| 552 | 552 |
| 553 void ExtensionInstallPrompt::ConfirmInstall( | 553 void ExtensionInstallPrompt::ConfirmInstall( |
| 554 Delegate* delegate, | 554 Delegate* delegate, |
| 555 const Extension* extension, | 555 const Extension* extension, |
| 556 const ShowDialogCallback& show_dialog_callback) { | 556 const ShowDialogCallback& show_dialog_callback) { |
| 557 DCHECK(ui_loop_ == base::MessageLoop::current()); | 557 DCHECK(ui_loop_ == base::MessageLoop::current()); |
| 558 extension_ = extension; | 558 extension_ = extension; |
| 559 permissions_ = extension->GetActivePermissions(); | 559 permissions_ = extension->permissions_data()->active_permissions(); |
| 560 delegate_ = delegate; | 560 delegate_ = delegate; |
| 561 prompt_.set_type(INSTALL_PROMPT); | 561 prompt_.set_type(INSTALL_PROMPT); |
| 562 show_dialog_callback_ = show_dialog_callback; | 562 show_dialog_callback_ = show_dialog_callback; |
| 563 | 563 |
| 564 // We special-case themes to not show any confirm UI. Instead they are | 564 // We special-case themes to not show any confirm UI. Instead they are |
| 565 // immediately installed, and then we show an infobar (see OnInstallSuccess) | 565 // immediately installed, and then we show an infobar (see OnInstallSuccess) |
| 566 // to allow the user to revert if they don't like it. | 566 // to allow the user to revert if they don't like it. |
| 567 // | 567 // |
| 568 // We don't do this in the case where off-store extension installs are | 568 // We don't do this in the case where off-store extension installs are |
| 569 // disabled because in that case, we don't show the dangerous download UI, so | 569 // disabled because in that case, we don't show the dangerous download UI, so |
| 570 // we need the UI confirmation. | 570 // we need the UI confirmation. |
| 571 if (extension->is_theme()) { | 571 if (extension->is_theme()) { |
| 572 if (extension->from_webstore() || | 572 if (extension->from_webstore() || |
| 573 extensions::FeatureSwitch::easy_off_store_install()->IsEnabled()) { | 573 extensions::FeatureSwitch::easy_off_store_install()->IsEnabled()) { |
| 574 delegate->InstallUIProceed(); | 574 delegate->InstallUIProceed(); |
| 575 return; | 575 return; |
| 576 } | 576 } |
| 577 } | 577 } |
| 578 | 578 |
| 579 LoadImageIfNeeded(); | 579 LoadImageIfNeeded(); |
| 580 } | 580 } |
| 581 | 581 |
| 582 void ExtensionInstallPrompt::ConfirmReEnable(Delegate* delegate, | 582 void ExtensionInstallPrompt::ConfirmReEnable(Delegate* delegate, |
| 583 const Extension* extension) { | 583 const Extension* extension) { |
| 584 DCHECK(ui_loop_ == base::MessageLoop::current()); | 584 DCHECK(ui_loop_ == base::MessageLoop::current()); |
| 585 extension_ = extension; | 585 extension_ = extension; |
| 586 permissions_ = extension->GetActivePermissions(); | 586 permissions_ = extension->permissions_data()->active_permissions(); |
| 587 delegate_ = delegate; | 587 delegate_ = delegate; |
| 588 bool is_remote_install = | 588 bool is_remote_install = |
| 589 install_ui_->profile() && | 589 install_ui_->profile() && |
| 590 extensions::ExtensionPrefs::Get(install_ui_->profile())->HasDisableReason( | 590 extensions::ExtensionPrefs::Get(install_ui_->profile())->HasDisableReason( |
| 591 extension->id(), extensions::Extension::DISABLE_REMOTE_INSTALL); | 591 extension->id(), extensions::Extension::DISABLE_REMOTE_INSTALL); |
| 592 bool is_ephemeral = | 592 bool is_ephemeral = |
| 593 extensions::util::IsEphemeralApp(extension->id(), install_ui_->profile()); | 593 extensions::util::IsEphemeralApp(extension->id(), install_ui_->profile()); |
| 594 if (is_ephemeral) | 594 if (is_ephemeral) |
| 595 prompt_.set_type(LAUNCH_PROMPT); | 595 prompt_.set_type(LAUNCH_PROMPT); |
| 596 else if (is_remote_install) | 596 else if (is_remote_install) |
| 597 prompt_.set_type(REMOTE_INSTALL_PROMPT); | 597 prompt_.set_type(REMOTE_INSTALL_PROMPT); |
| 598 else | 598 else |
| 599 prompt_.set_type(RE_ENABLE_PROMPT); | 599 prompt_.set_type(RE_ENABLE_PROMPT); |
| 600 LoadImageIfNeeded(); | 600 LoadImageIfNeeded(); |
| 601 } | 601 } |
| 602 | 602 |
| 603 void ExtensionInstallPrompt::ConfirmExternalInstall( | 603 void ExtensionInstallPrompt::ConfirmExternalInstall( |
| 604 Delegate* delegate, | 604 Delegate* delegate, |
| 605 const Extension* extension, | 605 const Extension* extension, |
| 606 const ShowDialogCallback& show_dialog_callback, | 606 const ShowDialogCallback& show_dialog_callback, |
| 607 const Prompt& prompt) { | 607 const Prompt& prompt) { |
| 608 DCHECK(ui_loop_ == base::MessageLoop::current()); | 608 DCHECK(ui_loop_ == base::MessageLoop::current()); |
| 609 extension_ = extension; | 609 extension_ = extension; |
| 610 permissions_ = extension->GetActivePermissions(); | 610 permissions_ = extension->permissions_data()->active_permissions(); |
| 611 delegate_ = delegate; | 611 delegate_ = delegate; |
| 612 prompt_ = prompt; | 612 prompt_ = prompt; |
| 613 show_dialog_callback_ = show_dialog_callback; | 613 show_dialog_callback_ = show_dialog_callback; |
| 614 | 614 |
| 615 LoadImageIfNeeded(); | 615 LoadImageIfNeeded(); |
| 616 } | 616 } |
| 617 | 617 |
| 618 void ExtensionInstallPrompt::ConfirmPermissions( | 618 void ExtensionInstallPrompt::ConfirmPermissions( |
| 619 Delegate* delegate, | 619 Delegate* delegate, |
| 620 const Extension* extension, | 620 const Extension* extension, |
| 621 const PermissionSet* permissions) { | 621 const PermissionSet* permissions) { |
| 622 DCHECK(ui_loop_ == base::MessageLoop::current()); | 622 DCHECK(ui_loop_ == base::MessageLoop::current()); |
| 623 extension_ = extension; | 623 extension_ = extension; |
| 624 permissions_ = permissions; | 624 permissions_ = permissions; |
| 625 delegate_ = delegate; | 625 delegate_ = delegate; |
| 626 prompt_.set_type(PERMISSIONS_PROMPT); | 626 prompt_.set_type(PERMISSIONS_PROMPT); |
| 627 | 627 |
| 628 LoadImageIfNeeded(); | 628 LoadImageIfNeeded(); |
| 629 } | 629 } |
| 630 | 630 |
| 631 void ExtensionInstallPrompt::ReviewPermissions( | 631 void ExtensionInstallPrompt::ReviewPermissions( |
| 632 Delegate* delegate, | 632 Delegate* delegate, |
| 633 const Extension* extension, | 633 const Extension* extension, |
| 634 const std::vector<base::FilePath>& retained_file_paths) { | 634 const std::vector<base::FilePath>& retained_file_paths) { |
| 635 DCHECK(ui_loop_ == base::MessageLoop::current()); | 635 DCHECK(ui_loop_ == base::MessageLoop::current()); |
| 636 extension_ = extension; | 636 extension_ = extension; |
| 637 permissions_ = extension->GetActivePermissions(); | 637 permissions_ = extension->permissions_data()->active_permissions(); |
| 638 prompt_.set_retained_files(retained_file_paths); | 638 prompt_.set_retained_files(retained_file_paths); |
| 639 delegate_ = delegate; | 639 delegate_ = delegate; |
| 640 prompt_.set_type(POST_INSTALL_PERMISSIONS_PROMPT); | 640 prompt_.set_type(POST_INSTALL_PERMISSIONS_PROMPT); |
| 641 | 641 |
| 642 LoadImageIfNeeded(); | 642 LoadImageIfNeeded(); |
| 643 } | 643 } |
| 644 | 644 |
| 645 void ExtensionInstallPrompt::OnInstallSuccess(const Extension* extension, | 645 void ExtensionInstallPrompt::OnInstallSuccess(const Extension* extension, |
| 646 SkBitmap* icon) { | 646 SkBitmap* icon) { |
| 647 extension_ = extension; | 647 extension_ = extension; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 } | 748 } |
| 749 | 749 |
| 750 if (AutoConfirmPrompt(delegate_)) | 750 if (AutoConfirmPrompt(delegate_)) |
| 751 return; | 751 return; |
| 752 | 752 |
| 753 if (show_dialog_callback_.is_null()) | 753 if (show_dialog_callback_.is_null()) |
| 754 GetDefaultShowDialogCallback().Run(show_params_, delegate_, prompt_); | 754 GetDefaultShowDialogCallback().Run(show_params_, delegate_, prompt_); |
| 755 else | 755 else |
| 756 show_dialog_callback_.Run(show_params_, delegate_, prompt_); | 756 show_dialog_callback_.Run(show_params_, delegate_, prompt_); |
| 757 } | 757 } |
| OLD | NEW |