Chromium Code Reviews| 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" |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 webstore_data_fetcher_.reset(new WebstoreDataFetcher( | 306 webstore_data_fetcher_.reset(new WebstoreDataFetcher( |
| 307 this, | 307 this, |
| 308 content::BrowserContext::GetDefaultStoragePartition(browser_context_)-> | 308 content::BrowserContext::GetDefaultStoragePartition(browser_context_)-> |
| 309 GetURLRequestContext(), | 309 GetURLRequestContext(), |
| 310 GURL(), extension_id_)); | 310 GURL(), extension_id_)); |
| 311 webstore_data_fetcher_->Start(); | 311 webstore_data_fetcher_->Start(); |
| 312 } | 312 } |
| 313 | 313 |
| 314 ExternalInstallError::~ExternalInstallError() { | 314 ExternalInstallError::~ExternalInstallError() { |
| 315 if (global_error_.get()) | 315 if (global_error_.get()) |
| 316 error_service_->RemoveGlobalError(global_error_.get()); | 316 error_service_->RemoveUnownedGlobalError(global_error_.get()); |
| 317 } | 317 } |
| 318 | 318 |
| 319 void ExternalInstallError::OnInstallPromptDone( | 319 void ExternalInstallError::OnInstallPromptDone( |
| 320 ExtensionInstallPrompt::Result result) { | 320 ExtensionInstallPrompt::Result result) { |
| 321 const Extension* extension = GetExtension(); | 321 const Extension* extension = GetExtension(); |
| 322 | 322 |
| 323 // 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 |
| 324 // 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 |
| 325 // 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. |
| 326 base::ThreadTaskRunnerHandle::Get()->PostTask( | 326 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 431 weak_factory_.GetWeakPtr())); | 431 weak_factory_.GetWeakPtr())); |
| 432 } | 432 } |
| 433 | 433 |
| 434 void ExternalInstallError::OnDialogReady( | 434 void ExternalInstallError::OnDialogReady( |
| 435 ExtensionInstallPromptShowParams* show_params, | 435 ExtensionInstallPromptShowParams* show_params, |
| 436 const ExtensionInstallPrompt::DoneCallback& callback, | 436 const ExtensionInstallPrompt::DoneCallback& callback, |
| 437 std::unique_ptr<ExtensionInstallPrompt::Prompt> prompt) { | 437 std::unique_ptr<ExtensionInstallPrompt::Prompt> prompt) { |
| 438 prompt_ = std::move(prompt); | 438 prompt_ = std::move(prompt); |
| 439 | 439 |
| 440 if (alert_type_ == BUBBLE_ALERT) { | 440 if (alert_type_ == BUBBLE_ALERT) { |
| 441 global_error_.reset(new ExternalInstallBubbleAlert(this, prompt_.get())); | 441 global_error_.reset(new ExternalInstallBubbleAlert(this, prompt_.get())); |
|
Nico
2016/10/10 14:03:37
This one looks like it could be a weak ptr and thi
Avi (use Gerrit)
2016/10/10 16:52:36
The GlobalErrorService is a PKS, and is guaranteed
| |
| 442 error_service_->AddGlobalError(global_error_.get()); | 442 error_service_->AddUnownedGlobalError(global_error_.get()); |
| 443 | 443 |
| 444 if (!manager_->has_currently_visible_install_alert()) { | 444 if (!manager_->has_currently_visible_install_alert()) { |
| 445 // |browser| is nullptr during unit tests, so call | 445 // |browser| is nullptr during unit tests, so call |
| 446 // DidChangeInstallAlertVisibility() regardless because we depend on this | 446 // DidChangeInstallAlertVisibility() regardless because we depend on this |
| 447 // in unit tests. | 447 // in unit tests. |
| 448 manager_->DidChangeInstallAlertVisibility(this, true); | 448 manager_->DidChangeInstallAlertVisibility(this, true); |
| 449 Browser* browser = chrome::FindTabbedBrowser( | 449 Browser* browser = chrome::FindTabbedBrowser( |
| 450 Profile::FromBrowserContext(browser_context_), true); | 450 Profile::FromBrowserContext(browser_context_), true); |
| 451 if (browser) | 451 if (browser) |
| 452 global_error_->ShowBubbleView(browser); | 452 global_error_->ShowBubbleView(browser); |
| 453 } | 453 } |
| 454 } else { | 454 } else { |
| 455 DCHECK(alert_type_ == MENU_ALERT); | 455 DCHECK(alert_type_ == MENU_ALERT); |
| 456 global_error_.reset(new ExternalInstallMenuAlert(this)); | 456 global_error_.reset(new ExternalInstallMenuAlert(this)); |
| 457 error_service_->AddGlobalError(global_error_.get()); | 457 error_service_->AddUnownedGlobalError(global_error_.get()); |
| 458 } | 458 } |
| 459 } | 459 } |
| 460 | 460 |
| 461 void ExternalInstallError::RemoveError() { | 461 void ExternalInstallError::RemoveError() { |
| 462 manager_->RemoveExternalInstallError(extension_id_); | 462 manager_->RemoveExternalInstallError(extension_id_); |
| 463 } | 463 } |
| 464 | 464 |
| 465 } // namespace extensions | 465 } // namespace extensions |
| OLD | NEW |