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" |
11 #include "base/string_util.h" | |
11 #include "base/values.h" | 12 #include "base/values.h" |
12 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
13 #include "chrome/browser/plugin_installer.h" | 14 #include "chrome/browser/plugin_installer.h" |
14 #include "chrome/browser/prefs/pref_service.h" | 15 #include "chrome/browser/prefs/pref_service.h" |
15 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
16 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
17 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
18 #include "grit/browser_resources.h" | 19 #include "grit/browser_resources.h" |
19 #include "ui/base/layout.h" | 20 #include "ui/base/layout.h" |
20 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 DCHECK(!installers_[identifier]); | 123 DCHECK(!installers_[identifier]); |
123 std::string url; | 124 std::string url; |
124 bool success = plugin_dict->GetString("url", &url); | 125 bool success = plugin_dict->GetString("url", &url); |
125 std::string help_url; | 126 std::string help_url; |
126 plugin_dict->GetString("help_url", &help_url); | 127 plugin_dict->GetString("help_url", &help_url); |
127 string16 name; | 128 string16 name; |
128 success = plugin_dict->GetString("name", &name); | 129 success = plugin_dict->GetString("name", &name); |
129 DCHECK(success); | 130 DCHECK(success); |
130 bool display_url = false; | 131 bool display_url = false; |
131 plugin_dict->GetBoolean("displayurl", &display_url); | 132 plugin_dict->GetBoolean("displayurl", &display_url); |
132 | 133 string16 group_name_matcher; |
134 success = plugin_dict->GetString("group_name_matcher", &group_name_matcher); | |
135 DCHECK(success); | |
133 PluginInstaller* installer = new PluginInstaller(identifier, | 136 PluginInstaller* installer = new PluginInstaller(identifier, |
134 name, | 137 name, |
135 display_url, | 138 display_url, |
136 GURL(url), | 139 GURL(url), |
137 GURL(help_url)); | 140 GURL(help_url), |
141 group_name_matcher); | |
138 const ListValue* versions = NULL; | 142 const ListValue* versions = NULL; |
139 if (plugin_dict->GetList("versions", &versions)) { | 143 if (plugin_dict->GetList("versions", &versions)) { |
140 for (ListValue::const_iterator it = versions->begin(); | 144 for (ListValue::const_iterator it = versions->begin(); |
141 it != versions->end(); ++it) { | 145 it != versions->end(); ++it) { |
142 DictionaryValue* version_dict = NULL; | 146 DictionaryValue* version_dict = NULL; |
143 if (!(*it)->GetAsDictionary(&version_dict)) { | 147 if (!(*it)->GetAsDictionary(&version_dict)) { |
144 NOTREACHED(); | 148 NOTREACHED(); |
145 continue; | 149 continue; |
146 } | 150 } |
147 std::string version; | 151 std::string version; |
148 success = version_dict->GetString("version", &version); | 152 success = version_dict->GetString("version", &version); |
149 DCHECK(success); | 153 DCHECK(success); |
150 std::string status_str; | 154 std::string status_str; |
151 success = version_dict->GetString("status", &status_str); | 155 success = version_dict->GetString("status", &status_str); |
152 DCHECK(success); | 156 DCHECK(success); |
153 PluginInstaller::SecurityStatus status = | 157 PluginInstaller::SecurityStatus status = |
154 PluginInstaller::SECURITY_STATUS_UP_TO_DATE; | 158 PluginInstaller::SECURITY_STATUS_UP_TO_DATE; |
155 success = PluginInstaller::ParseSecurityStatus(status_str, &status); | 159 success = PluginInstaller::ParseSecurityStatus(status_str, &status); |
156 DCHECK(success); | 160 DCHECK(success); |
157 installer->AddVersion(Version(version), status); | 161 installer->AddVersion(Version(version), status); |
158 } | 162 } |
159 } | 163 } |
160 | 164 |
161 installers_[identifier] = installer; | 165 installers_[identifier] = installer; |
162 return installer; | 166 return installer; |
163 } | 167 } |
168 | |
169 const std::map<std::string, PluginInstaller*>& PluginFinder:: | |
Bernhard Bauer
2012/08/21 12:30:18
Ugh. I would either break this line after the retu
ibraaaa
2012/08/21 14:26:04
Done.
| |
170 GetAllPluginInstallers() { | |
171 for (DictionaryValue::Iterator plugin_it(*plugin_list_); | |
172 plugin_it.HasNext(); plugin_it.Advance()) { | |
173 FindPluginWithIdentifier(plugin_it.key()); | |
Bernhard Bauer
2012/08/21 12:30:18
Can you add a comment that this triggers the lazy
ibraaaa
2012/08/21 14:26:04
Done.
| |
174 } | |
175 | |
176 return installers_; | |
177 } | |
OLD | NEW |