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

Side by Side Diff: chrome/browser/ui/webui/ntp/app_launcher_handler.cc

Issue 1865213004: Convert //chrome/browser/ui from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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 (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/ui/webui/ntp/app_launcher_handler.h" 5 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 NOTREACHED(); 332 NOTREACHED();
333 } 333 }
334 } 334 }
335 335
336 void AppLauncherHandler::OnExtensionLoaded( 336 void AppLauncherHandler::OnExtensionLoaded(
337 content::BrowserContext* browser_context, 337 content::BrowserContext* browser_context,
338 const Extension* extension) { 338 const Extension* extension) {
339 if (!ShouldShow(extension)) 339 if (!ShouldShow(extension))
340 return; 340 return;
341 341
342 scoped_ptr<base::DictionaryValue> app_info(GetAppInfo(extension)); 342 std::unique_ptr<base::DictionaryValue> app_info(GetAppInfo(extension));
343 if (!app_info.get()) 343 if (!app_info.get())
344 return; 344 return;
345 345
346 visible_apps_.insert(extension->id()); 346 visible_apps_.insert(extension->id());
347 ExtensionPrefs* prefs = ExtensionPrefs::Get(extension_service_->profile()); 347 ExtensionPrefs* prefs = ExtensionPrefs::Get(extension_service_->profile());
348 base::FundamentalValue highlight(prefs->IsFromBookmark(extension->id()) && 348 base::FundamentalValue highlight(prefs->IsFromBookmark(extension->id()) &&
349 attempted_bookmark_app_install_); 349 attempted_bookmark_app_install_);
350 attempted_bookmark_app_install_ = false; 350 attempted_bookmark_app_install_ = false;
351 web_ui()->CallJavascriptFunction("ntp.appAdded", *app_info, highlight); 351 web_ui()->CallJavascriptFunction("ntp.appAdded", *app_info, highlight);
352 } 352 }
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 712
713 Profile* profile = Profile::FromWebUI(web_ui()); 713 Profile* profile = Profile::FromWebUI(web_ui());
714 favicon::FaviconService* favicon_service = 714 favicon::FaviconService* favicon_service =
715 FaviconServiceFactory::GetForProfile(profile, 715 FaviconServiceFactory::GetForProfile(profile,
716 ServiceAccessType::EXPLICIT_ACCESS); 716 ServiceAccessType::EXPLICIT_ACCESS);
717 if (!favicon_service) { 717 if (!favicon_service) {
718 LOG(ERROR) << "No favicon service"; 718 LOG(ERROR) << "No favicon service";
719 return; 719 return;
720 } 720 }
721 721
722 scoped_ptr<AppInstallInfo> install_info(new AppInstallInfo()); 722 std::unique_ptr<AppInstallInfo> install_info(new AppInstallInfo());
723 install_info->title = title; 723 install_info->title = title;
724 install_info->app_url = launch_url; 724 install_info->app_url = launch_url;
725 install_info->page_ordinal = page_ordinal; 725 install_info->page_ordinal = page_ordinal;
726 726
727 favicon_service->GetFaviconImageForPageURL( 727 favicon_service->GetFaviconImageForPageURL(
728 launch_url, 728 launch_url,
729 base::Bind(&AppLauncherHandler::OnFaviconForApp, 729 base::Bind(&AppLauncherHandler::OnFaviconForApp,
730 base::Unretained(this), 730 base::Unretained(this),
731 base::Passed(&install_info)), 731 base::Passed(&install_info)),
732 &cancelable_task_tracker_); 732 &cancelable_task_tracker_);
(...skipping 15 matching lines...) Expand all
748 void AppLauncherHandler::HandlePageSelected(const base::ListValue* args) { 748 void AppLauncherHandler::HandlePageSelected(const base::ListValue* args) {
749 double index_double; 749 double index_double;
750 CHECK(args->GetDouble(0, &index_double)); 750 CHECK(args->GetDouble(0, &index_double));
751 int index = static_cast<int>(index_double); 751 int index = static_cast<int>(index_double);
752 752
753 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); 753 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
754 prefs->SetInteger(prefs::kNtpShownPage, APPS_PAGE_ID | index); 754 prefs->SetInteger(prefs::kNtpShownPage, APPS_PAGE_ID | index);
755 } 755 }
756 756
757 void AppLauncherHandler::OnFaviconForApp( 757 void AppLauncherHandler::OnFaviconForApp(
758 scoped_ptr<AppInstallInfo> install_info, 758 std::unique_ptr<AppInstallInfo> install_info,
759 const favicon_base::FaviconImageResult& image_result) { 759 const favicon_base::FaviconImageResult& image_result) {
760 scoped_ptr<WebApplicationInfo> web_app(new WebApplicationInfo()); 760 std::unique_ptr<WebApplicationInfo> web_app(new WebApplicationInfo());
761 web_app->title = install_info->title; 761 web_app->title = install_info->title;
762 web_app->app_url = install_info->app_url; 762 web_app->app_url = install_info->app_url;
763 763
764 if (!image_result.image.IsEmpty()) { 764 if (!image_result.image.IsEmpty()) {
765 WebApplicationInfo::IconInfo icon; 765 WebApplicationInfo::IconInfo icon;
766 icon.data = image_result.image.AsBitmap(); 766 icon.data = image_result.image.AsBitmap();
767 icon.width = icon.data.width(); 767 icon.width = icon.data.width();
768 icon.height = icon.data.height(); 768 icon.height = icon.data.height();
769 web_app->icons.push_back(icon); 769 web_app->icons.push_back(icon);
770 } 770 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 this)); 863 this));
864 } 864 }
865 return extension_uninstall_dialog_.get(); 865 return extension_uninstall_dialog_.get();
866 } 866 }
867 867
868 void AppLauncherHandler::AppRemoved(const Extension* extension, 868 void AppLauncherHandler::AppRemoved(const Extension* extension,
869 bool is_uninstall) { 869 bool is_uninstall) {
870 if (!ShouldShow(extension)) 870 if (!ShouldShow(extension))
871 return; 871 return;
872 872
873 scoped_ptr<base::DictionaryValue> app_info(GetAppInfo(extension)); 873 std::unique_ptr<base::DictionaryValue> app_info(GetAppInfo(extension));
874 if (!app_info.get()) 874 if (!app_info.get())
875 return; 875 return;
876 876
877 web_ui()->CallJavascriptFunction( 877 web_ui()->CallJavascriptFunction(
878 "ntp.appRemoved", *app_info, base::FundamentalValue(is_uninstall), 878 "ntp.appRemoved", *app_info, base::FundamentalValue(is_uninstall),
879 base::FundamentalValue(!extension_id_prompting_.empty())); 879 base::FundamentalValue(!extension_id_prompting_.empty()));
880 } 880 }
881 881
882 bool AppLauncherHandler::ShouldShow(const Extension* extension) const { 882 bool AppLauncherHandler::ShouldShow(const Extension* extension) const {
883 if (ignore_changes_ || !has_loaded_apps_ || !extension->is_app()) 883 if (ignore_changes_ || !has_loaded_apps_ || !extension->is_app())
884 return false; 884 return false;
885 885
886 Profile* profile = Profile::FromWebUI(web_ui()); 886 Profile* profile = Profile::FromWebUI(web_ui());
887 return extensions::ui_util::ShouldDisplayInNewTabPage(extension, profile); 887 return extensions::ui_util::ShouldDisplayInNewTabPage(extension, profile);
888 } 888 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/ntp/app_launcher_handler.h ('k') | chrome/browser/ui/webui/ntp/favicon_webui_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698