summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/app/theme/extension_default_icon.png (renamed from chrome/browser/resources/extension_default_icon.png)bin3932 -> 3932 bytes
-rw-r--r--chrome/app/theme/theme_resources.grd1
-rw-r--r--chrome/browser/browser_resources.grd1
-rw-r--r--chrome/browser/dom_ui/app_launcher_handler.cc28
-rw-r--r--chrome/browser/dom_ui/dom_ui_favicon_source.cc21
-rw-r--r--chrome/browser/dom_ui/dom_ui_favicon_source.h3
-rw-r--r--chrome/browser/extensions/crx_installer.cc2
-rw-r--r--chrome/browser/extensions/extension_install_ui.cc1
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.cc2
-rw-r--r--chrome/browser/resources/new_new_tab.css16
-rw-r--r--chrome/browser/resources/new_new_tab.html2
-rw-r--r--chrome/browser/resources/new_new_tab.js12
-rw-r--r--chrome/browser/resources/new_tab_theme.css2
-rw-r--r--chrome/browser/resources/ntp/apps.css4
-rw-r--r--chrome/browser/resources/ntp/apps.js26
-rw-r--r--chrome/browser/resources/ntp/most_visited.js18
-rw-r--r--chrome/common/extensions/extension.cc10
-rw-r--r--chrome/common/extensions/extension.h5
18 files changed, 112 insertions, 42 deletions
diff --git a/chrome/browser/resources/extension_default_icon.png b/chrome/app/theme/extension_default_icon.png
index 31aaf05..31aaf05 100644
--- a/chrome/browser/resources/extension_default_icon.png
+++ b/chrome/app/theme/extension_default_icon.png
Binary files differ
diff --git a/chrome/app/theme/theme_resources.grd b/chrome/app/theme/theme_resources.grd
index 27ba62a7..24c7f53 100644
--- a/chrome/app/theme/theme_resources.grd
+++ b/chrome/app/theme/theme_resources.grd
@@ -139,6 +139,7 @@
<include name="IDR_DOWNLOAD_PROGRESS_BACKGROUND_32" file="download_progress_background32.png" type="BINDATA" />
<include name="IDR_DOWNLOAD_PROGRESS_FOREGROUND_16" file="download_progress_foreground16.png" type="BINDATA" />
<include name="IDR_DOWNLOAD_PROGRESS_FOREGROUND_32" file="download_progress_foreground32.png" type="BINDATA" />
+ <include name="IDR_EXTENSION_DEFAULT_ICON" file="extension_default_icon.png" type="BINDATA" />
<include name="IDR_EXTENSIONS_SECTION" file="extensions_section.png" type="BINDATA" />
<include name="IDR_FINDINPAGE_NEXT" file="find_next.png" type="BINDATA" />
<include name="IDR_FINDINPAGE_NEXT_H" file="find_next_h.png" type="BINDATA" />
diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd
index 613418c..d6f6f1b 100644
--- a/chrome/browser/browser_resources.grd
+++ b/chrome/browser/browser_resources.grd
@@ -28,7 +28,6 @@ without changes to the corresponding grd file. eadeae-->
<include name="IDR_CREDITS_HTML" file="resources\about_credits.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_DOCS_APP_MANIFEST" file="resources\docs_app\manifest.json" type="BINDATA" />
<include name="IDR_DOWNLOADS_HTML" file="resources\downloads.html" flattenhtml="true" type="BINDATA" />
- <include name="IDR_EXTENSION_DEFAULT_ICON" file="resources\extension_default_icon.png" type="BINDATA" />
<if expr="os == 'darwin'">
<include name="IDR_EXTENSIONS_INFOBAR_CSS" file="resources\extensions_infobar_mac.css" flattenhtml="true" type="BINDATA" />
</if>
diff --git a/chrome/browser/dom_ui/app_launcher_handler.cc b/chrome/browser/dom_ui/app_launcher_handler.cc
index 1592528..2d3dee6 100644
--- a/chrome/browser/dom_ui/app_launcher_handler.cc
+++ b/chrome/browser/dom_ui/app_launcher_handler.cc
@@ -39,6 +39,15 @@ bool ExtractInt(const ListValue* list, size_t index, int* out_int) {
return false;
}
+std::string GetIconURL(Extension* extension, Extension::Icons icon,
+ const std::string& default_val) {
+ GURL url = extension->GetIconURL(icon);
+ if (!url.is_empty())
+ return url.spec();
+ else
+ return default_val;
+}
+
} // namespace
AppLauncherHandler::AppLauncherHandler(ExtensionsService* extension_service)
@@ -86,18 +95,13 @@ void AppLauncherHandler::CreateAppInfo(Extension* extension,
value->SetString("launch_url", extension->GetFullLaunchURL().spec());
value->SetString("options_url", extension->options_url().spec());
- FilePath relative_path =
- extension->GetIconResource(
- Extension::EXTENSION_ICON_LARGE).relative_path();
-
-#if defined(OS_POSIX)
- std::string path = relative_path.value();
-#elif defined(OS_WIN)
- std::string path = WideToUTF8(relative_path.value());
-#endif // OS_WIN
-
- GURL icon_url = extension->GetResourceURL(path);
- value->SetString("icon", icon_url.spec());
+ // TODO(aa): Need a better default icon for apps.
+ value->SetString("icon_big", GetIconURL(
+ extension, Extension::EXTENSION_ICON_LARGE,
+ "chrome://theme/IDR_EXTENSION_DEFAULT_ICON"));
+ value->SetString("icon_small", GetIconURL(
+ extension, Extension::EXTENSION_ICON_BITTY,
+ std::string("chrome://favicon/") + extension->GetFullLaunchURL().spec()));
}
void AppLauncherHandler::HandleGetApps(const ListValue* args) {
diff --git a/chrome/browser/dom_ui/dom_ui_favicon_source.cc b/chrome/browser/dom_ui/dom_ui_favicon_source.cc
index 5a52346..55818a3 100644
--- a/chrome/browser/dom_ui/dom_ui_favicon_source.cc
+++ b/chrome/browser/dom_ui/dom_ui_favicon_source.cc
@@ -26,6 +26,11 @@ void DOMUIFavIconSource::StartDataRequest(const std::string& path,
profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
if (favicon_service) {
FaviconService::Handle handle;
+ if (path.empty()) {
+ SendDefaultResponse(request_id);
+ return;
+ }
+
if (path.size() > 8 && path.substr(0, 8) == "iconurl/") {
handle = favicon_service->GetFavicon(
GURL(path.substr(8)),
@@ -65,12 +70,16 @@ void DOMUIFavIconSource::OnFavIconDataAvailable(
// Forward the data along to the networking system.
SendResponse(request_id, data);
} else {
- if (!default_favicon_.get()) {
- default_favicon_ =
- ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
- IDR_DEFAULT_FAVICON);
- }
+ SendDefaultResponse(request_id);
+ }
+}
- SendResponse(request_id, default_favicon_);
+void DOMUIFavIconSource::SendDefaultResponse(int request_id) {
+ if (!default_favicon_.get()) {
+ default_favicon_ =
+ ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
+ IDR_DEFAULT_FAVICON);
}
+
+ SendResponse(request_id, default_favicon_);
}
diff --git a/chrome/browser/dom_ui/dom_ui_favicon_source.h b/chrome/browser/dom_ui/dom_ui_favicon_source.h
index 7878fd2..84c29fc 100644
--- a/chrome/browser/dom_ui/dom_ui_favicon_source.h
+++ b/chrome/browser/dom_ui/dom_ui_favicon_source.h
@@ -38,6 +38,9 @@ class DOMUIFavIconSource : public ChromeURLDataManager::DataSource {
GURL url);
private:
+ // Sends the default favicon.
+ void SendDefaultResponse(int request_id);
+
virtual ~DOMUIFavIconSource();
Profile* profile_;
diff --git a/chrome/browser/extensions/crx_installer.cc b/chrome/browser/extensions/crx_installer.cc
index fc5a6f1..ad4a4cc 100644
--- a/chrome/browser/extensions/crx_installer.cc
+++ b/chrome/browser/extensions/crx_installer.cc
@@ -25,9 +25,9 @@
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/notification_type.h"
-#include "grit/browser_resources.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
+#include "grit/theme_resources.h"
#include "third_party/skia/include/core/SkBitmap.h"
namespace {
diff --git a/chrome/browser/extensions/extension_install_ui.cc b/chrome/browser/extensions/extension_install_ui.cc
index 4586cce..17bdcc5 100644
--- a/chrome/browser/extensions/extension_install_ui.cc
+++ b/chrome/browser/extensions/extension_install_ui.cc
@@ -32,7 +32,6 @@
#include "chrome/common/extensions/url_pattern.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/url_constants.h"
-#include "grit/browser_resources.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index b4727c7..0a27032 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.cc
+++ b/chrome/browser/renderer_host/browser_render_process_host.cc
@@ -671,7 +671,7 @@ void BrowserRenderProcessHost::SendExtensionInfo() {
info.web_extent = extension->web_extent();
info.name = extension->name();
info.icon_url =
- extension->GetIconUrlAllowLargerSize(Extension::EXTENSION_ICON_MEDIUM);
+ extension->GetIconURLAllowLargerSize(Extension::EXTENSION_ICON_MEDIUM);
params.extensions.push_back(info);
}
diff --git a/chrome/browser/resources/new_new_tab.css b/chrome/browser/resources/new_new_tab.css
index edf9612..5f27622 100644
--- a/chrome/browser/resources/new_new_tab.css
+++ b/chrome/browser/resources/new_new_tab.css
@@ -134,7 +134,6 @@ html[anim=false] *,
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
- text-decoration: none;
font-size: 100%;
}
@@ -194,10 +193,6 @@ html[dir=rtl] .item {
-webkit-box-orient: horizontal;
}
-#most-visited {
- margin-bottom: 20px;
-}
-
#sync-status {
display: none;
border-radius: 6px;
@@ -334,7 +329,13 @@ html[dir=rtl] #option-menu > [command=hide]:before {
}
.section > div {
- margin-bottom: 10px;
+ margin-bottom: 15px;
+}
+
+#apps-section-content {
+ /* This one is special because the app buttons already have a lot of empty
+ space around them. */
+ margin-bottom: 5px;
}
.section > h2 {
@@ -368,6 +369,9 @@ html[dir=rtl] #option-menu > [command=hide]:before {
.section > .miniview {
display: none;
+ /* Because the items have 10px horizontal margins. */
+ margin-left:-10px;
+ margin-right:-10px;
}
.section.hidden > * {
diff --git a/chrome/browser/resources/new_new_tab.html b/chrome/browser/resources/new_new_tab.html
index 6b60be9..cf93d2d 100644
--- a/chrome/browser/resources/new_new_tab.html
+++ b/chrome/browser/resources/new_new_tab.html
@@ -144,12 +144,14 @@ if ('mode' in hashParams) {
<h2><img src="ntp/ntp_disclosure_triangle.png"
><span i18n-content="apps"></span></h2>
<div id="apps-section-content"></div>
+ <div class="miniview"></div>
</div>
<div id="most-visited-section" class="section" section="THUMB">
<h2><img src="ntp/ntp_disclosure_triangle.png"
><span i18n-content="mostvisited"></span></h2>
<div id="most-visited"></div>
+ <div class="miniview"></div>
</div>
<!-- Start this section disabled because it might not have data, and looks
diff --git a/chrome/browser/resources/new_new_tab.js b/chrome/browser/resources/new_new_tab.js
index a03969a..2255005 100644
--- a/chrome/browser/resources/new_new_tab.js
+++ b/chrome/browser/resources/new_new_tab.js
@@ -2,6 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// To avoid creating tons of unnecessary nodes. We assume we cannot fit more
+// than this many items in the miniview.
+var MAX_MINIVIEW_ITEMS = 15;
+
var loading = true;
function updateSimpleSection(id, section) {
@@ -872,9 +876,11 @@ function fixLinkUnderline(el) {
updateAttribution();
-var mostVisited = new MostVisited($('most-visited'),
- useSmallGrid(),
- shownSections & Section.THUMB);
+var mostVisited = new MostVisited(
+ $('most-visited'),
+ $('most-visited-section').getElementsByClassName('miniview')[0],
+ useSmallGrid(),
+ shownSections & Section.THUMB);
function mostVisitedPages(data, firstRun) {
logEvent('received most visited pages');
diff --git a/chrome/browser/resources/new_tab_theme.css b/chrome/browser/resources/new_tab_theme.css
index d37693a..40225de 100644
--- a/chrome/browser/resources/new_tab_theme.css
+++ b/chrome/browser/resources/new_tab_theme.css
@@ -124,7 +124,7 @@ body {
background: $2; /* COLOR_NTP_BACKGROUND */
}
-#apps-section a {
+#apps-section .app a {
color: $8; /* COLOR_NTP_TEXT */
}
diff --git a/chrome/browser/resources/ntp/apps.css b/chrome/browser/resources/ntp/apps.css
index 3acaedd..5398044 100644
--- a/chrome/browser/resources/ntp/apps.css
+++ b/chrome/browser/resources/ntp/apps.css
@@ -65,7 +65,7 @@
.app > .front > .flip:hover {
-webkit-transition: none;
- background-image: url(chrome://theme/IDR_BALLOON_WRENCH_HOVER);
+ background-image: url(chrome://theme/IDR_BALLOON_WRENCH_H);
}
.app:hover > .front > .flip,
@@ -122,7 +122,7 @@
-webkit-transition: opacity .5s;
}
-#web-store-entry {
+a[app_id=web-store-entry] {
background-image: url("web_store_icon.png");
}
diff --git a/chrome/browser/resources/ntp/apps.js b/chrome/browser/resources/ntp/apps.js
index 64b490f..61712e4 100644
--- a/chrome/browser/resources/ntp/apps.js
+++ b/chrome/browser/resources/ntp/apps.js
@@ -6,13 +6,19 @@ function getAppsCallback(data) {
logEvent('recieved apps');
var appsSection = $('apps-section');
var appsSectionContent = $('apps-section-content');
+ var appsMiniview = appsSection.getElementsByClassName('miniview')[0];
appsSectionContent.textContent = '';
+ appsMiniview.textContent = '';
data.apps.forEach(function(app) {
appsSectionContent.appendChild(apps.createElement(app));
});
appsSectionContent.appendChild(apps.createWebStoreElement());
+
+ data.apps.slice(0, MAX_MINIVIEW_ITEMS).forEach(function(app) {
+ appsMiniview.appendChild(apps.createMiniviewElement(app));
+ });
}
var apps = {
@@ -41,7 +47,7 @@ var apps = {
var left = rect.left + ((rect.width - width) >> 1); // Integer divide by 2.
var top = rect.top + parseInt(cs.backgroundPositionY, 10);
- chrome.send('launchApp', [this.id, launchType,
+ chrome.send('launchApp', [this.getAttribute("app_id"), launchType,
String(left), String(top),
String(width), String(height)]);
return false;
@@ -55,7 +61,7 @@ var apps = {
front.className = 'front';
var a = front.appendChild(document.createElement('a'));
- a.id = app['id'];
+ a.setAttribute('app_id', app['id']);
a.xtitle = a.textContent = app['name'];
a.href = app['launch_url'];
@@ -68,7 +74,7 @@ var apps = {
var a = front.firstChild;
a.onclick = apps.handleClick_;
- a.style.backgroundImage = url(app['icon']);
+ a.style.backgroundImage = url(app['icon_big']);
if (hashParams['app-id'] == app['id']) {
div.setAttribute('new', 'new');
// Delay changing the attribute a bit to let the page settle down a bit.
@@ -111,6 +117,20 @@ var apps = {
return div;
},
+ createMiniviewElement: function(app) {
+ var span = document.createElement('span');
+ var a = span.appendChild(document.createElement('a'));
+
+ a.setAttribute('app_id', app['id']);
+ a.textContent = app['name'];
+ a.href = app['launch_url'];
+ a.onclick = apps.handleClick_;
+ a.style.backgroundImage = url(app['icon_small']);
+ a.className = 'item';
+ span.appendChild(a);
+ return span;
+ },
+
createWebStoreElement: function() {
return this.createElement_({
'id': 'web-store-entry',
diff --git a/chrome/browser/resources/ntp/most_visited.js b/chrome/browser/resources/ntp/most_visited.js
index 23ea4b2..acb0200 100644
--- a/chrome/browser/resources/ntp/most_visited.js
+++ b/chrome/browser/resources/ntp/most_visited.js
@@ -41,8 +41,9 @@ var MostVisited = (function() {
return Array.prototype.indexOf.call(nodes, el);
}
- function MostVisited(el, useSmallGrid, visible) {
+ function MostVisited(el, miniview, useSmallGrid, visible) {
this.element = el;
+ this.miniview = miniview;
this.useSmallGrid_ = useSmallGrid;
this.visible_ = visible;
@@ -501,6 +502,7 @@ var MostVisited = (function() {
// On setting we need to update the items
this.data_ = data;
this.updateMostVisited_();
+ this.updateMiniview_();
},
updateMostVisited_: function() {
@@ -555,6 +557,20 @@ var MostVisited = (function() {
}
},
+ updateMiniview_: function() {
+ this.miniview.textContent = '';
+ var data = this.data.slice(0, MAX_MINIVIEW_ITEMS);
+ for (var i = 0, item; item = data[i]; i++) {
+ var span = document.createElement('span');
+ var a = span.appendChild(document.createElement('a'));
+ a.href = item.url;
+ a.textContent = item.title;
+ a.style.backgroundImage = url('chrome://favicon/' + item.url);
+ a.className = 'item';
+ this.miniview.appendChild(span);
+ }
+ },
+
handleClick_: function(e) {
var target = e.target;
if (target.classList.contains('pin')) {
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index 728006c..0a0a9c4 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -1704,7 +1704,15 @@ Extension::Icons Extension::GetIconResourceAllowLargerSize(
return ret;
}
-GURL Extension::GetIconUrlAllowLargerSize(Icons icon) {
+GURL Extension::GetIconURL(Icons icon) {
+ std::string path = GetIconPath(icon);
+ if (path.empty())
+ return GURL();
+ else
+ return GetResourceURL(path);
+}
+
+GURL Extension::GetIconURLAllowLargerSize(Icons icon) {
std::string path;
GetIconPathAllowLargerSize(&path, icon);
return GetResourceURL(path);
diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h
index e9a25cc..f8c977d9 100644
--- a/chrome/common/extensions/extension.h
+++ b/chrome/common/extensions/extension.h
@@ -332,9 +332,8 @@ class Extension {
// NOTE: |resource| is not guaranteed to be non-empty.
Icons GetIconResourceAllowLargerSize(ExtensionResource* resource, Icons icon);
- // See GetIconPathAllowLargerSize. Returns a chrome-extension:// URL
- // instead of an ExtensionResource.
- GURL GetIconUrlAllowLargerSize(Icons icon);
+ GURL GetIconURL(Icons icon);
+ GURL GetIconURLAllowLargerSize(Icons icon);
const DictionaryValue* manifest_value() const {
return manifest_value_.get();