diff options
109 files changed, 424 insertions, 662 deletions
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc index 5f81728..c068a56 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, ui::SCALE_FACTOR_NONE)); + IDR_GPU_BLACKLIST)); 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::SCALE_FACTOR_100P); + resources_pack_path, ui::ResourceHandle::kScaleFactor100x); #endif // defined(OS_MACOSX) } diff --git a/chrome/browser/chrome_browser_main_mac.mm b/chrome/browser/chrome_browser_main_mac.mm index 54560b1..718c86f 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::SCALE_FACTOR_100P); + resources_pack_path, ui::ResourceHandle::kScaleFactor100x); } // 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 126f6dd..ac107da 100644 --- a/chrome/browser/chromeos/offline/offline_load_page.cc +++ b/chrome/browser/chromeos/offline/offline_load_page.cc @@ -33,7 +33,6 @@ #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; @@ -113,7 +112,7 @@ std::string OfflineLoadPage::GetHTMLContents() { base::StringPiece html( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_OFFLINE_LOAD_HTML, ui::SCALE_FACTOR_NONE)); + IDR_OFFLINE_LOAD_HTML)); 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 f29c647..260eefa 100644 --- a/chrome/browser/debugger/browser_list_tabcontents_provider.cc +++ b/chrome/browser/debugger/browser_list_tabcontents_provider.cc @@ -11,7 +11,6 @@ #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; @@ -42,8 +41,7 @@ std::string BrowserListTabContentsProvider::GetDiscoveryPageHTML() { } } return ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_DEVTOOLS_DISCOVERY_PAGE_HTML, - ui::SCALE_FACTOR_NONE).as_string(); + IDR_DEVTOOLS_DISCOVERY_PAGE_HTML).as_string(); } bool BrowserListTabContentsProvider::BundlesFrontendResources() { diff --git a/chrome/browser/extensions/component_loader.cc b/chrome/browser/extensions/component_loader.cc index 36ee3e0..b077315 100644 --- a/chrome/browser/extensions/component_loader.cc +++ b/chrome/browser/extensions/component_loader.cc @@ -24,7 +24,6 @@ #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) @@ -90,8 +89,7 @@ const Extension* ComponentLoader::Add( const FilePath& root_directory) { std::string manifest_contents = ResourceBundle::GetSharedInstance().GetRawDataResource( - manifest_resource_id, - ui::SCALE_FACTOR_NONE).as_string(); + manifest_resource_id).as_string(); return Add(manifest_contents, root_directory); } @@ -251,8 +249,7 @@ void ComponentLoader::AddOrReloadEnterpriseWebStore() { if (!enterprise_webstore_url.empty()) { std::string manifest_contents = ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_ENTERPRISE_WEBSTORE_MANIFEST, - ui::SCALE_FACTOR_NONE).as_string(); + IDR_ENTERPRISE_WEBSTORE_MANIFEST).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 a4582e5..722f279 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -49,7 +49,6 @@ #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) @@ -328,7 +327,7 @@ void ExtensionHost::InsertInfobarCSS() { static const base::StringPiece css( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_EXTENSIONS_INFOBAR_CSS, ui::SCALE_FACTOR_NONE)); + IDR_EXTENSIONS_INFOBAR_CSS)); 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 ed7416e..67e92a7 100644 --- a/chrome/browser/extensions/extension_protocols.cc +++ b/chrome/browser/extensions/extension_protocols.cc @@ -27,12 +27,11 @@ #include "grit/component_extension_resources_map.h" #include "net/base/mime_util.h" #include "net/base/net_errors.h" -#include "net/http/http_response_headers.h" #include "net/http/http_response_info.h" +#include "net/http/http_response_headers.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; @@ -74,8 +73,7 @@ class URLRequestResourceBundleJob : public net::URLRequestSimpleJob { std::string* charset, std::string* data) const OVERRIDE { const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - *data = rb.GetRawDataResource( - resource_id_, ui::SCALE_FACTOR_NONE).as_string(); + *data = rb.GetRawDataResource(resource_id_).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 a66fd8c..bd3aafe 100644 --- a/chrome/browser/first_run/first_run_win.cc +++ b/chrome/browser/first_run/first_run_win.cc @@ -48,7 +48,6 @@ #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" @@ -175,8 +174,7 @@ bool LaunchSetupWithParam(const std::string& param, // true if successful. bool WriteEULAtoTempFile(FilePath* eula_path) { base::StringPiece terms = - ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_TERMS_HTML, ui::SCALE_FACTOR_NONE); + ResourceBundle::GetSharedInstance().GetRawDataResource(IDR_TERMS_HTML); 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 779fe3b..9dab604 100644 --- a/chrome/browser/history/top_sites.cc +++ b/chrome/browser/history/top_sites.cc @@ -39,7 +39,6 @@ #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" @@ -255,8 +254,7 @@ 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, - ui::SCALE_FACTOR_100P); + kPrepopulatedPages[i].thumbnail_id); return true; } } diff --git a/chrome/browser/icon_loader_chromeos.cc b/chrome/browser/icon_loader_chromeos.cc index fbd87ad..cc4739f 100644 --- a/chrome/browser/icon_loader_chromeos.cc +++ b/chrome/browser/icon_loader_chromeos.cc @@ -16,7 +16,6 @@ #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" @@ -198,7 +197,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, ui::SCALE_FACTOR_100P)); + rb.LoadDataResourceBytes(idr)); 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 9ab605e..ff35176 100644 --- a/chrome/browser/notifications/desktop_notification_service.cc +++ b/chrome/browser/notifications/desktop_notification_service.cc @@ -41,7 +41,6 @@ #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; @@ -206,7 +205,7 @@ string16 DesktopNotificationService::CreateDataUrl( int resource, const std::vector<std::string>& subst) { const base::StringPiece template_html( ResourceBundle::GetSharedInstance().GetRawDataResource( - resource, ui::SCALE_FACTOR_NONE)); + resource)); 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 6b3da59fa..2456169 100644 --- a/chrome/browser/plugin_finder.cc +++ b/chrome/browser/plugin_finder.cc @@ -16,7 +16,6 @@ #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; @@ -45,7 +44,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, ui::SCALE_FACTOR_NONE)); + IDR_PLUGIN_DB_JSON)); 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 e4f0b4e..9398bf8 100644 --- a/chrome/browser/printing/cloud_print/cloud_print_setup_source.cc +++ b/chrome/browser/printing/cloud_print/cloud_print_setup_source.cc @@ -17,7 +17,6 @@ #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. @@ -68,8 +67,7 @@ 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, - ui::SCALE_FACTOR_NONE)); + .GetRawDataResource(IDR_CLOUD_PRINT_SETUP_LOGIN_HTML)); SetFontAndTextDirection(dict); response = jstemplate_builder::GetI18nTemplateHtml(html, dict); } else if (path_raw == kCloudPrintGaiaLoginPath) { @@ -105,8 +103,7 @@ 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, - ui::SCALE_FACTOR_NONE)); + .GetRawDataResource(IDR_GAIA_LOGIN_HTML)); SetFontAndTextDirection(dict); response = jstemplate_builder::GetI18nTemplateHtml(html, dict); } else if (path_raw == kCloudPrintSetupDonePath) { @@ -114,15 +111,13 @@ 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, - ui::SCALE_FACTOR_NONE)); + .GetRawDataResource(IDR_CLOUD_PRINT_SETUP_DONE_HTML)); 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, - ui::SCALE_FACTOR_NONE)); + .GetRawDataResource(IDR_CLOUD_PRINT_SETUP_FLOW_HTML)); 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 1e9f7be..dd3c3b2 100644 --- a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc +++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc @@ -38,7 +38,6 @@ #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; @@ -196,23 +195,20 @@ std::string SafeBrowsingBlockingPage::GetHTMLContents() { if (unsafe_resources_.size() > 1) { PopulateMultipleThreatStringDictionary(&strings); html = rb.GetRawDataResource( - IDR_SAFE_BROWSING_MULTIPLE_THREAT_BLOCK, - ui::SCALE_FACTOR_NONE).as_string(); + IDR_SAFE_BROWSING_MULTIPLE_THREAT_BLOCK).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, - ui::SCALE_FACTOR_NONE).as_string(); + IDR_SAFE_BROWSING_MALWARE_BLOCK).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, - ui::SCALE_FACTOR_NONE).as_string(); + IDR_SAFE_BROWSING_PHISHING_BLOCK).as_string(); } } diff --git a/chrome/browser/ssl/ssl_blocking_page.cc b/chrome/browser/ssl/ssl_blocking_page.cc index e5bc81d..3b301be 100644 --- a/chrome/browser/ssl/ssl_blocking_page.cc +++ b/chrome/browser/ssl/ssl_blocking_page.cc @@ -26,7 +26,6 @@ #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; @@ -121,8 +120,7 @@ std::string SSLBlockingPage::GetHTMLContents() { strings.SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr"); base::StringPiece html( - ResourceBundle::GetSharedInstance().GetRawDataResource( - resource_id, ui::SCALE_FACTOR_NONE)); + ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id)); 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 2e8e9bd..b5f17eb 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::SCALE_FACTOR_100P)); + new ui::DataPack(ui::ResourceHandle::kScaleFactor100x)); 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 5a75aa6..f9be837 100644 --- a/chrome/browser/themes/theme_service.cc +++ b/chrome/browser/themes/theme_service.cc @@ -21,7 +21,6 @@ #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" @@ -325,7 +324,7 @@ base::RefCountedMemory* ThemeService::GetRawData(int id) const { if (theme_pack_.get()) data = theme_pack_->GetRawData(id); if (!data) - data = rb_.LoadDataResourceBytes(id, ui::SCALE_FACTOR_100P); + data = rb_.LoadDataResourceBytes(id); return data; } diff --git a/chrome/browser/translate/translate_manager.cc b/chrome/browser/translate/translate_manager.cc index acf05e0..21565cf 100644 --- a/chrome/browser/translate/translate_manager.cc +++ b/chrome/browser/translate/translate_manager.cc @@ -50,7 +50,6 @@ #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 @@ -428,8 +427,7 @@ void TranslateManager::OnURLFetchComplete(const net::URLFetcher* source) { translate_script_request_pending_.release()); if (!error) { base::StringPiece str = ResourceBundle::GetSharedInstance(). - GetRawDataResource(IDR_TRANSLATE_JS, - ui::SCALE_FACTOR_NONE); + GetRawDataResource(IDR_TRANSLATE_JS); 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 8924fcc..340dba0 100644 --- a/chrome/browser/ui/pdf/pdf_unsupported_feature.cc +++ b/chrome/browser/ui/pdf/pdf_unsupported_feature.cc @@ -31,7 +31,6 @@ #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" @@ -205,8 +204,7 @@ 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, - ui::SCALE_FACTOR_NONE)); + GetRawDataResource(IDR_READER_OUT_OF_DATE_HTML)); 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 6d7d77c..89fd4fa 100644 --- a/chrome/browser/ui/webui/about_ui.cc +++ b/chrome/browser/ui/webui/about_ui.cc @@ -65,7 +65,6 @@ #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" @@ -73,8 +72,8 @@ #include "webkit/plugins/webplugininfo.h" #if defined(OS_LINUX) || defined(OS_OPENBSD) -#include "content/public/browser/zygote_host_linux.h" #include "content/public/common/sandbox_linux.h" +#include "content/public/browser/zygote_host_linux.h" #endif #if defined(OS_WIN) @@ -247,7 +246,7 @@ class ChromeOSTermsHandler // Do nothing if OEM EULA load failed. if (contents_.empty() && path_ != chrome::kOemEulaURLPath) { contents_ = ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_TERMS_HTML, ui::SCALE_FACTOR_NONE).as_string(); + IDR_TERMS_HTML).as_string(); } source_->FinishDataRequest(contents_, request_id_); } @@ -840,8 +839,7 @@ void FinishMemoryDataRequest(const std::string& path, source->FinishDataRequest( ResourceBundle::GetSharedInstance().GetRawDataResource( path == kMemoryJsPath ? IDR_ABOUT_MEMORY_JS : - IDR_ABOUT_MEMORY_HTML, - ui::SCALE_FACTOR_NONE).as_string(), request_id); + IDR_ABOUT_MEMORY_HTML).as_string(), request_id); } } @@ -992,8 +990,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), - ui::SCALE_FACTOR_NONE).as_string(); + (query == kStatsJsPath ? IDR_ABOUT_STATS_JS : IDR_ABOUT_STATS_HTML)). + as_string(); if (query != kStatsJsPath) { // Clear the timer list since we stored the data in the timers list @@ -1088,7 +1086,7 @@ std::string AboutVersionStaticContent(const std::string& query) { return ResourceBundle::GetSharedInstance().GetRawDataResource( query == kVersionJsPath ? IDR_ABOUT_VERSION_JS : - IDR_ABOUT_VERSION_HTML, ui::SCALE_FACTOR_NONE).as_string(); + IDR_ABOUT_VERSION_HTML).as_string(); } std::string AboutVersionStrings(DictionaryValue* localized_strings, @@ -1389,7 +1387,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, ui::SCALE_FACTOR_NONE).as_string(); + idr).as_string(); #if defined(OS_CHROMEOS) } else if (host == chrome::kChromeUICryptohomeHost) { FinishCryptohomeDataRequest(this, path, request_id); @@ -1420,7 +1418,7 @@ void AboutUIHTMLSource::StartDataRequest(const std::string& path, response = AboutNetwork(path); } else if (host == chrome::kChromeUIOSCreditsHost) { response = ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_OS_CREDITS_HTML, ui::SCALE_FACTOR_NONE).as_string(); + IDR_OS_CREDITS_HTML).as_string(); #endif #if defined(OS_LINUX) || defined(OS_OPENBSD) } else if (host == chrome::kChromeUISandboxHost) { @@ -1434,7 +1432,7 @@ void AboutUIHTMLSource::StartDataRequest(const std::string& path, return; #else response = ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_TERMS_HTML, ui::SCALE_FACTOR_NONE).as_string(); + IDR_TERMS_HTML).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 de67b3e..8154368 100644 --- a/chrome/browser/ui/webui/bookmarks_ui.cc +++ b/chrome/browser/ui/webui/bookmarks_ui.cc @@ -19,11 +19,10 @@ #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; @@ -71,6 +70,5 @@ BookmarksUI::BookmarksUI(content::WebUI* web_ui) : WebUIController(web_ui) { // static base::RefCountedMemory* BookmarksUI::GetFaviconResourceBytes() { return ResourceBundle::GetSharedInstance(). - LoadDataResourceBytes(IDR_BOOKMARKS_FAVICON, - ui::SCALE_FACTOR_100P); + LoadDataResourceBytes(IDR_BOOKMARKS_FAVICON); } 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 1fa1457..d4a1c67 100644 --- a/chrome/browser/ui/webui/chrome_web_ui_data_source.cc +++ b/chrome/browser/ui/webui/chrome_web_ui_data_source.cc @@ -10,7 +10,6 @@ #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) @@ -87,7 +86,6 @@ void ChromeWebUIDataSource::SendLocalizedStringsAsJSON(int request_id) { void ChromeWebUIDataSource::SendFromResourceBundle(int request_id, int idr) { scoped_refptr<base::RefCountedStaticMemory> response( - ResourceBundle::GetSharedInstance().LoadDataResourceBytes( - idr, ui::SCALE_FACTOR_NONE)); + ResourceBundle::GetSharedInstance().LoadDataResourceBytes(idr)); 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 0b36cd9..eda42a7 100644 --- a/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc +++ b/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc @@ -35,7 +35,6 @@ #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; @@ -108,8 +107,7 @@ void OobeUIHTMLSource::StartDataRequest(const std::string& path, std::string OobeUIHTMLSource::GetDataResource(int resource_id) const { const base::StringPiece html( - ResourceBundle::GetSharedInstance().GetRawDataResource( - resource_id, ui::SCALE_FACTOR_NONE)); + ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id)); 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 bf875d7..98dd59a 100644 --- a/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc +++ b/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc @@ -44,7 +44,6 @@ #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; @@ -484,7 +483,7 @@ void MobileSetupUIHTMLSource::StartDataRequest(const std::string& path, static const base::StringPiece html( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_MOBILE_SETUP_PAGE_HTML, ui::SCALE_FACTOR_NONE)); + IDR_MOBILE_SETUP_PAGE_HTML)); 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 ebd296b..4a4d7c9 100644 --- a/chrome/browser/ui/webui/chromeos/proxy_settings_ui.cc +++ b/chrome/browser/ui/webui/chromeos/proxy_settings_ui.cc @@ -20,7 +20,6 @@ #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; @@ -60,7 +59,7 @@ void ProxySettingsHTMLSource::StartDataRequest(const std::string& path, static const base::StringPiece html( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_PROXY_SETTINGS_HTML, ui::SCALE_FACTOR_NONE)); + IDR_PROXY_SETTINGS_HTML)); 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 ca1889a..394a928 100644 --- a/chrome/browser/ui/webui/chromeos/register_page_ui.cc +++ b/chrome/browser/ui/webui/chromeos/register_page_ui.cc @@ -31,7 +31,6 @@ #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; @@ -168,8 +167,7 @@ void RegisterPageUIHTMLSource::StartDataRequest(const std::string& path, scoped_refptr<base::RefCountedMemory> html_bytes( ResourceBundle::GetSharedInstance().LoadDataResourceBytes( - IDR_HOST_REGISTRATION_PAGE_HTML, - ui::SCALE_FACTOR_NONE)); + IDR_HOST_REGISTRATION_PAGE_HTML)); 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 ea7825e..a097d71 100644 --- a/chrome/browser/ui/webui/chromeos/sim_unlock_ui.cc +++ b/chrome/browser/ui/webui/chromeos/sim_unlock_ui.cc @@ -30,7 +30,6 @@ #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; @@ -306,7 +305,7 @@ void SimUnlockUIHTMLSource::StartDataRequest(const std::string& path, static const base::StringPiece html( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_SIM_UNLOCK_HTML, ui::SCALE_FACTOR_NONE)); + IDR_SIM_UNLOCK_HTML)); 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 8b3b599..0109bc4 100644 --- a/chrome/browser/ui/webui/chromeos/system_info_ui.cc +++ b/chrome/browser/ui/webui/chromeos/system_info_ui.cc @@ -34,7 +34,6 @@ #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; @@ -147,7 +146,7 @@ void SystemInfoUIHTMLSource::SyslogsComplete( } static const base::StringPiece systeminfo_html( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_ABOUT_SYS_HTML, ui::SCALE_FACTOR_NONE)); + IDR_ABOUT_SYS_HTML)); 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 d5e8ed9..75c1816 100644 --- a/chrome/browser/ui/webui/conflicts_ui.cc +++ b/chrome/browser/ui/webui/conflicts_ui.cc @@ -33,7 +33,6 @@ #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; @@ -175,7 +174,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, ui::SCALE_FACTOR_NONE)); + IDR_CONFLICT_FAVICON)); } #endif diff --git a/chrome/browser/ui/webui/crashes_ui.cc b/chrome/browser/ui/webui/crashes_ui.cc index bf68b06..f8c5760 100644 --- a/chrome/browser/ui/webui/crashes_ui.cc +++ b/chrome/browser/ui/webui/crashes_ui.cc @@ -30,7 +30,6 @@ #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) @@ -173,8 +172,7 @@ CrashesUI::CrashesUI(content::WebUI* web_ui) : WebUIController(web_ui) { // static base::RefCountedMemory* CrashesUI::GetFaviconResourceBytes() { return ResourceBundle::GetSharedInstance(). - LoadDataResourceBytes(IDR_SAD_FAVICON, - ui::SCALE_FACTOR_NONE); + LoadDataResourceBytes(IDR_SAD_FAVICON); } // static diff --git a/chrome/browser/ui/webui/devtools_ui.cc b/chrome/browser/ui/webui/devtools_ui.cc index a58de6a..14b04f4 100644 --- a/chrome/browser/ui/webui/devtools_ui.cc +++ b/chrome/browser/ui/webui/devtools_ui.cc @@ -19,7 +19,6 @@ #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; @@ -67,7 +66,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, ui::SCALE_FACTOR_NONE)); + resource_id)); SendResponse(request_id, bytes); } diff --git a/chrome/browser/ui/webui/downloads_ui.cc b/chrome/browser/ui/webui/downloads_ui.cc index 57b7f7a..efc035b 100644 --- a/chrome/browser/ui/webui/downloads_ui.cc +++ b/chrome/browser/ui/webui/downloads_ui.cc @@ -24,7 +24,6 @@ #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; @@ -104,6 +103,5 @@ DownloadsUI::DownloadsUI(content::WebUI* web_ui) : WebUIController(web_ui) { // static base::RefCountedMemory* DownloadsUI::GetFaviconResourceBytes() { return ResourceBundle::GetSharedInstance(). - LoadDataResourceBytes(IDR_DOWNLOADS_FAVICON, - ui::SCALE_FACTOR_NONE); + LoadDataResourceBytes(IDR_DOWNLOADS_FAVICON); } diff --git a/chrome/browser/ui/webui/extensions/extension_icon_source.cc b/chrome/browser/ui/webui/extensions/extension_icon_source.cc index 519832d..a8bbec6 100644 --- a/chrome/browser/ui/webui/extensions/extension_icon_source.cc +++ b/chrome/browser/ui/webui/extensions/extension_icon_source.cc @@ -19,11 +19,10 @@ #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" @@ -91,8 +90,7 @@ GURL ExtensionIconSource::GetIconURL(const Extension* extension, // static SkBitmap* ExtensionIconSource::LoadImageByResourceId(int resource_id) { std::string contents = ResourceBundle::GetSharedInstance() - .GetRawDataResource(resource_id, - ui::SCALE_FACTOR_100P).as_string(); + .GetRawDataResource(resource_id).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 6fa19b9..4a1b3c0 100644 --- a/chrome/browser/ui/webui/favicon_source.cc +++ b/chrome/browser/ui/webui/favicon_source.cc @@ -12,7 +12,6 @@ #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) @@ -97,8 +96,7 @@ void FaviconSource::StartDataRequest(const std::string& path, request_size_map_.erase(request_id); SendResponse(request_id, ResourceBundle::GetSharedInstance().LoadDataResourceBytes( - history::kPrepopulatedPages[i].favicon_id, - ui::SCALE_FACTOR_100P)); + history::kPrepopulatedPages[i].favicon_id)); return; } } @@ -150,14 +148,14 @@ void FaviconSource::SendDefaultResponse(int request_id) { if (!default_favicon_large_.get()) { default_favicon_large_ = ResourceBundle::GetSharedInstance().LoadDataResourceBytes( - IDR_DEFAULT_LARGE_FAVICON, ui::SCALE_FACTOR_100P); + IDR_DEFAULT_LARGE_FAVICON); } bytes = default_favicon_large_; } else { if (!default_favicon_.get()) { default_favicon_ = ResourceBundle::GetSharedInstance().LoadDataResourceBytes( - IDR_DEFAULT_FAVICON, ui::SCALE_FACTOR_100P); + IDR_DEFAULT_FAVICON); } bytes = default_favicon_; } diff --git a/chrome/browser/ui/webui/flags_ui.cc b/chrome/browser/ui/webui/flags_ui.cc index 42bf58b..2e7da67 100644 --- a/chrome/browser/ui/webui/flags_ui.cc +++ b/chrome/browser/ui/webui/flags_ui.cc @@ -26,10 +26,9 @@ #include "grit/browser_resources.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" -#include "grit/theme_resources.h" #include "grit/theme_resources_standard.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_CHROMEOS) @@ -170,7 +169,7 @@ FlagsUI::FlagsUI(content::WebUI* web_ui) : WebUIController(web_ui) { // static base::RefCountedMemory* FlagsUI::GetFaviconResourceBytes() { return ResourceBundle::GetSharedInstance(). - LoadDataResourceBytes(IDR_FLAGS, ui::SCALE_FACTOR_100P); + LoadDataResourceBytes(IDR_FLAGS); } // static diff --git a/chrome/browser/ui/webui/history_ui.cc b/chrome/browser/ui/webui/history_ui.cc index 158e976..1f3c0fa 100644 --- a/chrome/browser/ui/webui/history_ui.cc +++ b/chrome/browser/ui/webui/history_ui.cc @@ -45,7 +45,6 @@ #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; @@ -486,6 +485,5 @@ const GURL HistoryUI::GetHistoryURLWithSearchText(const string16& text) { // static base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes() { return ResourceBundle::GetSharedInstance(). - LoadDataResourceBytes(IDR_HISTORY_FAVICON, - ui::SCALE_FACTOR_100P); + LoadDataResourceBytes(IDR_HISTORY_FAVICON); } diff --git a/chrome/browser/ui/webui/ntp/new_tab_ui.cc b/chrome/browser/ui/webui/ntp/new_tab_ui.cc index 1a4f5e8..2ad684e 100644 --- a/chrome/browser/ui/webui/ntp/new_tab_ui.cc +++ b/chrome/browser/ui/webui/ntp/new_tab_ui.cc @@ -53,8 +53,6 @@ #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" @@ -357,7 +355,7 @@ void NewTabUI::NewTabHTMLSource::StartDataRequest(const std::string& path, scoped_refptr<base::RefCountedStaticMemory> resource_bytes( it->second.second ? ResourceBundle::GetSharedInstance().LoadDataResourceBytes( - it->second.second, ui::SCALE_FACTOR_NONE) : + it->second.second) : 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 034fc9f..fd46886 100644 --- a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc +++ b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc @@ -45,7 +45,6 @@ #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" @@ -292,7 +291,7 @@ void NTPResourceCache::CreateNewTabIncognitoHTML() { static const base::StringPiece incognito_tab_html( ResourceBundle::GetSharedInstance().GetRawDataResource( - new_tab_html_idr, ui::SCALE_FACTOR_NONE)); + new_tab_html_idr)); std::string full_html = jstemplate_builder::GetI18nTemplateHtml( incognito_tab_html, &localized_strings); @@ -428,8 +427,7 @@ 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, - ui::SCALE_FACTOR_NONE)); + GetRawDataResource(IDR_NEW_TAB_4_HTML)); jstemplate_builder::UseVersion2 version2; std::string full_html = jstemplate_builder::GetI18nTemplateHtml(new_tab_html, &load_time_data); @@ -460,7 +458,7 @@ void NTPResourceCache::CreateNewTabIncognitoCSS() { // Get our template. static const base::StringPiece new_tab_theme_css( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_NEW_INCOGNITO_TAB_THEME_CSS, ui::SCALE_FACTOR_NONE)); + IDR_NEW_INCOGNITO_TAB_THEME_CSS)); // Create the string from our template and the replacements. std::string full_css = ReplaceStringPlaceholders( @@ -555,7 +553,7 @@ void NTPResourceCache::CreateNewTabCSS() { // Get our template. static const base::StringPiece new_tab_theme_css( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_NEW_TAB_4_THEME_CSS, ui::SCALE_FACTOR_NONE)); + IDR_NEW_TAB_4_THEME_CSS)); // 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 61d6230..db8d468 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,7 +19,6 @@ #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; @@ -74,8 +73,7 @@ void NTPResourceCache::CreateNewTabHTML() { ChromeURLDataManager::DataSource::SetFontAndTextDirection(&localized_strings); base::StringPiece new_tab_html(ResourceBundle::GetSharedInstance(). - GetRawDataResource(IDR_NEW_TAB_4_HTML, - ui::SCALE_FACTOR_NONE)); + GetRawDataResource(IDR_NEW_TAB_4_HTML)); 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 73f7e3f..bc38e2d 100644 --- a/chrome/browser/ui/webui/options2/chromeos/wallpaper_thumbnail_source2.cc +++ b/chrome/browser/ui/webui/options2/chromeos/wallpaper_thumbnail_source2.cc @@ -19,7 +19,6 @@ #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" @@ -108,8 +107,7 @@ 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, - ui::SCALE_FACTOR_100P)); + SendResponse(request_id, rb.LoadDataResourceBytes(idr)); } } diff --git a/chrome/browser/ui/webui/options2/options_ui2.cc b/chrome/browser/ui/webui/options2/options_ui2.cc index 8edd569..33b13b7 100644 --- a/chrome/browser/ui/webui/options2/options_ui2.cc +++ b/chrome/browser/ui/webui/options2/options_ui2.cc @@ -57,7 +57,6 @@ #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) @@ -150,11 +149,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, ui::SCALE_FACTOR_NONE); + IDR_OPTIONS2_BUNDLE_JS); } else { // Return (and cache) the main options html page as the default. response_bytes = ResourceBundle::GetSharedInstance().LoadDataResourceBytes( - IDR_OPTIONS2_HTML, ui::SCALE_FACTOR_NONE); + IDR_OPTIONS2_HTML); } SendResponse(request_id, response_bytes); @@ -356,8 +355,7 @@ void OptionsUI::ProcessAutocompleteSuggestions( // static base::RefCountedMemory* OptionsUI::GetFaviconResourceBytes() { return ResourceBundle::GetSharedInstance(). - LoadDataResourceBytes(IDR_SETTINGS_FAVICON, - ui::SCALE_FACTOR_100P); + LoadDataResourceBytes(IDR_SETTINGS_FAVICON); } void OptionsUI::InitializeHandlers() { diff --git a/chrome/browser/ui/webui/plugins_ui.cc b/chrome/browser/ui/webui/plugins_ui.cc index 901ff58..34aef3c 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,7 +42,6 @@ #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" @@ -484,7 +483,7 @@ PluginsUI::PluginsUI(content::WebUI* web_ui) : WebUIController(web_ui) { // static base::RefCountedMemory* PluginsUI::GetFaviconResourceBytes() { return ResourceBundle::GetSharedInstance(). - LoadDataResourceBytes(IDR_PLUGIN, ui::SCALE_FACTOR_100P); + LoadDataResourceBytes(IDR_PLUGIN); } // static diff --git a/chrome/browser/ui/webui/sessions_ui.cc b/chrome/browser/ui/webui/sessions_ui.cc index cb68200..3743b31 100644 --- a/chrome/browser/ui/webui/sessions_ui.cc +++ b/chrome/browser/ui/webui/sessions_ui.cc @@ -28,7 +28,6 @@ #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; @@ -271,6 +270,5 @@ SessionsUI::SessionsUI(content::WebUI* web_ui) : WebUIController(web_ui) { // static base::RefCountedMemory* SessionsUI::GetFaviconResourceBytes() { return ResourceBundle::GetSharedInstance(). - LoadDataResourceBytes(IDR_HISTORY_FAVICON, - ui::SCALE_FACTOR_100P); + LoadDataResourceBytes(IDR_HISTORY_FAVICON); } diff --git a/chrome/browser/ui/webui/shared_resources_data_source.cc b/chrome/browser/ui/webui/shared_resources_data_source.cc index 2d6630b..378b8e3 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, ui::SCALE_FACTOR_NONE)); + rb.LoadDataResourceBytes(idr)); SendResponse(request_id, bytes); } diff --git a/chrome/browser/ui/webui/theme_source.cc b/chrome/browser/ui/webui/theme_source.cc index b51c05d..2c2a59b 100644 --- a/chrome/browser/ui/webui/theme_source.cc +++ b/chrome/browser/ui/webui/theme_source.cc @@ -6,7 +6,6 @@ #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" @@ -16,60 +15,21 @@ #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"; -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) { +static 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: @@ -86,9 +46,8 @@ ThemeSource::~ThemeSource() { void ThemeSource::StartDataRequest(const std::string& path, bool is_incognito, int request_id) { - // Default scale factor if not specified. - ui::ScaleFactor scale_factor; - std::string uncached_path = ParsePathAndScale(path, &scale_factor); + // Our path may include cachebuster arguments, so trim them off. + std::string uncached_path = StripQueryParams(path); if (uncached_path == kNewTabCSSPath || uncached_path == kNewIncognitoTabCSSPath) { @@ -101,7 +60,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, scale_factor); + SendThemeBitmap(request_id, resource_id); return; } } @@ -110,7 +69,7 @@ void ThemeSource::StartDataRequest(const std::string& path, } std::string ThemeSource::GetMimeType(const std::string& path) const { - std::string uncached_path = ParsePathAndScale(path, NULL); + std::string uncached_path = StripQueryParams(path); if (uncached_path == kNewTabCSSPath || uncached_path == kNewIncognitoTabCSSPath) { @@ -122,7 +81,7 @@ std::string ThemeSource::GetMimeType(const std::string& path) const { MessageLoop* ThemeSource::MessageLoopForRequestPath( const std::string& path) const { - std::string uncached_path = ParsePathAndScale(path, NULL); + std::string uncached_path = StripQueryParams(path); if (uncached_path == kNewTabCSSPath || uncached_path == kNewIncognitoTabCSSPath) { @@ -148,22 +107,18 @@ bool ThemeSource::ShouldReplaceExistingSource() const { //////////////////////////////////////////////////////////////////////////////// // ThemeSource, private: -void ThemeSource::SendThemeBitmap(int request_id, - int resource_id, - ui::ScaleFactor scale_factor) { +void ThemeSource::SendThemeBitmap(int request_id, int resource_id) { 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, scale_factor)); + SendResponse(request_id, rb.LoadDataResourceBytes(resource_id)); } } diff --git a/chrome/browser/ui/webui/theme_source.h b/chrome/browser/ui/webui/theme_source.h index 5b58d1c..9e6c30e 100644 --- a/chrome/browser/ui/webui/theme_source.h +++ b/chrome/browser/ui/webui/theme_source.h @@ -9,7 +9,6 @@ #include <string> #include "chrome/browser/ui/webui/chrome_url_data_manager.h" -#include "ui/base/layout.h" class Profile; @@ -39,9 +38,7 @@ class ThemeSource : public ChromeURLDataManager::DataSource { private: // Fetch and send the theme bitmap. - void SendThemeBitmap(int request_id, - int resource_id, - ui::ScaleFactor scale_factor); + void SendThemeBitmap(int request_id, int resource_id); // 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 ac95ea2..2a7e0bf 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::SCALE_FACTOR_100P); + resources_pack_path, ui::ResourceHandle::kScaleFactor100x); 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 46d2824..4ef88e0 100644 --- a/chrome/browser/ui/webui/web_ui_util.cc +++ b/chrome/browser/ui/webui/web_ui_util.cc @@ -11,7 +11,6 @@ #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" @@ -31,8 +30,7 @@ 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, - ui::SCALE_FACTOR_100P); + ResourceBundle::GetSharedInstance().LoadDataResourceBytes(res); 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 040c8b0..369bc0a 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,7 +25,6 @@ #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" @@ -416,11 +415,16 @@ string16 ChromeContentClient::GetLocalizedString(int message_id) const { return l10n_util::GetStringUTF16(message_id); } -base::StringPiece ChromeContentClient::GetDataResource( +base::StringPiece ChromeContentClient::GetDataResource(int resource_id) const { + return ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); +} + +base::StringPiece ChromeContentClient::GetImageResource( int resource_id, - ui::ScaleFactor scale_factor) const { - return ResourceBundle::GetSharedInstance().GetRawDataResource( - resource_id, scale_factor); + 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); } #if defined(OS_WIN) diff --git a/chrome/common/chrome_content_client.h b/chrome/common/chrome_content_client.h index e6074d5..a69cd87 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, - ui::ScaleFactor scale_factor) const OVERRIDE; + virtual base::StringPiece GetDataResource(int resource_id) const OVERRIDE; + virtual base::StringPiece GetImageResource(int resource_id, + float 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 16458f8..b713a27 100644 --- a/chrome/common/extensions/api/extension_api.cc +++ b/chrome/common/extensions/api/extension_api.cc @@ -23,7 +23,6 @@ #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; @@ -62,8 +61,7 @@ bool HasUnprivilegedChild(const DictionaryValue* name_space_node, } base::StringPiece ReadFromResource(int resource_id) { - return ResourceBundle::GetSharedInstance().GetRawDataResource( - resource_id, ui::SCALE_FACTOR_NONE); + return ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); } 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 d17c360..08bed31 100644 --- a/chrome/common/extensions/simple_feature_provider.cc +++ b/chrome/common/extensions/simple_feature_provider.cc @@ -9,7 +9,6 @@ #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 { @@ -43,7 +42,7 @@ struct Static { int resource_id) { std::string manifest_features = ResourceBundle::GetSharedInstance().GetRawDataResource( - resource_id, ui::SCALE_FACTOR_NONE).as_string(); + resource_id).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 31c0c4d..9d0d46b 100644 --- a/chrome/common/jstemplate_builder.cc +++ b/chrome/common/jstemplate_builder.cc @@ -12,7 +12,6 @@ #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 { @@ -92,7 +91,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, ui::SCALE_FACTOR_NONE)); + IDR_JSTEMPLATE_JS)); if (jstemplate_src.empty()) { NOTREACHED() << "Unable to get jstemplate src"; @@ -118,10 +117,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, ui::SCALE_FACTOR_NONE)); + IDR_I18N_TEMPLATE_JS)); static const base::StringPiece i18n_template2_src( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_I18N_TEMPLATE2_JS, ui::SCALE_FACTOR_NONE)); + IDR_I18N_TEMPLATE2_JS)); const base::StringPiece* template_src = g_version2 ? &i18n_template2_src : &i18n_template_src; @@ -141,7 +140,7 @@ void AppendI18nTemplateProcessHtml(std::string* output) { static const base::StringPiece i18n_process_src( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_I18N_PROCESS_JS, ui::SCALE_FACTOR_NONE)); + IDR_I18N_PROCESS_JS)); 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 db1a8ba..abea5f4 100644 --- a/chrome/common/net/net_resource_provider.cc +++ b/chrome/common/net/net_resource_provider.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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,7 +13,6 @@ #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 { @@ -41,7 +40,7 @@ struct LazyDirectoryListerCacher { l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); html_data = jstemplate_builder::GetI18nTemplateHtml( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_DIR_HEADER_HTML, ui::SCALE_FACTOR_NONE), + IDR_DIR_HEADER_HTML), &value); } @@ -58,8 +57,7 @@ base::StringPiece NetResourceProvider(int key) { if (IDR_DIR_HEADER_HTML == key) return base::StringPiece(lazy_dir_lister.html_data); - return ResourceBundle::GetSharedInstance().GetRawDataResource( - key, ui::SCALE_FACTOR_NONE); + return ResourceBundle::GetSharedInstance().GetRawDataResource(key); } } // namespace chrome_common_net diff --git a/chrome/common/web_apps.cc b/chrome/common/web_apps.cc index 1564754..bfcf199 100644 --- a/chrome/common/web_apps.cc +++ b/chrome/common/web_apps.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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,7 +25,6 @@ #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" @@ -217,8 +216,7 @@ bool ParseWebAppFromDefinitionFile(Value* definition_value, scoped_ptr<Value> schema( base::JSONReader::ReadAndReturnError( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_WEB_APP_SCHEMA, - ui::SCALE_FACTOR_NONE).as_string(), + IDR_WEB_APP_SCHEMA).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 7450dde..4013b92f 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,7 +83,6 @@ #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" @@ -660,8 +659,7 @@ void ChromeContentRendererClient::GetNavigationErrorStrings( } const base::StringPiece template_html( - ResourceBundle::GetSharedInstance().GetRawDataResource( - resource_id, ui::SCALE_FACTOR_NONE)); + ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id)); 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 30876ca..9706f67 100644 --- a/chrome/renderer/extensions/extension_dispatcher.cc +++ b/chrome/renderer/extensions/extension_dispatcher.cc @@ -57,7 +57,6 @@ #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" @@ -413,8 +412,7 @@ void ExtensionDispatcher::OnLoaded( patterns.assign(platform_app_patterns); WebView::addUserStyleSheet( WebString::fromUTF8(ResourceBundle::GetSharedInstance(). - GetRawDataResource(IDR_PLATFORM_APP_CSS, - ui::SCALE_FACTOR_NONE)), + GetRawDataResource(IDR_PLATFORM_APP_CSS)), patterns, WebView::UserContentInjectInAllFrames, WebView::UserStyleInjectInExistingDocuments); diff --git a/chrome/renderer/extensions/json_schema_unittest.cc b/chrome/renderer/extensions/json_schema_unittest.cc index 8eb4581..c4b0614 100644 --- a/chrome/renderer/extensions/json_schema_unittest.cc +++ b/chrome/renderer/extensions/json_schema_unittest.cc @@ -9,7 +9,6 @@ #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"; @@ -24,7 +23,7 @@ class JsonSchemaTest : public V8UnitTest { // Add the json schema code to the context. std::string code = ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_JSON_SCHEMA_JS, ui::SCALE_FACTOR_NONE).as_string(); + IDR_JSON_SCHEMA_JS).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 088dc56..9008381 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,10 +27,9 @@ #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 "ui/base/layout.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" #include "ui/base/resource/resource_bundle.h" using WebKit::WebFrame; @@ -119,7 +118,7 @@ UserScriptSlave::UserScriptSlave(const ExtensionSet* extensions) script_deleter_(&scripts_), extensions_(extensions) { api_js_ = ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_GREASEMONKEY_API_JS, ui::SCALE_FACTOR_NONE); + IDR_GREASEMONKEY_API_JS); } UserScriptSlave::~UserScriptSlave() {} diff --git a/chrome/renderer/plugins/plugin_placeholder.cc b/chrome/renderer/plugins/plugin_placeholder.cc index cf85d24..e87bbea 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/prerender_messages.h" #include "chrome/common/render_messages.h" +#include "chrome/common/prerender_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,6 +22,9 @@ #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" @@ -33,11 +36,7 @@ #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" @@ -102,7 +101,7 @@ PluginPlaceholder* PluginPlaceholder::CreateMissingPlugin( const WebPluginParams& params) { const base::StringPiece template_html( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_BLOCKED_PLUGIN_HTML, ui::SCALE_FACTOR_NONE)); + IDR_BLOCKED_PLUGIN_HTML)); DictionaryValue values; values.SetString("message", l10n_util::GetStringUTF8(IDS_PLUGIN_SEARCHING)); @@ -133,7 +132,7 @@ PluginPlaceholder* PluginPlaceholder::CreateErrorPlugin( const base::StringPiece template_html( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_BLOCKED_PLUGIN_HTML, ui::SCALE_FACTOR_NONE)); + IDR_BLOCKED_PLUGIN_HTML)); std::string html_data = jstemplate_builder::GetI18nTemplateHtml(template_html, &values); @@ -163,8 +162,7 @@ PluginPlaceholder* PluginPlaceholder::CreateBlockedPlugin( values.SetString("hide", l10n_util::GetStringUTF8(IDS_PLUGIN_HIDE)); const base::StringPiece template_html( - ResourceBundle::GetSharedInstance().GetRawDataResource( - template_id, ui::SCALE_FACTOR_NONE)); + ResourceBundle::GetSharedInstance().GetRawDataResource(template_id)); DCHECK(!template_html.empty()) << "unable to load template. ID: " << template_id; @@ -187,7 +185,7 @@ PluginPlaceholder* PluginPlaceholder::CreateMobileYoutubePlugin( const WebPluginParams& params) { const base::StringPiece template_html( ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_YOUTUBE_PLUGIN_HTML, ui::SCALE_FACTOR_NONE)); + IDR_YOUTUBE_PLUGIN_HTML)); 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 86ee68d..5a42582 100644 --- a/chrome/renderer/resource_bundle_source_map.cc +++ b/chrome/renderer/resource_bundle_source_map.cc @@ -4,7 +4,6 @@ #include "chrome/renderer/resource_bundle_source_map.h" -#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" ResourceBundleSourceMap::ResourceBundleSourceMap( @@ -25,8 +24,7 @@ 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, ui::SCALE_FACTOR_NONE)); + return ConvertString(resource_bundle_->GetRawDataResource(resource_id)); } 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 3795306..842e58c 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::SCALE_FACTOR_100P); + resources_pack_path, ui::ResourceHandle::kScaleFactor100x); // 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 d6bb6d3..ce77a20 100644 --- a/chrome/test/base/module_system_test.cc +++ b/chrome/test/base/module_system_test.cc @@ -8,7 +8,6 @@ #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> @@ -99,8 +98,7 @@ 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, - ui::SCALE_FACTOR_NONE).as_string(); + GetRawDataResource(resource_id).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 051013b..270e07f 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::SCALE_FACTOR_100P); + resource_pack = new ui::DataPack(ui::ResourceHandle::kScaleFactor100x); 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 72ab076..8d1524f 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::SCALE_FACTOR_100P)); + new ui::DataPack(ui::ResourceHandle::kScaleFactor100x)); 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 e00d4ab..bbe45a4 100644 --- a/content/browser/debugger/devtools_http_handler_impl.cc +++ b/content/browser/debugger/devtools_http_handler_impl.cc @@ -38,7 +38,6 @@ #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 { @@ -231,8 +230,7 @@ void DevToolsHttpHandlerImpl::OnHttpRequest( int resource_id = DevToolsHttpHandler::GetFrontendResourceId(filename); if (resource_id != -1) { base::StringPiece data = - content::GetContentClient()->GetDataResource( - resource_id, ui::SCALE_FACTOR_NONE); + content::GetContentClient()->GetDataResource(resource_id); server_->Send200(connection_id, data.as_string(), GetMimeType(filename)); diff --git a/content/common/sandbox_mac.mm b/content/common/sandbox_mac.mm index 90b7fe9..679fddf 100644 --- a/content/common/sandbox_mac.mm +++ b/content/common/sandbox_mac.mm @@ -31,7 +31,6 @@ 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" @@ -364,8 +363,7 @@ NSString* LoadSandboxTemplate(int sandbox_type) { } base::StringPiece sandbox_definition = - content::GetContentClient()->GetDataResource( - sandbox_profile_resource_id, ui::SCALE_FACTOR_NONE); + content::GetContentClient()->GetDataResource(sandbox_profile_resource_id); if (sandbox_definition.empty()) { LOG(FATAL) << "Failed to load the sandbox profile (resource id " << sandbox_profile_resource_id << ")"; @@ -373,8 +371,7 @@ NSString* LoadSandboxTemplate(int sandbox_type) { } base::StringPiece common_sandbox_definition = - content::GetContentClient()->GetDataResource( - IDR_COMMON_SANDBOX_PROFILE, ui::SCALE_FACTOR_NONE); + content::GetContentClient()->GetDataResource(IDR_COMMON_SANDBOX_PROFILE); 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 0fc1f2b..6309d9c 100644 --- a/content/common/webkitplatformsupport_impl.cc +++ b/content/common/webkitplatformsupport_impl.cc @@ -24,10 +24,15 @@ 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, - ui::ScaleFactor scale_factor) { - return content::GetContentClient()->GetDataResource(resource_id, - scale_factor); + float scale_factor) { + return content::GetContentClient()->GetImageResource(resource_id, + scale_factor); } void WebKitPlatformSupportImpl::GetPlugins( diff --git a/content/common/webkitplatformsupport_impl.h b/content/common/webkitplatformsupport_impl.h index 8d1e2f5..c190ae6 100644 --- a/content/common/webkitplatformsupport_impl.h +++ b/content/common/webkitplatformsupport_impl.h @@ -8,7 +8,6 @@ #include "base/compiler_specific.h" #include "content/common/content_export.h" -#include "ui/base/layout.h" #include "webkit/glue/webkitplatformsupport_impl.h" class GpuChannelHostFactory; @@ -24,9 +23,9 @@ class CONTENT_EXPORT WebKitPlatformSupportImpl virtual ~WebKitPlatformSupportImpl(); virtual string16 GetLocalizedString(int message_id) OVERRIDE; - virtual base::StringPiece GetDataResource( - int resource_id, - ui::ScaleFactor scale_factor) OVERRIDE; + virtual base::StringPiece GetDataResource(int resource_id) OVERRIDE; + virtual base::StringPiece GetImageResource(int resource_id, + float 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 1190328..61ad9b9 100644 --- a/content/public/common/content_client.h +++ b/content/public/common/content_client.h @@ -14,7 +14,6 @@ #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; @@ -116,9 +115,12 @@ 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, - ui::ScaleFactor scale_factor) const = 0; + 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; #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 dce3836..3df9f77 100644 --- a/content/renderer/render_thread_impl.cc +++ b/content/renderer/render_thread_impl.cc @@ -77,9 +77,8 @@ #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/WebView.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" -#include "ui/base/layout.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" #include "ui/base/ui_base_switches.h" #include "v8/include/v8.h" #include "webkit/glue/webkit_glue.h" @@ -493,7 +492,7 @@ void RenderThreadImpl::EnsureWebKitInitialized() { if (CommandLine::ForCurrentProcess()->HasSwitch( switches::kDomAutomationController)) { base::StringPiece extension = content::GetContentClient()->GetDataResource( - IDR_DOM_AUTOMATION_JS, ui::SCALE_FACTOR_NONE); + IDR_DOM_AUTOMATION_JS); 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 054b4f7..2f3a5ad 100644 --- a/content/shell/layout_test_controller_bindings.cc +++ b/content/shell/layout_test_controller_bindings.cc @@ -10,7 +10,6 @@ #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; @@ -21,8 +20,7 @@ namespace content { namespace { base::StringPiece GetStringResource(int resource_id) { - return ResourceBundle::GetSharedInstance().GetRawDataResource( - resource_id, ui::SCALE_FACTOR_NONE); + return ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); } RenderView* GetCurrentRenderView() { diff --git a/content/shell/shell_content_client.cc b/content/shell/shell_content_client.cc index c004593..e3c80d8 100644 --- a/content/shell/shell_content_client.cc +++ b/content/shell/shell_content_client.cc @@ -52,11 +52,16 @@ string16 ShellContentClient::GetLocalizedString(int message_id) const { return string16(); } -base::StringPiece ShellContentClient::GetDataResource( +base::StringPiece ShellContentClient::GetDataResource(int resource_id) const { + return ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); +} + +base::StringPiece ShellContentClient::GetImageResource( int resource_id, - ui::ScaleFactor scale_factor) const { - return ResourceBundle::GetSharedInstance().GetRawDataResource( - resource_id, scale_factor); + 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); } #if defined(OS_WIN) diff --git a/content/shell/shell_content_client.h b/content/shell/shell_content_client.h index 1d3aeda..d8b216e 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, - ui::ScaleFactor scale_factor) const OVERRIDE; + virtual base::StringPiece GetDataResource(int resource_id) const OVERRIDE; + virtual base::StringPiece GetImageResource(int resource_id, + float 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 cf35cd1..15cdce8 100644 --- a/content/shell/shell_devtools_delegate.cc +++ b/content/shell/shell_devtools_delegate.cc @@ -9,7 +9,6 @@ #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 { @@ -36,8 +35,7 @@ void ShellDevToolsDelegate::Stop() { std::string ShellDevToolsDelegate::GetDiscoveryPageHTML() { return ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_CONTENT_SHELL_DEVTOOLS_DISCOVERY_PAGE, - ui::SCALE_FACTOR_NONE).as_string(); + IDR_CONTENT_SHELL_DEVTOOLS_DISCOVERY_PAGE).as_string(); } bool ShellDevToolsDelegate::BundlesFrontendResources() { diff --git a/content/test/test_content_client.cc b/content/test/test_content_client.cc index 0d2e3e0..11d9bb6 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::SCALE_FACTOR_100P) { + : data_pack_(ui::ResourceHandle::kScaleFactor100x) { FilePath content_resources_pack_path; PathService::Get(base::DIR_MODULE, &content_resources_pack_path); content_resources_pack_path = content_resources_pack_path.Append( @@ -58,9 +58,15 @@ string16 TestContentClient::GetLocalizedString(int message_id) const { return string16(); } -base::StringPiece TestContentClient::GetDataResource( +base::StringPiece TestContentClient::GetDataResource(int resource_id) const { + base::StringPiece resource; + data_pack_.GetStringPiece(resource_id, &resource); + return resource; +} + +base::StringPiece TestContentClient::GetImageResource( int resource_id, - ui::ScaleFactor scale_factor) const { + float 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 ecf449b..94fb820 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, - ui::ScaleFactor scale_factor) const OVERRIDE; + virtual base::StringPiece GetDataResource(int resource_id) const OVERRIDE; + virtual base::StringPiece GetImageResource(int resource_id, + float 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 b65bfdd..be65e6e 100644 --- a/ui/base/layout.h +++ b/ui/base/layout.h @@ -27,16 +27,6 @@ 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 e1d8c14..0fa97a8 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(ui::ScaleFactor scale_factor) +DataPack::DataPack(float scale_factor) : resource_count_(0), text_encoding_type_(BINARY), scale_factor_(scale_factor) { @@ -145,11 +145,6 @@ 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 @@ -191,7 +186,7 @@ ResourceHandle::TextEncodingType DataPack::GetTextEncodingType() const { return text_encoding_type_; } -ui::ScaleFactor DataPack::GetScaleFactor() const { +float DataPack::GetScaleFactor() const { return scale_factor_; } diff --git a/ui/base/resource/data_pack.h b/ui/base/resource/data_pack.h index 3c03253..0ac5efe 100644 --- a/ui/base/resource/data_pack.h +++ b/ui/base/resource/data_pack.h @@ -15,9 +15,8 @@ #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" #include "base/string_piece.h" -#include "ui/base/layout.h" -#include "ui/base/resource/resource_handle.h" #include "ui/base/ui_export.h" +#include "ui/base/resource/resource_handle.h" class FilePath; @@ -33,7 +32,7 @@ namespace ui { class UI_EXPORT DataPack : public ResourceHandle { public: - DataPack(ui::ScaleFactor scale_factor); + DataPack(float scale_factor); virtual ~DataPack(); // Load a pack file from |path|, returning false on error. @@ -48,13 +47,12 @@ 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 ui::ScaleFactor GetScaleFactor() const OVERRIDE; + virtual float GetScaleFactor() const OVERRIDE; private: // The memory-mapped data. @@ -68,7 +66,7 @@ class UI_EXPORT DataPack : public ResourceHandle { // The scale of the image in this resource pack relative to images in the 1x // resource pak. - ui::ScaleFactor scale_factor_; + float 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 05e610b..510d07a 100644 --- a/ui/base/resource/data_pack_literal.cc +++ b/ui/base/resource/data_pack_literal.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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,23 +21,4 @@ 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 1ac2145..36be6fd 100644 --- a/ui/base/resource/data_pack_unittest.cc +++ b/ui/base/resource/data_pack_unittest.cc @@ -31,14 +31,12 @@ TEST(DataPackTest, Load) { static_cast<int>(kSamplePakSize)); // Load the file through the data pack API. - DataPack pack(SCALE_FACTOR_100P); + DataPack pack(ResourceHandle::kScaleFactor100x); 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); @@ -49,7 +47,6 @@ 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)); } @@ -66,7 +63,7 @@ TEST(DataPackTest, LoadFileWithTruncatedHeader) { data_path = data_path.Append(FILE_PATH_LITERAL( "ui/base/test/data/data_pack_unittest/truncated-header.pak")); - DataPack pack(SCALE_FACTOR_100P); + DataPack pack(ResourceHandle::kScaleFactor100x); ASSERT_FALSE(pack.Load(data_path)); } @@ -90,7 +87,7 @@ TEST_P(DataPackTest, Write) { ASSERT_TRUE(DataPack::WritePack(file, resources, GetParam())); // Now try to read the data back in. - DataPack pack(SCALE_FACTOR_100P); + DataPack pack(ResourceHandle::kScaleFactor100x); 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 bc77d53..c5fa973 100644 --- a/ui/base/resource/resource_bundle.cc +++ b/ui/base/resource/resource_bundle.cc @@ -19,7 +19,6 @@ #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" @@ -61,7 +60,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, path); + g_shared_instance_->LoadTestResources(path); } // static @@ -88,8 +87,7 @@ bool ResourceBundle::LocaleDataPakExists(const std::string& locale) { return !GetLocaleFilePath(locale).empty(); } -void ResourceBundle::AddDataPack(const FilePath& path, - ScaleFactor scale_factor) { +void ResourceBundle::AddDataPack(const FilePath& path, float 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()); @@ -103,7 +101,7 @@ void ResourceBundle::AddDataPack(const FilePath& path, return; scoped_ptr<DataPack> data_pack( - new DataPack(scale_factor)); + new DataPack(ResourceHandle::kScaleFactor100x)); if (data_pack->Load(pack_path)) { data_packs_.push_back(data_pack.release()); } else { @@ -166,7 +164,7 @@ std::string ResourceBundle::LoadLocaleResources( } scoped_ptr<DataPack> data_pack( - new DataPack(SCALE_FACTOR_100P)); + new DataPack(ResourceHandle::kScaleFactor100x)); if (!data_pack->Load(locale_file_path)) { UMA_HISTOGRAM_ENUMERATION("ResourceBundle.LoadLocaleResourcesError", logging::GetLastSystemErrorCode(), 16000); @@ -178,21 +176,16 @@ std::string ResourceBundle::LoadLocaleResources( return app_locale; } -void ResourceBundle::LoadTestResources(const FilePath& path, - const FilePath& locale_path) { +void ResourceBundle::LoadTestResources(const FilePath& path) { // Use the given resource pak for both common and localized resources. scoped_ptr<DataPack> data_pack( - new DataPack(SCALE_FACTOR_100P)); - if (!path.empty() && data_pack->Load(path)) + new DataPack(ResourceHandle::kScaleFactor100x)); + if (data_pack->Load(path)) data_packs_.push_back(data_pack.release()); - data_pack.reset(new DataPack(ui::SCALE_FACTOR_NONE)); - if (!locale_path.empty() && data_pack->Load(locale_path)) { + data_pack.reset(new DataPack(ResourceHandle::kScaleFactor100x)); + if (data_pack->Load(path)) locale_resources_data_.reset(data_pack.release()); - } else { - locale_resources_data_.reset( - new DataPack(ui::SCALE_FACTOR_NONE)); - } } void ResourceBundle::UnloadLocaleResources() { @@ -277,45 +270,30 @@ gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id) { } base::RefCountedStaticMemory* ResourceBundle::LoadDataResourceBytes( - int resource_id, - ScaleFactor scale_factor) const { + int resource_id) const { base::RefCountedStaticMemory* bytes = NULL; if (delegate_) - bytes = delegate_->LoadDataResourceBytes(resource_id, scale_factor); + bytes = delegate_->LoadDataResourceBytes(resource_id); if (!bytes) { - base::StringPiece data = GetRawDataResource(resource_id, scale_factor); - if (!data.empty()) { - bytes = new base::RefCountedStaticMemory( - reinterpret_cast<const unsigned char*>(data.data()), data.length()); - } + for (size_t i = 0; i < data_packs_.size() && !bytes; ++i) + bytes = data_packs_[i]->GetStaticMemory(resource_id); } return bytes; } -base::StringPiece ResourceBundle::GetRawDataResource( - int resource_id, - ScaleFactor scale_factor) const { +base::StringPiece ResourceBundle::GetRawDataResource(int resource_id) const { base::StringPiece data; - if (delegate_ && - delegate_->GetRawDataResource(resource_id, scale_factor, &data)) + if (delegate_ && delegate_->GetRawDataResource(resource_id, &data)) return data; DCHECK(locale_resources_data_.get()); if (locale_resources_data_->GetStringPiece(resource_id, &data)) return 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)) + for (size_t i = 0; i < data_packs_.size(); ++i) { + if (data_packs_[i]->GetStringPiece(resource_id, &data)) return data; } @@ -342,7 +320,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, ui::SCALE_FACTOR_NONE); + data = GetRawDataResource(message_id); 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 62d8fd6..df25f31 100644 --- a/ui/base/resource/resource_bundle.h +++ b/ui/base/resource/resource_bundle.h @@ -18,7 +18,6 @@ #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" @@ -70,7 +69,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, - ScaleFactor scale_factor) = 0; + float 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. @@ -90,13 +89,11 @@ 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, - ScaleFactor scale_factor) = 0; + int resource_id) = 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 @@ -140,7 +137,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, ScaleFactor scale_factor); + void AddDataPack(const FilePath& path, float 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 @@ -184,19 +181,13 @@ 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 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; + // 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; - // 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; + // Return the contents of a resource in a StringPiece given the resource id. + base::StringPiece GetRawDataResource(int resource_id) const; // Get a localized string given a message id. Returns an empty // string if the message_id is not found. @@ -222,7 +213,6 @@ 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); @@ -240,9 +230,8 @@ class UI_EXPORT ResourceBundle { // Returns the locale that is loaded. std::string LoadLocaleResources(const std::string& pref_locale); - // 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); + // Load test resources in given path. + void LoadTestResources(const FilePath& 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 b8d30d4..d770d3e 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"), - SCALE_FACTOR_100P); + ResourceHandle::kScaleFactor100x); AddDataPack(GetResourcesPakFilePath("theme_resources_standard.pak"), - SCALE_FACTOR_100P); + ResourceHandle::kScaleFactor100x); AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak"), - SCALE_FACTOR_100P); + ResourceHandle::kScaleFactor100x); } 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 535f455..6f63dff 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"), - SCALE_FACTOR_100P); + ResourceHandle::kScaleFactor100x); if (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) { AddDataPack(GetResourcesPakFilePath("theme_resources_touch_1x.pak"), - SCALE_FACTOR_100P); + ResourceHandle::kScaleFactor100x); AddDataPack(GetResourcesPakFilePath("ui_resources_touch.pak"), - SCALE_FACTOR_100P); + ResourceHandle::kScaleFactor100x); } else { AddDataPack(GetResourcesPakFilePath("theme_resources_standard.pak"), - SCALE_FACTOR_100P); + ResourceHandle::kScaleFactor100x); AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak"), - SCALE_FACTOR_100P); + ResourceHandle::kScaleFactor100x); } } diff --git a/ui/base/resource/resource_bundle_gtk.cc b/ui/base/resource/resource_bundle_gtk.cc index d969bc0..1c64e4d 100644 --- a/ui/base/resource/resource_bundle_gtk.cc +++ b/ui/base/resource/resource_bundle_gtk.cc @@ -8,11 +8,10 @@ #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" @@ -66,11 +65,11 @@ FilePath GetResourcesPakFilePath(const std::string& pak_name) { void ResourceBundle::LoadCommonResources() { AddDataPack(GetResourcesPakFilePath("chrome.pak"), - SCALE_FACTOR_100P); + ResourceHandle::kScaleFactor100x); AddDataPack(GetResourcesPakFilePath("theme_resources_standard.pak"), - SCALE_FACTOR_100P); + ResourceHandle::kScaleFactor100x); AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak"), - SCALE_FACTOR_100P); + ResourceHandle::kScaleFactor100x); } gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) { @@ -90,7 +89,7 @@ gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) { if (image.IsEmpty()) { scoped_refptr<base::RefCountedStaticMemory> data( - LoadDataResourceBytes(resource_id, SCALE_FACTOR_100P)); + LoadDataResourceBytes(resource_id)); 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 07736d8..8a559c4 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), - SCALE_FACTOR_100P); + ResourceHandle::kScaleFactor100x); AddDataPack(GetResourcesPakFilePath(@"theme_resources_standard", nil), - SCALE_FACTOR_100P); + ResourceHandle::kScaleFactor100x); AddDataPack(GetResourcesPakFilePath(@"ui_resources_standard", nil), - SCALE_FACTOR_100P); + ResourceHandle::kScaleFactor100x); // 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), - SCALE_FACTOR_200P); + ResourceHandle::kScaleFactor200x); AddDataPack(GetResourcesPakFilePath(@"theme_resources_standard_2x", nil), - SCALE_FACTOR_200P); + ResourceHandle::kScaleFactor200x); AddDataPack(GetResourcesPakFilePath(@"ui_resources_standard_2x", nil), - SCALE_FACTOR_200P); + ResourceHandle::kScaleFactor200x); } #endif } diff --git a/ui/base/resource/resource_bundle_unittest.cc b/ui/base/resource/resource_bundle_unittest.cc index 79a8ca9..1d72785 100644 --- a/ui/base/resource/resource_bundle_unittest.cc +++ b/ui/base/resource/resource_bundle_unittest.cc @@ -14,7 +14,6 @@ #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; @@ -26,10 +25,6 @@ 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 { @@ -42,23 +37,19 @@ class MockResourceBundleDelegate : public ui::ResourceBundle::Delegate { } MOCK_METHOD2(GetPathForResourcePack, FilePath(const FilePath& pack_path, - ui::ScaleFactor scale_factor)); + float 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_METHOD2(LoadDataResourceBytes, - base::RefCountedStaticMemory*(int resource_id, - ui::ScaleFactor scale_factor)); - MOCK_METHOD2(GetRawDataResourceMock, base::StringPiece( - int resource_id, - ui::ScaleFactor scale_factor)); + MOCK_METHOD1(LoadDataResourceBytes, + base::RefCountedStaticMemory*(int resource_id)); + MOCK_METHOD1(GetRawDataResourceMock, base::StringPiece(int resource_id)); virtual bool GetRawDataResource(int resource_id, - ui::ScaleFactor scale_factor, base::StringPiece* value) OVERRIDE { - *value = GetRawDataResourceMock(resource_id, scale_factor); + *value = GetRawDataResourceMock(resource_id); return true; } MOCK_METHOD1(GetLocalizedStringMock, string16(int message_id)); @@ -80,7 +71,7 @@ TEST(ResourceBundle, DelegateGetPathForResourcePack) { ResourceBundle resource_bundle(&delegate); FilePath pack_path(FILE_PATH_LITERAL("/path/to/test_path.pak")); - ui::ScaleFactor pack_scale_factor = ui::SCALE_FACTOR_200P; + double pack_scale_factor = 2.0; EXPECT_CALL(delegate, GetPathForResourcePack( @@ -161,14 +152,13 @@ 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, scale_factor)) + EXPECT_CALL(delegate, LoadDataResourceBytes(resource_id)) .Times(1) .WillOnce(Return(static_memory)); scoped_refptr<base::RefCountedStaticMemory> result = - resource_bundle.LoadDataResourceBytes(resource_id, scale_factor); + resource_bundle.LoadDataResourceBytes(resource_id); EXPECT_EQ(static_memory, result); } @@ -182,13 +172,11 @@ TEST(ResourceBundle, DelegateGetRawDataResource) { int resource_id = 5; - EXPECT_CALL(delegate, GetRawDataResourceMock( - resource_id, ui::SCALE_FACTOR_NONE)) + EXPECT_CALL(delegate, GetRawDataResourceMock(resource_id)) .Times(1) .WillOnce(Return(string_piece)); - base::StringPiece result = resource_bundle.GetRawDataResource( - resource_id, ui::SCALE_FACTOR_NONE); + base::StringPiece result = resource_bundle.GetRawDataResource(resource_id); EXPECT_EQ(string_piece.data(), result.data()); } @@ -244,58 +232,16 @@ TEST(ResourceBundle, LoadDataResourceBytes) { static_cast<int>(kSamplePakSize)); // Create a resource bundle from the file. - resource_bundle.LoadTestResources(data_path, data_path); + resource_bundle.LoadTestResources(data_path); const int kUnfoundResourceId = 10000; - EXPECT_EQ(NULL, resource_bundle.LoadDataResourceBytes( - kUnfoundResourceId, ui::SCALE_FACTOR_NONE)); + EXPECT_EQ(NULL, resource_bundle.LoadDataResourceBytes(kUnfoundResourceId)); // 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")), - 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)); + 1.0); + EXPECT_EQ(NULL, resource_bundle.LoadDataResourceBytes(kUnfoundResourceId)); } } diff --git a/ui/base/resource/resource_bundle_win.cc b/ui/base/resource/resource_bundle_win.cc index 4e525e7..e181e7d 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"), - SCALE_FACTOR_100P); + ResourceHandle::kScaleFactor100x); AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak"), - SCALE_FACTOR_100P); + ResourceHandle::kScaleFactor100x); break; default: if (use_hidpi) { AddDataPack(GetResourcesPakFilePath("theme_resources_2x.pak"), - SCALE_FACTOR_200P); + ResourceHandle::kScaleFactor200x); AddDataPack(GetResourcesPakFilePath("ui_resources_2x.pak"), - SCALE_FACTOR_200P); + ResourceHandle::kScaleFactor200x); } else { AddDataPack(GetResourcesPakFilePath("theme_resources_standard.pak"), - SCALE_FACTOR_100P); + ResourceHandle::kScaleFactor100x); AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak"), - SCALE_FACTOR_100P); + ResourceHandle::kScaleFactor100x); } break; } diff --git a/ui/base/resource/resource_data_dll_win.cc b/ui/base/resource/resource_data_dll_win.cc index c6c90c71..48e9db1 100644 --- a/ui/base/resource/resource_data_dll_win.cc +++ b/ui/base/resource/resource_data_dll_win.cc @@ -17,15 +17,6 @@ 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); @@ -57,8 +48,8 @@ ResourceHandle::TextEncodingType ResourceDataDLL::GetTextEncodingType() const { return BINARY; } -ScaleFactor ResourceDataDLL::GetScaleFactor() const { - return ui::SCALE_FACTOR_NONE; +float ResourceDataDLL::GetScaleFactor() const { + return 1.0; } } // namespace ui diff --git a/ui/base/resource/resource_data_dll_win.h b/ui/base/resource/resource_data_dll_win.h index a38dd54..e21e9aa 100644 --- a/ui/base/resource/resource_data_dll_win.h +++ b/ui/base/resource/resource_data_dll_win.h @@ -19,13 +19,12 @@ 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 ScaleFactor GetScaleFactor() const OVERRIDE; + virtual float GetScaleFactor() const OVERRIDE; private: const HINSTANCE module_; diff --git a/ui/base/resource/resource_handle.cc b/ui/base/resource/resource_handle.cc new file mode 100644 index 0000000..947ff80 --- /dev/null +++ b/ui/base/resource/resource_handle.cc @@ -0,0 +1,12 @@ +// 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 1d26e72..b40741e 100644 --- a/ui/base/resource/resource_handle.h +++ b/ui/base/resource/resource_handle.h @@ -8,7 +8,6 @@ #include "base/basictypes.h" #include "base/string_piece.h" -#include "ui/base/layout.h" #include "ui/base/ui_export.h" namespace base { @@ -26,10 +25,11 @@ class UI_EXPORT ResourceHandle { UTF16 }; - virtual ~ResourceHandle() {} + // The scale factors for image resources. + static const float kScaleFactor100x; + static const float kScaleFactor200x; - // Returns true if the DataPack contains a resource with id |resource_id|. - virtual bool HasResource(uint16 resource_id) const = 0; + virtual ~ResourceHandle() {} // Get resource by id |resource_id|, filling in |data|. // The data is owned by the DataPack object and should not be modified. @@ -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 ScaleFactor GetScaleFactor() const = 0; + virtual float GetScaleFactor() const = 0; }; } // namespace ui diff --git a/ui/compositor/test/compositor_test_support.cc b/ui/compositor/test/compositor_test_support.cc index 0ac2609..07c2ce7 100644 --- a/ui/compositor/test/compositor_test_support.cc +++ b/ui/compositor/test/compositor_test_support.cc @@ -17,9 +17,12 @@ class CompositorTestPlatformSupport: return string16(); } - virtual base::StringPiece GetDataResource( - int resource_id, - ui::ScaleFactor scale_factor) OVERRIDE { + virtual base::StringPiece GetDataResource(int resource_id) OVERRIDE { + return base::StringPiece(); + } + + virtual base::StringPiece GetImageResource(int resource_id, + float scale_factor) OVERRIDE { return base::StringPiece(); } diff --git a/ui/test/test_suite.cc b/ui/test/test_suite.cc index 26e0e93..da66f41 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"), - ui::SCALE_FACTOR_100P); + ResourceHandle::kScaleFactor100x); #endif } @@ -240,6 +240,7 @@ '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 f50b20e..39b6208 100644 --- a/webkit/glue/webkit_glue_unittest.cc +++ b/webkit/glue/webkit_glue_unittest.cc @@ -100,7 +100,12 @@ class TestWebKitPlatformSupport return string16(); } - virtual base::StringPiece GetDataResource(int, ui::ScaleFactor) OVERRIDE { + virtual base::StringPiece GetDataResource(int) OVERRIDE { + return base::StringPiece(); + } + + virtual base::StringPiece GetImageResource(int resource_id, + float scale_factor) OVERRIDE { return base::StringPiece(); } diff --git a/webkit/glue/webkitplatformsupport_impl.cc b/webkit/glue/webkitplatformsupport_impl.cc index 73e2e08..0849f76 100644 --- a/webkit/glue/webkitplatformsupport_impl.cc +++ b/webkit/glue/webkitplatformsupport_impl.cc @@ -29,15 +29,14 @@ #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/WebURL.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" -#include "ui/base/layout.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/websocketstreamhandle_impl.h" #include "webkit/glue/webthread_impl.h" @@ -370,8 +369,7 @@ WebData loadAudioSpatializationResource(WebKitPlatformSupportImpl* platform, is_resource_index_good) { const int kFirstAudioResourceIndex = IDR_AUDIO_SPATIALIZATION_T000_P000; base::StringPiece resource = - platform->GetDataResource(kFirstAudioResourceIndex + resource_index, - ui::SCALE_FACTOR_NONE); + platform->GetDataResource(kFirstAudioResourceIndex + resource_index); return WebData(resource.data(), resource.size()); } #endif // IDR_AUDIO_SPATIALIZATION_T000_P000 @@ -383,108 +381,89 @@ WebData loadAudioSpatializationResource(WebKitPlatformSupportImpl* platform, struct DataResource { const char* name; int id; - ui::ScaleFactor scale_factor; + float scale_factor; }; const DataResource kDataResources[] = { - { "missingImage", IDR_BROKENIMAGE, ui::SCALE_FACTOR_100P }, - { "missingImage@2x", IDR_BROKENIMAGE, ui::SCALE_FACTOR_200P }, + { "missingImage", IDR_BROKENIMAGE, 1.0 }, + { "missingImage@2x", IDR_BROKENIMAGE, 2.0 }, #if defined(OS_ANDROID) - { "mediaFullscreen", IDR_MEDIA_FULLSCREEN_BUTTON, ui::SCALE_FACTOR_100P }, + { "mediaFullscreen", IDR_MEDIA_FULLSCREEN_BUTTON, 1.0 }, #endif - { "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 }, + { "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 }, { "mediaplayerSoundLevel3Hover", - IDR_MEDIAPLAYER_SOUND_LEVEL3_BUTTON_HOVER, ui::SCALE_FACTOR_100P }, + IDR_MEDIAPLAYER_SOUND_LEVEL3_BUTTON_HOVER, 1.0 }, { "mediaplayerSoundLevel3Down", - IDR_MEDIAPLAYER_SOUND_LEVEL3_BUTTON_DOWN, ui::SCALE_FACTOR_100P }, - { "mediaplayerSoundLevel2", - IDR_MEDIAPLAYER_SOUND_LEVEL2_BUTTON, ui::SCALE_FACTOR_100P }, + IDR_MEDIAPLAYER_SOUND_LEVEL3_BUTTON_DOWN, 1.0 }, + { "mediaplayerSoundLevel2", IDR_MEDIAPLAYER_SOUND_LEVEL2_BUTTON, 1.0 }, { "mediaplayerSoundLevel2Hover", - IDR_MEDIAPLAYER_SOUND_LEVEL2_BUTTON_HOVER, ui::SCALE_FACTOR_100P }, + IDR_MEDIAPLAYER_SOUND_LEVEL2_BUTTON_HOVER, 1.0 }, { "mediaplayerSoundLevel2Down", - IDR_MEDIAPLAYER_SOUND_LEVEL2_BUTTON_DOWN, ui::SCALE_FACTOR_100P }, - { "mediaplayerSoundLevel1", - IDR_MEDIAPLAYER_SOUND_LEVEL1_BUTTON, ui::SCALE_FACTOR_100P }, + IDR_MEDIAPLAYER_SOUND_LEVEL2_BUTTON_DOWN, 1.0 }, + { "mediaplayerSoundLevel1", IDR_MEDIAPLAYER_SOUND_LEVEL1_BUTTON, 1.0 }, { "mediaplayerSoundLevel1Hover", - IDR_MEDIAPLAYER_SOUND_LEVEL1_BUTTON_HOVER, ui::SCALE_FACTOR_100P }, + IDR_MEDIAPLAYER_SOUND_LEVEL1_BUTTON_HOVER, 1.0 }, { "mediaplayerSoundLevel1Down", - IDR_MEDIAPLAYER_SOUND_LEVEL1_BUTTON_DOWN, ui::SCALE_FACTOR_100P }, - { "mediaplayerSoundLevel0", - IDR_MEDIAPLAYER_SOUND_LEVEL0_BUTTON, ui::SCALE_FACTOR_100P }, + IDR_MEDIAPLAYER_SOUND_LEVEL1_BUTTON_DOWN, 1.0 }, + { "mediaplayerSoundLevel0", IDR_MEDIAPLAYER_SOUND_LEVEL0_BUTTON, 1.0 }, { "mediaplayerSoundLevel0Hover", - IDR_MEDIAPLAYER_SOUND_LEVEL0_BUTTON_HOVER, ui::SCALE_FACTOR_100P }, + IDR_MEDIAPLAYER_SOUND_LEVEL0_BUTTON_HOVER, 1.0 }, { "mediaplayerSoundLevel0Down", - 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 }, + 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 }, { "mediaplayerVolumeSliderThumbHover", - IDR_MEDIAPLAYER_VOLUME_SLIDER_THUMB_HOVER, ui::SCALE_FACTOR_100P }, + IDR_MEDIAPLAYER_VOLUME_SLIDER_THUMB_HOVER, 1.0 }, { "mediaplayerVolumeSliderThumbDown", - IDR_MEDIAPLAYER_VOLUME_SLIDER_THUMB_DOWN, ui::SCALE_FACTOR_100P }, + IDR_MEDIAPLAYER_VOLUME_SLIDER_THUMB_DOWN, 1.0 }, { "mediaplayerVolumeSliderThumbDisabled", - IDR_MEDIAPLAYER_VOLUME_SLIDER_THUMB_DISABLED, ui::SCALE_FACTOR_100P }, - { "mediaplayerFullscreen", - IDR_MEDIAPLAYER_FULLSCREEN_BUTTON, ui::SCALE_FACTOR_100P }, + IDR_MEDIAPLAYER_VOLUME_SLIDER_THUMB_DISABLED, 1.0 }, + { "mediaplayerFullscreen", IDR_MEDIAPLAYER_FULLSCREEN_BUTTON, 1.0 }, { "mediaplayerFullscreenHover", - IDR_MEDIAPLAYER_FULLSCREEN_BUTTON_HOVER, ui::SCALE_FACTOR_100P }, - { "mediaplayerFullscreenDown", - IDR_MEDIAPLAYER_FULLSCREEN_BUTTON_DOWN, ui::SCALE_FACTOR_100P }, + IDR_MEDIAPLAYER_FULLSCREEN_BUTTON_HOVER, 1.0 }, + { "mediaplayerFullscreenDown", IDR_MEDIAPLAYER_FULLSCREEN_BUTTON_DOWN, 1.0 }, { "mediaplayerFullscreenDisabled", - IDR_MEDIAPLAYER_FULLSCREEN_BUTTON_DISABLED, ui::SCALE_FACTOR_100P }, + IDR_MEDIAPLAYER_FULLSCREEN_BUTTON_DISABLED, 1.0 }, #if defined(OS_MACOSX) - { "overhangPattern", IDR_OVERHANG_PATTERN, ui::SCALE_FACTOR_100P }, + { "overhangPattern", IDR_OVERHANG_PATTERN, 1.0 }, #endif - { "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 }, + { "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 }, }; } // namespace @@ -505,8 +484,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 = - GetDataResource(kDataResources[i].id, - kDataResources[i].scale_factor); + GetImageResource(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 46dd048..c58eb86 100644 --- a/webkit/glue/webkitplatformsupport_impl.h +++ b/webkit/glue/webkitplatformsupport_impl.h @@ -10,7 +10,6 @@ #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" @@ -120,8 +119,13 @@ 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, - ui::ScaleFactor scale_factor) = 0; + 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; // 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 dd6c914..79a9cd3 100644 --- a/webkit/support/platform_support_android.cc +++ b/webkit/support/platform_support_android.cc @@ -61,9 +61,13 @@ string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) { return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id); } -base::StringPiece TestWebKitPlatformSupport::GetDataResource( +base::StringPiece TestWebKitPlatformSupport::GetDataResource(int resource_id) { + return ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); +} + +base::StringPiece TestWebKitPlatformSupport::GetImageResource( int resource_id, - ui::ScaleFactor scale_factor) { + float scale_factor) { FilePath resources_path; PathService::Get(base::DIR_EXE, &resources_path); resources_path = resources_path.Append("DumpRenderTree_resources"); @@ -90,6 +94,6 @@ base::StringPiece TestWebKitPlatformSupport::GetDataResource( } } - return ResourceBundle::GetSharedInstance().GetRawDataResource( - resource_id, scale_factor); + // TODO(flackr): Pass scale_factor to ResourceBundle. + return ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); } diff --git a/webkit/support/platform_support_linux.cc b/webkit/support/platform_support_linux.cc index c696443..e777546 100644 --- a/webkit/support/platform_support_linux.cc +++ b/webkit/support/platform_support_linux.cc @@ -45,9 +45,13 @@ string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) { return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id); } -base::StringPiece TestWebKitPlatformSupport::GetDataResource( +base::StringPiece TestWebKitPlatformSupport::GetDataResource(int resource_id) { + return ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); +} + +base::StringPiece TestWebKitPlatformSupport::GetImageResource( int resource_id, - ui::ScaleFactor scale_factor) { + float scale_factor) { FilePath resources_path; PathService::Get(base::DIR_EXE, &resources_path); resources_path = resources_path.Append("DumpRenderTree_resources"); @@ -74,6 +78,6 @@ base::StringPiece TestWebKitPlatformSupport::GetDataResource( } } - return ResourceBundle::GetSharedInstance().GetRawDataResource( - resource_id, scale_factor); + // TODO(flackr): Pass scale_factor to ResourceBundle. + return ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); } diff --git a/webkit/support/platform_support_mac.mm b/webkit/support/platform_support_mac.mm index f7d4e33..f26ae69 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::SCALE_FACTOR_100P); + g_resource_data_pack = new ui::DataPack(ui::ResourceHandle::kScaleFactor100x); NSString* resource_path = [base::mac::FrameworkBundle() pathForResource:@"DumpRenderTree" ofType:@"pak"]; @@ -216,9 +216,16 @@ static FilePath GetResourcesFilePath() { return path.AppendASCII("Resources"); } -base::StringPiece TestWebKitPlatformSupport::GetDataResource( +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( int resource_id, - ui::ScaleFactor scale_factor) { + float 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 249a533..c385ccc 100644 --- a/webkit/support/platform_support_win.cc +++ b/webkit/support/platform_support_win.cc @@ -72,9 +72,13 @@ string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) { return string16(localized, length); } -base::StringPiece TestWebKitPlatformSupport::GetDataResource( +base::StringPiece TestWebKitPlatformSupport::GetDataResource(int resource_id) { + return ResourceProvider(resource_id); +} + +base::StringPiece TestWebKitPlatformSupport::GetImageResource( int resource_id, - ui::ScaleFactor scale_factor) { + float 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 5a7859a..fdbe18f 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, - ui::ScaleFactor scale_factor) OVERRIDE; + virtual base::StringPiece GetDataResource(int resource_id) OVERRIDE; + virtual base::StringPiece GetImageResource(int resource_id, + float 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 a58d72f..c99d070 100644 --- a/webkit/tools/test_shell/test_shell_gtk.cc +++ b/webkit/tools/test_shell/test_shell_gtk.cc @@ -23,10 +23,9 @@ #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/WebView.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.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" @@ -560,8 +559,7 @@ void TestShell::ShowStartupDebuggingDialog() { // static base::StringPiece TestShell::ResourceProvider(int key) { - return ResourceBundle::GetSharedInstance().GetRawDataResource( - key, ui::SCALE_FACTOR_NONE); + return ResourceBundle::GetSharedInstance().GetRawDataResource(key); } //----------------------------------------------------------------------------- @@ -570,9 +568,12 @@ string16 TestShellWebKitInit::GetLocalizedString(int message_id) { return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id); } -base::StringPiece TestShellWebKitInit::GetDataResource( - int resource_id, - ui::ScaleFactor scale_factor) { +base::StringPiece TestShellWebKitInit::GetDataResource(int resource_id) { + return TestShell::ResourceProvider(resource_id); +} + +base::StringPiece TestShellWebKitInit::GetImageResource(int resource_id, + float 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 d9b6ac2..9c38d44 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::SCALE_FACTOR_100P); + g_resource_data_pack = new ui::DataPack(ui::ResourceHandle::kScaleFactor100x); NSString *resource_path = [base::mac::FrameworkBundle() pathForResource:@"test_shell" ofType:@"pak"]; @@ -630,9 +630,12 @@ string16 TestShellWebKitInit::GetLocalizedString(int message_id) { return msg; } -base::StringPiece TestShellWebKitInit::GetDataResource( - int resource_id, - ui::ScaleFactor scale_factor) { +base::StringPiece TestShellWebKitInit::GetDataResource(int resource_id) { + return base::StringPiece(); +} + +base::StringPiece TestShellWebKitInit::GetImageResource(int resource_id, + float 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 7f0eb93..09f696d 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/WebStorageNamespace.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSerializedScriptValue.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageNamespace.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, - ui::ScaleFactor scale_factor) OVERRIDE; + virtual base::StringPiece GetDataResource(int resource_id) OVERRIDE; + virtual base::StringPiece GetImageResource(int resource_id, + float 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 70e1e05..e56530b 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_chromium_resources.h" #include "grit/webkit_resources.h" +#include "grit/webkit_chromium_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,10 +669,13 @@ 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::GetDataResource( - int resource_id, - ui::ScaleFactor scale_factor) { +base::StringPiece TestShellWebKitInit::GetImageResource(int resource_id, + float scale_factor) { switch (resource_id) { case IDR_BROKENIMAGE: { // Use webkit's broken image icon (16x16) |