From 37a1fd68c4366c1ad4d920620503a08f79e2c8f4 Mon Sep 17 00:00:00 2001 From: "asargent@chromium.org" Date: Fri, 29 Jul 2011 18:02:55 +0000 Subject: Revert 94714 - Improve layout for bookmark-apps. Add a treatment for small icons. BUG=none TEST=none Review URL: http://codereview.chromium.org/7452008 TBR=gbillock@chromium.org Review URL: http://codereview.chromium.org/7523058 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94715 0039d316-1c4b-4281-b951-d872f2087c98 --- .../browser/extensions/extension_management_api.cc | 2 +- chrome/browser/extensions/extensions_ui.cc | 2 +- chrome/browser/resources/ntp4/apps_page.css | 9 ------ chrome/browser/resources/ntp4/apps_page.js | 36 +++++----------------- chrome/browser/ui/webui/extension_icon_source.cc | 8 +---- chrome/browser/ui/webui/extension_icon_source.h | 7 ++--- .../browser/ui/webui/ntp/app_launcher_handler.cc | 9 ++---- 7 files changed, 15 insertions(+), 58 deletions(-) diff --git a/chrome/browser/extensions/extension_management_api.cc b/chrome/browser/extensions/extension_management_api.cc index e69a626..f0f01c1 100644 --- a/chrome/browser/extensions/extension_management_api.cc +++ b/chrome/browser/extensions/extension_management_api.cc @@ -87,7 +87,7 @@ static DictionaryValue* CreateExtensionInfo(const Extension& extension, DictionaryValue* icon_info = new DictionaryValue(); Extension::Icons size = static_cast(icon_iter->first); GURL url = ExtensionIconSource::GetIconURL( - &extension, size, ExtensionIconSet::MATCH_EXACTLY, false, NULL); + &extension, size, ExtensionIconSet::MATCH_EXACTLY, false); icon_info->SetInteger(kSizeKey, icon_iter->first); icon_info->SetString(kUrlKey, url.spec()); icon_list->Append(icon_info); diff --git a/chrome/browser/extensions/extensions_ui.cc b/chrome/browser/extensions/extensions_ui.cc index c74d07a..a5e9140 100644 --- a/chrome/browser/extensions/extensions_ui.cc +++ b/chrome/browser/extensions/extensions_ui.cc @@ -643,7 +643,7 @@ DictionaryValue* ExtensionsDOMHandler::CreateExtensionDetailValue( ExtensionIconSource::GetIconURL(extension, Extension::EXTENSION_ICON_MEDIUM, ExtensionIconSet::MATCH_BIGGER, - !enabled, NULL); + !enabled); extension_data->SetString("id", extension->id()); extension_data->SetString("name", extension->name()); extension_data->SetString("description", extension->description()); diff --git a/chrome/browser/resources/ntp4/apps_page.css b/chrome/browser/resources/ntp4/apps_page.css index 7562bde..ce4d6f7 100644 --- a/chrome/browser/resources/ntp4/apps_page.css +++ b/chrome/browser/resources/ntp4/apps_page.css @@ -26,15 +26,6 @@ -webkit-mask-size: 100% 100%; } -.app-icon-div { - border: 1px solid gray; - border-radius: 4px; - cursor: pointer; - display: -webkit-box; - vertical-align: middle; - -webkit-box-align: center; -} - .app-context-menu > button:first-child { font-weight: bold; } diff --git a/chrome/browser/resources/ntp4/apps_page.js b/chrome/browser/resources/ntp4/apps_page.js index e38590f..702c751 100644 --- a/chrome/browser/resources/ntp4/apps_page.js +++ b/chrome/browser/resources/ntp4/apps_page.js @@ -178,25 +178,15 @@ cr.define('ntp4', function() { this.className = 'app'; - if (!this.appData_.icon_big_exists && this.appData_.icon_small_exists) - this.useSmallIcon_ = true; - var appImg = this.ownerDocument.createElement('img'); - appImg.src = this.useSmallIcon_ ? this.appData_.icon_small : - this.appData_.icon_big; + appImg.src = this.appData_.icon_big; + // We use a mask of the same image so CSS rules can highlight just the + // image when it's touched. + appImg.style.WebkitMaskImage = url(this.appData_.icon_big); // We put a click handler just on the app image - so clicking on the // margins between apps doesn't do anything. appImg.addEventListener('click', this.onClick_.bind(this)); - if (this.useSmallIcon_) { - var imgDiv = this.ownerDocument.createElement('div'); - imgDiv.setAttribute('class', 'app-icon-div'); - imgDiv.appendChild(appImg); - imgDiv.addEventListener('click', this.onClick_.bind(this)); - this.imgDiv_ = imgDiv; - this.appendChild(imgDiv); - } else { - this.appendChild(appImg); - } + this.appendChild(appImg); this.appImg_ = appImg; var appSpan = this.ownerDocument.createElement('span'); @@ -216,20 +206,8 @@ cr.define('ntp4', function() { * animate. */ setBounds: function(size, x, y) { - if (this.useSmallIcon_) { - this.imgDiv_.style.width = (size * APP_IMG_SIZE_FRACTION) + 'px'; - this.imgDiv_.style.height = (size * APP_IMG_SIZE_FRACTION - 4) + 'px'; - this.appImg_.style.width = this.appImg_.style.height = '32px'; - var margin = (size - (size * APP_IMG_SIZE_FRACTION)) / 2; - this.imgDiv_.style['margin-left'] = margin + 'px'; - this.imgDiv_.style['margin-right'] = margin + 'px'; - this.imgDiv_.style['margin-bottom'] = '4px'; - } - else { - this.appImg_.style.width = this.appImg_.style.height = - (size * APP_IMG_SIZE_FRACTION) + 'px'; - } - + this.appImg_.style.width = this.appImg_.style.height = + (size * APP_IMG_SIZE_FRACTION) + 'px'; this.style.width = this.style.height = size + 'px'; this.style.left = x + 'px'; diff --git a/chrome/browser/ui/webui/extension_icon_source.cc b/chrome/browser/ui/webui/extension_icon_source.cc index 6a52ba6..78c7b27 100644 --- a/chrome/browser/ui/webui/extension_icon_source.cc +++ b/chrome/browser/ui/webui/extension_icon_source.cc @@ -75,16 +75,10 @@ ExtensionIconSource::~ExtensionIconSource() { GURL ExtensionIconSource::GetIconURL(const Extension* extension, Extension::Icons icon_size, ExtensionIconSet::MatchType match, - bool grayscale, - bool* exists) { - if (exists) - *exists = true; + bool grayscale) { if (extension->id() == extension_misc::kWebStoreAppId) return GURL("chrome://theme/IDR_WEBSTORE_ICON"); - if (exists && extension->GetIconURL(icon_size, match) == GURL()) - *exists = false; - GURL icon_url(base::StringPrintf("%s%s/%d/%d%s", chrome::kChromeUIExtensionIconURL, extension->id().c_str(), diff --git a/chrome/browser/ui/webui/extension_icon_source.h b/chrome/browser/ui/webui/extension_icon_source.h index 172cc9b..2d797c4 100644 --- a/chrome/browser/ui/webui/extension_icon_source.h +++ b/chrome/browser/ui/webui/extension_icon_source.h @@ -57,14 +57,11 @@ class ExtensionIconSource : public ChromeURLDataManager::DataSource, // Gets the URL of the |extension| icon in the given |size|, falling back // based on the |match| type. If |grayscale|, the URL will be for the - // desaturated version of the icon. |exists|, if non-NULL, will be set to true - // if the icon exists; false if it will lead to a default or not-present - // image. + // desaturated version of the icon. static GURL GetIconURL(const Extension* extension, Extension::Icons icon_size, ExtensionIconSet::MatchType match, - bool grayscale, - bool* exists); + bool grayscale); // A public utility function for accessing the bitmap of the image specified // by |resource_id|. diff --git a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc index 1c38ce3..1af426d 100644 --- a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc +++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc @@ -101,18 +101,16 @@ void AppLauncherHandler::CreateAppInfo(const Extension* extension, ExtensionService* service, DictionaryValue* value) { bool enabled = service->IsExtensionEnabled(extension->id()); - bool icon_big_exists = true; GURL icon_big = ExtensionIconSource::GetIconURL(extension, Extension::EXTENSION_ICON_LARGE, ExtensionIconSet::MATCH_EXACTLY, - !enabled, &icon_big_exists); - bool icon_small_exists = true; + !enabled); GURL icon_small = ExtensionIconSource::GetIconURL(extension, Extension::EXTENSION_ICON_BITTY, ExtensionIconSet::MATCH_BIGGER, - !enabled, &icon_small_exists); + !enabled); value->Clear(); value->SetString("id", extension->id()); @@ -124,9 +122,7 @@ void AppLauncherHandler::CreateAppInfo(const Extension* extension, value->SetBoolean("can_uninstall", Extension::UserMayDisable(extension->location())); value->SetString("icon_big", icon_big.spec()); - value->SetBoolean("icon_big_exists", icon_big_exists); value->SetString("icon_small", icon_small.spec()); - value->SetBoolean("icon_small_exists", icon_small_exists); value->SetInteger("launch_container", extension->launch_container()); ExtensionPrefs* prefs = service->extension_prefs(); value->SetInteger("launch_type", @@ -688,6 +684,7 @@ void AppLauncherHandler::HandleGenerateAppForLink(const ListValue* args) { return; } + // TODO(gbillock): get page thumb from thumbnail db/history svc? FaviconService::Handle h = favicon_service->GetFaviconForURL( launch_url, history::FAVICON, &favicon_consumer_, NewCallback(this, &AppLauncherHandler::OnFaviconForApp)); -- cgit v1.1