diff options
author | calamity@chromium.org <calamity@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-23 17:20:54 +0000 |
---|---|---|
committer | calamity@chromium.org <calamity@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-23 17:20:54 +0000 |
commit | 2e1db17f6cf6eb141e9fb3e7cd39d1801b682ca3 (patch) | |
tree | e09738ed6d0bdd44460cd9fbaf64c47ff0c2528b | |
parent | 0ea4fa665f6ea0816dc6b390ac7d7bffe0a3950c (diff) | |
download | chromium_src-2e1db17f6cf6eb141e9fb3e7cd39d1801b682ca3.zip chromium_src-2e1db17f6cf6eb141e9fb3e7cd39d1801b682ca3.tar.gz chromium_src-2e1db17f6cf6eb141e9fb3e7cd39d1801b682ca3.tar.bz2 |
Move the local NTP images into chrome/app/theme
This CL moves the local ntp images into chrome/app/theme and makes them
part of theme_resources.grd rather than browser_resources.grd. This will
allow the local ntp to use the correct scale factor for its logo and
lets these images be accessed via chrome://theme which will be used in
the experimental app list start page.
This CL adds a 1x image as none existed. This will need to be looked at
by a UI person and updated if necessary.
The addition binaries was landed in
https://codereview.chromium.org/248843002/ .
BUG=349727
Review URL: https://codereview.chromium.org/209663003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@265674 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/theme/theme_resources.grd | 4 | ||||
-rw-r--r-- | chrome/browser/browser_resources.grd | 2 | ||||
-rw-r--r-- | chrome/browser/resources/local_ntp/images/2x/ntp_google_logo.png | bin | 13823 -> 0 bytes | |||
-rw-r--r-- | chrome/browser/resources/local_ntp/images/2x/ntp_white_google_logo.png | bin | 6179 -> 0 bytes | |||
-rw-r--r-- | chrome/browser/resources/local_ntp/local_ntp.css | 6 | ||||
-rw-r--r-- | chrome/browser/search/local_ntp_source.cc | 28 |
6 files changed, 27 insertions, 13 deletions
diff --git a/chrome/app/theme/theme_resources.grd b/chrome/app/theme/theme_resources.grd index d3b513c..31e0efa 100644 --- a/chrome/app/theme/theme_resources.grd +++ b/chrome/app/theme/theme_resources.grd @@ -439,6 +439,10 @@ <if expr="enable_service_discovery"> <structure type="chrome_scaled_image" name="IDR_LOCAL_DISCOVERY_CLOUDPRINT_ICON" file="common/cloudprint.png" /> </if> + <!-- TODO(calamity): The 1x local ntp resources require a proper version. + See crbug.com/363519. --> + <structure type="chrome_scaled_image" name="IDR_LOCAL_NTP_IMAGES_LOGO_PNG" file="common/ntp_google_logo.png" /> + <structure type="chrome_scaled_image" name="IDR_LOCAL_NTP_IMAGES_WHITE_LOGO_PNG" file="common/ntp_white_google_logo.png" /> <structure type="chrome_scaled_image" name="IDR_LOCATION_BAR_HTTP" file="common/location_bar_http.png" /> <if expr="chromeos"> <!-- TODO(nkostylev): This resource needs to be removed when cros login code is moved to ash. --> diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd index 5a9ded1..2e420a2 100644 --- a/chrome/browser/browser_resources.grd +++ b/chrome/browser/browser_resources.grd @@ -193,8 +193,6 @@ <include name="IDR_LOCAL_NTP_HTML" file="resources\local_ntp\local_ntp.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" /> <include name="IDR_LOCAL_NTP_CSS" file="resources\local_ntp\local_ntp.css" type="BINDATA" /> <include name="IDR_LOCAL_NTP_JS" file="resources\local_ntp\local_ntp.js" flattenhtml="true" type="BINDATA" /> - <include name="IDR_LOCAL_NTP_IMAGES_2X_LOGO_PNG" file="resources\local_ntp\images\2x\ntp_google_logo.png" type="BINDATA" /> - <include name="IDR_LOCAL_NTP_IMAGES_2X_WHITE_LOGO_PNG" file="resources\local_ntp\images\2x\ntp_white_google_logo.png" type="BINDATA" /> <include name="IDR_MOST_VISITED_IFRAME_CSS" file="resources\local_ntp\most_visited_iframe.css" type="BINDATA" /> <include name="IDR_MOST_VISITED_TITLE_HTML" file="resources\local_ntp\most_visited_title.html" type="BINDATA" /> <include name="IDR_MOST_VISITED_TITLE_CSS" file="resources\local_ntp\most_visited_title.css" type="BINDATA" /> diff --git a/chrome/browser/resources/local_ntp/images/2x/ntp_google_logo.png b/chrome/browser/resources/local_ntp/images/2x/ntp_google_logo.png Binary files differdeleted file mode 100644 index 53a1e20..0000000 --- a/chrome/browser/resources/local_ntp/images/2x/ntp_google_logo.png +++ /dev/null diff --git a/chrome/browser/resources/local_ntp/images/2x/ntp_white_google_logo.png b/chrome/browser/resources/local_ntp/images/2x/ntp_white_google_logo.png Binary files differdeleted file mode 100644 index 4b3ac3e..0000000 --- a/chrome/browser/resources/local_ntp/images/2x/ntp_white_google_logo.png +++ /dev/null diff --git a/chrome/browser/resources/local_ntp/local_ntp.css b/chrome/browser/resources/local_ntp/local_ntp.css index c151464..cdc6ae4 100644 --- a/chrome/browser/resources/local_ntp/local_ntp.css +++ b/chrome/browser/resources/local_ntp/local_ntp.css @@ -36,7 +36,9 @@ body.fakebox-disable #fakebox > input { } #logo { - background-image: url(images/2x/google_logo.png); + background-image: -webkit-image-set( + url('images/google_logo.png') 1x, + url('images/google_logo.png@2x') 2x); background-repeat: no-repeat; background-size: 269px 95px; height: 95px; @@ -46,7 +48,7 @@ body.fakebox-disable #fakebox > input { } body.alternate-logo #logo { - background-image: url(images/2x/white_google_logo.png); + background-image: url(images/white_google_logo.png); } #fakebox { diff --git a/chrome/browser/search/local_ntp_source.cc b/chrome/browser/search/local_ntp_source.cc index 8944ac3..f6f649c 100644 --- a/chrome/browser/search/local_ntp_source.cc +++ b/chrome/browser/search/local_ntp_source.cc @@ -19,11 +19,13 @@ #include "chrome/common/url_constants.h" #include "grit/browser_resources.h" #include "grit/generated_resources.h" +#include "grit/theme_resources.h" #include "grit/ui_resources.h" #include "net/url_request/url_request.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" #include "ui/base/webui/jstemplate_builder.h" +#include "ui/base/webui/web_ui_util.h" #include "url/gurl.h" namespace { @@ -46,10 +48,9 @@ const struct Resource{ { "images/close_2_hover.png", IDR_CLOSE_2_H, "image/png" }, { "images/close_2_active.png", IDR_CLOSE_2_P, "image/png" }, { "images/close_2_white.png", IDR_CLOSE_2_MASK, "image/png" }, - { "images/2x/google_logo.png", - IDR_LOCAL_NTP_IMAGES_2X_LOGO_PNG, "image/png" }, - { "images/2x/white_google_logo.png", - IDR_LOCAL_NTP_IMAGES_2X_WHITE_LOGO_PNG, "image/png" }, + { "images/google_logo.png", IDR_LOCAL_NTP_IMAGES_LOGO_PNG, "image/png" }, + { "images/white_google_logo.png", + IDR_LOCAL_NTP_IMAGES_WHITE_LOGO_PNG, "image/png" }, }; // Strips any query parameters from the specified path. @@ -120,6 +121,11 @@ std::string GetConfigData(Profile* profile) { return config_data_js; } +std::string GetLocalNtpPath() { + return std::string(chrome::kChromeSearchScheme) + "://" + + std::string(chrome::kChromeSearchLocalNtpHost) + "/"; +} + } // namespace LocalNtpSource::LocalNtpSource(Profile* profile) : profile_(profile) { @@ -143,11 +149,15 @@ void LocalNtpSource::StartDataRequest( callback.Run(base::RefCountedString::TakeString(&config_data_js)); return; } + ui::ScaleFactor scale_factor; + std::string filename; + webui::ParsePathAndScale( + GURL(GetLocalNtpPath() + stripped_path), &filename, &scale_factor); for (size_t i = 0; i < arraysize(kResources); ++i) { - if (stripped_path == kResources[i].filename) { + if (filename == kResources[i].filename) { scoped_refptr<base::RefCountedStaticMemory> response( - ResourceBundle::GetSharedInstance().LoadDataResourceBytes( - kResources[i].identifier)); + ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale( + kResources[i].identifier, scale_factor)); callback.Run(response.get()); return; } @@ -172,8 +182,8 @@ bool LocalNtpSource::ShouldServiceRequest( return false; if (request->url().SchemeIs(chrome::kChromeSearchScheme)) { - DCHECK(StartsWithASCII(request->url().path(), "/", true)); - std::string filename = request->url().path().substr(1); + std::string filename; + webui::ParsePathAndScale(request->url(), &filename, NULL); for (size_t i = 0; i < arraysize(kResources); ++i) { if (filename == kResources[i].filename) return true; |