Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Side by Side Diff: chrome/browser/ui/webui/ntp/app_launcher_handler.cc

Issue 7553020: Revert 94715 - Revert 94714 - Improve layout for bookmark-apps. Add treatment for small icons. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Merging to head Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/extension_icon_source.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 } 109 }
110 return false; 110 return false;
111 } 111 }
112 112
113 void AppLauncherHandler::CreateAppInfo(const Extension* extension, 113 void AppLauncherHandler::CreateAppInfo(const Extension* extension,
114 const AppNotification* notification, 114 const AppNotification* notification,
115 ExtensionService* service, 115 ExtensionService* service,
116 DictionaryValue* value) { 116 DictionaryValue* value) {
117 bool enabled = service->IsExtensionEnabled(extension->id()) && 117 bool enabled = service->IsExtensionEnabled(extension->id()) &&
118 !service->GetTerminatedExtension(extension->id()); 118 !service->GetTerminatedExtension(extension->id());
119 bool icon_big_exists = true;
119 GURL icon_big = 120 GURL icon_big =
120 ExtensionIconSource::GetIconURL(extension, 121 ExtensionIconSource::GetIconURL(extension,
121 Extension::EXTENSION_ICON_LARGE, 122 Extension::EXTENSION_ICON_LARGE,
122 ExtensionIconSet::MATCH_EXACTLY, 123 ExtensionIconSet::MATCH_EXACTLY,
123 !enabled); 124 !enabled, &icon_big_exists);
125 bool icon_small_exists = true;
124 GURL icon_small = 126 GURL icon_small =
125 ExtensionIconSource::GetIconURL(extension, 127 ExtensionIconSource::GetIconURL(extension,
126 Extension::EXTENSION_ICON_BITTY, 128 Extension::EXTENSION_ICON_BITTY,
127 ExtensionIconSet::MATCH_BIGGER, 129 ExtensionIconSet::MATCH_BIGGER,
128 !enabled); 130 !enabled, &icon_small_exists);
129 131
130 value->Clear(); 132 value->Clear();
131 value->SetString("id", extension->id()); 133 value->SetString("id", extension->id());
132 value->SetString("name", extension->name()); 134 value->SetString("name", extension->name());
133 value->SetString("description", extension->description()); 135 value->SetString("description", extension->description());
134 value->SetString("launch_url", extension->GetFullLaunchURL().spec()); 136 value->SetString("launch_url", extension->GetFullLaunchURL().spec());
135 if (enabled) 137 if (enabled)
136 value->SetString("options_url", extension->options_url().spec()); 138 value->SetString("options_url", extension->options_url().spec());
137 value->SetBoolean("can_uninstall", 139 value->SetBoolean("can_uninstall",
138 Extension::UserMayDisable(extension->location())); 140 Extension::UserMayDisable(extension->location()));
139 value->SetString("icon_big", icon_big.spec()); 141 value->SetString("icon_big", icon_big.spec());
142 value->SetBoolean("icon_big_exists", icon_big_exists);
140 value->SetString("icon_small", icon_small.spec()); 143 value->SetString("icon_small", icon_small.spec());
144 value->SetBoolean("icon_small_exists", icon_small_exists);
141 value->SetInteger("launch_container", extension->launch_container()); 145 value->SetInteger("launch_container", extension->launch_container());
142 ExtensionPrefs* prefs = service->extension_prefs(); 146 ExtensionPrefs* prefs = service->extension_prefs();
143 value->SetInteger("launch_type", 147 value->SetInteger("launch_type",
144 prefs->GetLaunchType(extension->id(), 148 prefs->GetLaunchType(extension->id(),
145 ExtensionPrefs::LAUNCH_DEFAULT)); 149 ExtensionPrefs::LAUNCH_DEFAULT));
146 value->SetBoolean("is_component", 150 value->SetBoolean("is_component",
147 extension->location() == Extension::COMPONENT); 151 extension->location() == Extension::COMPONENT);
148 value->SetBoolean("is_webstore", 152 value->SetBoolean("is_webstore",
149 extension->id() == extension_misc::kWebStoreAppId); 153 extension->id() == extension_misc::kWebStoreAppId);
150 154
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 CHECK(args->GetDouble(1, &page_index)); 682 CHECK(args->GetDouble(1, &page_index));
679 683
680 AutoReset<bool> auto_reset(&ignore_changes_, true); 684 AutoReset<bool> auto_reset(&ignore_changes_, true);
681 PrefService* prefs = web_ui_->GetProfile()->GetPrefs(); 685 PrefService* prefs = web_ui_->GetProfile()->GetPrefs();
682 ListPrefUpdate update(prefs, prefs::kNTPAppPageNames); 686 ListPrefUpdate update(prefs, prefs::kNTPAppPageNames);
683 ListValue* list = update.Get(); 687 ListValue* list = update.Get();
684 list->Set(static_cast<size_t>(page_index), Value::CreateStringValue(name)); 688 list->Set(static_cast<size_t>(page_index), Value::CreateStringValue(name));
685 } 689 }
686 690
687 void AppLauncherHandler::HandleGenerateAppForLink(const ListValue* args) { 691 void AppLauncherHandler::HandleGenerateAppForLink(const ListValue* args) {
688 string16 url; 692 std::string url;
689 CHECK(args->GetString(0, &url)); 693 CHECK(args->GetString(0, &url));
690 694
691 string16 title; 695 string16 title;
692 CHECK(args->GetString(1, &title)); 696 CHECK(args->GetString(1, &title));
693 697
694 GURL launch_url(url); 698 GURL launch_url(url);
695 699
696 scoped_ptr<WebApplicationInfo> web_app(new WebApplicationInfo); 700 scoped_ptr<WebApplicationInfo> web_app(new WebApplicationInfo);
697 web_app->is_bookmark_app = true; 701 web_app->is_bookmark_app = true;
698 web_app->title = title; 702 web_app->title = title;
699 web_app->app_url = launch_url; 703 web_app->app_url = launch_url;
700 WebApplicationInfo::IconInfo icon; 704 WebApplicationInfo::IconInfo icon;
701 icon.url = GURL(); 705 icon.url = GURL();
702 icon.width = icon.height = 16; 706 icon.width = icon.height = 16;
703 web_app->icons.push_back(icon); 707 web_app->icons.push_back(icon);
704 708
705 Profile* profile = web_ui_->GetProfile(); 709 Profile* profile = web_ui_->GetProfile();
706 FaviconService* favicon_service = 710 FaviconService* favicon_service =
707 profile->GetFaviconService(Profile::EXPLICIT_ACCESS); 711 profile->GetFaviconService(Profile::EXPLICIT_ACCESS);
708 if (!favicon_service) { 712 if (!favicon_service) {
709 LOG(ERROR) << "No favicon service"; 713 LOG(ERROR) << "No favicon service";
710 scoped_refptr<CrxInstaller> installer( 714 scoped_refptr<CrxInstaller> installer(
711 extension_service_->MakeCrxInstaller(NULL)); 715 extension_service_->MakeCrxInstaller(NULL));
712 installer->InstallWebApp(*web_app); 716 installer->InstallWebApp(*web_app);
713 return; 717 return;
714 } 718 }
715 719
716 // TODO(gbillock): get page thumb from thumbnail db/history svc?
717 FaviconService::Handle h = favicon_service->GetFaviconForURL( 720 FaviconService::Handle h = favicon_service->GetFaviconForURL(
718 launch_url, history::FAVICON, &favicon_consumer_, 721 launch_url, history::FAVICON, &favicon_consumer_,
719 NewCallback(this, &AppLauncherHandler::OnFaviconForApp)); 722 NewCallback(this, &AppLauncherHandler::OnFaviconForApp));
720 favicon_consumer_.SetClientData(favicon_service, h, web_app.release()); 723 favicon_consumer_.SetClientData(favicon_service, h, web_app.release());
721 } 724 }
722 725
723 void AppLauncherHandler::HandleRecordAppLaunchByURL( 726 void AppLauncherHandler::HandleRecordAppLaunchByURL(
724 const base::ListValue* args) { 727 const base::ListValue* args) {
725 std::string url; 728 std::string url;
726 CHECK(args->GetString(0, &url)); 729 CHECK(args->GetString(0, &url));
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 913
911 void AppLauncherHandler::UninstallDefaultApps() { 914 void AppLauncherHandler::UninstallDefaultApps() {
912 AppsPromo* apps_promo = extension_service_->apps_promo(); 915 AppsPromo* apps_promo = extension_service_->apps_promo();
913 const ExtensionIdSet& app_ids = apps_promo->old_default_apps(); 916 const ExtensionIdSet& app_ids = apps_promo->old_default_apps();
914 for (ExtensionIdSet::const_iterator iter = app_ids.begin(); 917 for (ExtensionIdSet::const_iterator iter = app_ids.begin();
915 iter != app_ids.end(); ++iter) { 918 iter != app_ids.end(); ++iter) {
916 if (extension_service_->GetExtensionById(*iter, true)) 919 if (extension_service_->GetExtensionById(*iter, true))
917 extension_service_->UninstallExtension(*iter, false, NULL); 920 extension_service_->UninstallExtension(*iter, false, NULL);
918 } 921 }
919 } 922 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/extension_icon_source.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698