Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(543)

Side by Side Diff: chrome/browser/extensions/external_install_error.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 const Extension* ExternalInstallError::GetExtension() const { 376 const Extension* ExternalInstallError::GetExtension() const {
377 return ExtensionRegistry::Get(browser_context_) 377 return ExtensionRegistry::Get(browser_context_)
378 ->GetExtensionById(extension_id_, ExtensionRegistry::EVERYTHING); 378 ->GetExtensionById(extension_id_, ExtensionRegistry::EVERYTHING);
379 } 379 }
380 380
381 void ExternalInstallError::OnWebstoreRequestFailure() { 381 void ExternalInstallError::OnWebstoreRequestFailure() {
382 OnFetchComplete(); 382 OnFetchComplete();
383 } 383 }
384 384
385 void ExternalInstallError::OnWebstoreResponseParseSuccess( 385 void ExternalInstallError::OnWebstoreResponseParseSuccess(
386 scoped_ptr<base::DictionaryValue> webstore_data) { 386 std::unique_ptr<base::DictionaryValue> webstore_data) {
387 std::string localized_user_count; 387 std::string localized_user_count;
388 double average_rating = 0; 388 double average_rating = 0;
389 int rating_count = 0; 389 int rating_count = 0;
390 if (!webstore_data->GetString(kUsersKey, &localized_user_count) || 390 if (!webstore_data->GetString(kUsersKey, &localized_user_count) ||
391 !webstore_data->GetDouble(kAverageRatingKey, &average_rating) || 391 !webstore_data->GetDouble(kAverageRatingKey, &average_rating) ||
392 !webstore_data->GetInteger(kRatingCountKey, &rating_count)) { 392 !webstore_data->GetInteger(kRatingCountKey, &rating_count)) {
393 // If we don't get a valid webstore response, short circuit, and continue 393 // If we don't get a valid webstore response, short circuit, and continue
394 // to show a prompt without webstore data. 394 // to show a prompt without webstore data.
395 OnFetchComplete(); 395 OnFetchComplete();
396 return; 396 return;
(...skipping 25 matching lines...) Expand all
422 GetExtension(), 422 GetExtension(),
423 nullptr, // Force a fetch of the icon. 423 nullptr, // Force a fetch of the icon.
424 std::move(prompt_), 424 std::move(prompt_),
425 base::Bind(&ExternalInstallError::OnDialogReady, 425 base::Bind(&ExternalInstallError::OnDialogReady,
426 weak_factory_.GetWeakPtr())); 426 weak_factory_.GetWeakPtr()));
427 } 427 }
428 428
429 void ExternalInstallError::OnDialogReady( 429 void ExternalInstallError::OnDialogReady(
430 ExtensionInstallPromptShowParams* show_params, 430 ExtensionInstallPromptShowParams* show_params,
431 const ExtensionInstallPrompt::DoneCallback& callback, 431 const ExtensionInstallPrompt::DoneCallback& callback,
432 scoped_ptr<ExtensionInstallPrompt::Prompt> prompt) { 432 std::unique_ptr<ExtensionInstallPrompt::Prompt> prompt) {
433 prompt_ = std::move(prompt); 433 prompt_ = std::move(prompt);
434 434
435 if (alert_type_ == BUBBLE_ALERT) { 435 if (alert_type_ == BUBBLE_ALERT) {
436 global_error_.reset(new ExternalInstallBubbleAlert(this, prompt_.get())); 436 global_error_.reset(new ExternalInstallBubbleAlert(this, prompt_.get()));
437 error_service_->AddGlobalError(global_error_.get()); 437 error_service_->AddGlobalError(global_error_.get());
438 438
439 if (!manager_->has_currently_visible_install_alert()) { 439 if (!manager_->has_currently_visible_install_alert()) {
440 // |browser| is nullptr during unit tests, so call 440 // |browser| is nullptr during unit tests, so call
441 // DidChangeInstallAlertVisibility() regardless because we depend on this 441 // DidChangeInstallAlertVisibility() regardless because we depend on this
442 // in unit tests. 442 // in unit tests.
443 manager_->DidChangeInstallAlertVisibility(this, true); 443 manager_->DidChangeInstallAlertVisibility(this, true);
444 Browser* browser = chrome::FindTabbedBrowser( 444 Browser* browser = chrome::FindTabbedBrowser(
445 Profile::FromBrowserContext(browser_context_), true); 445 Profile::FromBrowserContext(browser_context_), true);
446 if (browser) 446 if (browser)
447 global_error_->ShowBubbleView(browser); 447 global_error_->ShowBubbleView(browser);
448 } 448 }
449 } else { 449 } else {
450 DCHECK(alert_type_ == MENU_ALERT); 450 DCHECK(alert_type_ == MENU_ALERT);
451 global_error_.reset(new ExternalInstallMenuAlert(this)); 451 global_error_.reset(new ExternalInstallMenuAlert(this));
452 error_service_->AddGlobalError(global_error_.get()); 452 error_service_->AddGlobalError(global_error_.get());
453 } 453 }
454 } 454 }
455 455
456 void ExternalInstallError::RemoveError() { 456 void ExternalInstallError::RemoveError() {
457 manager_->RemoveExternalInstallError(extension_id_); 457 manager_->RemoveExternalInstallError(extension_id_);
458 } 458 }
459 459
460 } // namespace extensions 460 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/external_install_error.h ('k') | chrome/browser/extensions/external_install_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698