| 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 "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 error); | 615 error); |
| 616 } | 616 } |
| 617 | 617 |
| 618 ExtensionInstallPrompt::ExtensionInstallPrompt(content::WebContents* contents) | 618 ExtensionInstallPrompt::ExtensionInstallPrompt(content::WebContents* contents) |
| 619 : profile_(ProfileForWebContents(contents)), | 619 : profile_(ProfileForWebContents(contents)), |
| 620 ui_loop_(base::MessageLoop::current()), | 620 ui_loop_(base::MessageLoop::current()), |
| 621 extension_(NULL), | 621 extension_(NULL), |
| 622 install_ui_(extensions::CreateExtensionInstallUI( | 622 install_ui_(extensions::CreateExtensionInstallUI( |
| 623 ProfileForWebContents(contents))), | 623 ProfileForWebContents(contents))), |
| 624 show_params_(new ExtensionInstallPromptShowParams(contents)), | 624 show_params_(new ExtensionInstallPromptShowParams(contents)), |
| 625 delegate_(NULL) { | 625 delegate_(NULL), |
| 626 did_call_show_dialog_(false) { |
| 626 } | 627 } |
| 627 | 628 |
| 628 ExtensionInstallPrompt::ExtensionInstallPrompt(Profile* profile, | 629 ExtensionInstallPrompt::ExtensionInstallPrompt(Profile* profile, |
| 629 gfx::NativeWindow native_window) | 630 gfx::NativeWindow native_window) |
| 630 : profile_(profile), | 631 : profile_(profile), |
| 631 ui_loop_(base::MessageLoop::current()), | 632 ui_loop_(base::MessageLoop::current()), |
| 632 extension_(NULL), | 633 extension_(NULL), |
| 633 install_ui_(extensions::CreateExtensionInstallUI(profile)), | 634 install_ui_(extensions::CreateExtensionInstallUI(profile)), |
| 634 show_params_( | 635 show_params_( |
| 635 new ExtensionInstallPromptShowParams(profile, native_window)), | 636 new ExtensionInstallPromptShowParams(profile, native_window)), |
| 636 delegate_(NULL) { | 637 delegate_(NULL), |
| 638 did_call_show_dialog_(false) { |
| 637 } | 639 } |
| 638 | 640 |
| 639 ExtensionInstallPrompt::~ExtensionInstallPrompt() { | 641 ExtensionInstallPrompt::~ExtensionInstallPrompt() { |
| 640 } | 642 } |
| 641 | 643 |
| 642 void ExtensionInstallPrompt::ShowDialog( | 644 void ExtensionInstallPrompt::ShowDialog( |
| 643 Delegate* delegate, | 645 Delegate* delegate, |
| 644 const Extension* extension, | 646 const Extension* extension, |
| 645 const SkBitmap* icon, | 647 const SkBitmap* icon, |
| 646 const ShowDialogCallback& show_dialog_callback) { | 648 const ShowDialogCallback& show_dialog_callback) { |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 DCHECK(prompt_->bundle()); | 822 DCHECK(prompt_->bundle()); |
| 821 break; | 823 break; |
| 822 } | 824 } |
| 823 case LAUNCH_PROMPT_DEPRECATED: | 825 case LAUNCH_PROMPT_DEPRECATED: |
| 824 default: | 826 default: |
| 825 NOTREACHED() << "Unknown message"; | 827 NOTREACHED() << "Unknown message"; |
| 826 return; | 828 return; |
| 827 } | 829 } |
| 828 prompt_->set_icon(gfx::Image::CreateFrom1xBitmap(icon_)); | 830 prompt_->set_icon(gfx::Image::CreateFrom1xBitmap(icon_)); |
| 829 | 831 |
| 830 g_last_prompt_type_for_tests = prompt_->type(); | |
| 831 | |
| 832 if (AutoConfirmPrompt(delegate_)) | |
| 833 return; | |
| 834 | |
| 835 if (show_params_->WasParentDestroyed()) { | 832 if (show_params_->WasParentDestroyed()) { |
| 836 delegate_->InstallUIAbort(false); | 833 delegate_->InstallUIAbort(false); |
| 837 return; | 834 return; |
| 838 } | 835 } |
| 839 | 836 |
| 837 g_last_prompt_type_for_tests = prompt_->type(); |
| 838 did_call_show_dialog_ = true; |
| 839 |
| 840 if (AutoConfirmPrompt(delegate_)) |
| 841 return; |
| 842 |
| 840 if (show_dialog_callback_.is_null()) | 843 if (show_dialog_callback_.is_null()) |
| 841 GetDefaultShowDialogCallback().Run(show_params_.get(), delegate_, | 844 GetDefaultShowDialogCallback().Run(show_params_.get(), delegate_, |
| 842 prompt_.Pass()); | 845 prompt_.Pass()); |
| 843 else | 846 else |
| 844 show_dialog_callback_.Run(show_params_.get(), delegate_, prompt_.Pass()); | 847 show_dialog_callback_.Run(show_params_.get(), delegate_, prompt_.Pass()); |
| 845 } | 848 } |
| OLD | NEW |