OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 } | 94 } |
95 return dictionary; | 95 return dictionary; |
96 } | 96 } |
97 | 97 |
98 // static | 98 // static |
99 void AppLauncherHandler::CreateAppInfo(const Extension* extension, | 99 void AppLauncherHandler::CreateAppInfo(const Extension* extension, |
100 const AppNotification* notification, | 100 const AppNotification* notification, |
101 ExtensionService* service, | 101 ExtensionService* service, |
102 DictionaryValue* value) { | 102 DictionaryValue* value) { |
103 bool enabled = service->IsExtensionEnabled(extension->id()); | 103 bool enabled = service->IsExtensionEnabled(extension->id()); |
| 104 bool icon_big_exists = true; |
104 GURL icon_big = | 105 GURL icon_big = |
105 ExtensionIconSource::GetIconURL(extension, | 106 ExtensionIconSource::GetIconURL(extension, |
106 Extension::EXTENSION_ICON_LARGE, | 107 Extension::EXTENSION_ICON_LARGE, |
107 ExtensionIconSet::MATCH_EXACTLY, | 108 ExtensionIconSet::MATCH_EXACTLY, |
108 !enabled); | 109 !enabled, &icon_big_exists); |
| 110 bool icon_small_exists = true; |
109 GURL icon_small = | 111 GURL icon_small = |
110 ExtensionIconSource::GetIconURL(extension, | 112 ExtensionIconSource::GetIconURL(extension, |
111 Extension::EXTENSION_ICON_BITTY, | 113 Extension::EXTENSION_ICON_BITTY, |
112 ExtensionIconSet::MATCH_BIGGER, | 114 ExtensionIconSet::MATCH_BIGGER, |
113 !enabled); | 115 !enabled, &icon_small_exists); |
114 | 116 |
115 value->Clear(); | 117 value->Clear(); |
116 value->SetString("id", extension->id()); | 118 value->SetString("id", extension->id()); |
117 value->SetString("name", extension->name()); | 119 value->SetString("name", extension->name()); |
118 value->SetString("description", extension->description()); | 120 value->SetString("description", extension->description()); |
119 value->SetString("launch_url", extension->GetFullLaunchURL().spec()); | 121 value->SetString("launch_url", extension->GetFullLaunchURL().spec()); |
120 if (enabled) | 122 if (enabled) |
121 value->SetString("options_url", extension->options_url().spec()); | 123 value->SetString("options_url", extension->options_url().spec()); |
122 value->SetBoolean("can_uninstall", | 124 value->SetBoolean("can_uninstall", |
123 Extension::UserMayDisable(extension->location())); | 125 Extension::UserMayDisable(extension->location())); |
124 value->SetString("icon_big", icon_big.spec()); | 126 value->SetString("icon_big", icon_big.spec()); |
| 127 value->SetBoolean("icon_big_exists", icon_big_exists); |
125 value->SetString("icon_small", icon_small.spec()); | 128 value->SetString("icon_small", icon_small.spec()); |
| 129 value->SetBoolean("icon_small_exists", icon_small_exists); |
126 value->SetInteger("launch_container", extension->launch_container()); | 130 value->SetInteger("launch_container", extension->launch_container()); |
127 ExtensionPrefs* prefs = service->extension_prefs(); | 131 ExtensionPrefs* prefs = service->extension_prefs(); |
128 value->SetInteger("launch_type", | 132 value->SetInteger("launch_type", |
129 prefs->GetLaunchType(extension->id(), | 133 prefs->GetLaunchType(extension->id(), |
130 ExtensionPrefs::LAUNCH_DEFAULT)); | 134 ExtensionPrefs::LAUNCH_DEFAULT)); |
131 value->SetBoolean("is_component", | 135 value->SetBoolean("is_component", |
132 extension->location() == Extension::COMPONENT); | 136 extension->location() == Extension::COMPONENT); |
133 value->SetBoolean("is_webstore", | 137 value->SetBoolean("is_webstore", |
134 extension->id() == extension_misc::kWebStoreAppId); | 138 extension->id() == extension_misc::kWebStoreAppId); |
135 | 139 |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 FaviconService* favicon_service = | 683 FaviconService* favicon_service = |
680 profile->GetFaviconService(Profile::EXPLICIT_ACCESS); | 684 profile->GetFaviconService(Profile::EXPLICIT_ACCESS); |
681 if (!favicon_service) { | 685 if (!favicon_service) { |
682 LOG(ERROR) << "No favicon service"; | 686 LOG(ERROR) << "No favicon service"; |
683 scoped_refptr<CrxInstaller> installer( | 687 scoped_refptr<CrxInstaller> installer( |
684 extensions_service_->MakeCrxInstaller(NULL)); | 688 extensions_service_->MakeCrxInstaller(NULL)); |
685 installer->InstallWebApp(*web_app); | 689 installer->InstallWebApp(*web_app); |
686 return; | 690 return; |
687 } | 691 } |
688 | 692 |
689 // TODO(gbillock): get page thumb from thumbnail db/history svc? | |
690 FaviconService::Handle h = favicon_service->GetFaviconForURL( | 693 FaviconService::Handle h = favicon_service->GetFaviconForURL( |
691 launch_url, history::FAVICON, &favicon_consumer_, | 694 launch_url, history::FAVICON, &favicon_consumer_, |
692 NewCallback(this, &AppLauncherHandler::OnFaviconForApp)); | 695 NewCallback(this, &AppLauncherHandler::OnFaviconForApp)); |
693 favicon_consumer_.SetClientData(favicon_service, h, web_app.release()); | 696 favicon_consumer_.SetClientData(favicon_service, h, web_app.release()); |
694 } | 697 } |
695 | 698 |
696 void AppLauncherHandler::OnFaviconForApp(FaviconService::Handle handle, | 699 void AppLauncherHandler::OnFaviconForApp(FaviconService::Handle handle, |
697 history::FaviconData data) { | 700 history::FaviconData data) { |
698 scoped_ptr<WebApplicationInfo> web_app( | 701 scoped_ptr<WebApplicationInfo> web_app( |
699 favicon_consumer_.GetClientDataForCurrentRequest()); | 702 favicon_consumer_.GetClientDataForCurrentRequest()); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 | 864 |
862 void AppLauncherHandler::UninstallDefaultApps() { | 865 void AppLauncherHandler::UninstallDefaultApps() { |
863 AppsPromo* apps_promo = extensions_service_->apps_promo(); | 866 AppsPromo* apps_promo = extensions_service_->apps_promo(); |
864 const ExtensionIdSet& app_ids = apps_promo->old_default_apps(); | 867 const ExtensionIdSet& app_ids = apps_promo->old_default_apps(); |
865 for (ExtensionIdSet::const_iterator iter = app_ids.begin(); | 868 for (ExtensionIdSet::const_iterator iter = app_ids.begin(); |
866 iter != app_ids.end(); ++iter) { | 869 iter != app_ids.end(); ++iter) { |
867 if (extensions_service_->GetExtensionById(*iter, true)) | 870 if (extensions_service_->GetExtensionById(*iter, true)) |
868 extensions_service_->UninstallExtension(*iter, false, NULL); | 871 extensions_service_->UninstallExtension(*iter, false, NULL); |
869 } | 872 } |
870 } | 873 } |
OLD | NEW |