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

Side by Side Diff: chrome/common/extensions/simple_feature_provider.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/common/extensions/simple_feature_provider.h" 5 #include "chrome/common/extensions/simple_feature_provider.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "chrome/common/extensions/manifest_feature.h" 9 #include "chrome/common/extensions/manifest_feature.h"
10 #include "chrome/common/extensions/permission_feature.h" 10 #include "chrome/common/extensions/permission_feature.h"
11 #include "grit/common_resources.h" 11 #include "grit/common_resources.h"
12 #include "ui/base/layout.h"
12 #include "ui/base/resource/resource_bundle.h" 13 #include "ui/base/resource/resource_bundle.h"
13 14
14 namespace extensions { 15 namespace extensions {
15 16
16 namespace { 17 namespace {
17 18
18 template<class FeatureClass> 19 template<class FeatureClass>
19 Feature* CreateFeature() { 20 Feature* CreateFeature() {
20 return new FeatureClass(); 21 return new FeatureClass();
21 } 22 }
(...skipping 13 matching lines...) Expand all
35 scoped_ptr<SimpleFeatureProvider> manifest_features; 36 scoped_ptr<SimpleFeatureProvider> manifest_features;
36 scoped_ptr<SimpleFeatureProvider> permission_features; 37 scoped_ptr<SimpleFeatureProvider> permission_features;
37 38
38 private: 39 private:
39 scoped_ptr<SimpleFeatureProvider> LoadProvider( 40 scoped_ptr<SimpleFeatureProvider> LoadProvider(
40 const std::string& debug_string, 41 const std::string& debug_string,
41 SimpleFeatureProvider::FeatureFactory factory, 42 SimpleFeatureProvider::FeatureFactory factory,
42 int resource_id) { 43 int resource_id) {
43 std::string manifest_features = 44 std::string manifest_features =
44 ResourceBundle::GetSharedInstance().GetRawDataResource( 45 ResourceBundle::GetSharedInstance().GetRawDataResource(
45 resource_id).as_string(); 46 resource_id, ui::SCALE_FACTOR_NONE).as_string();
46 int error_code = 0; 47 int error_code = 0;
47 std::string error_message; 48 std::string error_message;
48 Value* value = base::JSONReader::ReadAndReturnError( 49 Value* value = base::JSONReader::ReadAndReturnError(
49 manifest_features, base::JSON_PARSE_RFC, 50 manifest_features, base::JSON_PARSE_RFC,
50 &error_code, &error_message); 51 &error_code, &error_message);
51 CHECK(value) << "Could not load features: " << debug_string << " " 52 CHECK(value) << "Could not load features: " << debug_string << " "
52 << error_message; 53 << error_message;
53 CHECK(value->IsType(Value::TYPE_DICTIONARY)) << debug_string; 54 CHECK(value->IsType(Value::TYPE_DICTIONARY)) << debug_string;
54 scoped_ptr<DictionaryValue> dictionary_value( 55 scoped_ptr<DictionaryValue> dictionary_value(
55 static_cast<DictionaryValue*>(value)); 56 static_cast<DictionaryValue*>(value));
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 116
116 Feature* SimpleFeatureProvider::GetFeature(const std::string& name) { 117 Feature* SimpleFeatureProvider::GetFeature(const std::string& name) {
117 FeatureMap::iterator iter = features_.find(name); 118 FeatureMap::iterator iter = features_.find(name);
118 if (iter != features_.end()) 119 if (iter != features_.end())
119 return iter->second.get(); 120 return iter->second.get();
120 else 121 else
121 return NULL; 122 return NULL;
122 } 123 }
123 124
124 } // namespace 125 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698