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 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
747 CHECK(args->GetBoolean(1, &disabled)); | 747 CHECK(args->GetBoolean(1, &disabled)); |
748 | 748 |
749 const Extension* extension = extension_service_->GetExtensionById( | 749 const Extension* extension = extension_service_->GetExtensionById( |
750 extension_id, true); | 750 extension_id, true); |
751 if (!extension) | 751 if (!extension) |
752 return; | 752 return; |
753 extension_service_->SetAppNotificationDisabled(extension_id, disabled); | 753 extension_service_->SetAppNotificationDisabled(extension_id, disabled); |
754 } | 754 } |
755 | 755 |
756 void AppLauncherHandler::OnFaviconForApp(FaviconService::Handle handle, | 756 void AppLauncherHandler::OnFaviconForApp(FaviconService::Handle handle, |
757 history::FaviconData data) { | 757 history::FaviconData data, |
758 std::vector<GURL> icon_urls_in_db) { | |
758 scoped_ptr<AppInstallInfo> install_info( | 759 scoped_ptr<AppInstallInfo> install_info( |
759 favicon_consumer_.GetClientDataForCurrentRequest()); | 760 favicon_consumer_.GetClientDataForCurrentRequest()); |
760 scoped_ptr<WebApplicationInfo> web_app(new WebApplicationInfo()); | 761 scoped_ptr<WebApplicationInfo> web_app(new WebApplicationInfo()); |
761 web_app->is_bookmark_app = install_info->is_bookmark_app; | 762 web_app->is_bookmark_app = install_info->is_bookmark_app; |
762 web_app->title = install_info->title; | 763 web_app->title = install_info->title; |
763 web_app->app_url = install_info->app_url; | 764 web_app->app_url = install_info->app_url; |
764 web_app->urls.push_back(install_info->app_url); | 765 web_app->urls.push_back(install_info->app_url); |
765 | 766 |
766 WebApplicationInfo::IconInfo icon; | 767 WebApplicationInfo::IconInfo icon; |
767 web_app->icons.push_back(icon); | 768 web_app->icons.push_back(icon); |
768 if (data.is_valid() && gfx::PNGCodec::Decode(data.image_data->front(), | 769 bool bitmap_data_valid = false; |
769 data.image_data->size(), | 770 if (data.has_valid_bitmaps()) { |
770 &(web_app->icons[0].data))) { | 771 scoped_refptr<base::RefCountedMemory> bitmap_data(data.first_bitmap()); |
771 web_app->icons[0].url = GURL(); | 772 if (gfx::PNGCodec::Decode(bitmap_data->front(), bitmap_data->size(), |
772 web_app->icons[0].width = web_app->icons[0].data.width(); | 773 &(web_app->icons[0].data))) { |
773 web_app->icons[0].height = web_app->icons[0].data.height(); | 774 bitmap_data_valid = true; |
774 } else { | 775 web_app->icons[0].url = GURL(); |
sky
2012/08/23 15:50:38
I realize your copying code, but is this line nece
| |
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 |