| 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" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/single_thread_task_runner.h" |
| 12 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
| 16 #include "chrome/browser/extensions/extension_install_prompt_show_params.h" | 17 #include "chrome/browser/extensions/extension_install_prompt_show_params.h" |
| 17 #include "chrome/browser/extensions/extension_util.h" | 18 #include "chrome/browser/extensions/extension_util.h" |
| 18 #include "chrome/browser/extensions/permissions_updater.h" | 19 #include "chrome/browser/extensions/permissions_updater.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/ui/extensions/extension_install_ui_factory.h" | 21 #include "chrome/browser/ui/extensions/extension_install_ui_factory.h" |
| 21 #include "chrome/grit/chromium_strings.h" | 22 #include "chrome/grit/chromium_strings.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 // If auto confirm is enabled then posts a task to proceed with or cancel the | 148 // If auto confirm is enabled then posts a task to proceed with or cancel the |
| 148 // install and returns true. Otherwise returns false. | 149 // install and returns true. Otherwise returns false. |
| 149 bool AutoConfirmPrompt(ExtensionInstallPrompt::DoneCallback* callback) { | 150 bool AutoConfirmPrompt(ExtensionInstallPrompt::DoneCallback* callback) { |
| 150 switch (extensions::ScopedTestDialogAutoConfirm::GetAutoConfirmValue()) { | 151 switch (extensions::ScopedTestDialogAutoConfirm::GetAutoConfirmValue()) { |
| 151 case extensions::ScopedTestDialogAutoConfirm::NONE: | 152 case extensions::ScopedTestDialogAutoConfirm::NONE: |
| 152 return false; | 153 return false; |
| 153 // We use PostTask instead of calling the callback directly here, because in | 154 // We use PostTask instead of calling the callback directly here, because in |
| 154 // the real implementations it's highly likely the message loop will be | 155 // the real implementations it's highly likely the message loop will be |
| 155 // pumping a few times before the user clicks accept or cancel. | 156 // pumping a few times before the user clicks accept or cancel. |
| 156 case extensions::ScopedTestDialogAutoConfirm::ACCEPT: | 157 case extensions::ScopedTestDialogAutoConfirm::ACCEPT: |
| 157 base::MessageLoop::current()->PostTask( | 158 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 158 FROM_HERE, base::Bind(base::ResetAndReturn(callback), | 159 FROM_HERE, base::Bind(base::ResetAndReturn(callback), |
| 159 ExtensionInstallPrompt::Result::ACCEPTED)); | 160 ExtensionInstallPrompt::Result::ACCEPTED)); |
| 160 return true; | 161 return true; |
| 161 case extensions::ScopedTestDialogAutoConfirm::CANCEL: | 162 case extensions::ScopedTestDialogAutoConfirm::CANCEL: |
| 162 base::ThreadTaskRunnerHandle::Get()->PostTask( | 163 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 163 FROM_HERE, base::Bind(base::ResetAndReturn(callback), | 164 FROM_HERE, base::Bind(base::ResetAndReturn(callback), |
| 164 ExtensionInstallPrompt::Result::USER_CANCELED)); | 165 ExtensionInstallPrompt::Result::USER_CANCELED)); |
| 165 return true; | 166 return true; |
| 166 } | 167 } |
| 167 | 168 |
| (...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 | 828 |
| 828 if (AutoConfirmPrompt(&done_callback_)) | 829 if (AutoConfirmPrompt(&done_callback_)) |
| 829 return; | 830 return; |
| 830 | 831 |
| 831 if (show_dialog_callback_.is_null()) | 832 if (show_dialog_callback_.is_null()) |
| 832 show_dialog_callback_ = GetDefaultShowDialogCallback(); | 833 show_dialog_callback_ = GetDefaultShowDialogCallback(); |
| 833 base::ResetAndReturn(&show_dialog_callback_) | 834 base::ResetAndReturn(&show_dialog_callback_) |
| 834 .Run(show_params_.get(), base::ResetAndReturn(&done_callback_), | 835 .Run(show_params_.get(), base::ResetAndReturn(&done_callback_), |
| 835 std::move(prompt_)); | 836 std::move(prompt_)); |
| 836 } | 837 } |
| OLD | NEW |