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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 // install and returns true. Otherwise returns false. | 74 // install and returns true. Otherwise returns false. |
75 bool AutoConfirmPrompt(ExtensionInstallPrompt::DoneCallback* callback) { | 75 bool AutoConfirmPrompt(ExtensionInstallPrompt::DoneCallback* callback) { |
76 switch (extensions::ScopedTestDialogAutoConfirm::GetAutoConfirmValue()) { | 76 switch (extensions::ScopedTestDialogAutoConfirm::GetAutoConfirmValue()) { |
77 case extensions::ScopedTestDialogAutoConfirm::NONE: | 77 case extensions::ScopedTestDialogAutoConfirm::NONE: |
78 return false; | 78 return false; |
79 // We use PostTask instead of calling the callback directly here, because in | 79 // We use PostTask instead of calling the callback directly here, because in |
80 // the real implementations it's highly likely the message loop will be | 80 // the real implementations it's highly likely the message loop will be |
81 // pumping a few times before the user clicks accept or cancel. | 81 // pumping a few times before the user clicks accept or cancel. |
82 case extensions::ScopedTestDialogAutoConfirm::ACCEPT: | 82 case extensions::ScopedTestDialogAutoConfirm::ACCEPT: |
83 base::ThreadTaskRunnerHandle::Get()->PostTask( | 83 base::ThreadTaskRunnerHandle::Get()->PostTask( |
84 FROM_HERE, base::Bind(base::ResetAndReturn(callback), | 84 FROM_HERE, base::BindOnce(base::ResetAndReturn(callback), |
85 ExtensionInstallPrompt::Result::ACCEPTED)); | 85 ExtensionInstallPrompt::Result::ACCEPTED)); |
86 return true; | 86 return true; |
87 case extensions::ScopedTestDialogAutoConfirm::CANCEL: | 87 case extensions::ScopedTestDialogAutoConfirm::CANCEL: |
88 base::ThreadTaskRunnerHandle::Get()->PostTask( | 88 base::ThreadTaskRunnerHandle::Get()->PostTask( |
89 FROM_HERE, base::Bind(base::ResetAndReturn(callback), | 89 FROM_HERE, |
90 ExtensionInstallPrompt::Result::USER_CANCELED)); | 90 base::BindOnce(base::ResetAndReturn(callback), |
| 91 ExtensionInstallPrompt::Result::USER_CANCELED)); |
91 return true; | 92 return true; |
92 } | 93 } |
93 | 94 |
94 NOTREACHED(); | 95 NOTREACHED(); |
95 return false; | 96 return false; |
96 } | 97 } |
97 | 98 |
98 Profile* ProfileForWebContents(content::WebContents* web_contents) { | 99 Profile* ProfileForWebContents(content::WebContents* web_contents) { |
99 if (!web_contents) | 100 if (!web_contents) |
100 return NULL; | 101 return NULL; |
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 | 820 |
820 if (AutoConfirmPrompt(&done_callback_)) | 821 if (AutoConfirmPrompt(&done_callback_)) |
821 return; | 822 return; |
822 | 823 |
823 if (show_dialog_callback_.is_null()) | 824 if (show_dialog_callback_.is_null()) |
824 show_dialog_callback_ = GetDefaultShowDialogCallback(); | 825 show_dialog_callback_ = GetDefaultShowDialogCallback(); |
825 base::ResetAndReturn(&show_dialog_callback_) | 826 base::ResetAndReturn(&show_dialog_callback_) |
826 .Run(show_params_.get(), base::ResetAndReturn(&done_callback_), | 827 .Run(show_params_.get(), base::ResetAndReturn(&done_callback_), |
827 std::move(prompt_)); | 828 std::move(prompt_)); |
828 } | 829 } |
OLD | NEW |