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

Side by Side Diff: chrome/browser/plugin_finder.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/browser/plugin_finder.h" 5 #include "chrome/browser/plugin_finder.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/plugin_installer.h" 13 #include "chrome/browser/plugin_installer.h"
14 #include "chrome/browser/prefs/pref_service.h" 14 #include "chrome/browser/prefs/pref_service.h"
15 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
16 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
17 #include "googleurl/src/gurl.h" 17 #include "googleurl/src/gurl.h"
18 #include "grit/browser_resources.h" 18 #include "grit/browser_resources.h"
19 #include "ui/base/layout.h"
19 #include "ui/base/resource/resource_bundle.h" 20 #include "ui/base/resource/resource_bundle.h"
20 21
21 using base::DictionaryValue; 22 using base::DictionaryValue;
22 23
23 // static 24 // static
24 void PluginFinder::Get(const base::Callback<void(PluginFinder*)>& cb) { 25 void PluginFinder::Get(const base::Callback<void(PluginFinder*)>& cb) {
25 // At a later point we might want to do intialization here that needs to be 26 // At a later point we might want to do intialization here that needs to be
26 // done asynchronously, like loading the plug-in list from disk or from a URL. 27 // done asynchronously, like loading the plug-in list from disk or from a URL.
27 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(cb, GetInstance())); 28 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(cb, GetInstance()));
28 } 29 }
29 30
30 // static 31 // static
31 PluginFinder* PluginFinder::GetInstance() { 32 PluginFinder* PluginFinder::GetInstance() {
32 // PluginFinder::GetInstance() is the only method that's allowed to call 33 // PluginFinder::GetInstance() is the only method that's allowed to call
33 // Singleton<PluginFinder>::get(). 34 // Singleton<PluginFinder>::get().
34 return Singleton<PluginFinder>::get(); 35 return Singleton<PluginFinder>::get();
35 } 36 }
36 37
37 PluginFinder::PluginFinder() : plugin_list_(LoadPluginList()) { 38 PluginFinder::PluginFinder() : plugin_list_(LoadPluginList()) {
38 if (!plugin_list_.get()) 39 if (!plugin_list_.get())
39 plugin_list_.reset(new DictionaryValue()); 40 plugin_list_.reset(new DictionaryValue());
40 } 41 }
41 42
42 // static 43 // static
43 DictionaryValue* PluginFinder::LoadPluginList() { 44 DictionaryValue* PluginFinder::LoadPluginList() {
44 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) 45 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)
45 base::StringPiece json_resource( 46 base::StringPiece json_resource(
46 ResourceBundle::GetSharedInstance().GetRawDataResource( 47 ResourceBundle::GetSharedInstance().GetRawDataResource(
47 IDR_PLUGIN_DB_JSON)); 48 IDR_PLUGIN_DB_JSON, ui::SCALE_FACTOR_NONE));
48 std::string error_str; 49 std::string error_str;
49 scoped_ptr<base::Value> value(base::JSONReader::ReadAndReturnError( 50 scoped_ptr<base::Value> value(base::JSONReader::ReadAndReturnError(
50 json_resource.as_string(), 51 json_resource.as_string(),
51 base::JSON_PARSE_RFC, 52 base::JSON_PARSE_RFC,
52 NULL, 53 NULL,
53 &error_str)); 54 &error_str));
54 if (!value.get()) { 55 if (!value.get()) {
55 DLOG(ERROR) << error_str; 56 DLOG(ERROR) << error_str;
56 return NULL; 57 return NULL;
57 } 58 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 plugin_dict->GetBoolean("requires_authorization", &requires_authorization); 135 plugin_dict->GetBoolean("requires_authorization", &requires_authorization);
135 PluginInstaller* installer = new PluginInstaller(identifier, 136 PluginInstaller* installer = new PluginInstaller(identifier,
136 GURL(url), 137 GURL(url),
137 GURL(help_url), 138 GURL(help_url),
138 name, 139 name,
139 display_url, 140 display_url,
140 requires_authorization); 141 requires_authorization);
141 installers_[identifier] = installer; 142 installers_[identifier] = installer;
142 return installer; 143 return installer;
143 } 144 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698