| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 // If auto confirm is enabled then posts a task to proceed with or cancel the | 73 // If auto confirm is enabled then posts a task to proceed with or cancel the |
| 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 case extensions::ScopedTestDialogAutoConfirm::ACCEPT_AND_OPTION: |
| 83 base::ThreadTaskRunnerHandle::Get()->PostTask( | 84 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 84 FROM_HERE, base::BindOnce(base::ResetAndReturn(callback), | 85 FROM_HERE, base::BindOnce(base::ResetAndReturn(callback), |
| 85 ExtensionInstallPrompt::Result::ACCEPTED)); | 86 ExtensionInstallPrompt::Result::ACCEPTED)); |
| 86 return true; | 87 return true; |
| 87 case extensions::ScopedTestDialogAutoConfirm::CANCEL: | 88 case extensions::ScopedTestDialogAutoConfirm::CANCEL: |
| 88 base::ThreadTaskRunnerHandle::Get()->PostTask( | 89 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 89 FROM_HERE, | 90 FROM_HERE, |
| 90 base::BindOnce(base::ResetAndReturn(callback), | 91 base::BindOnce(base::ResetAndReturn(callback), |
| 91 ExtensionInstallPrompt::Result::USER_CANCELED)); | 92 ExtensionInstallPrompt::Result::USER_CANCELED)); |
| 92 return true; | 93 return true; |
| (...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 | 821 |
| 821 if (AutoConfirmPrompt(&done_callback_)) | 822 if (AutoConfirmPrompt(&done_callback_)) |
| 822 return; | 823 return; |
| 823 | 824 |
| 824 if (show_dialog_callback_.is_null()) | 825 if (show_dialog_callback_.is_null()) |
| 825 show_dialog_callback_ = GetDefaultShowDialogCallback(); | 826 show_dialog_callback_ = GetDefaultShowDialogCallback(); |
| 826 base::ResetAndReturn(&show_dialog_callback_) | 827 base::ResetAndReturn(&show_dialog_callback_) |
| 827 .Run(show_params_.get(), base::ResetAndReturn(&done_callback_), | 828 .Run(show_params_.get(), base::ResetAndReturn(&done_callback_), |
| 828 std::move(prompt_)); | 829 std::move(prompt_)); |
| 829 } | 830 } |
| OLD | NEW |