| 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> |
| 8 |
| 7 #include "base/location.h" | 9 #include "base/location.h" |
| 8 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
| 12 #include "chrome/browser/extensions/bundle_installer.h" | 14 #include "chrome/browser/extensions/bundle_installer.h" |
| 13 #include "chrome/browser/extensions/extension_install_prompt_show_params.h" | 15 #include "chrome/browser/extensions/extension_install_prompt_show_params.h" |
| 14 #include "chrome/browser/extensions/extension_util.h" | 16 #include "chrome/browser/extensions/extension_util.h" |
| 15 #include "chrome/browser/extensions/permissions_updater.h" | 17 #include "chrome/browser/extensions/permissions_updater.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 ShowDialog(delegate, extension, icon, | 651 ShowDialog(delegate, extension, icon, |
| 650 make_scoped_ptr(new Prompt(INSTALL_PROMPT)), show_dialog_callback); | 652 make_scoped_ptr(new Prompt(INSTALL_PROMPT)), show_dialog_callback); |
| 651 } | 653 } |
| 652 | 654 |
| 653 void ExtensionInstallPrompt::ShowDialog( | 655 void ExtensionInstallPrompt::ShowDialog( |
| 654 Delegate* delegate, | 656 Delegate* delegate, |
| 655 const Extension* extension, | 657 const Extension* extension, |
| 656 const SkBitmap* icon, | 658 const SkBitmap* icon, |
| 657 scoped_ptr<Prompt> prompt, | 659 scoped_ptr<Prompt> prompt, |
| 658 const ShowDialogCallback& show_dialog_callback) { | 660 const ShowDialogCallback& show_dialog_callback) { |
| 659 ShowDialog(delegate, extension, icon, prompt.Pass(), nullptr, | 661 ShowDialog(delegate, 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 Delegate* delegate, | 666 Delegate* delegate, |
| 665 const Extension* extension, | 667 const Extension* extension, |
| 666 const SkBitmap* icon, | 668 const SkBitmap* icon, |
| 667 scoped_ptr<Prompt> prompt, | 669 scoped_ptr<Prompt> prompt, |
| 668 scoped_ptr<const PermissionSet> custom_permissions, | 670 scoped_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 delegate_ = delegate; | 675 delegate_ = delegate; |
| 674 if (icon && !icon->empty()) | 676 if (icon && !icon->empty()) |
| 675 SetIcon(icon); | 677 SetIcon(icon); |
| 676 prompt_ = prompt.Pass(); | 678 prompt_ = std::move(prompt); |
| 677 custom_permissions_ = custom_permissions.Pass(); | 679 custom_permissions_ = std::move(custom_permissions); |
| 678 show_dialog_callback_ = show_dialog_callback; | 680 show_dialog_callback_ = show_dialog_callback; |
| 679 | 681 |
| 680 // We special-case themes to not show any confirm UI. Instead they are | 682 // We special-case themes to not show any confirm UI. Instead they are |
| 681 // immediately installed, and then we show an infobar (see OnInstallSuccess) | 683 // immediately installed, and then we show an infobar (see OnInstallSuccess) |
| 682 // to allow the user to revert if they don't like it. | 684 // to allow the user to revert if they don't like it. |
| 683 // | 685 // |
| 684 // We don't do this in the case where off-store extension installs are | 686 // We don't do this in the case where off-store extension installs are |
| 685 // disabled because in that case, we don't show the dangerous download UI, so | 687 // disabled because in that case, we don't show the dangerous download UI, so |
| 686 // we need the UI confirmation. | 688 // we need the UI confirmation. |
| 687 if (extension->is_theme()) { | 689 if (extension->is_theme()) { |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 } | 838 } |
| 837 | 839 |
| 838 g_last_prompt_type_for_tests = prompt_->type(); | 840 g_last_prompt_type_for_tests = prompt_->type(); |
| 839 did_call_show_dialog_ = true; | 841 did_call_show_dialog_ = true; |
| 840 | 842 |
| 841 if (AutoConfirmPrompt(delegate_)) | 843 if (AutoConfirmPrompt(delegate_)) |
| 842 return; | 844 return; |
| 843 | 845 |
| 844 if (show_dialog_callback_.is_null()) | 846 if (show_dialog_callback_.is_null()) |
| 845 GetDefaultShowDialogCallback().Run(show_params_.get(), delegate_, | 847 GetDefaultShowDialogCallback().Run(show_params_.get(), delegate_, |
| 846 prompt_.Pass()); | 848 std::move(prompt_)); |
| 847 else | 849 else |
| 848 show_dialog_callback_.Run(show_params_.get(), delegate_, prompt_.Pass()); | 850 show_dialog_callback_.Run(show_params_.get(), delegate_, |
| 851 std::move(prompt_)); |
| 849 } | 852 } |
| OLD | NEW |