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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 return NULL; | 74 return NULL; |
75 for (DictionaryValue::Iterator plugin_it(*plugin_list_); | 75 for (DictionaryValue::Iterator plugin_it(*plugin_list_); |
76 plugin_it.HasNext(); plugin_it.Advance()) { | 76 plugin_it.HasNext(); plugin_it.Advance()) { |
77 const DictionaryValue* plugin = NULL; | 77 const DictionaryValue* plugin = NULL; |
78 if (!plugin_it.value().GetAsDictionary(&plugin)) { | 78 if (!plugin_it.value().GetAsDictionary(&plugin)) { |
79 NOTREACHED(); | 79 NOTREACHED(); |
80 continue; | 80 continue; |
81 } | 81 } |
82 std::string language_str; | 82 std::string language_str; |
83 bool success = plugin->GetString("lang", &language_str); | 83 bool success = plugin->GetString("lang", &language_str); |
84 DCHECK(success); | |
85 if (language_str != language) | 84 if (language_str != language) |
86 continue; | 85 continue; |
87 ListValue* mime_types = NULL; | 86 ListValue* mime_types = NULL; |
88 plugin->GetList("mime_types", &mime_types); | 87 plugin->GetList("mime_types", &mime_types); |
89 DCHECK(success); | 88 DCHECK(success); |
90 for (ListValue::const_iterator mime_type_it = mime_types->begin(); | 89 for (ListValue::const_iterator mime_type_it = mime_types->begin(); |
91 mime_type_it != mime_types->end(); ++mime_type_it) { | 90 mime_type_it != mime_types->end(); ++mime_type_it) { |
92 std::string mime_type_str; | 91 std::string mime_type_str; |
93 success = (*mime_type_it)->GetAsString(&mime_type_str); | 92 success = (*mime_type_it)->GetAsString(&mime_type_str); |
94 DCHECK(success); | 93 DCHECK(success); |
(...skipping 21 matching lines...) Expand all Loading... |
116 return CreateInstaller(identifier, plugin); | 115 return CreateInstaller(identifier, plugin); |
117 return NULL; | 116 return NULL; |
118 } | 117 } |
119 | 118 |
120 PluginInstaller* PluginFinder::CreateInstaller( | 119 PluginInstaller* PluginFinder::CreateInstaller( |
121 const std::string& identifier, | 120 const std::string& identifier, |
122 const DictionaryValue* plugin_dict) { | 121 const DictionaryValue* plugin_dict) { |
123 DCHECK(!installers_[identifier]); | 122 DCHECK(!installers_[identifier]); |
124 std::string url; | 123 std::string url; |
125 bool success = plugin_dict->GetString("url", &url); | 124 bool success = plugin_dict->GetString("url", &url); |
126 DCHECK(success); | |
127 std::string help_url; | 125 std::string help_url; |
128 plugin_dict->GetString("help_url", &help_url); | 126 plugin_dict->GetString("help_url", &help_url); |
129 string16 name; | 127 string16 name; |
130 success = plugin_dict->GetString("name", &name); | 128 success = plugin_dict->GetString("name", &name); |
131 DCHECK(success); | 129 DCHECK(success); |
132 bool display_url = false; | 130 bool display_url = false; |
133 plugin_dict->GetBoolean("displayurl", &display_url); | 131 plugin_dict->GetBoolean("displayurl", &display_url); |
134 | 132 |
135 PluginInstaller* installer = new PluginInstaller(identifier, | 133 PluginInstaller* installer = new PluginInstaller(identifier, |
136 name, | 134 name, |
(...skipping 19 matching lines...) Expand all Loading... |
156 PluginInstaller::SECURITY_STATUS_UP_TO_DATE; | 154 PluginInstaller::SECURITY_STATUS_UP_TO_DATE; |
157 success = PluginInstaller::ParseSecurityStatus(status_str, &status); | 155 success = PluginInstaller::ParseSecurityStatus(status_str, &status); |
158 DCHECK(success); | 156 DCHECK(success); |
159 installer->AddVersion(Version(version), status); | 157 installer->AddVersion(Version(version), status); |
160 } | 158 } |
161 } | 159 } |
162 | 160 |
163 installers_[identifier] = installer; | 161 installers_[identifier] = installer; |
164 return installer; | 162 return installer; |
165 } | 163 } |
OLD | NEW |