| 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 | 137 |
| 134 if (notification) | 138 if (notification) |
| 135 value->Set("notification", SerializeNotification(*notification)); | 139 value->Set("notification", SerializeNotification(*notification)); |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 FaviconService* favicon_service = | 681 FaviconService* favicon_service = |
| 678 profile->GetFaviconService(Profile::EXPLICIT_ACCESS); | 682 profile->GetFaviconService(Profile::EXPLICIT_ACCESS); |
| 679 if (!favicon_service) { | 683 if (!favicon_service) { |
| 680 LOG(ERROR) << "No favicon service"; | 684 LOG(ERROR) << "No favicon service"; |
| 681 scoped_refptr<CrxInstaller> installer( | 685 scoped_refptr<CrxInstaller> installer( |
| 682 extensions_service_->MakeCrxInstaller(NULL)); | 686 extensions_service_->MakeCrxInstaller(NULL)); |
| 683 installer->InstallWebApp(*web_app); | 687 installer->InstallWebApp(*web_app); |
| 684 return; | 688 return; |
| 685 } | 689 } |
| 686 | 690 |
| 687 // TODO(gbillock): get page thumb from thumbnail db/history svc? | |
| 688 FaviconService::Handle h = favicon_service->GetFaviconForURL( | 691 FaviconService::Handle h = favicon_service->GetFaviconForURL( |
| 689 launch_url, history::FAVICON, &favicon_consumer_, | 692 launch_url, history::FAVICON, &favicon_consumer_, |
| 690 NewCallback(this, &AppLauncherHandler::OnFaviconForApp)); | 693 NewCallback(this, &AppLauncherHandler::OnFaviconForApp)); |
| 691 favicon_consumer_.SetClientData(favicon_service, h, web_app.release()); | 694 favicon_consumer_.SetClientData(favicon_service, h, web_app.release()); |
| 692 } | 695 } |
| 693 | 696 |
| 694 void AppLauncherHandler::OnFaviconForApp(FaviconService::Handle handle, | 697 void AppLauncherHandler::OnFaviconForApp(FaviconService::Handle handle, |
| 695 history::FaviconData data) { | 698 history::FaviconData data) { |
| 696 scoped_ptr<WebApplicationInfo> web_app( | 699 scoped_ptr<WebApplicationInfo> web_app( |
| 697 favicon_consumer_.GetClientDataForCurrentRequest()); | 700 favicon_consumer_.GetClientDataForCurrentRequest()); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 | 862 |
| 860 void AppLauncherHandler::UninstallDefaultApps() { | 863 void AppLauncherHandler::UninstallDefaultApps() { |
| 861 AppsPromo* apps_promo = extensions_service_->apps_promo(); | 864 AppsPromo* apps_promo = extensions_service_->apps_promo(); |
| 862 const ExtensionIdSet& app_ids = apps_promo->old_default_apps(); | 865 const ExtensionIdSet& app_ids = apps_promo->old_default_apps(); |
| 863 for (ExtensionIdSet::const_iterator iter = app_ids.begin(); | 866 for (ExtensionIdSet::const_iterator iter = app_ids.begin(); |
| 864 iter != app_ids.end(); ++iter) { | 867 iter != app_ids.end(); ++iter) { |
| 865 if (extensions_service_->GetExtensionById(*iter, true)) | 868 if (extensions_service_->GetExtensionById(*iter, true)) |
| 866 extensions_service_->UninstallExtension(*iter, false, NULL); | 869 extensions_service_->UninstallExtension(*iter, false, NULL); |
| 867 } | 870 } |
| 868 } | 871 } |
| OLD | NEW |