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