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" |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 base::FilePath(), | 602 base::FilePath(), |
603 Manifest::INTERNAL, | 603 Manifest::INTERNAL, |
604 localized_manifest.get() ? *localized_manifest.get() : *manifest, | 604 localized_manifest.get() ? *localized_manifest.get() : *manifest, |
605 flags, | 605 flags, |
606 id, | 606 id, |
607 error); | 607 error); |
608 } | 608 } |
609 | 609 |
610 ExtensionInstallPrompt::ExtensionInstallPrompt(content::WebContents* contents) | 610 ExtensionInstallPrompt::ExtensionInstallPrompt(content::WebContents* contents) |
611 : profile_(ProfileForWebContents(contents)), | 611 : profile_(ProfileForWebContents(contents)), |
612 ui_loop_(base::MessageLoop::current()), | |
613 extension_(NULL), | 612 extension_(NULL), |
614 install_ui_(extensions::CreateExtensionInstallUI( | 613 install_ui_(extensions::CreateExtensionInstallUI( |
615 ProfileForWebContents(contents))), | 614 ProfileForWebContents(contents))), |
616 show_params_(new ExtensionInstallPromptShowParams(contents)), | 615 show_params_(new ExtensionInstallPromptShowParams(contents)), |
617 did_call_show_dialog_(false), | 616 did_call_show_dialog_(false), |
618 weak_factory_(this) { | 617 weak_factory_(this) { |
619 } | 618 } |
620 | 619 |
621 ExtensionInstallPrompt::ExtensionInstallPrompt(Profile* profile, | 620 ExtensionInstallPrompt::ExtensionInstallPrompt(Profile* profile, |
622 gfx::NativeWindow native_window) | 621 gfx::NativeWindow native_window) |
623 : profile_(profile), | 622 : profile_(profile), |
624 ui_loop_(base::MessageLoop::current()), | |
625 extension_(NULL), | 623 extension_(NULL), |
626 install_ui_(extensions::CreateExtensionInstallUI(profile)), | 624 install_ui_(extensions::CreateExtensionInstallUI(profile)), |
627 show_params_( | 625 show_params_( |
628 new ExtensionInstallPromptShowParams(profile, native_window)), | 626 new ExtensionInstallPromptShowParams(profile, native_window)), |
629 did_call_show_dialog_(false), | 627 did_call_show_dialog_(false), |
630 weak_factory_(this) { | 628 weak_factory_(this) { |
631 } | 629 } |
632 | 630 |
633 ExtensionInstallPrompt::~ExtensionInstallPrompt() { | 631 ExtensionInstallPrompt::~ExtensionInstallPrompt() { |
634 } | 632 } |
(...skipping 18 matching lines...) Expand all Loading... |
653 show_dialog_callback); | 651 show_dialog_callback); |
654 } | 652 } |
655 | 653 |
656 void ExtensionInstallPrompt::ShowDialog( | 654 void ExtensionInstallPrompt::ShowDialog( |
657 const DoneCallback& done_callback, | 655 const DoneCallback& done_callback, |
658 const Extension* extension, | 656 const Extension* extension, |
659 const SkBitmap* icon, | 657 const SkBitmap* icon, |
660 std::unique_ptr<Prompt> prompt, | 658 std::unique_ptr<Prompt> prompt, |
661 std::unique_ptr<const PermissionSet> custom_permissions, | 659 std::unique_ptr<const PermissionSet> custom_permissions, |
662 const ShowDialogCallback& show_dialog_callback) { | 660 const ShowDialogCallback& show_dialog_callback) { |
663 DCHECK(ui_loop_ == base::MessageLoop::current()); | 661 DCHECK(ui_thread_checker_.CalledOnValidThread()); |
664 DCHECK(prompt); | 662 DCHECK(prompt); |
665 extension_ = extension; | 663 extension_ = extension; |
666 done_callback_ = done_callback; | 664 done_callback_ = done_callback; |
667 if (icon && !icon->empty()) | 665 if (icon && !icon->empty()) |
668 SetIcon(icon); | 666 SetIcon(icon); |
669 prompt_ = std::move(prompt); | 667 prompt_ = std::move(prompt); |
670 custom_permissions_ = std::move(custom_permissions); | 668 custom_permissions_ = std::move(custom_permissions); |
671 show_dialog_callback_ = show_dialog_callback; | 669 show_dialog_callback_ = show_dialog_callback; |
672 | 670 |
673 // We special-case themes to not show any confirm UI. Instead they are | 671 // We special-case themes to not show any confirm UI. Instead they are |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 | 826 |
829 if (AutoConfirmPrompt(&done_callback_)) | 827 if (AutoConfirmPrompt(&done_callback_)) |
830 return; | 828 return; |
831 | 829 |
832 if (show_dialog_callback_.is_null()) | 830 if (show_dialog_callback_.is_null()) |
833 show_dialog_callback_ = GetDefaultShowDialogCallback(); | 831 show_dialog_callback_ = GetDefaultShowDialogCallback(); |
834 base::ResetAndReturn(&show_dialog_callback_) | 832 base::ResetAndReturn(&show_dialog_callback_) |
835 .Run(show_params_.get(), base::ResetAndReturn(&done_callback_), | 833 .Run(show_params_.get(), base::ResetAndReturn(&done_callback_), |
836 std::move(prompt_)); | 834 std::move(prompt_)); |
837 } | 835 } |
OLD | NEW |