diff options
109 files changed, 662 insertions, 424 deletions
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc index c068a56..5f81728 100644 --- a/chrome/browser/chrome_browser_main.cc +++ b/chrome/browser/chrome_browser_main.cc @@ -427,7 +427,7 @@ void InitializeGpuDataManager(const CommandLine& parsed_command_line) { const base::StringPiece gpu_blacklist_json( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_GPU_BLACKLIST)); + IDR_GPU_BLACKLIST, ui::SCALE_FACTOR_NONE)); GpuBlacklist* gpu_blacklist = GpuBlacklist::GetInstance(); bool succeed = gpu_blacklist->LoadGpuBlacklist( gpu_blacklist_json.as_string(), GpuBlacklist::kCurrentOsOnly); @@ -1303,7 +1303,7 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() { FilePath resources_pack_path; PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); ResourceBundle::GetSharedInstance().AddDataPack( - resources_pack_path, ui::ResourceHandle::kScaleFactor100x); + resources_pack_path, ui::SCALE_FACTOR_100P); #endif // defined(OS_MACOSX) } diff --git a/chrome/browser/chrome_browser_main_mac.mm b/chrome/browser/chrome_browser_main_mac.mm index 718c86f..54560b1 100644 --- a/chrome/browser/chrome_browser_main_mac.mm +++ b/chrome/browser/chrome_browser_main_mac.mm @@ -138,7 +138,7 @@ void ChromeBrowserMainPartsMac::PreMainMessageLoopStart() { FilePath resources_pack_path; PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); ResourceBundle::GetSharedInstance().AddDataPack( - resources_pack_path, ui::ResourceHandle::kScaleFactor100x); + resources_pack_path, ui::SCALE_FACTOR_100P); } // This is a no-op if the KeystoneRegistration framework is not present. diff --git a/chrome/browser/chromeos/offline/offline_load_page.cc b/chrome/browser/chromeos/offline/offline_load_page.cc index ac107da..126f6dd 100644 --- a/chrome/browser/chromeos/offline/offline_load_page.cc +++ b/chrome/browser/chromeos/offline/offline_load_page.cc @@ -33,6 +33,7 @@ #include "grit/generated_resources.h" #include "net/base/escape.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" using content::BrowserThread; @@ -112,7 +113,7 @@ std::string OfflineLoadPage::GetHTMLContents() { base::StringPiece html( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_OFFLINE_LOAD_HTML)); + IDR_OFFLINE_LOAD_HTML, ui::SCALE_FACTOR_NONE)); return jstemplate_builder::GetI18nTemplateHtml(html, &strings); } diff --git a/chrome/browser/debugger/browser_list_tabcontents_provider.cc b/chrome/browser/debugger/browser_list_tabcontents_provider.cc index 260eefa..f29c647 100644 --- a/chrome/browser/debugger/browser_list_tabcontents_provider.cc +++ b/chrome/browser/debugger/browser_list_tabcontents_provider.cc @@ -11,6 +11,7 @@ #include "content/public/browser/browser_thread.h" #include "grit/devtools_discovery_page_resources.h" #include "net/url_request/url_request_context_getter.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" using content::DevToolsHttpHandlerDelegate; @@ -41,7 +42,8 @@ std::string BrowserListTabContentsProvider::GetDiscoveryPageHTML() { } } return ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_DEVTOOLS_DISCOVERY_PAGE_HTML).as_string(); + IDR_DEVTOOLS_DISCOVERY_PAGE_HTML, + ui::SCALE_FACTOR_NONE).as_string(); } bool BrowserListTabContentsProvider::BundlesFrontendResources() { diff --git a/chrome/browser/extensions/component_loader.cc b/chrome/browser/extensions/component_loader.cc index b077315..36ee3e0 100644 --- a/chrome/browser/extensions/component_loader.cc +++ b/chrome/browser/extensions/component_loader.cc @@ -24,6 +24,7 @@ #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_source.h" #include "grit/browser_resources.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" #if defined(OFFICIAL_BUILD) @@ -89,7 +90,8 @@ const Extension* ComponentLoader::Add( const FilePath& root_directory) { std::string manifest_contents = ResourceBundle::GetSharedInstance().GetRawDataResource( - manifest_resource_id).as_string(); + manifest_resource_id, + ui::SCALE_FACTOR_NONE).as_string(); return Add(manifest_contents, root_directory); } @@ -249,7 +251,8 @@ void ComponentLoader::AddOrReloadEnterpriseWebStore() { if (!enterprise_webstore_url.empty()) { std::string manifest_contents = ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_ENTERPRISE_WEBSTORE_MANIFEST).as_string(); + IDR_ENTERPRISE_WEBSTORE_MANIFEST, + ui::SCALE_FACTOR_NONE).as_string(); // The manifest is missing some values that are provided by policy. DictionaryValue* manifest = ParseManifest(manifest_contents); diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index 722f279..a4582e5 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -49,6 +49,7 @@ #include "grit/generated_resources.h" #include "ui/base/keycodes/keyboard_codes.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" #if defined(TOOLKIT_VIEWS) @@ -327,7 +328,7 @@ void ExtensionHost::InsertInfobarCSS() { static const base::StringPiece css( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_EXTENSIONS_INFOBAR_CSS)); + IDR_EXTENSIONS_INFOBAR_CSS, ui::SCALE_FACTOR_NONE)); render_view_host()->InsertCSS(string16(), css.as_string()); } diff --git a/chrome/browser/extensions/extension_protocols.cc b/chrome/browser/extensions/extension_protocols.cc index 67e92a7..ed7416e 100644 --- a/chrome/browser/extensions/extension_protocols.cc +++ b/chrome/browser/extensions/extension_protocols.cc @@ -27,11 +27,12 @@ #include "grit/component_extension_resources_map.h" #include "net/base/mime_util.h" #include "net/base/net_errors.h" -#include "net/http/http_response_info.h" #include "net/http/http_response_headers.h" +#include "net/http/http_response_info.h" #include "net/url_request/url_request_error_job.h" #include "net/url_request/url_request_file_job.h" #include "net/url_request/url_request_simple_job.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" using content::ResourceRequestInfo; @@ -73,7 +74,8 @@ class URLRequestResourceBundleJob : public net::URLRequestSimpleJob { std::string* charset, std::string* data) const OVERRIDE { const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - *data = rb.GetRawDataResource(resource_id_).as_string(); + *data = rb.GetRawDataResource( + resource_id_, ui::SCALE_FACTOR_NONE).as_string(); // Requests should not block on the disk! On Windows this goes to the // registry. diff --git a/chrome/browser/first_run/first_run_win.cc b/chrome/browser/first_run/first_run_win.cc index bd3aafe..a66fd8c 100644 --- a/chrome/browser/first_run/first_run_win.cc +++ b/chrome/browser/first_run/first_run_win.cc @@ -48,6 +48,7 @@ #include "grit/generated_resources.h" #include "grit/locale_settings.h" #include "grit/theme_resources.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" #include "ui/base/ui_base_switches.h" @@ -174,7 +175,8 @@ bool LaunchSetupWithParam(const std::string& param, // true if successful. bool WriteEULAtoTempFile(FilePath* eula_path) { base::StringPiece terms = - ResourceBundle::GetSharedInstance().GetRawDataResource(IDR_TERMS_HTML); + ResourceBundle::GetSharedInstance().GetRawDataResource( + IDR_TERMS_HTML, ui::SCALE_FACTOR_NONE); if (terms.empty()) return false; FILE *file = file_util::CreateAndOpenTemporaryFile(eula_path); diff --git a/chrome/browser/history/top_sites.cc b/chrome/browser/history/top_sites.cc index 9dab604..779fe3b 100644 --- a/chrome/browser/history/top_sites.cc +++ b/chrome/browser/history/top_sites.cc @@ -39,6 +39,7 @@ #include "grit/locale_settings.h" #include "grit/theme_resources.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/image/image_util.h" @@ -254,7 +255,8 @@ bool TopSites::GetPageThumbnail(const GURL& url, for (size_t i = 0; i < arraysize(kPrepopulatedPages); i++) { if (url.spec() == l10n_util::GetStringUTF8(kPrepopulatedPages[i].url_id)) { *bytes = ResourceBundle::GetSharedInstance().LoadDataResourceBytes( - kPrepopulatedPages[i].thumbnail_id); + kPrepopulatedPages[i].thumbnail_id, + ui::SCALE_FACTOR_100P); return true; } } diff --git a/chrome/browser/icon_loader_chromeos.cc b/chrome/browser/icon_loader_chromeos.cc index cc4739f..fbd87ad 100644 --- a/chrome/browser/icon_loader_chromeos.cc +++ b/chrome/browser/icon_loader_chromeos.cc @@ -16,6 +16,7 @@ #include "grit/component_extension_resources.h" #include "skia/ext/image_operations.h" #include "third_party/skia/include/core/SkBitmap.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/canvas.h" #include "ui/gfx/codec/png_codec.h" @@ -197,7 +198,7 @@ void IconLoader::ReadIcon() { int idr = icon_mapper.Get().Lookup(group_, icon_size_); ResourceBundle& rb = ResourceBundle::GetSharedInstance(); scoped_refptr<base::RefCountedStaticMemory> bytes( - rb.LoadDataResourceBytes(idr)); + rb.LoadDataResourceBytes(idr, ui::SCALE_FACTOR_100P)); DCHECK(bytes.get()); SkBitmap bitmap; if (!gfx::PNGCodec::Decode(bytes->front(), bytes->size(), &bitmap)) diff --git a/chrome/browser/notifications/desktop_notification_service.cc b/chrome/browser/notifications/desktop_notification_service.cc index ff35176..9ab605e 100644 --- a/chrome/browser/notifications/desktop_notification_service.cc +++ b/chrome/browser/notifications/desktop_notification_service.cc @@ -41,6 +41,7 @@ #include "net/base/escape.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" using content::BrowserThread; @@ -205,7 +206,7 @@ string16 DesktopNotificationService::CreateDataUrl( int resource, const std::vector<std::string>& subst) { const base::StringPiece template_html( ResourceBundle::GetSharedInstance().GetRawDataResource( - resource)); + resource, ui::SCALE_FACTOR_NONE)); if (template_html.empty()) { NOTREACHED() << "unable to load template. ID: " << resource; diff --git a/chrome/browser/plugin_finder.cc b/chrome/browser/plugin_finder.cc index 2456169..6b3da59fa 100644 --- a/chrome/browser/plugin_finder.cc +++ b/chrome/browser/plugin_finder.cc @@ -16,6 +16,7 @@ #include "content/public/browser/browser_thread.h" #include "googleurl/src/gurl.h" #include "grit/browser_resources.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" using base::DictionaryValue; @@ -44,7 +45,7 @@ DictionaryValue* PluginFinder::LoadPluginList() { #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) base::StringPiece json_resource( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_PLUGIN_DB_JSON)); + IDR_PLUGIN_DB_JSON, ui::SCALE_FACTOR_NONE)); std::string error_str; scoped_ptr<base::Value> value(base::JSONReader::ReadAndReturnError( json_resource.as_string(), diff --git a/chrome/browser/printing/cloud_print/cloud_print_setup_source.cc b/chrome/browser/printing/cloud_print/cloud_print_setup_source.cc index 9398bf8..e4f0b4e 100644 --- a/chrome/browser/printing/cloud_print/cloud_print_setup_source.cc +++ b/chrome/browser/printing/cloud_print/cloud_print_setup_source.cc @@ -17,6 +17,7 @@ #include "grit/locale_settings.h" #include "grit/ui_resources.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" // Define the values of standard URLs. @@ -67,7 +68,8 @@ void CloudPrintSetupSource::StartDataRequest(const std::string& path_raw, AddString(dict, "sharingexplain", IDS_CLOUD_PRINT_SETUP_SHARING_EXPLAIN); static const base::StringPiece html(ResourceBundle::GetSharedInstance() - .GetRawDataResource(IDR_CLOUD_PRINT_SETUP_LOGIN_HTML)); + .GetRawDataResource(IDR_CLOUD_PRINT_SETUP_LOGIN_HTML, + ui::SCALE_FACTOR_NONE)); SetFontAndTextDirection(dict); response = jstemplate_builder::GetI18nTemplateHtml(html, dict); } else if (path_raw == kCloudPrintGaiaLoginPath) { @@ -103,7 +105,8 @@ void CloudPrintSetupSource::StartDataRequest(const std::string& path_raw, AddString(dict, "getaccesscodeurl", IDS_SYNC_GET_ACCESS_CODE_URL); static const base::StringPiece html(ResourceBundle::GetSharedInstance() - .GetRawDataResource(IDR_GAIA_LOGIN_HTML)); + .GetRawDataResource(IDR_GAIA_LOGIN_HTML, + ui::SCALE_FACTOR_NONE)); SetFontAndTextDirection(dict); response = jstemplate_builder::GetI18nTemplateHtml(html, dict); } else if (path_raw == kCloudPrintSetupDonePath) { @@ -111,13 +114,15 @@ void CloudPrintSetupSource::StartDataRequest(const std::string& path_raw, AddString(dict, "success", IDS_SYNC_SUCCESS); AddString(dict, "okay", IDS_SYNC_SETUP_OK_BUTTON_LABEL); static const base::StringPiece html(ResourceBundle::GetSharedInstance() - .GetRawDataResource(IDR_CLOUD_PRINT_SETUP_DONE_HTML)); + .GetRawDataResource(IDR_CLOUD_PRINT_SETUP_DONE_HTML, + ui::SCALE_FACTOR_NONE)); SetFontAndTextDirection(dict); response = jstemplate_builder::GetI18nTemplateHtml(html, dict); } else if (path_raw == kCloudPrintSetupFlowPath) { static const base::StringPiece html( ResourceBundle::GetSharedInstance() - .GetRawDataResource(IDR_CLOUD_PRINT_SETUP_FLOW_HTML)); + .GetRawDataResource(IDR_CLOUD_PRINT_SETUP_FLOW_HTML, + ui::SCALE_FACTOR_NONE)); response = html.as_string(); } diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc index dd3c3b2..1e9f7be 100644 --- a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc +++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc @@ -38,6 +38,7 @@ #include "grit/locale_settings.h" #include "net/base/escape.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" using content::BrowserThread; @@ -195,20 +196,23 @@ std::string SafeBrowsingBlockingPage::GetHTMLContents() { if (unsafe_resources_.size() > 1) { PopulateMultipleThreatStringDictionary(&strings); html = rb.GetRawDataResource( - IDR_SAFE_BROWSING_MULTIPLE_THREAT_BLOCK).as_string(); + IDR_SAFE_BROWSING_MULTIPLE_THREAT_BLOCK, + ui::SCALE_FACTOR_NONE).as_string(); } else { SafeBrowsingService::UrlCheckResult threat_type = unsafe_resources_[0].threat_type; if (threat_type == SafeBrowsingService::URL_MALWARE) { PopulateMalwareStringDictionary(&strings); html = rb.GetRawDataResource( - IDR_SAFE_BROWSING_MALWARE_BLOCK).as_string(); + IDR_SAFE_BROWSING_MALWARE_BLOCK, + ui::SCALE_FACTOR_NONE).as_string(); } else { // Phishing. DCHECK(threat_type == SafeBrowsingService::URL_PHISHING || threat_type == SafeBrowsingService::CLIENT_SIDE_PHISHING_URL); PopulatePhishingStringDictionary(&strings); html = rb.GetRawDataResource( - IDR_SAFE_BROWSING_PHISHING_BLOCK).as_string(); + IDR_SAFE_BROWSING_PHISHING_BLOCK, + ui::SCALE_FACTOR_NONE).as_string(); } } diff --git a/chrome/browser/ssl/ssl_blocking_page.cc b/chrome/browser/ssl/ssl_blocking_page.cc index 3b301be..e5bc81d 100644 --- a/chrome/browser/ssl/ssl_blocking_page.cc +++ b/chrome/browser/ssl/ssl_blocking_page.cc @@ -26,6 +26,7 @@ #include "grit/browser_resources.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" using content::InterstitialPage; @@ -120,7 +121,8 @@ std::string SSLBlockingPage::GetHTMLContents() { strings.SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr"); base::StringPiece html( - ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id)); + ResourceBundle::GetSharedInstance().GetRawDataResource( + resource_id, ui::SCALE_FACTOR_NONE)); return jstemplate_builder::GetI18nTemplateHtml(html, &strings); } diff --git a/chrome/browser/themes/browser_theme_pack.cc b/chrome/browser/themes/browser_theme_pack.cc index b5f17eb..2e8e9bd 100644 --- a/chrome/browser/themes/browser_theme_pack.cc +++ b/chrome/browser/themes/browser_theme_pack.cc @@ -384,7 +384,7 @@ scoped_refptr<BrowserThemePack> BrowserThemePack::BuildFromDataPack( base::ThreadRestrictions::ScopedAllowIO allow_io; scoped_refptr<BrowserThemePack> pack(new BrowserThemePack); pack->data_pack_.reset( - new ui::DataPack(ui::ResourceHandle::kScaleFactor100x)); + new ui::DataPack(ui::SCALE_FACTOR_100P)); if (!pack->data_pack_->Load(path)) { LOG(ERROR) << "Failed to load theme data pack."; diff --git a/chrome/browser/themes/theme_service.cc b/chrome/browser/themes/theme_service.cc index f9be837..5a75aa6 100644 --- a/chrome/browser/themes/theme_service.cc +++ b/chrome/browser/themes/theme_service.cc @@ -21,6 +21,7 @@ #include "grit/theme_resources.h" #include "grit/theme_resources_standard.h" #include "grit/ui_resources.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/image/image_skia.h" @@ -324,7 +325,7 @@ base::RefCountedMemory* ThemeService::GetRawData(int id) const { if (theme_pack_.get()) data = theme_pack_->GetRawData(id); if (!data) - data = rb_.LoadDataResourceBytes(id); + data = rb_.LoadDataResourceBytes(id, ui::SCALE_FACTOR_100P); return data; } diff --git a/chrome/browser/translate/translate_manager.cc b/chrome/browser/translate/translate_manager.cc index 21565cf..acf05e0 100644 --- a/chrome/browser/translate/translate_manager.cc +++ b/chrome/browser/translate/translate_manager.cc @@ -50,6 +50,7 @@ #include "net/base/escape.h" #include "net/base/load_flags.h" #include "net/url_request/url_request_status.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" #ifdef FILE_MANAGER_EXTENSION @@ -427,7 +428,8 @@ void TranslateManager::OnURLFetchComplete(const net::URLFetcher* source) { translate_script_request_pending_.release()); if (!error) { base::StringPiece str = ResourceBundle::GetSharedInstance(). - GetRawDataResource(IDR_TRANSLATE_JS); + GetRawDataResource(IDR_TRANSLATE_JS, + ui::SCALE_FACTOR_NONE); DCHECK(translate_script_.empty()); str.CopyToString(&translate_script_); std::string data; diff --git a/chrome/browser/ui/pdf/pdf_unsupported_feature.cc b/chrome/browser/ui/pdf/pdf_unsupported_feature.cc index 340dba0..8924fcc 100644 --- a/chrome/browser/ui/pdf/pdf_unsupported_feature.cc +++ b/chrome/browser/ui/pdf/pdf_unsupported_feature.cc @@ -31,6 +31,7 @@ #include "grit/generated_resources.h" #include "grit/theme_resources_standard.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/image/image.h" #include "webkit/plugins/npapi/plugin_group.h" @@ -204,7 +205,8 @@ class PDFUnsupportedFeatureInterstitial l10n_util::GetStringUTF16(IDS_READER_OUT_OF_DATE_BLOCKING_PAGE_CANCEL)); base::StringPiece html(ResourceBundle::GetSharedInstance(). - GetRawDataResource(IDR_READER_OUT_OF_DATE_HTML)); + GetRawDataResource(IDR_READER_OUT_OF_DATE_HTML, + ui::SCALE_FACTOR_NONE)); return jstemplate_builder::GetI18nTemplateHtml(html, &strings); } diff --git a/chrome/browser/ui/webui/about_ui.cc b/chrome/browser/ui/webui/about_ui.cc index 89fd4fa..6d7d77c 100644 --- a/chrome/browser/ui/webui/about_ui.cc +++ b/chrome/browser/ui/webui/about_ui.cc @@ -65,6 +65,7 @@ #include "net/base/escape.h" #include "net/base/net_util.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" #include "v8/include/v8.h" #include "webkit/glue/user_agent.h" @@ -72,8 +73,8 @@ #include "webkit/plugins/webplugininfo.h" #if defined(OS_LINUX) || defined(OS_OPENBSD) -#include "content/public/common/sandbox_linux.h" #include "content/public/browser/zygote_host_linux.h" +#include "content/public/common/sandbox_linux.h" #endif #if defined(OS_WIN) @@ -246,7 +247,7 @@ class ChromeOSTermsHandler // Do nothing if OEM EULA load failed. if (contents_.empty() && path_ != chrome::kOemEulaURLPath) { contents_ = ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_TERMS_HTML).as_string(); + IDR_TERMS_HTML, ui::SCALE_FACTOR_NONE).as_string(); } source_->FinishDataRequest(contents_, request_id_); } @@ -839,7 +840,8 @@ void FinishMemoryDataRequest(const std::string& path, source->FinishDataRequest( ResourceBundle::GetSharedInstance().GetRawDataResource( path == kMemoryJsPath ? IDR_ABOUT_MEMORY_JS : - IDR_ABOUT_MEMORY_HTML).as_string(), request_id); + IDR_ABOUT_MEMORY_HTML, + ui::SCALE_FACTOR_NONE).as_string(), request_id); } } @@ -990,8 +992,8 @@ std::string AboutStats(const std::string& query) { } else { // Get about_stats.html/js from resource bundle. data = ResourceBundle::GetSharedInstance().GetRawDataResource( - (query == kStatsJsPath ? IDR_ABOUT_STATS_JS : IDR_ABOUT_STATS_HTML)). - as_string(); + (query == kStatsJsPath ? IDR_ABOUT_STATS_JS : IDR_ABOUT_STATS_HTML), + ui::SCALE_FACTOR_NONE).as_string(); if (query != kStatsJsPath) { // Clear the timer list since we stored the data in the timers list @@ -1086,7 +1088,7 @@ std::string AboutVersionStaticContent(const std::string& query) { return ResourceBundle::GetSharedInstance().GetRawDataResource( query == kVersionJsPath ? IDR_ABOUT_VERSION_JS : - IDR_ABOUT_VERSION_HTML).as_string(); + IDR_ABOUT_VERSION_HTML, ui::SCALE_FACTOR_NONE).as_string(); } std::string AboutVersionStrings(DictionaryValue* localized_strings, @@ -1387,7 +1389,7 @@ void AboutUIHTMLSource::StartDataRequest(const std::string& path, } else if (host == chrome::kChromeUICreditsHost) { int idr = (path == kCreditsJsPath) ? IDR_CREDITS_JS : IDR_CREDITS_HTML; response = ResourceBundle::GetSharedInstance().GetRawDataResource( - idr).as_string(); + idr, ui::SCALE_FACTOR_NONE).as_string(); #if defined(OS_CHROMEOS) } else if (host == chrome::kChromeUICryptohomeHost) { FinishCryptohomeDataRequest(this, path, request_id); @@ -1418,7 +1420,7 @@ void AboutUIHTMLSource::StartDataRequest(const std::string& path, response = AboutNetwork(path); } else if (host == chrome::kChromeUIOSCreditsHost) { response = ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_OS_CREDITS_HTML).as_string(); + IDR_OS_CREDITS_HTML, ui::SCALE_FACTOR_NONE).as_string(); #endif #if defined(OS_LINUX) || defined(OS_OPENBSD) } else if (host == chrome::kChromeUISandboxHost) { @@ -1432,7 +1434,7 @@ void AboutUIHTMLSource::StartDataRequest(const std::string& path, return; #else response = ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_TERMS_HTML).as_string(); + IDR_TERMS_HTML, ui::SCALE_FACTOR_NONE).as_string(); #endif } else if (host == chrome::kChromeUIVersionHost) { if (path == kStringsJsPath) { diff --git a/chrome/browser/ui/webui/bookmarks_ui.cc b/chrome/browser/ui/webui/bookmarks_ui.cc index 8154368..de67b3e 100644 --- a/chrome/browser/ui/webui/bookmarks_ui.cc +++ b/chrome/browser/ui/webui/bookmarks_ui.cc @@ -19,10 +19,11 @@ #include "chrome/common/url_constants.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_ui.h" +#include "googleurl/src/gurl.h" #include "grit/theme_resources.h" #include "grit/theme_resources_standard.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" -#include "googleurl/src/gurl.h" using content::WebContents; @@ -70,5 +71,6 @@ BookmarksUI::BookmarksUI(content::WebUI* web_ui) : WebUIController(web_ui) { // static base::RefCountedMemory* BookmarksUI::GetFaviconResourceBytes() { return ResourceBundle::GetSharedInstance(). - LoadDataResourceBytes(IDR_BOOKMARKS_FAVICON); + LoadDataResourceBytes(IDR_BOOKMARKS_FAVICON, + ui::SCALE_FACTOR_100P); } diff --git a/chrome/browser/ui/webui/chrome_web_ui_data_source.cc b/chrome/browser/ui/webui/chrome_web_ui_data_source.cc index d4a1c67..1fa1457 100644 --- a/chrome/browser/ui/webui/chrome_web_ui_data_source.cc +++ b/chrome/browser/ui/webui/chrome_web_ui_data_source.cc @@ -10,6 +10,7 @@ #include "base/string_util.h" #include "chrome/common/jstemplate_builder.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" ChromeWebUIDataSource::ChromeWebUIDataSource(const std::string& source_name) @@ -86,6 +87,7 @@ void ChromeWebUIDataSource::SendLocalizedStringsAsJSON(int request_id) { void ChromeWebUIDataSource::SendFromResourceBundle(int request_id, int idr) { scoped_refptr<base::RefCountedStaticMemory> response( - ResourceBundle::GetSharedInstance().LoadDataResourceBytes(idr)); + ResourceBundle::GetSharedInstance().LoadDataResourceBytes( + idr, ui::SCALE_FACTOR_NONE)); SendResponse(request_id, response); } diff --git a/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc b/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc index eda42a7..0b36cd9 100644 --- a/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc +++ b/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc @@ -35,6 +35,7 @@ #include "content/public/browser/web_contents.h" #include "content/public/browser/web_ui.h" #include "grit/browser_resources.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" using content::WebContents; @@ -107,7 +108,8 @@ void OobeUIHTMLSource::StartDataRequest(const std::string& path, std::string OobeUIHTMLSource::GetDataResource(int resource_id) const { const base::StringPiece html( - ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id)); + ResourceBundle::GetSharedInstance().GetRawDataResource( + resource_id, ui::SCALE_FACTOR_NONE)); return jstemplate_builder::GetI18nTemplateHtml(html, localized_strings_.get()); } diff --git a/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc b/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc index 98dd59a..bf875d7 100644 --- a/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc +++ b/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc @@ -44,6 +44,7 @@ #include "grit/generated_resources.h" #include "grit/locale_settings.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" using content::BrowserThread; @@ -483,7 +484,7 @@ void MobileSetupUIHTMLSource::StartDataRequest(const std::string& path, static const base::StringPiece html( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_MOBILE_SETUP_PAGE_HTML)); + IDR_MOBILE_SETUP_PAGE_HTML, ui::SCALE_FACTOR_NONE)); std::string full_html = jstemplate_builder::GetI18nTemplateHtml(html, &strings); diff --git a/chrome/browser/ui/webui/chromeos/proxy_settings_ui.cc b/chrome/browser/ui/webui/chromeos/proxy_settings_ui.cc index 4a4d7c9..ebd296b 100644 --- a/chrome/browser/ui/webui/chromeos/proxy_settings_ui.cc +++ b/chrome/browser/ui/webui/chromeos/proxy_settings_ui.cc @@ -20,6 +20,7 @@ #include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui_message_handler.h" #include "grit/browser_resources.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" using content::WebContents; @@ -59,7 +60,7 @@ void ProxySettingsHTMLSource::StartDataRequest(const std::string& path, static const base::StringPiece html( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_PROXY_SETTINGS_HTML)); + IDR_PROXY_SETTINGS_HTML, ui::SCALE_FACTOR_NONE)); std::string full_html = jstemplate_builder::GetI18nTemplateHtml( html, localized_strings_.get()); diff --git a/chrome/browser/ui/webui/chromeos/register_page_ui.cc b/chrome/browser/ui/webui/chromeos/register_page_ui.cc index 394a928..ca1889a 100644 --- a/chrome/browser/ui/webui/chromeos/register_page_ui.cc +++ b/chrome/browser/ui/webui/chromeos/register_page_ui.cc @@ -31,6 +31,7 @@ #include "content/public/browser/web_ui_message_handler.h" #include "googleurl/src/gurl.h" #include "grit/browser_resources.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" using content::WebContents; @@ -167,7 +168,8 @@ void RegisterPageUIHTMLSource::StartDataRequest(const std::string& path, scoped_refptr<base::RefCountedMemory> html_bytes( ResourceBundle::GetSharedInstance().LoadDataResourceBytes( - IDR_HOST_REGISTRATION_PAGE_HTML)); + IDR_HOST_REGISTRATION_PAGE_HTML, + ui::SCALE_FACTOR_NONE)); SendResponse(request_id, html_bytes); } diff --git a/chrome/browser/ui/webui/chromeos/sim_unlock_ui.cc b/chrome/browser/ui/webui/chromeos/sim_unlock_ui.cc index a097d71..ea7825e 100644 --- a/chrome/browser/ui/webui/chromeos/sim_unlock_ui.cc +++ b/chrome/browser/ui/webui/chromeos/sim_unlock_ui.cc @@ -30,6 +30,7 @@ #include "grit/browser_resources.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" using content::BrowserThread; @@ -305,7 +306,7 @@ void SimUnlockUIHTMLSource::StartDataRequest(const std::string& path, static const base::StringPiece html( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_SIM_UNLOCK_HTML)); + IDR_SIM_UNLOCK_HTML, ui::SCALE_FACTOR_NONE)); std::string full_html = jstemplate_builder::GetI18nTemplateHtml(html, &strings); diff --git a/chrome/browser/ui/webui/chromeos/system_info_ui.cc b/chrome/browser/ui/webui/chromeos/system_info_ui.cc index 0109bc4..8b3b599 100644 --- a/chrome/browser/ui/webui/chromeos/system_info_ui.cc +++ b/chrome/browser/ui/webui/chromeos/system_info_ui.cc @@ -34,6 +34,7 @@ #include "net/base/directory_lister.h" #include "net/base/escape.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" using content::WebContents; @@ -146,7 +147,7 @@ void SystemInfoUIHTMLSource::SyslogsComplete( } static const base::StringPiece systeminfo_html( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_ABOUT_SYS_HTML)); + IDR_ABOUT_SYS_HTML, ui::SCALE_FACTOR_NONE)); std::string full_html = jstemplate_builder::GetTemplatesHtml( systeminfo_html, &strings, "t" /* template root node id */); diff --git a/chrome/browser/ui/webui/conflicts_ui.cc b/chrome/browser/ui/webui/conflicts_ui.cc index 75c1816..d5e8ed9 100644 --- a/chrome/browser/ui/webui/conflicts_ui.cc +++ b/chrome/browser/ui/webui/conflicts_ui.cc @@ -33,6 +33,7 @@ #include "grit/theme_resources.h" #include "grit/theme_resources_standard.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" using content::UserMetricsAction; @@ -174,7 +175,7 @@ ConflictsUI::ConflictsUI(content::WebUI* web_ui) : WebUIController(web_ui) { base::RefCountedMemory* ConflictsUI::GetFaviconResourceBytes() { return static_cast<base::RefCountedMemory*>( ResourceBundle::GetSharedInstance().LoadDataResourceBytes( - IDR_CONFLICT_FAVICON)); + IDR_CONFLICT_FAVICON, ui::SCALE_FACTOR_NONE)); } #endif diff --git a/chrome/browser/ui/webui/crashes_ui.cc b/chrome/browser/ui/webui/crashes_ui.cc index f8c5760..bf68b06 100644 --- a/chrome/browser/ui/webui/crashes_ui.cc +++ b/chrome/browser/ui/webui/crashes_ui.cc @@ -30,6 +30,7 @@ #include "grit/theme_resources.h" #include "grit/theme_resources_standard.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" #if defined(OS_CHROMEOS) @@ -172,7 +173,8 @@ CrashesUI::CrashesUI(content::WebUI* web_ui) : WebUIController(web_ui) { // static base::RefCountedMemory* CrashesUI::GetFaviconResourceBytes() { return ResourceBundle::GetSharedInstance(). - LoadDataResourceBytes(IDR_SAD_FAVICON); + LoadDataResourceBytes(IDR_SAD_FAVICON, + ui::SCALE_FACTOR_NONE); } // static diff --git a/chrome/browser/ui/webui/devtools_ui.cc b/chrome/browser/ui/webui/devtools_ui.cc index 14b04f4..a58de6a 100644 --- a/chrome/browser/ui/webui/devtools_ui.cc +++ b/chrome/browser/ui/webui/devtools_ui.cc @@ -19,6 +19,7 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_ui.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" using content::BrowserThread; @@ -66,7 +67,7 @@ void DevToolsDataSource::StartDataRequest(const std::string& path, " with --debug-devtools."; const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); scoped_refptr<base::RefCountedStaticMemory> bytes(rb.LoadDataResourceBytes( - resource_id)); + resource_id, ui::SCALE_FACTOR_NONE)); SendResponse(request_id, bytes); } diff --git a/chrome/browser/ui/webui/downloads_ui.cc b/chrome/browser/ui/webui/downloads_ui.cc index efc035b..57b7f7a 100644 --- a/chrome/browser/ui/webui/downloads_ui.cc +++ b/chrome/browser/ui/webui/downloads_ui.cc @@ -24,6 +24,7 @@ #include "grit/generated_resources.h" #include "grit/theme_resources.h" #include "grit/theme_resources_standard.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" using content::DownloadManager; @@ -103,5 +104,6 @@ DownloadsUI::DownloadsUI(content::WebUI* web_ui) : WebUIController(web_ui) { // static base::RefCountedMemory* DownloadsUI::GetFaviconResourceBytes() { return ResourceBundle::GetSharedInstance(). - LoadDataResourceBytes(IDR_DOWNLOADS_FAVICON); + LoadDataResourceBytes(IDR_DOWNLOADS_FAVICON, + ui::SCALE_FACTOR_NONE); } diff --git a/chrome/browser/ui/webui/extensions/extension_icon_source.cc b/chrome/browser/ui/webui/extensions/extension_icon_source.cc index a8bbec6..519832d 100644 --- a/chrome/browser/ui/webui/extensions/extension_icon_source.cc +++ b/chrome/browser/ui/webui/extensions/extension_icon_source.cc @@ -19,10 +19,11 @@ #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_resource.h" #include "chrome/common/url_constants.h" +#include "googleurl/src/gurl.h" #include "grit/component_extension_resources_map.h" #include "grit/theme_resources.h" -#include "googleurl/src/gurl.h" #include "skia/ext/image_operations.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/codec/png_codec.h" #include "ui/gfx/color_utils.h" @@ -90,7 +91,8 @@ GURL ExtensionIconSource::GetIconURL(const Extension* extension, // static SkBitmap* ExtensionIconSource::LoadImageByResourceId(int resource_id) { std::string contents = ResourceBundle::GetSharedInstance() - .GetRawDataResource(resource_id).as_string(); + .GetRawDataResource(resource_id, + ui::SCALE_FACTOR_100P).as_string(); // Convert and return it. const unsigned char* data = diff --git a/chrome/browser/ui/webui/favicon_source.cc b/chrome/browser/ui/webui/favicon_source.cc index 4a1b3c0..6fa19b9 100644 --- a/chrome/browser/ui/webui/favicon_source.cc +++ b/chrome/browser/ui/webui/favicon_source.cc @@ -12,6 +12,7 @@ #include "grit/locale_settings.h" #include "grit/ui_resources.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" FaviconSource::FaviconSource(Profile* profile, IconType type) @@ -96,7 +97,8 @@ void FaviconSource::StartDataRequest(const std::string& path, request_size_map_.erase(request_id); SendResponse(request_id, ResourceBundle::GetSharedInstance().LoadDataResourceBytes( - history::kPrepopulatedPages[i].favicon_id)); + history::kPrepopulatedPages[i].favicon_id, + ui::SCALE_FACTOR_100P)); return; } } @@ -148,14 +150,14 @@ void FaviconSource::SendDefaultResponse(int request_id) { if (!default_favicon_large_.get()) { default_favicon_large_ = ResourceBundle::GetSharedInstance().LoadDataResourceBytes( - IDR_DEFAULT_LARGE_FAVICON); + IDR_DEFAULT_LARGE_FAVICON, ui::SCALE_FACTOR_100P); } bytes = default_favicon_large_; } else { if (!default_favicon_.get()) { default_favicon_ = ResourceBundle::GetSharedInstance().LoadDataResourceBytes( - IDR_DEFAULT_FAVICON); + IDR_DEFAULT_FAVICON, ui::SCALE_FACTOR_100P); } bytes = default_favicon_; } diff --git a/chrome/browser/ui/webui/flags_ui.cc b/chrome/browser/ui/webui/flags_ui.cc index 2e7da67..42bf58b 100644 --- a/chrome/browser/ui/webui/flags_ui.cc +++ b/chrome/browser/ui/webui/flags_ui.cc @@ -26,9 +26,10 @@ #include "grit/browser_resources.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" -#include "grit/theme_resources_standard.h" #include "grit/theme_resources.h" +#include "grit/theme_resources_standard.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" #if defined(OS_CHROMEOS) @@ -169,7 +170,7 @@ FlagsUI::FlagsUI(content::WebUI* web_ui) : WebUIController(web_ui) { // static base::RefCountedMemory* FlagsUI::GetFaviconResourceBytes() { return ResourceBundle::GetSharedInstance(). - LoadDataResourceBytes(IDR_FLAGS); + LoadDataResourceBytes(IDR_FLAGS, ui::SCALE_FACTOR_100P); } // static diff --git a/chrome/browser/ui/webui/history_ui.cc b/chrome/browser/ui/webui/history_ui.cc index 1f3c0fa..158e976 100644 --- a/chrome/browser/ui/webui/history_ui.cc +++ b/chrome/browser/ui/webui/history_ui.cc @@ -45,6 +45,7 @@ #include "grit/theme_resources_standard.h" #include "net/base/escape.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" using content::UserMetricsAction; @@ -485,5 +486,6 @@ const GURL HistoryUI::GetHistoryURLWithSearchText(const string16& text) { // static base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes() { return ResourceBundle::GetSharedInstance(). - LoadDataResourceBytes(IDR_HISTORY_FAVICON); + LoadDataResourceBytes(IDR_HISTORY_FAVICON, + ui::SCALE_FACTOR_100P); } diff --git a/chrome/browser/ui/webui/ntp/new_tab_ui.cc b/chrome/browser/ui/webui/ntp/new_tab_ui.cc index 2ad684e..1a4f5e8 100644 --- a/chrome/browser/ui/webui/ntp/new_tab_ui.cc +++ b/chrome/browser/ui/webui/ntp/new_tab_ui.cc @@ -53,6 +53,8 @@ #include "grit/generated_resources.h" #include "grit/theme_resources.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/layout.h" +#include "ui/base/resource/resource_bundle.h" #if !defined(OS_ANDROID) #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" @@ -355,7 +357,7 @@ void NewTabUI::NewTabHTMLSource::StartDataRequest(const std::string& path, scoped_refptr<base::RefCountedStaticMemory> resource_bytes( it->second.second ? ResourceBundle::GetSharedInstance().LoadDataResourceBytes( - it->second.second) : + it->second.second, ui::SCALE_FACTOR_NONE) : new base::RefCountedStaticMemory); SendResponse(request_id, resource_bytes); return; diff --git a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc index fd46886..034fc9f 100644 --- a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc +++ b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc @@ -45,6 +45,7 @@ #include "grit/theme_resources.h" #include "ui/base/animation/animation.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" #include "ui/base/theme_provider.h" #include "ui/gfx/color_utils.h" @@ -291,7 +292,7 @@ void NTPResourceCache::CreateNewTabIncognitoHTML() { static const base::StringPiece incognito_tab_html( ResourceBundle::GetSharedInstance().GetRawDataResource( - new_tab_html_idr)); + new_tab_html_idr, ui::SCALE_FACTOR_NONE)); std::string full_html = jstemplate_builder::GetI18nTemplateHtml( incognito_tab_html, &localized_strings); @@ -427,7 +428,8 @@ void NTPResourceCache::CreateNewTabHTML() { // Load the new tab page appropriate for this build base::StringPiece new_tab_html(ResourceBundle::GetSharedInstance(). - GetRawDataResource(IDR_NEW_TAB_4_HTML)); + GetRawDataResource(IDR_NEW_TAB_4_HTML, + ui::SCALE_FACTOR_NONE)); jstemplate_builder::UseVersion2 version2; std::string full_html = jstemplate_builder::GetI18nTemplateHtml(new_tab_html, &load_time_data); @@ -458,7 +460,7 @@ void NTPResourceCache::CreateNewTabIncognitoCSS() { // Get our template. static const base::StringPiece new_tab_theme_css( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_NEW_INCOGNITO_TAB_THEME_CSS)); + IDR_NEW_INCOGNITO_TAB_THEME_CSS, ui::SCALE_FACTOR_NONE)); // Create the string from our template and the replacements. std::string full_css = ReplaceStringPlaceholders( @@ -553,7 +555,7 @@ void NTPResourceCache::CreateNewTabCSS() { // Get our template. static const base::StringPiece new_tab_theme_css( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_NEW_TAB_4_THEME_CSS)); + IDR_NEW_TAB_4_THEME_CSS, ui::SCALE_FACTOR_NONE)); // Create the string from our template and the replacements. std::string css_string; diff --git a/chrome/browser/ui/webui/ntp/ntp_resource_cache_android.cc b/chrome/browser/ui/webui/ntp/ntp_resource_cache_android.cc index db8d468..61d6230 100644 --- a/chrome/browser/ui/webui/ntp/ntp_resource_cache_android.cc +++ b/chrome/browser/ui/webui/ntp/ntp_resource_cache_android.cc @@ -4,11 +4,11 @@ #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h" +#include "base/memory/ref_counted_memory.h" #include "base/string16.h" #include "base/string_piece.h" #include "base/utf_string_conversions.h" #include "base/values.h" -#include "base/memory/ref_counted_memory.h" #include "chrome/browser/google/google_util.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/webui/chrome_url_data_manager.h" @@ -19,6 +19,7 @@ #include "grit/browser_resources.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" using content::BrowserThread; @@ -73,7 +74,8 @@ void NTPResourceCache::CreateNewTabHTML() { ChromeURLDataManager::DataSource::SetFontAndTextDirection(&localized_strings); base::StringPiece new_tab_html(ResourceBundle::GetSharedInstance(). - GetRawDataResource(IDR_NEW_TAB_4_HTML)); + GetRawDataResource(IDR_NEW_TAB_4_HTML, + ui::SCALE_FACTOR_NONE)); const char* new_tab_link = kLearnMoreIncognitoUrl; string16 learnMoreLink = ASCIIToUTF16( diff --git a/chrome/browser/ui/webui/options2/chromeos/wallpaper_thumbnail_source2.cc b/chrome/browser/ui/webui/options2/chromeos/wallpaper_thumbnail_source2.cc index bc38e2d..73f7e3f 100644 --- a/chrome/browser/ui/webui/options2/chromeos/wallpaper_thumbnail_source2.cc +++ b/chrome/browser/ui/webui/options2/chromeos/wallpaper_thumbnail_source2.cc @@ -19,6 +19,7 @@ #include "content/public/browser/browser_thread.h" #include "grit/ui_resources.h" #include "net/base/mime_util.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/codec/png_codec.h" @@ -107,7 +108,8 @@ void WallpaperThumbnailSource::StartDataRequest(const std::string& path, if (idr != -1) { DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - SendResponse(request_id, rb.LoadDataResourceBytes(idr)); + SendResponse(request_id, rb.LoadDataResourceBytes(idr, + ui::SCALE_FACTOR_100P)); } } diff --git a/chrome/browser/ui/webui/options2/options_ui2.cc b/chrome/browser/ui/webui/options2/options_ui2.cc index 33b13b7..8edd569 100644 --- a/chrome/browser/ui/webui/options2/options_ui2.cc +++ b/chrome/browser/ui/webui/options2/options_ui2.cc @@ -57,6 +57,7 @@ #include "grit/theme_resources.h" #include "grit/theme_resources_standard.h" #include "net/base/escape.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" #if defined(OS_CHROMEOS) @@ -149,11 +150,11 @@ void OptionsUIHTMLSource::StartDataRequest(const std::string& path, } else if (path == kOptionsBundleJsFile) { // Return (and cache) the options javascript code. response_bytes = ResourceBundle::GetSharedInstance().LoadDataResourceBytes( - IDR_OPTIONS2_BUNDLE_JS); + IDR_OPTIONS2_BUNDLE_JS, ui::SCALE_FACTOR_NONE); } else { // Return (and cache) the main options html page as the default. response_bytes = ResourceBundle::GetSharedInstance().LoadDataResourceBytes( - IDR_OPTIONS2_HTML); + IDR_OPTIONS2_HTML, ui::SCALE_FACTOR_NONE); } SendResponse(request_id, response_bytes); @@ -355,7 +356,8 @@ void OptionsUI::ProcessAutocompleteSuggestions( // static base::RefCountedMemory* OptionsUI::GetFaviconResourceBytes() { return ResourceBundle::GetSharedInstance(). - LoadDataResourceBytes(IDR_SETTINGS_FAVICON); + LoadDataResourceBytes(IDR_SETTINGS_FAVICON, + ui::SCALE_FACTOR_100P); } void OptionsUI::InitializeHandlers() { diff --git a/chrome/browser/ui/webui/plugins_ui.cc b/chrome/browser/ui/webui/plugins_ui.cc index 34aef3c..901ff58 100644 --- a/chrome/browser/ui/webui/plugins_ui.cc +++ b/chrome/browser/ui/webui/plugins_ui.cc @@ -19,9 +19,9 @@ #include "base/values.h" #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/plugin_prefs.h" -#include "chrome/browser/prefs/scoped_user_pref_update.h" #include "chrome/browser/prefs/pref_member.h" #include "chrome/browser/prefs/pref_service.h" +#include "chrome/browser/prefs/scoped_user_pref_update.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_window.h" @@ -42,6 +42,7 @@ #include "grit/theme_resources.h" #include "grit/theme_resources_standard.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" #include "webkit/plugins/npapi/plugin_group.h" @@ -483,7 +484,7 @@ PluginsUI::PluginsUI(content::WebUI* web_ui) : WebUIController(web_ui) { // static base::RefCountedMemory* PluginsUI::GetFaviconResourceBytes() { return ResourceBundle::GetSharedInstance(). - LoadDataResourceBytes(IDR_PLUGIN); + LoadDataResourceBytes(IDR_PLUGIN, ui::SCALE_FACTOR_100P); } // static diff --git a/chrome/browser/ui/webui/sessions_ui.cc b/chrome/browser/ui/webui/sessions_ui.cc index 3743b31..cb68200 100644 --- a/chrome/browser/ui/webui/sessions_ui.cc +++ b/chrome/browser/ui/webui/sessions_ui.cc @@ -28,6 +28,7 @@ #include "grit/theme_resources.h" #include "grit/theme_resources_standard.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" using content::WebContents; @@ -270,5 +271,6 @@ SessionsUI::SessionsUI(content::WebUI* web_ui) : WebUIController(web_ui) { // static base::RefCountedMemory* SessionsUI::GetFaviconResourceBytes() { return ResourceBundle::GetSharedInstance(). - LoadDataResourceBytes(IDR_HISTORY_FAVICON); + LoadDataResourceBytes(IDR_HISTORY_FAVICON, + ui::SCALE_FACTOR_100P); } diff --git a/chrome/browser/ui/webui/shared_resources_data_source.cc b/chrome/browser/ui/webui/shared_resources_data_source.cc index 378b8e3..2d6630b 100644 --- a/chrome/browser/ui/webui/shared_resources_data_source.cc +++ b/chrome/browser/ui/webui/shared_resources_data_source.cc @@ -76,7 +76,7 @@ void SharedResourcesDataSource::StartDataRequest(const std::string& path, DCHECK_NE(-1, idr) << " path: " << path; const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); scoped_refptr<base::RefCountedStaticMemory> bytes( - rb.LoadDataResourceBytes(idr)); + rb.LoadDataResourceBytes(idr, ui::SCALE_FACTOR_NONE)); SendResponse(request_id, bytes); } diff --git a/chrome/browser/ui/webui/theme_source.cc b/chrome/browser/ui/webui/theme_source.cc index 2c2a59b..b51c05d 100644 --- a/chrome/browser/ui/webui/theme_source.cc +++ b/chrome/browser/ui/webui/theme_source.cc @@ -6,6 +6,7 @@ #include "base/memory/ref_counted_memory.h" #include "base/message_loop.h" +#include "base/string_number_conversions.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/resources_util.h" #include "chrome/browser/themes/theme_service.h" @@ -15,21 +16,60 @@ #include "chrome/common/url_constants.h" #include "content/public/browser/browser_thread.h" #include "googleurl/src/gurl.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" #include "ui/base/theme_provider.h" using content::BrowserThread; +namespace { + // use a resource map rather than hard-coded strings. static const char* kNewTabCSSPath = "css/new_tab_theme.css"; static const char* kNewIncognitoTabCSSPath = "css/incognito_new_tab_theme.css"; -static std::string StripQueryParams(const std::string& path) { +struct ScaleFactorMap { + const char* name; + ui::ScaleFactor scale_factor; +}; + +const ScaleFactorMap kScaleFactorMap[] = { + { "1x", ui::SCALE_FACTOR_100P }, + { "2x", ui::SCALE_FACTOR_200P }, +}; + +std::string StripQueryParams(const std::string& path) { GURL path_url = GURL(std::string(chrome::kChromeUIScheme) + "://" + std::string(chrome::kChromeUIThemePath) + "/" + path); return path_url.path().substr(1); // path() always includes a leading '/'. } +std::string ParsePathAndScale(const std::string& path, + ui::ScaleFactor* scale_factor) { + // Our path may include cachebuster arguments, so trim them off. + std::string uncached_path = StripQueryParams(path); + if (scale_factor) + *scale_factor = ui::SCALE_FACTOR_100P; + + // Detect and parse resource string ending in @<scale>x. + std::size_t pos = uncached_path.rfind('@'); + if (pos != std::string::npos) { + if (scale_factor) { + for (size_t i = 0; i < arraysize(kScaleFactorMap); i++) { + if (uncached_path.compare(pos + 1, uncached_path.length() - pos - 1, + kScaleFactorMap[i].name) == 0) { + *scale_factor = kScaleFactorMap[i].scale_factor; + } + } + } + // Strip scale factor specification from path. + uncached_path = uncached_path.substr(0, pos); + } + return uncached_path; +} + +} // namespace + //////////////////////////////////////////////////////////////////////////////// // ThemeSource, public: @@ -46,8 +86,9 @@ ThemeSource::~ThemeSource() { void ThemeSource::StartDataRequest(const std::string& path, bool is_incognito, int request_id) { - // Our path may include cachebuster arguments, so trim them off. - std::string uncached_path = StripQueryParams(path); + // Default scale factor if not specified. + ui::ScaleFactor scale_factor; + std::string uncached_path = ParsePathAndScale(path, &scale_factor); if (uncached_path == kNewTabCSSPath || uncached_path == kNewIncognitoTabCSSPath) { @@ -60,7 +101,7 @@ void ThemeSource::StartDataRequest(const std::string& path, } else { int resource_id = ResourcesUtil::GetThemeResourceId(uncached_path); if (resource_id != -1) { - SendThemeBitmap(request_id, resource_id); + SendThemeBitmap(request_id, resource_id, scale_factor); return; } } @@ -69,7 +110,7 @@ void ThemeSource::StartDataRequest(const std::string& path, } std::string ThemeSource::GetMimeType(const std::string& path) const { - std::string uncached_path = StripQueryParams(path); + std::string uncached_path = ParsePathAndScale(path, NULL); if (uncached_path == kNewTabCSSPath || uncached_path == kNewIncognitoTabCSSPath) { @@ -81,7 +122,7 @@ std::string ThemeSource::GetMimeType(const std::string& path) const { MessageLoop* ThemeSource::MessageLoopForRequestPath( const std::string& path) const { - std::string uncached_path = StripQueryParams(path); + std::string uncached_path = ParsePathAndScale(path, NULL); if (uncached_path == kNewTabCSSPath || uncached_path == kNewIncognitoTabCSSPath) { @@ -107,18 +148,22 @@ bool ThemeSource::ShouldReplaceExistingSource() const { //////////////////////////////////////////////////////////////////////////////// // ThemeSource, private: -void ThemeSource::SendThemeBitmap(int request_id, int resource_id) { +void ThemeSource::SendThemeBitmap(int request_id, + int resource_id, + ui::ScaleFactor scale_factor) { if (ThemeService::IsThemeableImage(resource_id)) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_); DCHECK(tp); + // TODO(flackr): Pass scale factor when fetching themeable images. scoped_refptr<base::RefCountedMemory> image_data(tp->GetRawData( resource_id)); SendResponse(request_id, image_data); } else { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - SendResponse(request_id, rb.LoadDataResourceBytes(resource_id)); + SendResponse(request_id, + rb.LoadDataResourceBytes(resource_id, scale_factor)); } } diff --git a/chrome/browser/ui/webui/theme_source.h b/chrome/browser/ui/webui/theme_source.h index 9e6c30e..5b58d1c 100644 --- a/chrome/browser/ui/webui/theme_source.h +++ b/chrome/browser/ui/webui/theme_source.h @@ -9,6 +9,7 @@ #include <string> #include "chrome/browser/ui/webui/chrome_url_data_manager.h" +#include "ui/base/layout.h" class Profile; @@ -38,7 +39,9 @@ class ThemeSource : public ChromeURLDataManager::DataSource { private: // Fetch and send the theme bitmap. - void SendThemeBitmap(int request_id, int resource_id); + void SendThemeBitmap(int request_id, + int resource_id, + ui::ScaleFactor scale_factor); // The original profile (never an OTR profile). Profile* profile_; diff --git a/chrome/browser/ui/webui/web_ui_browsertest.cc b/chrome/browser/ui/webui/web_ui_browsertest.cc index 2a7e0bf..ac95ea2 100644 --- a/chrome/browser/ui/webui/web_ui_browsertest.cc +++ b/chrome/browser/ui/webui/web_ui_browsertest.cc @@ -322,7 +322,7 @@ void WebUIBrowserTest::SetUpInProcessBrowserTestFixture() { FilePath resources_pack_path; PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); ResourceBundle::GetSharedInstance().AddDataPack( - resources_pack_path, ui::ResourceHandle::kScaleFactor100x); + resources_pack_path, ui::SCALE_FACTOR_100P); FilePath mockPath; ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &mockPath)); diff --git a/chrome/browser/ui/webui/web_ui_util.cc b/chrome/browser/ui/webui/web_ui_util.cc index 4ef88e0..46d2824 100644 --- a/chrome/browser/ui/webui/web_ui_util.cc +++ b/chrome/browser/ui/webui/web_ui_util.cc @@ -11,6 +11,7 @@ #include "base/memory/ref_counted_memory.h" #include "base/values.h" #include "chrome/browser/disposition_utils.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/codec/png_codec.h" @@ -30,7 +31,8 @@ std::string GetImageDataUrl(const SkBitmap& bitmap) { std::string GetImageDataUrlFromResource(int res) { // Load resource icon and covert to base64 encoded data url base::RefCountedStaticMemory* icon_data = - ResourceBundle::GetSharedInstance().LoadDataResourceBytes(res); + ResourceBundle::GetSharedInstance().LoadDataResourceBytes(res, + ui::SCALE_FACTOR_100P); if (!icon_data) return std::string(); scoped_refptr<base::RefCountedMemory> raw_icon(icon_data); diff --git a/chrome/common/chrome_content_client.cc b/chrome/common/chrome_content_client.cc index 369bc0a..040c8b0 100644 --- a/chrome/common/chrome_content_client.cc +++ b/chrome/common/chrome_content_client.cc @@ -9,9 +9,9 @@ #include "base/path_service.h" #include "base/process_util.h" #include "base/string_number_conversions.h" -#include "base/stringprintf.h" #include "base/string_split.h" #include "base/string_util.h" +#include "base/stringprintf.h" #include "base/utf_string_conversions.h" #include "chrome/common/child_process_logging.h" #include "chrome/common/chrome_paths.h" @@ -25,6 +25,7 @@ #include "grit/common_resources.h" #include "remoting/client/plugin/pepper_entrypoints.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" #include "webkit/glue/user_agent.h" #include "webkit/plugins/npapi/plugin_list.h" @@ -415,16 +416,11 @@ string16 ChromeContentClient::GetLocalizedString(int message_id) const { return l10n_util::GetStringUTF16(message_id); } -base::StringPiece ChromeContentClient::GetDataResource(int resource_id) const { - return ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); -} - -base::StringPiece ChromeContentClient::GetImageResource( +base::StringPiece ChromeContentClient::GetDataResource( int resource_id, - float scale_factor) const { - // TODO(flackr): Pass scale_factor to ResourceBundle to get best matching - // image resource for the given scale factor. - return ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); + ui::ScaleFactor scale_factor) const { + return ResourceBundle::GetSharedInstance().GetRawDataResource( + resource_id, scale_factor); } #if defined(OS_WIN) diff --git a/chrome/common/chrome_content_client.h b/chrome/common/chrome_content_client.h index a69cd87..e6074d5 100644 --- a/chrome/common/chrome_content_client.h +++ b/chrome/common/chrome_content_client.h @@ -33,9 +33,9 @@ class ChromeContentClient : public content::ContentClient { virtual bool CanHandleWhileSwappedOut(const IPC::Message& msg) OVERRIDE; virtual std::string GetUserAgent() const OVERRIDE; virtual string16 GetLocalizedString(int message_id) const OVERRIDE; - virtual base::StringPiece GetDataResource(int resource_id) const OVERRIDE; - virtual base::StringPiece GetImageResource(int resource_id, - float scale_factor) const OVERRIDE; + virtual base::StringPiece GetDataResource( + int resource_id, + ui::ScaleFactor scale_factor) const OVERRIDE; #if defined(OS_WIN) virtual bool SandboxPlugin(CommandLine* command_line, diff --git a/chrome/common/extensions/api/extension_api.cc b/chrome/common/extensions/api/extension_api.cc index b713a27..16458f8 100644 --- a/chrome/common/extensions/api/extension_api.cc +++ b/chrome/common/extensions/api/extension_api.cc @@ -23,6 +23,7 @@ #include "googleurl/src/gurl.h" #include "grit/common_resources.h" #include "grit/extensions_api_resources.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" using base::DictionaryValue; @@ -61,7 +62,8 @@ bool HasUnprivilegedChild(const DictionaryValue* name_space_node, } base::StringPiece ReadFromResource(int resource_id) { - return ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); + return ResourceBundle::GetSharedInstance().GetRawDataResource( + resource_id, ui::SCALE_FACTOR_NONE); } scoped_ptr<ListValue> LoadSchemaList(const std::string& name, diff --git a/chrome/common/extensions/simple_feature_provider.cc b/chrome/common/extensions/simple_feature_provider.cc index 08bed31..d17c360 100644 --- a/chrome/common/extensions/simple_feature_provider.cc +++ b/chrome/common/extensions/simple_feature_provider.cc @@ -9,6 +9,7 @@ #include "chrome/common/extensions/manifest_feature.h" #include "chrome/common/extensions/permission_feature.h" #include "grit/common_resources.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" namespace extensions { @@ -42,7 +43,7 @@ struct Static { int resource_id) { std::string manifest_features = ResourceBundle::GetSharedInstance().GetRawDataResource( - resource_id).as_string(); + resource_id, ui::SCALE_FACTOR_NONE).as_string(); int error_code = 0; std::string error_message; Value* value = base::JSONReader::ReadAndReturnError( diff --git a/chrome/common/jstemplate_builder.cc b/chrome/common/jstemplate_builder.cc index 9d0d46b..31c0c4d 100644 --- a/chrome/common/jstemplate_builder.cc +++ b/chrome/common/jstemplate_builder.cc @@ -12,6 +12,7 @@ #include "base/logging.h" #include "base/string_util.h" #include "grit/common_resources.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" namespace { @@ -91,7 +92,7 @@ void AppendJsTemplateSourceHtml(std::string* output) { // fetch and cache the pointer of the jstemplate resource source text. static const base::StringPiece jstemplate_src( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_JSTEMPLATE_JS)); + IDR_JSTEMPLATE_JS, ui::SCALE_FACTOR_NONE)); if (jstemplate_src.empty()) { NOTREACHED() << "Unable to get jstemplate src"; @@ -117,10 +118,10 @@ void AppendI18nTemplateSourceHtml(std::string* output) { // fetch and cache the pointer of the jstemplate resource source text. static const base::StringPiece i18n_template_src( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_I18N_TEMPLATE_JS)); + IDR_I18N_TEMPLATE_JS, ui::SCALE_FACTOR_NONE)); static const base::StringPiece i18n_template2_src( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_I18N_TEMPLATE2_JS)); + IDR_I18N_TEMPLATE2_JS, ui::SCALE_FACTOR_NONE)); const base::StringPiece* template_src = g_version2 ? &i18n_template2_src : &i18n_template_src; @@ -140,7 +141,7 @@ void AppendI18nTemplateProcessHtml(std::string* output) { static const base::StringPiece i18n_process_src( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_I18N_PROCESS_JS)); + IDR_I18N_PROCESS_JS, ui::SCALE_FACTOR_NONE)); if (i18n_process_src.empty()) { NOTREACHED() << "Unable to get i18n process src"; diff --git a/chrome/common/net/net_resource_provider.cc b/chrome/common/net/net_resource_provider.cc index abea5f4..db1a8ba 100644 --- a/chrome/common/net/net_resource_provider.cc +++ b/chrome/common/net/net_resource_provider.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -13,6 +13,7 @@ #include "grit/generated_resources.h" #include "grit/net_resources.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" namespace { @@ -40,7 +41,7 @@ struct LazyDirectoryListerCacher { l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); html_data = jstemplate_builder::GetI18nTemplateHtml( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_DIR_HEADER_HTML), + IDR_DIR_HEADER_HTML, ui::SCALE_FACTOR_NONE), &value); } @@ -57,7 +58,8 @@ base::StringPiece NetResourceProvider(int key) { if (IDR_DIR_HEADER_HTML == key) return base::StringPiece(lazy_dir_lister.html_data); - return ResourceBundle::GetSharedInstance().GetRawDataResource(key); + return ResourceBundle::GetSharedInstance().GetRawDataResource( + key, ui::SCALE_FACTOR_NONE); } } // namespace chrome_common_net diff --git a/chrome/common/web_apps.cc b/chrome/common/web_apps.cc index bfcf199..1564754 100644 --- a/chrome/common/web_apps.cc +++ b/chrome/common/web_apps.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -25,6 +25,7 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/size.h" #include "webkit/glue/dom_operations.h" @@ -216,7 +217,8 @@ bool ParseWebAppFromDefinitionFile(Value* definition_value, scoped_ptr<Value> schema( base::JSONReader::ReadAndReturnError( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_WEB_APP_SCHEMA).as_string(), + IDR_WEB_APP_SCHEMA, + ui::SCALE_FACTOR_NONE).as_string(), base::JSON_PARSE_RFC, // options &error_code, &error_message)); diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc index 4013b92f..7450dde 100644 --- a/chrome/renderer/chrome_content_renderer_client.cc +++ b/chrome/renderer/chrome_content_renderer_client.cc @@ -18,11 +18,11 @@ #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/content_settings_pattern.h" -#include "chrome/common/external_ipc_fuzzer.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_constants.h" #include "chrome/common/extensions/extension_process_policy.h" #include "chrome/common/extensions/extension_set.h" +#include "chrome/common/external_ipc_fuzzer.h" #include "chrome/common/jstemplate_builder.h" #include "chrome/common/render_messages.h" #include "chrome/common/url_constants.h" @@ -83,6 +83,7 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLError.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRequest.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" #include "webkit/plugins/npapi/plugin_list.h" #include "webkit/plugins/ppapi/plugin_module.h" @@ -659,7 +660,8 @@ void ChromeContentRendererClient::GetNavigationErrorStrings( } const base::StringPiece template_html( - ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id)); + ResourceBundle::GetSharedInstance().GetRawDataResource( + resource_id, ui::SCALE_FACTOR_NONE)); if (template_html.empty()) { NOTREACHED() << "unable to load template. ID: " << resource_id; } else { diff --git a/chrome/renderer/extensions/extension_dispatcher.cc b/chrome/renderer/extensions/extension_dispatcher.cc index 9706f67..30876ca 100644 --- a/chrome/renderer/extensions/extension_dispatcher.cc +++ b/chrome/renderer/extensions/extension_dispatcher.cc @@ -57,6 +57,7 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRequest.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" #include "v8/include/v8.h" @@ -412,7 +413,8 @@ void ExtensionDispatcher::OnLoaded( patterns.assign(platform_app_patterns); WebView::addUserStyleSheet( WebString::fromUTF8(ResourceBundle::GetSharedInstance(). - GetRawDataResource(IDR_PLATFORM_APP_CSS)), + GetRawDataResource(IDR_PLATFORM_APP_CSS, + ui::SCALE_FACTOR_NONE)), patterns, WebView::UserContentInjectInAllFrames, WebView::UserStyleInjectInExistingDocuments); diff --git a/chrome/renderer/extensions/json_schema_unittest.cc b/chrome/renderer/extensions/json_schema_unittest.cc index c4b0614..8eb4581 100644 --- a/chrome/renderer/extensions/json_schema_unittest.cc +++ b/chrome/renderer/extensions/json_schema_unittest.cc @@ -9,6 +9,7 @@ #include "chrome/test/base/v8_unit_test.h" #include "grit/renderer_resources.h" #include "testing/gtest/include/gtest/gtest.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" static const char kJsonSchema[] = "json_schema.js"; @@ -23,7 +24,7 @@ class JsonSchemaTest : public V8UnitTest { // Add the json schema code to the context. std::string code = ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_JSON_SCHEMA_JS).as_string(); + IDR_JSON_SCHEMA_JS, ui::SCALE_FACTOR_NONE).as_string(); // json_schema.js expects to have requireNative() defined. ExecuteScriptInContext( diff --git a/chrome/renderer/extensions/user_script_slave.cc b/chrome/renderer/extensions/user_script_slave.cc index 9008381..088dc56 100644 --- a/chrome/renderer/extensions/user_script_slave.cc +++ b/chrome/renderer/extensions/user_script_slave.cc @@ -8,10 +8,10 @@ #include "base/command_line.h" #include "base/logging.h" +#include "base/metrics/histogram.h" #include "base/perftimer.h" #include "base/pickle.h" #include "base/shared_memory.h" -#include "base/metrics/histogram.h" #include "base/stringprintf.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_set.h" @@ -27,9 +27,10 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRequest.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" using WebKit::WebFrame; @@ -118,7 +119,7 @@ UserScriptSlave::UserScriptSlave(const ExtensionSet* extensions) script_deleter_(&scripts_), extensions_(extensions) { api_js_ = ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_GREASEMONKEY_API_JS); + IDR_GREASEMONKEY_API_JS, ui::SCALE_FACTOR_NONE); } UserScriptSlave::~UserScriptSlave() {} diff --git a/chrome/renderer/plugins/plugin_placeholder.cc b/chrome/renderer/plugins/plugin_placeholder.cc index e87bbea..cf85d24 100644 --- a/chrome/renderer/plugins/plugin_placeholder.cc +++ b/chrome/renderer/plugins/plugin_placeholder.cc @@ -12,8 +12,8 @@ #include "base/utf_string_conversions.h" #include "base/values.h" #include "chrome/common/jstemplate_builder.h" -#include "chrome/common/render_messages.h" #include "chrome/common/prerender_messages.h" +#include "chrome/common/render_messages.h" #include "chrome/renderer/chrome_content_renderer_client.h" #include "chrome/renderer/custom_menu_commands.h" #include "chrome/renderer/plugins/plugin_uma.h" @@ -22,9 +22,6 @@ #include "grit/generated_resources.h" #include "grit/renderer_resources.h" #include "grit/webkit_strings.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebData.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" @@ -36,7 +33,11 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCaseSensitivity.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebData.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" #include "webkit/glue/webpreferences.h" #include "webkit/plugins/npapi/plugin_group.h" @@ -101,7 +102,7 @@ PluginPlaceholder* PluginPlaceholder::CreateMissingPlugin( const WebPluginParams& params) { const base::StringPiece template_html( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_BLOCKED_PLUGIN_HTML)); + IDR_BLOCKED_PLUGIN_HTML, ui::SCALE_FACTOR_NONE)); DictionaryValue values; values.SetString("message", l10n_util::GetStringUTF8(IDS_PLUGIN_SEARCHING)); @@ -132,7 +133,7 @@ PluginPlaceholder* PluginPlaceholder::CreateErrorPlugin( const base::StringPiece template_html( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_BLOCKED_PLUGIN_HTML)); + IDR_BLOCKED_PLUGIN_HTML, ui::SCALE_FACTOR_NONE)); std::string html_data = jstemplate_builder::GetI18nTemplateHtml(template_html, &values); @@ -162,7 +163,8 @@ PluginPlaceholder* PluginPlaceholder::CreateBlockedPlugin( values.SetString("hide", l10n_util::GetStringUTF8(IDS_PLUGIN_HIDE)); const base::StringPiece template_html( - ResourceBundle::GetSharedInstance().GetRawDataResource(template_id)); + ResourceBundle::GetSharedInstance().GetRawDataResource( + template_id, ui::SCALE_FACTOR_NONE)); DCHECK(!template_html.empty()) << "unable to load template. ID: " << template_id; @@ -185,7 +187,7 @@ PluginPlaceholder* PluginPlaceholder::CreateMobileYoutubePlugin( const WebPluginParams& params) { const base::StringPiece template_html( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_YOUTUBE_PLUGIN_HTML)); + IDR_YOUTUBE_PLUGIN_HTML, ui::SCALE_FACTOR_NONE)); DictionaryValue values; values.SetString("video_id", GetYoutubeVideoId(params)); diff --git a/chrome/renderer/resource_bundle_source_map.cc b/chrome/renderer/resource_bundle_source_map.cc index 5a42582..86ee68d 100644 --- a/chrome/renderer/resource_bundle_source_map.cc +++ b/chrome/renderer/resource_bundle_source_map.cc @@ -4,6 +4,7 @@ #include "chrome/renderer/resource_bundle_source_map.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" ResourceBundleSourceMap::ResourceBundleSourceMap( @@ -24,7 +25,8 @@ v8::Handle<v8::Value> ResourceBundleSourceMap::GetSource( if (!Contains(name)) return v8::Undefined(); int resource_id = resource_id_map_[name]; - return ConvertString(resource_bundle_->GetRawDataResource(resource_id)); + return ConvertString(resource_bundle_->GetRawDataResource( + resource_id, ui::SCALE_FACTOR_NONE)); } bool ResourceBundleSourceMap::Contains(const std::string& name) { diff --git a/chrome/test/base/chrome_test_suite.cc b/chrome/test/base/chrome_test_suite.cc index 842e58c..3795306 100644 --- a/chrome/test/base/chrome_test_suite.cc +++ b/chrome/test/base/chrome_test_suite.cc @@ -201,7 +201,7 @@ void ChromeTestSuite::Initialize() { resources_pack_path = resources_pack_path.Append(FILE_PATH_LITERAL("resources.pak")); ResourceBundle::GetSharedInstance().AddDataPack( - resources_pack_path, ui::ResourceHandle::kScaleFactor100x); + resources_pack_path, ui::SCALE_FACTOR_100P); // Mock out the compositor on platforms that use it. ui::SetupTestCompositor(); diff --git a/chrome/test/base/module_system_test.cc b/chrome/test/base/module_system_test.cc index ce77a20..d6bb6d3 100644 --- a/chrome/test/base/module_system_test.cc +++ b/chrome/test/base/module_system_test.cc @@ -8,6 +8,7 @@ #include "base/memory/scoped_ptr.h" #include "base/string_piece.h" #include "chrome/renderer/native_handler.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" #include <map> @@ -98,7 +99,8 @@ void ModuleSystemTest::RegisterModule(const std::string& name, void ModuleSystemTest::RegisterModule(const std::string& name, int resource_id) { const std::string& code = ResourceBundle::GetSharedInstance(). - GetRawDataResource(resource_id).as_string(); + GetRawDataResource(resource_id, + ui::SCALE_FACTOR_NONE).as_string(); source_map_->RegisterModule(name, code); } diff --git a/chrome/tools/mac_helpers/infoplist_strings_util.mm b/chrome/tools/mac_helpers/infoplist_strings_util.mm index 270e07f..051013b 100644 --- a/chrome/tools/mac_helpers/infoplist_strings_util.mm +++ b/chrome/tools/mac_helpers/infoplist_strings_util.mm @@ -60,7 +60,7 @@ ui::DataPack* LoadResourceDataPack(const char* dir_path, dir_path, branding_strings_name, locale_name]; if (resource_path) { FilePath resources_pak_path([resource_path fileSystemRepresentation]); - resource_pack = new ui::DataPack(ui::ResourceHandle::kScaleFactor100x); + resource_pack = new ui::DataPack(ui::SCALE_FACTOR_100P); bool success = resource_pack->Load(resources_pak_path); if (!success) { delete resource_pack; diff --git a/chrome_frame/simple_resource_loader.cc b/chrome_frame/simple_resource_loader.cc index 8d1524f..72ab076 100644 --- a/chrome_frame/simple_resource_loader.cc +++ b/chrome_frame/simple_resource_loader.cc @@ -206,7 +206,7 @@ bool SimpleResourceLoader::LoadLocalePack( if (file_util::PathExists(resource_pack_path) && file_util::PathExists(dll_path)) { scoped_ptr<ui::DataPack> cur_data_pack( - new ui::DataPack(ui::ResourceHandle::kScaleFactor100x)); + new ui::DataPack(ui::SCALE_FACTOR_100P)); if (!cur_data_pack->Load(resource_pack_path)) continue; diff --git a/content/browser/debugger/devtools_http_handler_impl.cc b/content/browser/debugger/devtools_http_handler_impl.cc index bbe45a4..e00d4ab 100644 --- a/content/browser/debugger/devtools_http_handler_impl.cc +++ b/content/browser/debugger/devtools_http_handler_impl.cc @@ -38,6 +38,7 @@ #include "net/server/http_server_request_info.h" #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context_getter.h" +#include "ui/base/layout.h" namespace content { @@ -230,7 +231,8 @@ void DevToolsHttpHandlerImpl::OnHttpRequest( int resource_id = DevToolsHttpHandler::GetFrontendResourceId(filename); if (resource_id != -1) { base::StringPiece data = - content::GetContentClient()->GetDataResource(resource_id); + content::GetContentClient()->GetDataResource( + resource_id, ui::SCALE_FACTOR_NONE); server_->Send200(connection_id, data.as_string(), GetMimeType(filename)); diff --git a/content/common/sandbox_mac.mm b/content/common/sandbox_mac.mm index 679fddf..90b7fe9 100644 --- a/content/common/sandbox_mac.mm +++ b/content/common/sandbox_mac.mm @@ -31,6 +31,7 @@ extern "C" { #include "content/public/common/content_client.h" #include "content/public/common/content_switches.h" #include "grit/content_resources.h" +#include "ui/base/layout.h" #include "ui/gl/gl_surface.h" #include "unicode/uchar.h" @@ -363,7 +364,8 @@ NSString* LoadSandboxTemplate(int sandbox_type) { } base::StringPiece sandbox_definition = - content::GetContentClient()->GetDataResource(sandbox_profile_resource_id); + content::GetContentClient()->GetDataResource( + sandbox_profile_resource_id, ui::SCALE_FACTOR_NONE); if (sandbox_definition.empty()) { LOG(FATAL) << "Failed to load the sandbox profile (resource id " << sandbox_profile_resource_id << ")"; @@ -371,7 +373,8 @@ NSString* LoadSandboxTemplate(int sandbox_type) { } base::StringPiece common_sandbox_definition = - content::GetContentClient()->GetDataResource(IDR_COMMON_SANDBOX_PROFILE); + content::GetContentClient()->GetDataResource( + IDR_COMMON_SANDBOX_PROFILE, ui::SCALE_FACTOR_NONE); if (common_sandbox_definition.empty()) { LOG(FATAL) << "Failed to load the common sandbox profile"; return nil; diff --git a/content/common/webkitplatformsupport_impl.cc b/content/common/webkitplatformsupport_impl.cc index 6309d9c..0fc1f2b 100644 --- a/content/common/webkitplatformsupport_impl.cc +++ b/content/common/webkitplatformsupport_impl.cc @@ -24,15 +24,10 @@ string16 WebKitPlatformSupportImpl::GetLocalizedString(int message_id) { } base::StringPiece WebKitPlatformSupportImpl::GetDataResource( - int resource_id) { - return content::GetContentClient()->GetDataResource(resource_id); -} - -base::StringPiece WebKitPlatformSupportImpl::GetImageResource( int resource_id, - float scale_factor) { - return content::GetContentClient()->GetImageResource(resource_id, - scale_factor); + ui::ScaleFactor scale_factor) { + return content::GetContentClient()->GetDataResource(resource_id, + scale_factor); } void WebKitPlatformSupportImpl::GetPlugins( diff --git a/content/common/webkitplatformsupport_impl.h b/content/common/webkitplatformsupport_impl.h index c190ae6..8d1e2f5 100644 --- a/content/common/webkitplatformsupport_impl.h +++ b/content/common/webkitplatformsupport_impl.h @@ -8,6 +8,7 @@ #include "base/compiler_specific.h" #include "content/common/content_export.h" +#include "ui/base/layout.h" #include "webkit/glue/webkitplatformsupport_impl.h" class GpuChannelHostFactory; @@ -23,9 +24,9 @@ class CONTENT_EXPORT WebKitPlatformSupportImpl virtual ~WebKitPlatformSupportImpl(); virtual string16 GetLocalizedString(int message_id) OVERRIDE; - virtual base::StringPiece GetDataResource(int resource_id) OVERRIDE; - virtual base::StringPiece GetImageResource(int resource_id, - float scale_factor) OVERRIDE; + virtual base::StringPiece GetDataResource( + int resource_id, + ui::ScaleFactor scale_factor) OVERRIDE; virtual void GetPlugins(bool refresh, std::vector<webkit::WebPluginInfo>* plugins) OVERRIDE; virtual webkit_glue::ResourceLoaderBridge* CreateResourceLoader( diff --git a/content/public/common/content_client.h b/content/public/common/content_client.h index 61ad9b9..1190328 100644 --- a/content/public/common/content_client.h +++ b/content/public/common/content_client.h @@ -14,6 +14,7 @@ #include "base/string_piece.h" #include "build/build_config.h" #include "content/common/content_export.h" +#include "ui/base/layout.h" class CommandLine; class GURL; @@ -115,12 +116,9 @@ class CONTENT_EXPORT ContentClient { virtual string16 GetLocalizedString(int message_id) const = 0; // Return the contents of a resource in a StringPiece given the resource id. - virtual base::StringPiece GetDataResource(int resource_id) const = 0; - - // Return the contents of an image resource in a StringPiece given the - // resource id. - virtual base::StringPiece GetImageResource(int resource_id, - float scale_factor) const = 0; + virtual base::StringPiece GetDataResource( + int resource_id, + ui::ScaleFactor scale_factor) const = 0; #if defined(OS_WIN) // Allows the embedder to sandbox a plugin, and apply a custom policy. diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc index 3df9f77..dce3836 100644 --- a/content/renderer/render_thread_impl.cc +++ b/content/renderer/render_thread_impl.cc @@ -77,8 +77,9 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptController.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" +#include "ui/base/layout.h" #include "ui/base/ui_base_switches.h" #include "v8/include/v8.h" #include "webkit/glue/webkit_glue.h" @@ -492,7 +493,7 @@ void RenderThreadImpl::EnsureWebKitInitialized() { if (CommandLine::ForCurrentProcess()->HasSwitch( switches::kDomAutomationController)) { base::StringPiece extension = content::GetContentClient()->GetDataResource( - IDR_DOM_AUTOMATION_JS); + IDR_DOM_AUTOMATION_JS, ui::SCALE_FACTOR_NONE); RegisterExtension(new v8::Extension( "dom_automation.js", extension.data(), 0, NULL, extension.size())); } diff --git a/content/shell/layout_test_controller_bindings.cc b/content/shell/layout_test_controller_bindings.cc index 2f3a5ad..054b4f7 100644 --- a/content/shell/layout_test_controller_bindings.cc +++ b/content/shell/layout_test_controller_bindings.cc @@ -10,6 +10,7 @@ #include "grit/shell_resources.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" using WebKit::WebFrame; @@ -20,7 +21,8 @@ namespace content { namespace { base::StringPiece GetStringResource(int resource_id) { - return ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); + return ResourceBundle::GetSharedInstance().GetRawDataResource( + resource_id, ui::SCALE_FACTOR_NONE); } RenderView* GetCurrentRenderView() { diff --git a/content/shell/shell_content_client.cc b/content/shell/shell_content_client.cc index e3c80d8..c004593 100644 --- a/content/shell/shell_content_client.cc +++ b/content/shell/shell_content_client.cc @@ -52,16 +52,11 @@ string16 ShellContentClient::GetLocalizedString(int message_id) const { return string16(); } -base::StringPiece ShellContentClient::GetDataResource(int resource_id) const { - return ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); -} - -base::StringPiece ShellContentClient::GetImageResource( +base::StringPiece ShellContentClient::GetDataResource( int resource_id, - float scale_factor) const { - // TODO(flackr): Pass scale_factor to ResourceBundle to get best matching - // image resource for the given scale factor. - return ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); + ui::ScaleFactor scale_factor) const { + return ResourceBundle::GetSharedInstance().GetRawDataResource( + resource_id, scale_factor); } #if defined(OS_WIN) diff --git a/content/shell/shell_content_client.h b/content/shell/shell_content_client.h index d8b216e..1d3aeda 100644 --- a/content/shell/shell_content_client.h +++ b/content/shell/shell_content_client.h @@ -31,9 +31,9 @@ class ShellContentClient : public ContentClient { virtual bool CanHandleWhileSwappedOut(const IPC::Message& msg) OVERRIDE; virtual std::string GetUserAgent() const OVERRIDE; virtual string16 GetLocalizedString(int message_id) const OVERRIDE; - virtual base::StringPiece GetDataResource(int resource_id) const OVERRIDE; - virtual base::StringPiece GetImageResource(int resource_id, - float scale_factor) const OVERRIDE; + virtual base::StringPiece GetDataResource( + int resource_id, + ui::ScaleFactor scale_factor) const OVERRIDE; #if defined(OS_WIN) virtual bool SandboxPlugin(CommandLine* command_line, diff --git a/content/shell/shell_devtools_delegate.cc b/content/shell/shell_devtools_delegate.cc index 15cdce8..cf35cd1 100644 --- a/content/shell/shell_devtools_delegate.cc +++ b/content/shell/shell_devtools_delegate.cc @@ -9,6 +9,7 @@ #include "content/public/browser/devtools_http_handler.h" #include "grit/shell_resources.h" #include "net/url_request/url_request_context_getter.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" namespace content { @@ -35,7 +36,8 @@ void ShellDevToolsDelegate::Stop() { std::string ShellDevToolsDelegate::GetDiscoveryPageHTML() { return ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_CONTENT_SHELL_DEVTOOLS_DISCOVERY_PAGE).as_string(); + IDR_CONTENT_SHELL_DEVTOOLS_DISCOVERY_PAGE, + ui::SCALE_FACTOR_NONE).as_string(); } bool ShellDevToolsDelegate::BundlesFrontendResources() { diff --git a/content/test/test_content_client.cc b/content/test/test_content_client.cc index 11d9bb6..0d2e3e0 100644 --- a/content/test/test_content_client.cc +++ b/content/test/test_content_client.cc @@ -11,7 +11,7 @@ #include "base/string_piece.h" TestContentClient::TestContentClient() - : data_pack_(ui::ResourceHandle::kScaleFactor100x) { + : data_pack_(ui::SCALE_FACTOR_100P) { FilePath content_resources_pack_path; PathService::Get(base::DIR_MODULE, &content_resources_pack_path); content_resources_pack_path = content_resources_pack_path.Append( @@ -58,15 +58,9 @@ string16 TestContentClient::GetLocalizedString(int message_id) const { return string16(); } -base::StringPiece TestContentClient::GetDataResource(int resource_id) const { - base::StringPiece resource; - data_pack_.GetStringPiece(resource_id, &resource); - return resource; -} - -base::StringPiece TestContentClient::GetImageResource( +base::StringPiece TestContentClient::GetDataResource( int resource_id, - float scale_factor) const { + ui::ScaleFactor scale_factor) const { base::StringPiece resource; data_pack_.GetStringPiece(resource_id, &resource); return resource; diff --git a/content/test/test_content_client.h b/content/test/test_content_client.h index 94fb820..ecf449b 100644 --- a/content/test/test_content_client.h +++ b/content/test/test_content_client.h @@ -32,9 +32,9 @@ class TestContentClient : public content::ContentClient { virtual bool CanHandleWhileSwappedOut(const IPC::Message& msg) OVERRIDE; virtual std::string GetUserAgent() const OVERRIDE; virtual string16 GetLocalizedString(int message_id) const OVERRIDE; - virtual base::StringPiece GetDataResource(int resource_id) const OVERRIDE; - virtual base::StringPiece GetImageResource(int resource_id, - float scale_factor) const OVERRIDE; + virtual base::StringPiece GetDataResource( + int resource_id, + ui::ScaleFactor scale_factor) const OVERRIDE; #if defined(OS_WIN) virtual bool SandboxPlugin(CommandLine* command_line, sandbox::TargetPolicy* policy) OVERRIDE; diff --git a/ui/base/layout.h b/ui/base/layout.h index be65e6e..b65bfdd 100644 --- a/ui/base/layout.h +++ b/ui/base/layout.h @@ -27,6 +27,16 @@ enum DisplayLayout { // the .pak file of theme resources to load. UI_EXPORT DisplayLayout GetDisplayLayout(); +enum ScaleFactor { + SCALE_FACTOR_100P, + + // The scale factor used for unscaled binary data, the 1x (default) scale + // factor data packs. + SCALE_FACTOR_NONE = SCALE_FACTOR_100P, + + SCALE_FACTOR_200P, +}; + } // namespace ui #endif // UI_BASE_LAYOUT_H_ diff --git a/ui/base/resource/data_pack.cc b/ui/base/resource/data_pack.cc index 0fa97a8..e1d8c14 100644 --- a/ui/base/resource/data_pack.cc +++ b/ui/base/resource/data_pack.cc @@ -61,7 +61,7 @@ enum LoadErrors { namespace ui { -DataPack::DataPack(float scale_factor) +DataPack::DataPack(ui::ScaleFactor scale_factor) : resource_count_(0), text_encoding_type_(BINARY), scale_factor_(scale_factor) { @@ -145,6 +145,11 @@ bool DataPack::Load(const FilePath& path) { return true; } +bool DataPack::HasResource(uint16 resource_id) const { + return !!bsearch(&resource_id, mmap_->data() + kHeaderLength, resource_count_, + sizeof(DataPackEntry), DataPackEntry::CompareById); +} + bool DataPack::GetStringPiece(uint16 resource_id, base::StringPiece* data) const { // It won't be hard to make this endian-agnostic, but it's not worth @@ -186,7 +191,7 @@ ResourceHandle::TextEncodingType DataPack::GetTextEncodingType() const { return text_encoding_type_; } -float DataPack::GetScaleFactor() const { +ui::ScaleFactor DataPack::GetScaleFactor() const { return scale_factor_; } diff --git a/ui/base/resource/data_pack.h b/ui/base/resource/data_pack.h index 0ac5efe..3c03253 100644 --- a/ui/base/resource/data_pack.h +++ b/ui/base/resource/data_pack.h @@ -15,8 +15,9 @@ #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" #include "base/string_piece.h" -#include "ui/base/ui_export.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_handle.h" +#include "ui/base/ui_export.h" class FilePath; @@ -32,7 +33,7 @@ namespace ui { class UI_EXPORT DataPack : public ResourceHandle { public: - DataPack(float scale_factor); + DataPack(ui::ScaleFactor scale_factor); virtual ~DataPack(); // Load a pack file from |path|, returning false on error. @@ -47,12 +48,13 @@ class UI_EXPORT DataPack : public ResourceHandle { TextEncodingType textEncodingType); // ResourceHandle implementation: + virtual bool HasResource(uint16 resource_id) const OVERRIDE; virtual bool GetStringPiece(uint16 resource_id, base::StringPiece* data) const OVERRIDE; virtual base::RefCountedStaticMemory* GetStaticMemory( uint16 resource_id) const OVERRIDE; virtual TextEncodingType GetTextEncodingType() const OVERRIDE; - virtual float GetScaleFactor() const OVERRIDE; + virtual ui::ScaleFactor GetScaleFactor() const OVERRIDE; private: // The memory-mapped data. @@ -66,7 +68,7 @@ class UI_EXPORT DataPack : public ResourceHandle { // The scale of the image in this resource pack relative to images in the 1x // resource pak. - float scale_factor_; + ui::ScaleFactor scale_factor_; DISALLOW_COPY_AND_ASSIGN(DataPack); }; diff --git a/ui/base/resource/data_pack_literal.cc b/ui/base/resource/data_pack_literal.cc index 510d07a..05e610b 100644 --- a/ui/base/resource/data_pack_literal.cc +++ b/ui/base/resource/data_pack_literal.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -21,4 +21,23 @@ extern const char kSamplePakContents[] = { extern const size_t kSamplePakSize = sizeof(kSamplePakContents); +extern const char kSamplePakContents2x[] = { + 0x04, 0x00, 0x00, 0x00, // header(version + 0x01, 0x00, 0x00, 0x00, // no. entries + 0x01, // encoding) + 0x04, 0x00, 0x15, 0x00, 0x00, 0x00, // index entry 4 + 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, // extra entry for the size of last + 't', 'h', 'i', 's', ' ', 'i', 's', ' ', 'i', 'd', ' ', '4', ' ', '2', 'x' +}; + +extern const size_t kSamplePakSize2x = sizeof(kSamplePakContents2x); + +extern const char kEmptyPakContents[] = { + 0x04, 0x00, 0x00, 0x00, // header(version + 0x00, 0x00, 0x00, 0x00, // no. entries + 0x01 +}; + +extern const size_t kEmptyPakSize = sizeof(kEmptyPakContents); + } // namespace ui diff --git a/ui/base/resource/data_pack_unittest.cc b/ui/base/resource/data_pack_unittest.cc index 36be6fd..1ac2145 100644 --- a/ui/base/resource/data_pack_unittest.cc +++ b/ui/base/resource/data_pack_unittest.cc @@ -31,12 +31,14 @@ TEST(DataPackTest, Load) { static_cast<int>(kSamplePakSize)); // Load the file through the data pack API. - DataPack pack(ResourceHandle::kScaleFactor100x); + DataPack pack(SCALE_FACTOR_100P); ASSERT_TRUE(pack.Load(data_path)); base::StringPiece data; + ASSERT_TRUE(pack.HasResource(4)); ASSERT_TRUE(pack.GetStringPiece(4, &data)); EXPECT_EQ("this is id 4", data); + ASSERT_TRUE(pack.HasResource(6)); ASSERT_TRUE(pack.GetStringPiece(6, &data)); EXPECT_EQ("this is id 6", data); @@ -47,6 +49,7 @@ TEST(DataPackTest, Load) { EXPECT_EQ(0U, data.length()); // Try looking up an invalid key. + ASSERT_FALSE(pack.HasResource(140)); ASSERT_FALSE(pack.GetStringPiece(140, &data)); } @@ -63,7 +66,7 @@ TEST(DataPackTest, LoadFileWithTruncatedHeader) { data_path = data_path.Append(FILE_PATH_LITERAL( "ui/base/test/data/data_pack_unittest/truncated-header.pak")); - DataPack pack(ResourceHandle::kScaleFactor100x); + DataPack pack(SCALE_FACTOR_100P); ASSERT_FALSE(pack.Load(data_path)); } @@ -87,7 +90,7 @@ TEST_P(DataPackTest, Write) { ASSERT_TRUE(DataPack::WritePack(file, resources, GetParam())); // Now try to read the data back in. - DataPack pack(ResourceHandle::kScaleFactor100x); + DataPack pack(SCALE_FACTOR_100P); ASSERT_TRUE(pack.Load(file)); EXPECT_EQ(pack.GetTextEncodingType(), GetParam()); diff --git a/ui/base/resource/resource_bundle.cc b/ui/base/resource/resource_bundle.cc index c5fa973..bc77d53 100644 --- a/ui/base/resource/resource_bundle.cc +++ b/ui/base/resource/resource_bundle.cc @@ -19,6 +19,7 @@ #include "build/build_config.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/layout.h" #include "ui/base/resource/data_pack.h" #include "ui/base/ui_base_paths.h" #include "ui/base/ui_base_switches.h" @@ -60,7 +61,7 @@ void ResourceBundle::InitSharedInstanceWithPakFile(const FilePath& path) { DCHECK(g_shared_instance_ == NULL) << "ResourceBundle initialized twice"; g_shared_instance_ = new ResourceBundle(NULL); - g_shared_instance_->LoadTestResources(path); + g_shared_instance_->LoadTestResources(path, path); } // static @@ -87,7 +88,8 @@ bool ResourceBundle::LocaleDataPakExists(const std::string& locale) { return !GetLocaleFilePath(locale).empty(); } -void ResourceBundle::AddDataPack(const FilePath& path, float scale_factor) { +void ResourceBundle::AddDataPack(const FilePath& path, + ScaleFactor scale_factor) { // Do not pass an empty |path| value to this method. If the absolute path is // unknown pass just the pack file name. DCHECK(!path.empty()); @@ -101,7 +103,7 @@ void ResourceBundle::AddDataPack(const FilePath& path, float scale_factor) { return; scoped_ptr<DataPack> data_pack( - new DataPack(ResourceHandle::kScaleFactor100x)); + new DataPack(scale_factor)); if (data_pack->Load(pack_path)) { data_packs_.push_back(data_pack.release()); } else { @@ -164,7 +166,7 @@ std::string ResourceBundle::LoadLocaleResources( } scoped_ptr<DataPack> data_pack( - new DataPack(ResourceHandle::kScaleFactor100x)); + new DataPack(SCALE_FACTOR_100P)); if (!data_pack->Load(locale_file_path)) { UMA_HISTOGRAM_ENUMERATION("ResourceBundle.LoadLocaleResourcesError", logging::GetLastSystemErrorCode(), 16000); @@ -176,16 +178,21 @@ std::string ResourceBundle::LoadLocaleResources( return app_locale; } -void ResourceBundle::LoadTestResources(const FilePath& path) { +void ResourceBundle::LoadTestResources(const FilePath& path, + const FilePath& locale_path) { // Use the given resource pak for both common and localized resources. scoped_ptr<DataPack> data_pack( - new DataPack(ResourceHandle::kScaleFactor100x)); - if (data_pack->Load(path)) + new DataPack(SCALE_FACTOR_100P)); + if (!path.empty() && data_pack->Load(path)) data_packs_.push_back(data_pack.release()); - data_pack.reset(new DataPack(ResourceHandle::kScaleFactor100x)); - if (data_pack->Load(path)) + data_pack.reset(new DataPack(ui::SCALE_FACTOR_NONE)); + if (!locale_path.empty() && data_pack->Load(locale_path)) { locale_resources_data_.reset(data_pack.release()); + } else { + locale_resources_data_.reset( + new DataPack(ui::SCALE_FACTOR_NONE)); + } } void ResourceBundle::UnloadLocaleResources() { @@ -270,30 +277,45 @@ gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id) { } base::RefCountedStaticMemory* ResourceBundle::LoadDataResourceBytes( - int resource_id) const { + int resource_id, + ScaleFactor scale_factor) const { base::RefCountedStaticMemory* bytes = NULL; if (delegate_) - bytes = delegate_->LoadDataResourceBytes(resource_id); + bytes = delegate_->LoadDataResourceBytes(resource_id, scale_factor); if (!bytes) { - for (size_t i = 0; i < data_packs_.size() && !bytes; ++i) - bytes = data_packs_[i]->GetStaticMemory(resource_id); + base::StringPiece data = GetRawDataResource(resource_id, scale_factor); + if (!data.empty()) { + bytes = new base::RefCountedStaticMemory( + reinterpret_cast<const unsigned char*>(data.data()), data.length()); + } } return bytes; } -base::StringPiece ResourceBundle::GetRawDataResource(int resource_id) const { +base::StringPiece ResourceBundle::GetRawDataResource( + int resource_id, + ScaleFactor scale_factor) const { base::StringPiece data; - if (delegate_ && delegate_->GetRawDataResource(resource_id, &data)) + if (delegate_ && + delegate_->GetRawDataResource(resource_id, scale_factor, &data)) return data; DCHECK(locale_resources_data_.get()); if (locale_resources_data_->GetStringPiece(resource_id, &data)) return data; - for (size_t i = 0; i < data_packs_.size(); ++i) { - if (data_packs_[i]->GetStringPiece(resource_id, &data)) + if (scale_factor != ui::SCALE_FACTOR_100P) { + for (size_t i = 0; i < data_packs_.size(); i++) { + if (data_packs_[i]->GetScaleFactor() == scale_factor && + data_packs_[i]->GetStringPiece(resource_id, &data)) + return data; + } + } + for (size_t i = 0; i < data_packs_.size(); i++) { + if (data_packs_[i]->GetScaleFactor() == ui::SCALE_FACTOR_100P && + data_packs_[i]->GetStringPiece(resource_id, &data)) return data; } @@ -320,7 +342,7 @@ string16 ResourceBundle::GetLocalizedString(int message_id) { if (!locale_resources_data_->GetStringPiece(message_id, &data)) { // Fall back on the main data pack (shouldn't be any strings here except in // unittests). - data = GetRawDataResource(message_id); + data = GetRawDataResource(message_id, ui::SCALE_FACTOR_NONE); if (data.empty()) { NOTREACHED() << "unable to find resource: " << message_id; return string16(); diff --git a/ui/base/resource/resource_bundle.h b/ui/base/resource/resource_bundle.h index df25f31..62d8fd6 100644 --- a/ui/base/resource/resource_bundle.h +++ b/ui/base/resource/resource_bundle.h @@ -18,6 +18,7 @@ #include "base/memory/scoped_vector.h" #include "base/string16.h" #include "base/string_piece.h" +#include "ui/base/layout.h" #include "ui/base/ui_export.h" #include "ui/gfx/font.h" #include "ui/gfx/image/image.h" @@ -69,7 +70,7 @@ class UI_EXPORT ResourceBundle { // |pack_path| will contain the complete default path for the pack file if // known or just the pack file name otherwise. virtual FilePath GetPathForResourcePack(const FilePath& pack_path, - float scale_factor) = 0; + ScaleFactor scale_factor) = 0; // Called before a locale pack file is loaded. Return the full path for // the pack file to continue loading or an empty value to cancel loading. @@ -89,11 +90,13 @@ class UI_EXPORT ResourceBundle { // Return a static memory resource or NULL to attempt retrieval of the // default resource. virtual base::RefCountedStaticMemory* LoadDataResourceBytes( - int resource_id) = 0; + int resource_id, + ScaleFactor scale_factor) = 0; // Retrieve a raw data resource. Return true if a resource was provided or // false to attempt retrieval of the default resource. virtual bool GetRawDataResource(int resource_id, + ScaleFactor scale_factor, base::StringPiece* value) = 0; // Retrieve a localized string. Return true if a string was provided or @@ -137,7 +140,7 @@ class UI_EXPORT ResourceBundle { // this value). |scale_factor| is the scale of images in this resource pak // relative to the images in the 1x resource pak. This method is not thread // safe! You should call it immediately after calling InitSharedInstance. - void AddDataPack(const FilePath& path, float scale_factor); + void AddDataPack(const FilePath& path, ScaleFactor scale_factor); // Changes the locale for an already-initialized ResourceBundle, returning the // name of the newly-loaded locale. Future calls to get strings will return @@ -181,13 +184,19 @@ class UI_EXPORT ResourceBundle { // Same as GetNativeImageNamed() except that RTL is not enabled. gfx::Image& GetNativeImageNamed(int resource_id); - // Loads the raw bytes of a data resource into |bytes|, - // without doing any processing or interpretation of - // the resource. Returns whether we successfully read the resource. - base::RefCountedStaticMemory* LoadDataResourceBytes(int resource_id) const; + // Loads the raw bytes of a data resource nearest the scale factor + // |scale_factor| into |bytes|, without doing any processing or interpretation + // of the resource. Use ResourceHandle::SCALE_FACTOR_NONE for non-image + // resources. Returns NULL if we fail to read the resource. + base::RefCountedStaticMemory* LoadDataResourceBytes( + int resource_id, + ScaleFactor scale_factor) const; - // Return the contents of a resource in a StringPiece given the resource id. - base::StringPiece GetRawDataResource(int resource_id) const; + // Return the contents of a resource in a StringPiece given the resource id + // nearest the scale factor |scale_factor|. + // Use ResourceHanlde::SCALE_FACTOR_NONE for non-image resources. + base::StringPiece GetRawDataResource(int resource_id, + ScaleFactor scale_factor) const; // Get a localized string given a message id. Returns an empty // string if the message_id is not found. @@ -213,6 +222,7 @@ class UI_EXPORT ResourceBundle { FRIEND_TEST_ALL_PREFIXES(ResourceBundle, DelegateGetRawDataResource); FRIEND_TEST_ALL_PREFIXES(ResourceBundle, DelegateGetLocalizedString); FRIEND_TEST_ALL_PREFIXES(ResourceBundle, DelegateGetFont); + FRIEND_TEST_ALL_PREFIXES(ResourceBundle, GetRawDataResource); FRIEND_TEST_ALL_PREFIXES(ResourceBundle, LoadDataResourceBytes); FRIEND_TEST_ALL_PREFIXES(ResourceBundle, LocaleDataPakExists); @@ -230,8 +240,9 @@ class UI_EXPORT ResourceBundle { // Returns the locale that is loaded. std::string LoadLocaleResources(const std::string& pref_locale); - // Load test resources in given path. - void LoadTestResources(const FilePath& path); + // Load test resources in given paths. If either path is empty an empty + // resource pack is loaded. + void LoadTestResources(const FilePath& path, const FilePath& locale_path); // Unload the locale specific strings and prepares to load new ones. See // comments for ReloadLocaleResources(). diff --git a/ui/base/resource/resource_bundle_android.cc b/ui/base/resource/resource_bundle_android.cc index d770d3e..b8d30d4 100644 --- a/ui/base/resource/resource_bundle_android.cc +++ b/ui/base/resource/resource_bundle_android.cc @@ -30,11 +30,11 @@ namespace ui { void ResourceBundle::LoadCommonResources() { AddDataPack(GetResourcesPakFilePath("chrome.pak"), - ResourceHandle::kScaleFactor100x); + SCALE_FACTOR_100P); AddDataPack(GetResourcesPakFilePath("theme_resources_standard.pak"), - ResourceHandle::kScaleFactor100x); + SCALE_FACTOR_100P); AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak"), - ResourceHandle::kScaleFactor100x); + SCALE_FACTOR_100P); } gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) { diff --git a/ui/base/resource/resource_bundle_aurax11.cc b/ui/base/resource/resource_bundle_aurax11.cc index 6f63dff..535f455 100644 --- a/ui/base/resource/resource_bundle_aurax11.cc +++ b/ui/base/resource/resource_bundle_aurax11.cc @@ -28,18 +28,18 @@ namespace ui { void ResourceBundle::LoadCommonResources() { AddDataPack(GetResourcesPakFilePath("chrome.pak"), - ResourceHandle::kScaleFactor100x); + SCALE_FACTOR_100P); if (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) { AddDataPack(GetResourcesPakFilePath("theme_resources_touch_1x.pak"), - ResourceHandle::kScaleFactor100x); + SCALE_FACTOR_100P); AddDataPack(GetResourcesPakFilePath("ui_resources_touch.pak"), - ResourceHandle::kScaleFactor100x); + SCALE_FACTOR_100P); } else { AddDataPack(GetResourcesPakFilePath("theme_resources_standard.pak"), - ResourceHandle::kScaleFactor100x); + SCALE_FACTOR_100P); AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak"), - ResourceHandle::kScaleFactor100x); + SCALE_FACTOR_100P); } } diff --git a/ui/base/resource/resource_bundle_gtk.cc b/ui/base/resource/resource_bundle_gtk.cc index 1c64e4d..d969bc0 100644 --- a/ui/base/resource/resource_bundle_gtk.cc +++ b/ui/base/resource/resource_bundle_gtk.cc @@ -8,10 +8,11 @@ #include "base/logging.h" #include "base/memory/ref_counted_memory.h" #include "base/path_service.h" -#include "ui/base/resource/resource_handle.h" #include "base/synchronization/lock.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/gtk/scoped_gobject.h" +#include "ui/base/layout.h" +#include "ui/base/resource/resource_handle.h" #include "ui/base/ui_base_paths.h" #include "ui/gfx/image/image.h" @@ -65,11 +66,11 @@ FilePath GetResourcesPakFilePath(const std::string& pak_name) { void ResourceBundle::LoadCommonResources() { AddDataPack(GetResourcesPakFilePath("chrome.pak"), - ResourceHandle::kScaleFactor100x); + SCALE_FACTOR_100P); AddDataPack(GetResourcesPakFilePath("theme_resources_standard.pak"), - ResourceHandle::kScaleFactor100x); + SCALE_FACTOR_100P); AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak"), - ResourceHandle::kScaleFactor100x); + SCALE_FACTOR_100P); } gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) { @@ -89,7 +90,7 @@ gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) { if (image.IsEmpty()) { scoped_refptr<base::RefCountedStaticMemory> data( - LoadDataResourceBytes(resource_id)); + LoadDataResourceBytes(resource_id, SCALE_FACTOR_100P)); GdkPixbuf* pixbuf = LoadPixbuf(data.get(), rtl == RTL_ENABLED); if (!pixbuf) { diff --git a/ui/base/resource/resource_bundle_mac.mm b/ui/base/resource/resource_bundle_mac.mm index 8a559c4..07736d8 100644 --- a/ui/base/resource/resource_bundle_mac.mm +++ b/ui/base/resource/resource_bundle_mac.mm @@ -50,22 +50,22 @@ FilePath GetResourcesPakFilePath(NSString* name, NSString* mac_locale) { void ResourceBundle::LoadCommonResources() { AddDataPack(GetResourcesPakFilePath(@"chrome", nil), - ResourceHandle::kScaleFactor100x); + SCALE_FACTOR_100P); AddDataPack(GetResourcesPakFilePath(@"theme_resources_standard", nil), - ResourceHandle::kScaleFactor100x); + SCALE_FACTOR_100P); AddDataPack(GetResourcesPakFilePath(@"ui_resources_standard", nil), - ResourceHandle::kScaleFactor100x); + SCALE_FACTOR_100P); // On Windows and ChromeOS we load either the 1x resource or the 2x resource. // On Mac we load both and let the UI framework decide which one to use. #if defined(ENABLE_HIDPI) if (base::mac::IsOSLionOrLater()) { AddDataPack(GetResourcesPakFilePath(@"theme_resources_2x", nil), - ResourceHandle::kScaleFactor200x); + SCALE_FACTOR_200P); AddDataPack(GetResourcesPakFilePath(@"theme_resources_standard_2x", nil), - ResourceHandle::kScaleFactor200x); + SCALE_FACTOR_200P); AddDataPack(GetResourcesPakFilePath(@"ui_resources_standard_2x", nil), - ResourceHandle::kScaleFactor200x); + SCALE_FACTOR_200P); } #endif } diff --git a/ui/base/resource/resource_bundle_unittest.cc b/ui/base/resource/resource_bundle_unittest.cc index 1d72785..79a8ca9 100644 --- a/ui/base/resource/resource_bundle_unittest.cc +++ b/ui/base/resource/resource_bundle_unittest.cc @@ -14,6 +14,7 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/skia/include/core/SkBitmap.h" +#include "ui/base/layout.h" using ::testing::_; using ::testing::Between; @@ -25,6 +26,10 @@ namespace ui { extern const char kSamplePakContents[]; extern const size_t kSamplePakSize; +extern const char kSamplePakContents2x[]; +extern const size_t kSamplePakSize2x; +extern const char kEmptyPakContents[]; +extern const size_t kEmptyPakSize; namespace { @@ -37,19 +42,23 @@ class MockResourceBundleDelegate : public ui::ResourceBundle::Delegate { } MOCK_METHOD2(GetPathForResourcePack, FilePath(const FilePath& pack_path, - float scale_factor)); + ui::ScaleFactor scale_factor)); MOCK_METHOD2(GetPathForLocalePack, FilePath(const FilePath& pack_path, const std::string& locale)); MOCK_METHOD1(GetImageNamed, gfx::Image(int resource_id)); MOCK_METHOD2(GetNativeImageNamed, gfx::Image(int resource_id, ui::ResourceBundle::ImageRTL rtl)); - MOCK_METHOD1(LoadDataResourceBytes, - base::RefCountedStaticMemory*(int resource_id)); - MOCK_METHOD1(GetRawDataResourceMock, base::StringPiece(int resource_id)); + MOCK_METHOD2(LoadDataResourceBytes, + base::RefCountedStaticMemory*(int resource_id, + ui::ScaleFactor scale_factor)); + MOCK_METHOD2(GetRawDataResourceMock, base::StringPiece( + int resource_id, + ui::ScaleFactor scale_factor)); virtual bool GetRawDataResource(int resource_id, + ui::ScaleFactor scale_factor, base::StringPiece* value) OVERRIDE { - *value = GetRawDataResourceMock(resource_id); + *value = GetRawDataResourceMock(resource_id, scale_factor); return true; } MOCK_METHOD1(GetLocalizedStringMock, string16(int message_id)); @@ -71,7 +80,7 @@ TEST(ResourceBundle, DelegateGetPathForResourcePack) { ResourceBundle resource_bundle(&delegate); FilePath pack_path(FILE_PATH_LITERAL("/path/to/test_path.pak")); - double pack_scale_factor = 2.0; + ui::ScaleFactor pack_scale_factor = ui::SCALE_FACTOR_200P; EXPECT_CALL(delegate, GetPathForResourcePack( @@ -152,13 +161,14 @@ TEST(ResourceBundle, DelegateLoadDataResourceBytes) { new base::RefCountedStaticMemory(data, sizeof(data))); int resource_id = 5; + ui::ScaleFactor scale_factor = ui::SCALE_FACTOR_NONE; - EXPECT_CALL(delegate, LoadDataResourceBytes(resource_id)) + EXPECT_CALL(delegate, LoadDataResourceBytes(resource_id, scale_factor)) .Times(1) .WillOnce(Return(static_memory)); scoped_refptr<base::RefCountedStaticMemory> result = - resource_bundle.LoadDataResourceBytes(resource_id); + resource_bundle.LoadDataResourceBytes(resource_id, scale_factor); EXPECT_EQ(static_memory, result); } @@ -172,11 +182,13 @@ TEST(ResourceBundle, DelegateGetRawDataResource) { int resource_id = 5; - EXPECT_CALL(delegate, GetRawDataResourceMock(resource_id)) + EXPECT_CALL(delegate, GetRawDataResourceMock( + resource_id, ui::SCALE_FACTOR_NONE)) .Times(1) .WillOnce(Return(string_piece)); - base::StringPiece result = resource_bundle.GetRawDataResource(resource_id); + base::StringPiece result = resource_bundle.GetRawDataResource( + resource_id, ui::SCALE_FACTOR_NONE); EXPECT_EQ(string_piece.data(), result.data()); } @@ -232,16 +244,58 @@ TEST(ResourceBundle, LoadDataResourceBytes) { static_cast<int>(kSamplePakSize)); // Create a resource bundle from the file. - resource_bundle.LoadTestResources(data_path); + resource_bundle.LoadTestResources(data_path, data_path); const int kUnfoundResourceId = 10000; - EXPECT_EQ(NULL, resource_bundle.LoadDataResourceBytes(kUnfoundResourceId)); + EXPECT_EQ(NULL, resource_bundle.LoadDataResourceBytes( + kUnfoundResourceId, ui::SCALE_FACTOR_NONE)); // Give a .pak file that doesn't exist so we will fail to load it. resource_bundle.AddDataPack( FilePath(FILE_PATH_LITERAL("non-existant-file.pak")), - 1.0); - EXPECT_EQ(NULL, resource_bundle.LoadDataResourceBytes(kUnfoundResourceId)); + ui::SCALE_FACTOR_NONE); + EXPECT_EQ(NULL, resource_bundle.LoadDataResourceBytes( + kUnfoundResourceId, ui::SCALE_FACTOR_NONE)); + } +} + +TEST(ResourceBundle, GetRawDataResource) { + + // On Windows, the default data is compiled into the binary so this does + // nothing. + ScopedTempDir dir; + ASSERT_TRUE(dir.CreateUniqueTempDir()); + FilePath locale_path = dir.path().Append(FILE_PATH_LITERAL("empty.pak")); + FilePath data_path = dir.path().Append(FILE_PATH_LITERAL("sample.pak")); + FilePath data_2x_path = dir.path().Append(FILE_PATH_LITERAL("sample_2x.pak")); + + { + ResourceBundle resource_bundle(NULL); + // Dump contents into the pak files. + ASSERT_EQ(file_util::WriteFile(locale_path, kEmptyPakContents, + kEmptyPakSize), static_cast<int>(kEmptyPakSize)); + ASSERT_EQ(file_util::WriteFile(data_path, kSamplePakContents, + kSamplePakSize), static_cast<int>(kSamplePakSize)); + ASSERT_EQ(file_util::WriteFile(data_2x_path, kSamplePakContents2x, + kSamplePakSize2x), static_cast<int>(kSamplePakSize2x)); + + // Load the regular and 2x pak files. + resource_bundle.LoadTestResources(data_path, locale_path); + resource_bundle.AddDataPack(data_2x_path, SCALE_FACTOR_200P); + + // Resource ID 4 exists in both 1x and 2x paks, so we expect a different + // result when requesting the 2x scale. + EXPECT_EQ("this is id 4", resource_bundle.GetRawDataResource(4, + SCALE_FACTOR_100P)); + EXPECT_EQ("this is id 4 2x", resource_bundle.GetRawDataResource(4, + SCALE_FACTOR_200P)); + + // Resource ID 6 only exists in the 1x pak so we expect the same resource + // for both scale factor requests. + EXPECT_EQ("this is id 6", resource_bundle.GetRawDataResource(6, + SCALE_FACTOR_100P)); + EXPECT_EQ("this is id 6", resource_bundle.GetRawDataResource(6, + SCALE_FACTOR_200P)); } } diff --git a/ui/base/resource/resource_bundle_win.cc b/ui/base/resource/resource_bundle_win.cc index e181e7d..4e525e7 100644 --- a/ui/base/resource/resource_bundle_win.cc +++ b/ui/base/resource/resource_bundle_win.cc @@ -49,21 +49,21 @@ void ResourceBundle::LoadCommonResources() { switch (ui::GetDisplayLayout()) { case ui::LAYOUT_TOUCH: AddDataPack(GetResourcesPakFilePath("theme_resources_touch_1x.pak"), - ResourceHandle::kScaleFactor100x); + SCALE_FACTOR_100P); AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak"), - ResourceHandle::kScaleFactor100x); + SCALE_FACTOR_100P); break; default: if (use_hidpi) { AddDataPack(GetResourcesPakFilePath("theme_resources_2x.pak"), - ResourceHandle::kScaleFactor200x); + SCALE_FACTOR_200P); AddDataPack(GetResourcesPakFilePath("ui_resources_2x.pak"), - ResourceHandle::kScaleFactor200x); + SCALE_FACTOR_200P); } else { AddDataPack(GetResourcesPakFilePath("theme_resources_standard.pak"), - ResourceHandle::kScaleFactor100x); + SCALE_FACTOR_100P); AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak"), - ResourceHandle::kScaleFactor100x); + SCALE_FACTOR_100P); } break; } diff --git a/ui/base/resource/resource_data_dll_win.cc b/ui/base/resource/resource_data_dll_win.cc index 48e9db1..c6c90c71 100644 --- a/ui/base/resource/resource_data_dll_win.cc +++ b/ui/base/resource/resource_data_dll_win.cc @@ -17,6 +17,15 @@ ResourceDataDLL::ResourceDataDLL(HINSTANCE module) : module_(module) { ResourceDataDLL::~ResourceDataDLL() { } +bool ResourceDataDLL::HasResource(uint16 resource_id) const { + void* data_ptr; + size_t data_size; + return base::win::GetDataResourceFromModule(module_, + resource_id, + &data_ptr, + &data_size); +} + bool ResourceDataDLL::GetStringPiece(uint16 resource_id, base::StringPiece* data) const { DCHECK(data); @@ -48,8 +57,8 @@ ResourceHandle::TextEncodingType ResourceDataDLL::GetTextEncodingType() const { return BINARY; } -float ResourceDataDLL::GetScaleFactor() const { - return 1.0; +ScaleFactor ResourceDataDLL::GetScaleFactor() const { + return ui::SCALE_FACTOR_NONE; } } // namespace ui diff --git a/ui/base/resource/resource_data_dll_win.h b/ui/base/resource/resource_data_dll_win.h index e21e9aa..a38dd54 100644 --- a/ui/base/resource/resource_data_dll_win.h +++ b/ui/base/resource/resource_data_dll_win.h @@ -19,12 +19,13 @@ class ResourceDataDLL : public ResourceHandle { virtual ~ResourceDataDLL(); // ResourceHandle implementation: + virtual bool HasResource(uint16 resource_id) const OVERRIDE; virtual bool GetStringPiece(uint16 resource_id, base::StringPiece* data) const OVERRIDE; virtual base::RefCountedStaticMemory* GetStaticMemory( uint16 resource_id) const OVERRIDE; virtual TextEncodingType GetTextEncodingType() const OVERRIDE; - virtual float GetScaleFactor() const OVERRIDE; + virtual ScaleFactor GetScaleFactor() const OVERRIDE; private: const HINSTANCE module_; diff --git a/ui/base/resource/resource_handle.cc b/ui/base/resource/resource_handle.cc deleted file mode 100644 index 947ff80..0000000 --- a/ui/base/resource/resource_handle.cc +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ui/base/resource/resource_handle.h" - -namespace ui { - -const float ResourceHandle::kScaleFactor100x = 1.0; -const float ResourceHandle::kScaleFactor200x = 2.0; - -} // namespace ui diff --git a/ui/base/resource/resource_handle.h b/ui/base/resource/resource_handle.h index b40741e..1d26e72 100644 --- a/ui/base/resource/resource_handle.h +++ b/ui/base/resource/resource_handle.h @@ -8,6 +8,7 @@ #include "base/basictypes.h" #include "base/string_piece.h" +#include "ui/base/layout.h" #include "ui/base/ui_export.h" namespace base { @@ -25,12 +26,11 @@ class UI_EXPORT ResourceHandle { UTF16 }; - // The scale factors for image resources. - static const float kScaleFactor100x; - static const float kScaleFactor200x; - virtual ~ResourceHandle() {} + // Returns true if the DataPack contains a resource with id |resource_id|. + virtual bool HasResource(uint16 resource_id) const = 0; + // Get resource by id |resource_id|, filling in |data|. // The data is owned by the DataPack object and should not be modified. // Returns false if the resource id isn't found. @@ -47,7 +47,7 @@ class UI_EXPORT ResourceHandle { // The scale of images in this resource pack relative to images in the 1x // resource pak. - virtual float GetScaleFactor() const = 0; + virtual ScaleFactor GetScaleFactor() const = 0; }; } // namespace ui diff --git a/ui/compositor/test/compositor_test_support.cc b/ui/compositor/test/compositor_test_support.cc index 07c2ce7..0ac2609 100644 --- a/ui/compositor/test/compositor_test_support.cc +++ b/ui/compositor/test/compositor_test_support.cc @@ -17,12 +17,9 @@ class CompositorTestPlatformSupport: return string16(); } - virtual base::StringPiece GetDataResource(int resource_id) OVERRIDE { - return base::StringPiece(); - } - - virtual base::StringPiece GetImageResource(int resource_id, - float scale_factor) OVERRIDE { + virtual base::StringPiece GetDataResource( + int resource_id, + ui::ScaleFactor scale_factor) OVERRIDE { return base::StringPiece(); } diff --git a/ui/test/test_suite.cc b/ui/test/test_suite.cc index da66f41..26e0e93 100644 --- a/ui/test/test_suite.cc +++ b/ui/test/test_suite.cc @@ -56,7 +56,7 @@ void UITestSuite::Initialize() { #if !defined(OS_MACOSX) && defined(OS_POSIX) ui::ResourceBundle::GetSharedInstance().AddDataPack( pak_dir.AppendASCII("ui_resources.pak"), - ResourceHandle::kScaleFactor100x); + ui::SCALE_FACTOR_100P); #endif } @@ -240,7 +240,6 @@ 'base/resource/resource_bundle_win.h', 'base/resource/resource_data_dll_win.cc', 'base/resource/resource_data_dll_win.h', - 'base/resource/resource_handle.cc', 'base/resource/resource_handle.h', 'base/text/bytes_formatting.cc', 'base/text/bytes_formatting.h', diff --git a/webkit/glue/webkit_glue_unittest.cc b/webkit/glue/webkit_glue_unittest.cc index 39b6208..f50b20e 100644 --- a/webkit/glue/webkit_glue_unittest.cc +++ b/webkit/glue/webkit_glue_unittest.cc @@ -100,12 +100,7 @@ class TestWebKitPlatformSupport return string16(); } - virtual base::StringPiece GetDataResource(int) OVERRIDE { - return base::StringPiece(); - } - - virtual base::StringPiece GetImageResource(int resource_id, - float scale_factor) OVERRIDE { + virtual base::StringPiece GetDataResource(int, ui::ScaleFactor) OVERRIDE { return base::StringPiece(); } diff --git a/webkit/glue/webkitplatformsupport_impl.cc b/webkit/glue/webkitplatformsupport_impl.cc index 0849f76..73e2e08 100644 --- a/webkit/glue/webkitplatformsupport_impl.cc +++ b/webkit/glue/webkitplatformsupport_impl.cc @@ -29,14 +29,15 @@ #include "grit/webkit_chromium_resources.h" #include "grit/webkit_resources.h" #include "grit/webkit_strings.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCookie.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebData.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginListBuilder.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCookie.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebData.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" +#include "ui/base/layout.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/websocketstreamhandle_impl.h" #include "webkit/glue/webthread_impl.h" @@ -369,7 +370,8 @@ WebData loadAudioSpatializationResource(WebKitPlatformSupportImpl* platform, is_resource_index_good) { const int kFirstAudioResourceIndex = IDR_AUDIO_SPATIALIZATION_T000_P000; base::StringPiece resource = - platform->GetDataResource(kFirstAudioResourceIndex + resource_index); + platform->GetDataResource(kFirstAudioResourceIndex + resource_index, + ui::SCALE_FACTOR_NONE); return WebData(resource.data(), resource.size()); } #endif // IDR_AUDIO_SPATIALIZATION_T000_P000 @@ -381,89 +383,108 @@ WebData loadAudioSpatializationResource(WebKitPlatformSupportImpl* platform, struct DataResource { const char* name; int id; - float scale_factor; + ui::ScaleFactor scale_factor; }; const DataResource kDataResources[] = { - { "missingImage", IDR_BROKENIMAGE, 1.0 }, - { "missingImage@2x", IDR_BROKENIMAGE, 2.0 }, + { "missingImage", IDR_BROKENIMAGE, ui::SCALE_FACTOR_100P }, + { "missingImage@2x", IDR_BROKENIMAGE, ui::SCALE_FACTOR_200P }, #if defined(OS_ANDROID) - { "mediaFullscreen", IDR_MEDIA_FULLSCREEN_BUTTON, 1.0 }, + { "mediaFullscreen", IDR_MEDIA_FULLSCREEN_BUTTON, ui::SCALE_FACTOR_100P }, #endif - { "mediaPause", IDR_MEDIA_PAUSE_BUTTON, 1.0 }, - { "mediaPlay", IDR_MEDIA_PLAY_BUTTON, 1.0 }, - { "mediaPlayDisabled", IDR_MEDIA_PLAY_BUTTON_DISABLED, 1.0 }, - { "mediaSoundDisabled", IDR_MEDIA_SOUND_DISABLED, 1.0 }, - { "mediaSoundFull", IDR_MEDIA_SOUND_FULL_BUTTON, 1.0 }, - { "mediaSoundNone", IDR_MEDIA_SOUND_NONE_BUTTON, 1.0 }, - { "mediaSliderThumb", IDR_MEDIA_SLIDER_THUMB, 1.0 }, - { "mediaVolumeSliderThumb", IDR_MEDIA_VOLUME_SLIDER_THUMB, 1.0 }, - { "mediaplayerPause", IDR_MEDIAPLAYER_PAUSE_BUTTON, 1.0 }, - { "mediaplayerPauseHover", IDR_MEDIAPLAYER_PAUSE_BUTTON_HOVER, 1.0 }, - { "mediaplayerPauseDown", IDR_MEDIAPLAYER_PAUSE_BUTTON_DOWN, 1.0 }, - { "mediaplayerPlay", IDR_MEDIAPLAYER_PLAY_BUTTON, 1.0 }, - { "mediaplayerPlayHover", IDR_MEDIAPLAYER_PLAY_BUTTON_HOVER, 1.0 }, - { "mediaplayerPlayDown", IDR_MEDIAPLAYER_PLAY_BUTTON_DOWN, 1.0 }, - { "mediaplayerPlayDisabled", IDR_MEDIAPLAYER_PLAY_BUTTON_DISABLED, 1.0 }, - { "mediaplayerSoundLevel3", IDR_MEDIAPLAYER_SOUND_LEVEL3_BUTTON, 1.0 }, + { "mediaPause", IDR_MEDIA_PAUSE_BUTTON, ui::SCALE_FACTOR_100P }, + { "mediaPlay", IDR_MEDIA_PLAY_BUTTON, ui::SCALE_FACTOR_100P }, + { "mediaPlayDisabled", + IDR_MEDIA_PLAY_BUTTON_DISABLED, ui::SCALE_FACTOR_100P }, + { "mediaSoundDisabled", IDR_MEDIA_SOUND_DISABLED, ui::SCALE_FACTOR_100P }, + { "mediaSoundFull", IDR_MEDIA_SOUND_FULL_BUTTON, ui::SCALE_FACTOR_100P }, + { "mediaSoundNone", IDR_MEDIA_SOUND_NONE_BUTTON, ui::SCALE_FACTOR_100P }, + { "mediaSliderThumb", IDR_MEDIA_SLIDER_THUMB, ui::SCALE_FACTOR_100P }, + { "mediaVolumeSliderThumb", + IDR_MEDIA_VOLUME_SLIDER_THUMB, ui::SCALE_FACTOR_100P }, + { "mediaplayerPause", IDR_MEDIAPLAYER_PAUSE_BUTTON, ui::SCALE_FACTOR_100P }, + { "mediaplayerPauseHover", + IDR_MEDIAPLAYER_PAUSE_BUTTON_HOVER, ui::SCALE_FACTOR_100P }, + { "mediaplayerPauseDown", + IDR_MEDIAPLAYER_PAUSE_BUTTON_DOWN, ui::SCALE_FACTOR_100P }, + { "mediaplayerPlay", IDR_MEDIAPLAYER_PLAY_BUTTON, ui::SCALE_FACTOR_100P }, + { "mediaplayerPlayHover", + IDR_MEDIAPLAYER_PLAY_BUTTON_HOVER, ui::SCALE_FACTOR_100P }, + { "mediaplayerPlayDown", + IDR_MEDIAPLAYER_PLAY_BUTTON_DOWN, ui::SCALE_FACTOR_100P }, + { "mediaplayerPlayDisabled", + IDR_MEDIAPLAYER_PLAY_BUTTON_DISABLED, ui::SCALE_FACTOR_100P }, + { "mediaplayerSoundLevel3", + IDR_MEDIAPLAYER_SOUND_LEVEL3_BUTTON, ui::SCALE_FACTOR_100P }, { "mediaplayerSoundLevel3Hover", - IDR_MEDIAPLAYER_SOUND_LEVEL3_BUTTON_HOVER, 1.0 }, + IDR_MEDIAPLAYER_SOUND_LEVEL3_BUTTON_HOVER, ui::SCALE_FACTOR_100P }, { "mediaplayerSoundLevel3Down", - IDR_MEDIAPLAYER_SOUND_LEVEL3_BUTTON_DOWN, 1.0 }, - { "mediaplayerSoundLevel2", IDR_MEDIAPLAYER_SOUND_LEVEL2_BUTTON, 1.0 }, + IDR_MEDIAPLAYER_SOUND_LEVEL3_BUTTON_DOWN, ui::SCALE_FACTOR_100P }, + { "mediaplayerSoundLevel2", + IDR_MEDIAPLAYER_SOUND_LEVEL2_BUTTON, ui::SCALE_FACTOR_100P }, { "mediaplayerSoundLevel2Hover", - IDR_MEDIAPLAYER_SOUND_LEVEL2_BUTTON_HOVER, 1.0 }, + IDR_MEDIAPLAYER_SOUND_LEVEL2_BUTTON_HOVER, ui::SCALE_FACTOR_100P }, { "mediaplayerSoundLevel2Down", - IDR_MEDIAPLAYER_SOUND_LEVEL2_BUTTON_DOWN, 1.0 }, - { "mediaplayerSoundLevel1", IDR_MEDIAPLAYER_SOUND_LEVEL1_BUTTON, 1.0 }, + IDR_MEDIAPLAYER_SOUND_LEVEL2_BUTTON_DOWN, ui::SCALE_FACTOR_100P }, + { "mediaplayerSoundLevel1", + IDR_MEDIAPLAYER_SOUND_LEVEL1_BUTTON, ui::SCALE_FACTOR_100P }, { "mediaplayerSoundLevel1Hover", - IDR_MEDIAPLAYER_SOUND_LEVEL1_BUTTON_HOVER, 1.0 }, + IDR_MEDIAPLAYER_SOUND_LEVEL1_BUTTON_HOVER, ui::SCALE_FACTOR_100P }, { "mediaplayerSoundLevel1Down", - IDR_MEDIAPLAYER_SOUND_LEVEL1_BUTTON_DOWN, 1.0 }, - { "mediaplayerSoundLevel0", IDR_MEDIAPLAYER_SOUND_LEVEL0_BUTTON, 1.0 }, + IDR_MEDIAPLAYER_SOUND_LEVEL1_BUTTON_DOWN, ui::SCALE_FACTOR_100P }, + { "mediaplayerSoundLevel0", + IDR_MEDIAPLAYER_SOUND_LEVEL0_BUTTON, ui::SCALE_FACTOR_100P }, { "mediaplayerSoundLevel0Hover", - IDR_MEDIAPLAYER_SOUND_LEVEL0_BUTTON_HOVER, 1.0 }, + IDR_MEDIAPLAYER_SOUND_LEVEL0_BUTTON_HOVER, ui::SCALE_FACTOR_100P }, { "mediaplayerSoundLevel0Down", - IDR_MEDIAPLAYER_SOUND_LEVEL0_BUTTON_DOWN, 1.0 }, - { "mediaplayerSoundDisabled", IDR_MEDIAPLAYER_SOUND_DISABLED, 1.0 }, - { "mediaplayerSliderThumb", IDR_MEDIAPLAYER_SLIDER_THUMB, 1.0 }, - { "mediaplayerSliderThumbHover", IDR_MEDIAPLAYER_SLIDER_THUMB_HOVER, 1.0 }, - { "mediaplayerSliderThumbDown", IDR_MEDIAPLAYER_SLIDER_THUMB_DOWN, 1.0 }, - { "mediaplayerVolumeSliderThumb", IDR_MEDIAPLAYER_VOLUME_SLIDER_THUMB, 1.0 }, + IDR_MEDIAPLAYER_SOUND_LEVEL0_BUTTON_DOWN, ui::SCALE_FACTOR_100P }, + { "mediaplayerSoundDisabled", + IDR_MEDIAPLAYER_SOUND_DISABLED, ui::SCALE_FACTOR_100P }, + { "mediaplayerSliderThumb", + IDR_MEDIAPLAYER_SLIDER_THUMB, ui::SCALE_FACTOR_100P }, + { "mediaplayerSliderThumbHover", + IDR_MEDIAPLAYER_SLIDER_THUMB_HOVER, ui::SCALE_FACTOR_100P }, + { "mediaplayerSliderThumbDown", + IDR_MEDIAPLAYER_SLIDER_THUMB_DOWN, ui::SCALE_FACTOR_100P }, + { "mediaplayerVolumeSliderThumb", + IDR_MEDIAPLAYER_VOLUME_SLIDER_THUMB, ui::SCALE_FACTOR_100P }, { "mediaplayerVolumeSliderThumbHover", - IDR_MEDIAPLAYER_VOLUME_SLIDER_THUMB_HOVER, 1.0 }, + IDR_MEDIAPLAYER_VOLUME_SLIDER_THUMB_HOVER, ui::SCALE_FACTOR_100P }, { "mediaplayerVolumeSliderThumbDown", - IDR_MEDIAPLAYER_VOLUME_SLIDER_THUMB_DOWN, 1.0 }, + IDR_MEDIAPLAYER_VOLUME_SLIDER_THUMB_DOWN, ui::SCALE_FACTOR_100P }, { "mediaplayerVolumeSliderThumbDisabled", - IDR_MEDIAPLAYER_VOLUME_SLIDER_THUMB_DISABLED, 1.0 }, - { "mediaplayerFullscreen", IDR_MEDIAPLAYER_FULLSCREEN_BUTTON, 1.0 }, + IDR_MEDIAPLAYER_VOLUME_SLIDER_THUMB_DISABLED, ui::SCALE_FACTOR_100P }, + { "mediaplayerFullscreen", + IDR_MEDIAPLAYER_FULLSCREEN_BUTTON, ui::SCALE_FACTOR_100P }, { "mediaplayerFullscreenHover", - IDR_MEDIAPLAYER_FULLSCREEN_BUTTON_HOVER, 1.0 }, - { "mediaplayerFullscreenDown", IDR_MEDIAPLAYER_FULLSCREEN_BUTTON_DOWN, 1.0 }, + IDR_MEDIAPLAYER_FULLSCREEN_BUTTON_HOVER, ui::SCALE_FACTOR_100P }, + { "mediaplayerFullscreenDown", + IDR_MEDIAPLAYER_FULLSCREEN_BUTTON_DOWN, ui::SCALE_FACTOR_100P }, { "mediaplayerFullscreenDisabled", - IDR_MEDIAPLAYER_FULLSCREEN_BUTTON_DISABLED, 1.0 }, + IDR_MEDIAPLAYER_FULLSCREEN_BUTTON_DISABLED, ui::SCALE_FACTOR_100P }, #if defined(OS_MACOSX) - { "overhangPattern", IDR_OVERHANG_PATTERN, 1.0 }, + { "overhangPattern", IDR_OVERHANG_PATTERN, ui::SCALE_FACTOR_100P }, #endif - { "panIcon", IDR_PAN_SCROLL_ICON, 1.0 }, - { "searchCancel", IDR_SEARCH_CANCEL, 1.0 }, - { "searchCancelPressed", IDR_SEARCH_CANCEL_PRESSED, 1.0 }, - { "searchMagnifier", IDR_SEARCH_MAGNIFIER, 1.0 }, - { "searchMagnifierResults", IDR_SEARCH_MAGNIFIER_RESULTS, 1.0 }, - { "textAreaResizeCorner", IDR_TEXTAREA_RESIZER, 1.0 }, - { "textAreaResizeCorner@2x", IDR_TEXTAREA_RESIZER, 2.0 }, - { "tickmarkDash", IDR_TICKMARK_DASH, 1.0 }, - { "inputSpeech", IDR_INPUT_SPEECH, 1.0 }, - { "inputSpeechRecording", IDR_INPUT_SPEECH_RECORDING, 1.0 }, - { "inputSpeechWaiting", IDR_INPUT_SPEECH_WAITING, 1.0 }, - { "americanExpressCC", IDR_AUTOFILL_CC_AMEX, 1.0 }, - { "dinersCC", IDR_AUTOFILL_CC_DINERS, 1.0 }, - { "discoverCC", IDR_AUTOFILL_CC_DISCOVER, 1.0 }, - { "genericCC", IDR_AUTOFILL_CC_GENERIC, 1.0 }, - { "jcbCC", IDR_AUTOFILL_CC_JCB, 1.0 }, - { "masterCardCC", IDR_AUTOFILL_CC_MASTERCARD, 1.0 }, - { "soloCC", IDR_AUTOFILL_CC_SOLO, 1.0 }, - { "visaCC", IDR_AUTOFILL_CC_VISA, 1.0 }, + { "panIcon", IDR_PAN_SCROLL_ICON, ui::SCALE_FACTOR_100P }, + { "searchCancel", IDR_SEARCH_CANCEL, ui::SCALE_FACTOR_100P }, + { "searchCancelPressed", IDR_SEARCH_CANCEL_PRESSED, ui::SCALE_FACTOR_100P }, + { "searchMagnifier", IDR_SEARCH_MAGNIFIER, ui::SCALE_FACTOR_100P }, + { "searchMagnifierResults", + IDR_SEARCH_MAGNIFIER_RESULTS, ui::SCALE_FACTOR_100P }, + { "textAreaResizeCorner", IDR_TEXTAREA_RESIZER, ui::SCALE_FACTOR_100P }, + { "textAreaResizeCorner@2x", IDR_TEXTAREA_RESIZER, ui::SCALE_FACTOR_200P }, + { "tickmarkDash", IDR_TICKMARK_DASH, ui::SCALE_FACTOR_100P }, + { "inputSpeech", IDR_INPUT_SPEECH, ui::SCALE_FACTOR_100P }, + { "inputSpeechRecording", IDR_INPUT_SPEECH_RECORDING, ui::SCALE_FACTOR_100P }, + { "inputSpeechWaiting", IDR_INPUT_SPEECH_WAITING, ui::SCALE_FACTOR_100P }, + { "americanExpressCC", IDR_AUTOFILL_CC_AMEX, ui::SCALE_FACTOR_100P }, + { "dinersCC", IDR_AUTOFILL_CC_DINERS, ui::SCALE_FACTOR_100P }, + { "discoverCC", IDR_AUTOFILL_CC_DISCOVER, ui::SCALE_FACTOR_100P }, + { "genericCC", IDR_AUTOFILL_CC_GENERIC, ui::SCALE_FACTOR_100P }, + { "jcbCC", IDR_AUTOFILL_CC_JCB, ui::SCALE_FACTOR_100P }, + { "masterCardCC", IDR_AUTOFILL_CC_MASTERCARD, ui::SCALE_FACTOR_100P }, + { "soloCC", IDR_AUTOFILL_CC_SOLO, ui::SCALE_FACTOR_100P }, + { "visaCC", IDR_AUTOFILL_CC_VISA, ui::SCALE_FACTOR_100P }, }; } // namespace @@ -484,8 +505,8 @@ WebData WebKitPlatformSupportImpl::loadResource(const char* name) { for (size_t i = 0; i < arraysize(kDataResources); ++i) { if (!strcmp(name, kDataResources[i].name)) { base::StringPiece resource = - GetImageResource(kDataResources[i].id, - kDataResources[i].scale_factor); + GetDataResource(kDataResources[i].id, + kDataResources[i].scale_factor); return WebData(resource.data(), resource.size()); } } diff --git a/webkit/glue/webkitplatformsupport_impl.h b/webkit/glue/webkitplatformsupport_impl.h index c58eb86..46dd048 100644 --- a/webkit/glue/webkitplatformsupport_impl.h +++ b/webkit/glue/webkitplatformsupport_impl.h @@ -10,6 +10,7 @@ #include "base/threading/thread_local_storage.h" #include "base/timer.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebKitPlatformSupport.h" +#include "ui/base/layout.h" #include "webkit/glue/resource_loader_bridge.h" #include "webkit/glue/webkit_glue_export.h" @@ -119,13 +120,8 @@ class WEBKIT_GLUE_EXPORT WebKitPlatformSupportImpl : // Returns the raw data for a resource. This resource must have been // specified as BINDATA in the relevant .rc file. - virtual base::StringPiece GetDataResource(int resource_id) = 0; - - // Returns the raw data for an image resource with a scale factor as close as - // is available to |scale_factor|. This resource must have been specified as - // BINDATA in the relevant .rc file. - virtual base::StringPiece GetImageResource(int resource_id, - float scale_factor) = 0; + virtual base::StringPiece GetDataResource(int resource_id, + ui::ScaleFactor scale_factor) = 0; // Returns the list of plugins. virtual void GetPlugins(bool refresh, diff --git a/webkit/support/platform_support_android.cc b/webkit/support/platform_support_android.cc index 79a9cd3..dd6c914 100644 --- a/webkit/support/platform_support_android.cc +++ b/webkit/support/platform_support_android.cc @@ -61,13 +61,9 @@ string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) { return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id); } -base::StringPiece TestWebKitPlatformSupport::GetDataResource(int resource_id) { - return ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); -} - -base::StringPiece TestWebKitPlatformSupport::GetImageResource( +base::StringPiece TestWebKitPlatformSupport::GetDataResource( int resource_id, - float scale_factor) { + ui::ScaleFactor scale_factor) { FilePath resources_path; PathService::Get(base::DIR_EXE, &resources_path); resources_path = resources_path.Append("DumpRenderTree_resources"); @@ -94,6 +90,6 @@ base::StringPiece TestWebKitPlatformSupport::GetImageResource( } } - // TODO(flackr): Pass scale_factor to ResourceBundle. - return ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); + return ResourceBundle::GetSharedInstance().GetRawDataResource( + resource_id, scale_factor); } diff --git a/webkit/support/platform_support_linux.cc b/webkit/support/platform_support_linux.cc index e777546..c696443 100644 --- a/webkit/support/platform_support_linux.cc +++ b/webkit/support/platform_support_linux.cc @@ -45,13 +45,9 @@ string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) { return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id); } -base::StringPiece TestWebKitPlatformSupport::GetDataResource(int resource_id) { - return ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); -} - -base::StringPiece TestWebKitPlatformSupport::GetImageResource( +base::StringPiece TestWebKitPlatformSupport::GetDataResource( int resource_id, - float scale_factor) { + ui::ScaleFactor scale_factor) { FilePath resources_path; PathService::Get(base::DIR_EXE, &resources_path); resources_path = resources_path.Append("DumpRenderTree_resources"); @@ -78,6 +74,6 @@ base::StringPiece TestWebKitPlatformSupport::GetImageResource( } } - // TODO(flackr): Pass scale_factor to ResourceBundle. - return ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); + return ResourceBundle::GetSharedInstance().GetRawDataResource( + resource_id, scale_factor); } diff --git a/webkit/support/platform_support_mac.mm b/webkit/support/platform_support_mac.mm index f26ae69..f7d4e33 100644 --- a/webkit/support/platform_support_mac.mm +++ b/webkit/support/platform_support_mac.mm @@ -103,7 +103,7 @@ void AfterInitialize(bool unit_test_mode) { return; // We don't have a resource pack when running the unit-tests. // Load a data pack. - g_resource_data_pack = new ui::DataPack(ui::ResourceHandle::kScaleFactor100x); + g_resource_data_pack = new ui::DataPack(ui::SCALE_FACTOR_100P); NSString* resource_path = [base::mac::FrameworkBundle() pathForResource:@"DumpRenderTree" ofType:@"pak"]; @@ -216,16 +216,9 @@ static FilePath GetResourcesFilePath() { return path.AppendASCII("Resources"); } -base::StringPiece TestWebKitPlatformSupport::GetDataResource(int resource_id) { - base::StringPiece res; - if (g_resource_data_pack) - g_resource_data_pack->GetStringPiece(resource_id, &res); - return res; -} - -base::StringPiece TestWebKitPlatformSupport::GetImageResource( +base::StringPiece TestWebKitPlatformSupport::GetDataResource( int resource_id, - float scale_factor) { + ui::ScaleFactor scale_factor) { switch (resource_id) { case IDR_BROKENIMAGE: { // Use webkit's broken image icon (16x16) diff --git a/webkit/support/platform_support_win.cc b/webkit/support/platform_support_win.cc index c385ccc..249a533 100644 --- a/webkit/support/platform_support_win.cc +++ b/webkit/support/platform_support_win.cc @@ -72,13 +72,9 @@ string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) { return string16(localized, length); } -base::StringPiece TestWebKitPlatformSupport::GetDataResource(int resource_id) { - return ResourceProvider(resource_id); -} - -base::StringPiece TestWebKitPlatformSupport::GetImageResource( +base::StringPiece TestWebKitPlatformSupport::GetDataResource( int resource_id, - float scale_factor) { + ui::ScaleFactor scale_factor) { switch (resource_id) { case IDR_BROKENIMAGE: { // Use webkit's broken image icon (16x16) diff --git a/webkit/support/test_webkit_platform_support.h b/webkit/support/test_webkit_platform_support.h index fdbe18f..5a7859a 100644 --- a/webkit/support/test_webkit_platform_support.h +++ b/webkit/support/test_webkit_platform_support.h @@ -111,9 +111,9 @@ class TestWebKitPlatformSupport : void setGamepadData(const WebKit::WebGamepads& data); virtual string16 GetLocalizedString(int message_id) OVERRIDE; - virtual base::StringPiece GetDataResource(int resource_id) OVERRIDE; - virtual base::StringPiece GetImageResource(int resource_id, - float scale_factor) OVERRIDE; + virtual base::StringPiece GetDataResource( + int resource_id, + ui::ScaleFactor scale_factor) OVERRIDE; virtual void GetPlugins(bool refresh, std::vector<webkit::WebPluginInfo>* plugins) OVERRIDE; virtual webkit_glue::ResourceLoaderBridge* CreateResourceLoader( diff --git a/webkit/tools/test_shell/test_shell_gtk.cc b/webkit/tools/test_shell/test_shell_gtk.cc index c99d070..a58d72f 100644 --- a/webkit/tools/test_shell/test_shell_gtk.cc +++ b/webkit/tools/test_shell/test_shell_gtk.cc @@ -23,9 +23,10 @@ #include "net/base/mime_util.h" #include "net/base/net_util.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h" #include "ui/base/gtk/gtk_compat.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" #include "webkit/glue/resource_loader_bridge.h" #include "webkit/glue/webkit_glue.h" @@ -559,7 +560,8 @@ void TestShell::ShowStartupDebuggingDialog() { // static base::StringPiece TestShell::ResourceProvider(int key) { - return ResourceBundle::GetSharedInstance().GetRawDataResource(key); + return ResourceBundle::GetSharedInstance().GetRawDataResource( + key, ui::SCALE_FACTOR_NONE); } //----------------------------------------------------------------------------- @@ -568,12 +570,9 @@ string16 TestShellWebKitInit::GetLocalizedString(int message_id) { return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id); } -base::StringPiece TestShellWebKitInit::GetDataResource(int resource_id) { - return TestShell::ResourceProvider(resource_id); -} - -base::StringPiece TestShellWebKitInit::GetImageResource(int resource_id, - float scale_factor) { +base::StringPiece TestShellWebKitInit::GetDataResource( + int resource_id, + ui::ScaleFactor scale_factor) { switch (resource_id) { case IDR_BROKENIMAGE: resource_id = IDR_BROKENIMAGE_TESTSHELL; diff --git a/webkit/tools/test_shell/test_shell_mac.mm b/webkit/tools/test_shell/test_shell_mac.mm index 9c38d44..d9b6ac2 100644 --- a/webkit/tools/test_shell/test_shell_mac.mm +++ b/webkit/tools/test_shell/test_shell_mac.mm @@ -212,7 +212,7 @@ void TestShell::InitializeTestShell(bool layout_test_mode, // mmap the data pack which holds strings used by WebCore. This is only // a fatal error if we're bundled, which means we might be running layout // tests. This is a harmless failure for test_shell_tests. - g_resource_data_pack = new ui::DataPack(ui::ResourceHandle::kScaleFactor100x); + g_resource_data_pack = new ui::DataPack(ui::SCALE_FACTOR_100P); NSString *resource_path = [base::mac::FrameworkBundle() pathForResource:@"test_shell" ofType:@"pak"]; @@ -630,12 +630,9 @@ string16 TestShellWebKitInit::GetLocalizedString(int message_id) { return msg; } -base::StringPiece TestShellWebKitInit::GetDataResource(int resource_id) { - return base::StringPiece(); -} - -base::StringPiece TestShellWebKitInit::GetImageResource(int resource_id, - float scale_factor) { +base::StringPiece TestShellWebKitInit::GetDataResource( + int resource_id, + ui::ScaleFactor scale_factor) { switch (resource_id) { case IDR_BROKENIMAGE: { // Use webkit's broken image icon (16x16) diff --git a/webkit/tools/test_shell/test_shell_webkit_init.h b/webkit/tools/test_shell/test_shell_webkit_init.h index 09f696d..7f0eb93 100644 --- a/webkit/tools/test_shell/test_shell_webkit_init.h +++ b/webkit/tools/test_shell/test_shell_webkit_init.h @@ -10,8 +10,8 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBFactory.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKey.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyPath.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSerializedScriptValue.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageNamespace.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSerializedScriptValue.h" #include "webkit/glue/webclipboard_impl.h" #include "webkit/glue/webfileutilities_impl.h" #include "webkit/glue/webkit_glue.h" @@ -105,9 +105,9 @@ class TestShellWebKitInit : public webkit_glue::WebKitPlatformSupportImpl { const WebKit::WebGraphicsContext3D::Attributes& attributes); virtual string16 GetLocalizedString(int message_id) OVERRIDE; - virtual base::StringPiece GetDataResource(int resource_id) OVERRIDE; - virtual base::StringPiece GetImageResource(int resource_id, - float scale_factor) OVERRIDE; + virtual base::StringPiece GetDataResource( + int resource_id, + ui::ScaleFactor scale_factor) OVERRIDE; virtual void GetPlugins(bool refresh, std::vector<webkit::WebPluginInfo>* plugins) OVERRIDE; virtual webkit_glue::ResourceLoaderBridge* CreateResourceLoader( diff --git a/webkit/tools/test_shell/test_shell_win.cc b/webkit/tools/test_shell/test_shell_win.cc index e56530b..70e1e05 100644 --- a/webkit/tools/test_shell/test_shell_win.cc +++ b/webkit/tools/test_shell/test_shell_win.cc @@ -21,8 +21,8 @@ #include "base/utf_string_conversions.h" #include "base/win/resource_util.h" #include "breakpad/src/client/windows/handler/exception_handler.h" -#include "grit/webkit_resources.h" #include "grit/webkit_chromium_resources.h" +#include "grit/webkit_resources.h" #include "net/base/net_module.h" #include "net/url_request/url_request_file_job.h" #include "skia/ext/bitmap_platform_device.h" @@ -669,13 +669,10 @@ string16 TestShellWebKitInit::GetLocalizedString(int message_id) { return string16(localized, length); } -base::StringPiece TestShellWebKitInit::GetDataResource(int resource_id) { - return base::StringPiece(); -} - // TODO(tc): Convert this to using resources from test_shell.rc. -base::StringPiece TestShellWebKitInit::GetImageResource(int resource_id, - float scale_factor) { +base::StringPiece TestShellWebKitInit::GetDataResource( + int resource_id, + ui::ScaleFactor scale_factor) { switch (resource_id) { case IDR_BROKENIMAGE: { // Use webkit's broken image icon (16x16) |