Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: chrome/renderer/resource_bundle_source_map.cc

Issue 10387010: Select theme resources from ResourceBundle at requested scale factor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with master. Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/resource_bundle_source_map.h" 5 #include "chrome/renderer/resource_bundle_source_map.h"
6 6
7 #include "ui/base/layout.h"
7 #include "ui/base/resource/resource_bundle.h" 8 #include "ui/base/resource/resource_bundle.h"
8 9
9 ResourceBundleSourceMap::ResourceBundleSourceMap( 10 ResourceBundleSourceMap::ResourceBundleSourceMap(
10 const ui::ResourceBundle* resource_bundle) 11 const ui::ResourceBundle* resource_bundle)
11 : resource_bundle_(resource_bundle) { 12 : resource_bundle_(resource_bundle) {
12 } 13 }
13 14
14 ResourceBundleSourceMap::~ResourceBundleSourceMap() { 15 ResourceBundleSourceMap::~ResourceBundleSourceMap() {
15 } 16 }
16 17
17 void ResourceBundleSourceMap::RegisterSource(const std::string& name, 18 void ResourceBundleSourceMap::RegisterSource(const std::string& name,
18 int resource_id) { 19 int resource_id) {
19 resource_id_map_[name] = resource_id; 20 resource_id_map_[name] = resource_id;
20 } 21 }
21 22
22 v8::Handle<v8::Value> ResourceBundleSourceMap::GetSource( 23 v8::Handle<v8::Value> ResourceBundleSourceMap::GetSource(
23 const std::string& name) { 24 const std::string& name) {
24 if (!Contains(name)) 25 if (!Contains(name))
25 return v8::Undefined(); 26 return v8::Undefined();
26 int resource_id = resource_id_map_[name]; 27 int resource_id = resource_id_map_[name];
27 return ConvertString(resource_bundle_->GetRawDataResource(resource_id)); 28 return ConvertString(resource_bundle_->GetRawDataResource(
29 resource_id, ui::SCALE_FACTOR_NONE));
28 } 30 }
29 31
30 bool ResourceBundleSourceMap::Contains(const std::string& name) { 32 bool ResourceBundleSourceMap::Contains(const std::string& name) {
31 return !!resource_id_map_.count(name); 33 return !!resource_id_map_.count(name);
32 } 34 }
33 35
34 v8::Handle<v8::String> ResourceBundleSourceMap::ConvertString( 36 v8::Handle<v8::String> ResourceBundleSourceMap::ConvertString(
35 const base::StringPiece& string) { 37 const base::StringPiece& string) {
36 // v8 takes ownership of the StaticV8ExternalAsciiStringResource (see 38 // v8 takes ownership of the StaticV8ExternalAsciiStringResource (see
37 // v8::String::NewExternal()). 39 // v8::String::NewExternal()).
38 return v8::String::NewExternal( 40 return v8::String::NewExternal(
39 new StaticV8ExternalAsciiStringResource(string)); 41 new StaticV8ExternalAsciiStringResource(string));
40 } 42 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698