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 <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 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 scoped_ptr<AppInstallInfo> install_info( | 757 scoped_ptr<AppInstallInfo> install_info( |
758 favicon_consumer_.GetClientDataForCurrentRequest()); | 758 favicon_consumer_.GetClientDataForCurrentRequest()); |
759 scoped_ptr<WebApplicationInfo> web_app(new WebApplicationInfo()); | 759 scoped_ptr<WebApplicationInfo> web_app(new WebApplicationInfo()); |
760 web_app->is_bookmark_app = install_info->is_bookmark_app; | 760 web_app->is_bookmark_app = install_info->is_bookmark_app; |
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 web_app->urls.push_back(install_info->app_url); | 763 web_app->urls.push_back(install_info->app_url); |
764 | 764 |
765 WebApplicationInfo::IconInfo icon; | 765 WebApplicationInfo::IconInfo icon; |
766 web_app->icons.push_back(icon); | 766 web_app->icons.push_back(icon); |
767 if (data.is_valid() && gfx::PNGCodec::Decode(data.image_data->front(), | 767 bool bitmap_data_valid = false; |
768 data.image_data->size(), | 768 if (data.is_valid()) { |
769 &(web_app->icons[0].data))) { | 769 history::FaviconDataElement element = data.elements[0]; |
770 web_app->icons[0].url = GURL(); | 770 if (gfx::PNGCodec::Decode(element.bitmap_data->front(), |
771 web_app->icons[0].width = web_app->icons[0].data.width(); | 771 element.bitmap_data->size(), |
772 web_app->icons[0].height = web_app->icons[0].data.height(); | 772 &(web_app->icons[0].data))) { |
773 } else { | 773 bitmap_data_valid = true; |
| 774 web_app->icons[0].url = GURL(); |
| 775 web_app->icons[0].width = web_app->icons[0].data.width(); |
| 776 web_app->icons[0].height = web_app->icons[0].data.height(); |
| 777 } |
| 778 } |
| 779 |
| 780 if (!bitmap_data_valid) |
774 web_app->icons.clear(); | 781 web_app->icons.clear(); |
775 } | |
776 | 782 |
777 scoped_refptr<CrxInstaller> installer( | 783 scoped_refptr<CrxInstaller> installer( |
778 CrxInstaller::Create(extension_service_, NULL)); | 784 CrxInstaller::Create(extension_service_, NULL)); |
779 installer->set_page_ordinal(install_info->page_ordinal); | 785 installer->set_page_ordinal(install_info->page_ordinal); |
780 installer->InstallWebApp(*web_app); | 786 installer->InstallWebApp(*web_app); |
781 attempted_bookmark_app_install_ = true; | 787 attempted_bookmark_app_install_ = true; |
782 } | 788 } |
783 | 789 |
784 void AppLauncherHandler::SetAppToBeHighlighted() { | 790 void AppLauncherHandler::SetAppToBeHighlighted() { |
785 if (highlight_app_id_.empty()) | 791 if (highlight_app_id_.empty()) |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
939 | 945 |
940 ExtensionInstallPrompt* AppLauncherHandler::GetExtensionInstallPrompt() { | 946 ExtensionInstallPrompt* AppLauncherHandler::GetExtensionInstallPrompt() { |
941 if (!extension_install_ui_.get()) { | 947 if (!extension_install_ui_.get()) { |
942 Browser* browser = browser::FindBrowserWithWebContents( | 948 Browser* browser = browser::FindBrowserWithWebContents( |
943 web_ui()->GetWebContents()); | 949 web_ui()->GetWebContents()); |
944 extension_install_ui_.reset( | 950 extension_install_ui_.reset( |
945 chrome::CreateExtensionInstallPromptWithBrowser(browser)); | 951 chrome::CreateExtensionInstallPromptWithBrowser(browser)); |
946 } | 952 } |
947 return extension_install_ui_.get(); | 953 return extension_install_ui_.get(); |
948 } | 954 } |
OLD | NEW |