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/ui/webui/ntp/app_launcher_handler.h" | 5 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "apps/metrics_names.h" | 9 #include "apps/metrics_names.h" |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 | 694 |
695 Profile* profile = Profile::FromWebUI(web_ui()); | 695 Profile* profile = Profile::FromWebUI(web_ui()); |
696 FaviconService* favicon_service = | 696 FaviconService* favicon_service = |
697 FaviconServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS); | 697 FaviconServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS); |
698 if (!favicon_service) { | 698 if (!favicon_service) { |
699 LOG(ERROR) << "No favicon service"; | 699 LOG(ERROR) << "No favicon service"; |
700 return; | 700 return; |
701 } | 701 } |
702 | 702 |
703 scoped_ptr<AppInstallInfo> install_info(new AppInstallInfo()); | 703 scoped_ptr<AppInstallInfo> install_info(new AppInstallInfo()); |
704 install_info->is_bookmark_app = true; | |
705 install_info->title = title; | 704 install_info->title = title; |
706 install_info->app_url = launch_url; | 705 install_info->app_url = launch_url; |
707 install_info->page_ordinal = page_ordinal; | 706 install_info->page_ordinal = page_ordinal; |
708 | 707 |
709 favicon_service->GetFaviconImageForURL( | 708 favicon_service->GetFaviconImageForURL( |
710 FaviconService::FaviconForURLParams(launch_url, | 709 FaviconService::FaviconForURLParams(launch_url, |
711 chrome::FAVICON, | 710 chrome::FAVICON, |
712 gfx::kFaviconSize), | 711 gfx::kFaviconSize), |
713 base::Bind(&AppLauncherHandler::OnFaviconForApp, | 712 base::Bind(&AppLauncherHandler::OnFaviconForApp, |
714 base::Unretained(this), | 713 base::Unretained(this), |
(...skipping 11 matching lines...) Expand all Loading... |
726 } | 725 } |
727 | 726 |
728 void AppLauncherHandler::OnLearnMore(const base::ListValue* args) { | 727 void AppLauncherHandler::OnLearnMore(const base::ListValue* args) { |
729 RecordAppLauncherPromoHistogram(apps::APP_LAUNCHER_PROMO_LEARN_MORE); | 728 RecordAppLauncherPromoHistogram(apps::APP_LAUNCHER_PROMO_LEARN_MORE); |
730 } | 729 } |
731 | 730 |
732 void AppLauncherHandler::OnFaviconForApp( | 731 void AppLauncherHandler::OnFaviconForApp( |
733 scoped_ptr<AppInstallInfo> install_info, | 732 scoped_ptr<AppInstallInfo> install_info, |
734 const chrome::FaviconImageResult& image_result) { | 733 const chrome::FaviconImageResult& image_result) { |
735 scoped_ptr<WebApplicationInfo> web_app(new WebApplicationInfo()); | 734 scoped_ptr<WebApplicationInfo> web_app(new WebApplicationInfo()); |
736 web_app->is_bookmark_app = install_info->is_bookmark_app; | |
737 web_app->title = install_info->title; | 735 web_app->title = install_info->title; |
738 web_app->app_url = install_info->app_url; | 736 web_app->app_url = install_info->app_url; |
739 web_app->urls.push_back(install_info->app_url); | |
740 | 737 |
741 if (!image_result.image.IsEmpty()) { | 738 if (!image_result.image.IsEmpty()) { |
742 WebApplicationInfo::IconInfo icon; | 739 WebApplicationInfo::IconInfo icon; |
743 icon.data = image_result.image.AsBitmap(); | 740 icon.data = image_result.image.AsBitmap(); |
744 icon.width = icon.data.width(); | 741 icon.width = icon.data.width(); |
745 icon.height = icon.data.height(); | 742 icon.height = icon.data.height(); |
746 web_app->icons.push_back(icon); | 743 web_app->icons.push_back(icon); |
747 } | 744 } |
748 | 745 |
749 scoped_refptr<CrxInstaller> installer( | 746 scoped_refptr<CrxInstaller> installer( |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 ExtensionUninstallDialog* AppLauncherHandler::GetExtensionUninstallDialog() { | 843 ExtensionUninstallDialog* AppLauncherHandler::GetExtensionUninstallDialog() { |
847 if (!extension_uninstall_dialog_.get()) { | 844 if (!extension_uninstall_dialog_.get()) { |
848 Browser* browser = chrome::FindBrowserWithWebContents( | 845 Browser* browser = chrome::FindBrowserWithWebContents( |
849 web_ui()->GetWebContents()); | 846 web_ui()->GetWebContents()); |
850 extension_uninstall_dialog_.reset( | 847 extension_uninstall_dialog_.reset( |
851 ExtensionUninstallDialog::Create(extension_service_->profile(), | 848 ExtensionUninstallDialog::Create(extension_service_->profile(), |
852 browser, this)); | 849 browser, this)); |
853 } | 850 } |
854 return extension_uninstall_dialog_.get(); | 851 return extension_uninstall_dialog_.get(); |
855 } | 852 } |
OLD | NEW |