| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/memory/ptr_util.h" |
| 11 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/thread_task_runner_handle.h" | 15 #include "base/thread_task_runner_handle.h" |
| 15 #include "chrome/browser/extensions/bundle_installer.h" | 16 #include "chrome/browser/extensions/bundle_installer.h" |
| 16 #include "chrome/browser/extensions/extension_install_prompt_show_params.h" | 17 #include "chrome/browser/extensions/extension_install_prompt_show_params.h" |
| 17 #include "chrome/browser/extensions/extension_util.h" | 18 #include "chrome/browser/extensions/extension_util.h" |
| 18 #include "chrome/browser/extensions/permissions_updater.h" | 19 #include "chrome/browser/extensions/permissions_updater.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/ui/extensions/extension_install_ui_factory.h" | 21 #include "chrome/browser/ui/extensions/extension_install_ui_factory.h" |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 | 587 |
| 587 // static | 588 // static |
| 588 scoped_refptr<Extension> | 589 scoped_refptr<Extension> |
| 589 ExtensionInstallPrompt::GetLocalizedExtensionForDisplay( | 590 ExtensionInstallPrompt::GetLocalizedExtensionForDisplay( |
| 590 const base::DictionaryValue* manifest, | 591 const base::DictionaryValue* manifest, |
| 591 int flags, | 592 int flags, |
| 592 const std::string& id, | 593 const std::string& id, |
| 593 const std::string& localized_name, | 594 const std::string& localized_name, |
| 594 const std::string& localized_description, | 595 const std::string& localized_description, |
| 595 std::string* error) { | 596 std::string* error) { |
| 596 scoped_ptr<base::DictionaryValue> localized_manifest; | 597 std::unique_ptr<base::DictionaryValue> localized_manifest; |
| 597 if (!localized_name.empty() || !localized_description.empty()) { | 598 if (!localized_name.empty() || !localized_description.empty()) { |
| 598 localized_manifest.reset(manifest->DeepCopy()); | 599 localized_manifest.reset(manifest->DeepCopy()); |
| 599 if (!localized_name.empty()) { | 600 if (!localized_name.empty()) { |
| 600 localized_manifest->SetString(extensions::manifest_keys::kName, | 601 localized_manifest->SetString(extensions::manifest_keys::kName, |
| 601 localized_name); | 602 localized_name); |
| 602 } | 603 } |
| 603 if (!localized_description.empty()) { | 604 if (!localized_description.empty()) { |
| 604 localized_manifest->SetString(extensions::manifest_keys::kDescription, | 605 localized_manifest->SetString(extensions::manifest_keys::kDescription, |
| 605 localized_description); | 606 localized_description); |
| 606 } | 607 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 | 641 |
| 641 ExtensionInstallPrompt::~ExtensionInstallPrompt() { | 642 ExtensionInstallPrompt::~ExtensionInstallPrompt() { |
| 642 } | 643 } |
| 643 | 644 |
| 644 void ExtensionInstallPrompt::ShowDialog( | 645 void ExtensionInstallPrompt::ShowDialog( |
| 645 const DoneCallback& done_callback, | 646 const DoneCallback& done_callback, |
| 646 const Extension* extension, | 647 const Extension* extension, |
| 647 const SkBitmap* icon, | 648 const SkBitmap* icon, |
| 648 const ShowDialogCallback& show_dialog_callback) { | 649 const ShowDialogCallback& show_dialog_callback) { |
| 649 ShowDialog(done_callback, extension, icon, | 650 ShowDialog(done_callback, extension, icon, |
| 650 make_scoped_ptr(new Prompt(INSTALL_PROMPT)), show_dialog_callback); | 651 base::WrapUnique(new Prompt(INSTALL_PROMPT)), |
| 652 show_dialog_callback); |
| 651 } | 653 } |
| 652 | 654 |
| 653 void ExtensionInstallPrompt::ShowDialog( | 655 void ExtensionInstallPrompt::ShowDialog( |
| 654 const DoneCallback& done_callback, | 656 const DoneCallback& done_callback, |
| 655 const Extension* extension, | 657 const Extension* extension, |
| 656 const SkBitmap* icon, | 658 const SkBitmap* icon, |
| 657 scoped_ptr<Prompt> prompt, | 659 std::unique_ptr<Prompt> prompt, |
| 658 const ShowDialogCallback& show_dialog_callback) { | 660 const ShowDialogCallback& show_dialog_callback) { |
| 659 ShowDialog(done_callback, extension, icon, std::move(prompt), nullptr, | 661 ShowDialog(done_callback, extension, icon, std::move(prompt), nullptr, |
| 660 show_dialog_callback); | 662 show_dialog_callback); |
| 661 } | 663 } |
| 662 | 664 |
| 663 void ExtensionInstallPrompt::ShowDialog( | 665 void ExtensionInstallPrompt::ShowDialog( |
| 664 const DoneCallback& done_callback, | 666 const DoneCallback& done_callback, |
| 665 const Extension* extension, | 667 const Extension* extension, |
| 666 const SkBitmap* icon, | 668 const SkBitmap* icon, |
| 667 scoped_ptr<Prompt> prompt, | 669 std::unique_ptr<Prompt> prompt, |
| 668 scoped_ptr<const PermissionSet> custom_permissions, | 670 std::unique_ptr<const PermissionSet> custom_permissions, |
| 669 const ShowDialogCallback& show_dialog_callback) { | 671 const ShowDialogCallback& show_dialog_callback) { |
| 670 DCHECK(ui_loop_ == base::MessageLoop::current()); | 672 DCHECK(ui_loop_ == base::MessageLoop::current()); |
| 671 DCHECK(prompt); | 673 DCHECK(prompt); |
| 672 extension_ = extension; | 674 extension_ = extension; |
| 673 done_callback_ = done_callback; | 675 done_callback_ = done_callback; |
| 674 if (icon && !icon->empty()) | 676 if (icon && !icon->empty()) |
| 675 SetIcon(icon); | 677 SetIcon(icon); |
| 676 prompt_ = std::move(prompt); | 678 prompt_ = std::move(prompt); |
| 677 custom_permissions_ = std::move(custom_permissions); | 679 custom_permissions_ = std::move(custom_permissions); |
| 678 show_dialog_callback_ = show_dialog_callback; | 680 show_dialog_callback_ = show_dialog_callback; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 gfx::Size(), | 752 gfx::Size(), |
| 751 ui::SCALE_FACTOR_100P)); | 753 ui::SCALE_FACTOR_100P)); |
| 752 loader->LoadImagesAsync( | 754 loader->LoadImagesAsync( |
| 753 extension_, | 755 extension_, |
| 754 images_list, | 756 images_list, |
| 755 base::Bind(&ExtensionInstallPrompt::OnImageLoaded, | 757 base::Bind(&ExtensionInstallPrompt::OnImageLoaded, |
| 756 weak_factory_.GetWeakPtr())); | 758 weak_factory_.GetWeakPtr())); |
| 757 } | 759 } |
| 758 | 760 |
| 759 void ExtensionInstallPrompt::ShowConfirmation() { | 761 void ExtensionInstallPrompt::ShowConfirmation() { |
| 760 scoped_ptr<const PermissionSet> permissions_wrapper; | 762 std::unique_ptr<const PermissionSet> permissions_wrapper; |
| 761 const PermissionSet* permissions_to_display = nullptr; | 763 const PermissionSet* permissions_to_display = nullptr; |
| 762 if (custom_permissions_.get()) { | 764 if (custom_permissions_.get()) { |
| 763 permissions_to_display = custom_permissions_.get(); | 765 permissions_to_display = custom_permissions_.get(); |
| 764 } else if (extension_) { | 766 } else if (extension_) { |
| 765 // Initialize permissions if they have not already been set so that | 767 // Initialize permissions if they have not already been set so that |
| 766 // withheld permissions are displayed properly in the install prompt. | 768 // withheld permissions are displayed properly in the install prompt. |
| 767 extensions::PermissionsUpdater( | 769 extensions::PermissionsUpdater( |
| 768 profile_, extensions::PermissionsUpdater::INIT_FLAG_TRANSIENT) | 770 profile_, extensions::PermissionsUpdater::INIT_FLAG_TRANSIENT) |
| 769 .InitializePermissions(extension_); | 771 .InitializePermissions(extension_); |
| 770 permissions_to_display = | 772 permissions_to_display = |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 | 843 |
| 842 if (AutoConfirmPrompt(&done_callback_)) | 844 if (AutoConfirmPrompt(&done_callback_)) |
| 843 return; | 845 return; |
| 844 | 846 |
| 845 if (show_dialog_callback_.is_null()) | 847 if (show_dialog_callback_.is_null()) |
| 846 show_dialog_callback_ = GetDefaultShowDialogCallback(); | 848 show_dialog_callback_ = GetDefaultShowDialogCallback(); |
| 847 base::ResetAndReturn(&show_dialog_callback_) | 849 base::ResetAndReturn(&show_dialog_callback_) |
| 848 .Run(show_params_.get(), base::ResetAndReturn(&done_callback_), | 850 .Run(show_params_.get(), base::ResetAndReturn(&done_callback_), |
| 849 std::move(prompt_)); | 851 std::move(prompt_)); |
| 850 } | 852 } |
| OLD | NEW |