OLD | NEW |
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" |
(...skipping 17 matching lines...) Expand all Loading... |
28 } | 28 } |
29 | 29 |
30 // static | 30 // static |
31 PluginFinder* PluginFinder::GetInstance() { | 31 PluginFinder* PluginFinder::GetInstance() { |
32 // PluginFinder::GetInstance() is the only method that's allowed to call | 32 // PluginFinder::GetInstance() is the only method that's allowed to call |
33 // Singleton<PluginFinder>::get(). | 33 // Singleton<PluginFinder>::get(). |
34 return Singleton<PluginFinder>::get(); | 34 return Singleton<PluginFinder>::get(); |
35 } | 35 } |
36 | 36 |
37 PluginFinder::PluginFinder() : plugin_list_(LoadPluginList()) { | 37 PluginFinder::PluginFinder() : plugin_list_(LoadPluginList()) { |
38 if (!plugin_list_.get()) { | 38 if (!plugin_list_.get()) |
39 NOTREACHED(); | |
40 plugin_list_.reset(new DictionaryValue()); | 39 plugin_list_.reset(new DictionaryValue()); |
41 } | |
42 } | 40 } |
43 | 41 |
44 // static | 42 // static |
45 scoped_ptr<DictionaryValue> PluginFinder::LoadPluginList() { | 43 DictionaryValue* PluginFinder::LoadPluginList() { |
46 return scoped_ptr<DictionaryValue>(LoadPluginListInternal()); | |
47 } | |
48 | |
49 DictionaryValue* PluginFinder::LoadPluginListInternal() { | |
50 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) | 44 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) |
51 base::StringPiece json_resource( | 45 base::StringPiece json_resource( |
52 ResourceBundle::GetSharedInstance().GetRawDataResource( | 46 ResourceBundle::GetSharedInstance().GetRawDataResource( |
53 IDR_PLUGIN_DB_JSON)); | 47 IDR_PLUGIN_DB_JSON)); |
54 std::string error_str; | 48 std::string error_str; |
55 scoped_ptr<base::Value> value(base::JSONReader::ReadAndReturnError( | 49 scoped_ptr<base::Value> value(base::JSONReader::ReadAndReturnError( |
56 json_resource.as_string(), | 50 json_resource.as_string(), |
57 base::JSON_PARSE_RFC, | 51 base::JSON_PARSE_RFC, |
58 NULL, | 52 NULL, |
59 &error_str)); | 53 &error_str)); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 plugin_dict->GetBoolean("requires_authorization", &requires_authorization); | 134 plugin_dict->GetBoolean("requires_authorization", &requires_authorization); |
141 PluginInstaller* installer = new PluginInstaller(identifier, | 135 PluginInstaller* installer = new PluginInstaller(identifier, |
142 GURL(url), | 136 GURL(url), |
143 GURL(help_url), | 137 GURL(help_url), |
144 name, | 138 name, |
145 display_url, | 139 display_url, |
146 requires_authorization); | 140 requires_authorization); |
147 installers_[identifier] = installer; | 141 installers_[identifier] = installer; |
148 return installer; | 142 return installer; |
149 } | 143 } |
OLD | NEW |