| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/external_install_error.h" | 5 #include "chrome/browser/extensions/external_install_error.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/location.h" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/message_loop/message_loop.h" | |
| 13 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
| 14 #include "base/single_thread_task_runner.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/threading/thread_task_runner_handle.h" |
| 15 #include "chrome/app/chrome_command_ids.h" | 17 #include "chrome/app/chrome_command_ids.h" |
| 16 #include "chrome/browser/extensions/extension_install_error_menu_item_id_provide
r.h" | 18 #include "chrome/browser/extensions/extension_install_error_menu_item_id_provide
r.h" |
| 17 #include "chrome/browser/extensions/extension_install_prompt_show_params.h" | 19 #include "chrome/browser/extensions/extension_install_prompt_show_params.h" |
| 18 #include "chrome/browser/extensions/extension_service.h" | 20 #include "chrome/browser/extensions/extension_service.h" |
| 19 #include "chrome/browser/extensions/external_install_manager.h" | 21 #include "chrome/browser/extensions/external_install_manager.h" |
| 20 #include "chrome/browser/extensions/webstore_data_fetcher.h" | 22 #include "chrome/browser/extensions/webstore_data_fetcher.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
| 23 #include "chrome/browser/ui/browser_finder.h" | 25 #include "chrome/browser/ui/browser_finder.h" |
| 24 #include "chrome/browser/ui/global_error/global_error.h" | 26 #include "chrome/browser/ui/global_error/global_error.h" |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 error_service_->RemoveGlobalError(global_error_.get()); | 316 error_service_->RemoveGlobalError(global_error_.get()); |
| 315 } | 317 } |
| 316 | 318 |
| 317 void ExternalInstallError::OnInstallPromptDone( | 319 void ExternalInstallError::OnInstallPromptDone( |
| 318 ExtensionInstallPrompt::Result result) { | 320 ExtensionInstallPrompt::Result result) { |
| 319 const Extension* extension = GetExtension(); | 321 const Extension* extension = GetExtension(); |
| 320 | 322 |
| 321 // If the error isn't removed and deleted as part of handling the user's | 323 // If the error isn't removed and deleted as part of handling the user's |
| 322 // response (which can happen, e.g., if an uninstall fails), be sure to remove | 324 // response (which can happen, e.g., if an uninstall fails), be sure to remove |
| 323 // the error directly in order to ensure it's not called twice. | 325 // the error directly in order to ensure it's not called twice. |
| 324 base::MessageLoop::current()->PostTask( | 326 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 325 FROM_HERE, | 327 FROM_HERE, base::Bind(&ExternalInstallError::RemoveError, |
| 326 base::Bind(&ExternalInstallError::RemoveError, | 328 weak_factory_.GetWeakPtr())); |
| 327 weak_factory_.GetWeakPtr())); | |
| 328 | 329 |
| 329 switch (result) { | 330 switch (result) { |
| 330 case ExtensionInstallPrompt::Result::ACCEPTED: | 331 case ExtensionInstallPrompt::Result::ACCEPTED: |
| 331 if (extension) { | 332 if (extension) { |
| 332 ExtensionSystem::Get(browser_context_) | 333 ExtensionSystem::Get(browser_context_) |
| 333 ->extension_service() | 334 ->extension_service() |
| 334 ->GrantPermissionsAndEnableExtension(extension); | 335 ->GrantPermissionsAndEnableExtension(extension); |
| 335 } | 336 } |
| 336 break; | 337 break; |
| 337 case ExtensionInstallPrompt::Result::USER_CANCELED: | 338 case ExtensionInstallPrompt::Result::USER_CANCELED: |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 global_error_.reset(new ExternalInstallMenuAlert(this)); | 456 global_error_.reset(new ExternalInstallMenuAlert(this)); |
| 456 error_service_->AddGlobalError(global_error_.get()); | 457 error_service_->AddGlobalError(global_error_.get()); |
| 457 } | 458 } |
| 458 } | 459 } |
| 459 | 460 |
| 460 void ExternalInstallError::RemoveError() { | 461 void ExternalInstallError::RemoveError() { |
| 461 manager_->RemoveExternalInstallError(extension_id_); | 462 manager_->RemoveExternalInstallError(extension_id_); |
| 462 } | 463 } |
| 463 | 464 |
| 464 } // namespace extensions | 465 } // namespace extensions |
| OLD | NEW |