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

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

Issue 10870022: Change FaviconData to be able to return data for multiple bitmaps for same icon URL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
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 <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "chrome/common/web_apps.h" 47 #include "chrome/common/web_apps.h"
48 #include "content/public/browser/notification_service.h" 48 #include "content/public/browser/notification_service.h"
49 #include "content/public/browser/web_ui.h" 49 #include "content/public/browser/web_ui.h"
50 #include "googleurl/src/gurl.h" 50 #include "googleurl/src/gurl.h"
51 #include "grit/browser_resources.h" 51 #include "grit/browser_resources.h"
52 #include "grit/generated_resources.h" 52 #include "grit/generated_resources.h"
53 #include "net/base/escape.h" 53 #include "net/base/escape.h"
54 #include "ui/base/animation/animation.h" 54 #include "ui/base/animation/animation.h"
55 #include "ui/base/l10n/l10n_util.h" 55 #include "ui/base/l10n/l10n_util.h"
56 #include "ui/gfx/codec/png_codec.h" 56 #include "ui/gfx/codec/png_codec.h"
57 #include "ui/gfx/favicon_size.h"
57 58
58 using application_launch::LaunchParams; 59 using application_launch::LaunchParams;
59 using application_launch::OpenApplication; 60 using application_launch::OpenApplication;
60 using content::WebContents; 61 using content::WebContents;
61 using extensions::CrxInstaller; 62 using extensions::CrxInstaller;
62 using extensions::Extension; 63 using extensions::Extension;
63 using extensions::ExtensionPrefs; 64 using extensions::ExtensionPrefs;
64 65
65 namespace { 66 namespace {
66 67
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 LOG(ERROR) << "No favicon service"; 698 LOG(ERROR) << "No favicon service";
698 return; 699 return;
699 } 700 }
700 701
701 scoped_ptr<AppInstallInfo> install_info(new AppInstallInfo()); 702 scoped_ptr<AppInstallInfo> install_info(new AppInstallInfo());
702 install_info->is_bookmark_app = true; 703 install_info->is_bookmark_app = true;
703 install_info->title = title; 704 install_info->title = title;
704 install_info->app_url = launch_url; 705 install_info->app_url = launch_url;
705 install_info->page_ordinal = page_ordinal; 706 install_info->page_ordinal = page_ordinal;
706 707
707 FaviconService::Handle h = favicon_service->GetFaviconForURL( 708 FaviconService::Handle h = favicon_service->GetFaviconImageForURL(
708 profile, launch_url, history::FAVICON, &favicon_consumer_, 709 profile, launch_url, history::FAVICON, gfx::kFaviconSize,
710 &favicon_consumer_,
709 base::Bind(&AppLauncherHandler::OnFaviconForApp, base::Unretained(this))); 711 base::Bind(&AppLauncherHandler::OnFaviconForApp, base::Unretained(this)));
710 favicon_consumer_.SetClientData(favicon_service, h, install_info.release()); 712 favicon_consumer_.SetClientData(favicon_service, h, install_info.release());
711 } 713 }
712 714
713 void AppLauncherHandler::HandleRecordAppLaunchByUrl( 715 void AppLauncherHandler::HandleRecordAppLaunchByUrl(
714 const base::ListValue* args) { 716 const base::ListValue* args) {
715 std::string url; 717 std::string url;
716 CHECK(args->GetString(0, &url)); 718 CHECK(args->GetString(0, &url));
717 double source; 719 double source;
718 CHECK(args->GetDouble(1, &source)); 720 CHECK(args->GetDouble(1, &source));
(...skipping 28 matching lines...) Expand all
747 CHECK(args->GetString(0, &extension_id)); 749 CHECK(args->GetString(0, &extension_id));
748 CHECK(args->GetBoolean(1, &disabled)); 750 CHECK(args->GetBoolean(1, &disabled));
749 751
750 const Extension* extension = extension_service_->GetExtensionById( 752 const Extension* extension = extension_service_->GetExtensionById(
751 extension_id, true); 753 extension_id, true);
752 if (!extension) 754 if (!extension)
753 return; 755 return;
754 extension_service_->SetAppNotificationDisabled(extension_id, disabled); 756 extension_service_->SetAppNotificationDisabled(extension_id, disabled);
755 } 757 }
756 758
757 void AppLauncherHandler::OnFaviconForApp(FaviconService::Handle handle, 759 void AppLauncherHandler::OnFaviconForApp(
758 history::FaviconData data) { 760 FaviconService::Handle handle,
761 const history::FaviconImageResult& image_result) {
759 scoped_ptr<AppInstallInfo> install_info( 762 scoped_ptr<AppInstallInfo> install_info(
760 favicon_consumer_.GetClientDataForCurrentRequest()); 763 favicon_consumer_.GetClientDataForCurrentRequest());
761 scoped_ptr<WebApplicationInfo> web_app(new WebApplicationInfo()); 764 scoped_ptr<WebApplicationInfo> web_app(new WebApplicationInfo());
762 web_app->is_bookmark_app = install_info->is_bookmark_app; 765 web_app->is_bookmark_app = install_info->is_bookmark_app;
763 web_app->title = install_info->title; 766 web_app->title = install_info->title;
764 web_app->app_url = install_info->app_url; 767 web_app->app_url = install_info->app_url;
765 web_app->urls.push_back(install_info->app_url); 768 web_app->urls.push_back(install_info->app_url);
766 769
767 WebApplicationInfo::IconInfo icon; 770 WebApplicationInfo::IconInfo icon;
768 web_app->icons.push_back(icon); 771 if (!image_result.image.IsEmpty()) {
769 if (data.is_valid() && gfx::PNGCodec::Decode(data.image_data->front(), 772 icon.data = image_result.image.AsBitmap();
770 data.image_data->size(), 773 icon.width = icon.data.width();
771 &(web_app->icons[0].data))) { 774 icon.height = icon.data.height();
772 web_app->icons[0].url = GURL(); 775 web_app->icons.push_back(icon);
773 web_app->icons[0].width = web_app->icons[0].data.width();
774 web_app->icons[0].height = web_app->icons[0].data.height();
775 } else {
776 web_app->icons.clear();
sky 2012/08/27 14:52:01 Don't you need this else branch?
pkotwicz 2012/08/27 19:35:03 |web_app| is constructed on line 761, so I don't t
777 } 776 }
778 777
779 scoped_refptr<CrxInstaller> installer( 778 scoped_refptr<CrxInstaller> installer(
780 CrxInstaller::Create(extension_service_, NULL)); 779 CrxInstaller::Create(extension_service_, NULL));
781 installer->set_page_ordinal(install_info->page_ordinal); 780 installer->set_page_ordinal(install_info->page_ordinal);
782 installer->InstallWebApp(*web_app); 781 installer->InstallWebApp(*web_app);
783 attempted_bookmark_app_install_ = true; 782 attempted_bookmark_app_install_ = true;
784 } 783 }
785 784
786 void AppLauncherHandler::SetAppToBeHighlighted() { 785 void AppLauncherHandler::SetAppToBeHighlighted() {
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 940
942 ExtensionInstallPrompt* AppLauncherHandler::GetExtensionInstallPrompt() { 941 ExtensionInstallPrompt* AppLauncherHandler::GetExtensionInstallPrompt() {
943 if (!extension_install_ui_.get()) { 942 if (!extension_install_ui_.get()) {
944 Browser* browser = browser::FindBrowserWithWebContents( 943 Browser* browser = browser::FindBrowserWithWebContents(
945 web_ui()->GetWebContents()); 944 web_ui()->GetWebContents());
946 extension_install_ui_.reset( 945 extension_install_ui_.reset(
947 chrome::CreateExtensionInstallPromptWithBrowser(browser)); 946 chrome::CreateExtensionInstallPromptWithBrowser(browser));
948 } 947 }
949 return extension_install_ui_.get(); 948 return extension_install_ui_.get();
950 } 949 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698