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/common/chrome_content_client.h" | 5 #include "chrome/common/chrome_content_client.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 version_vector.push_back( | 136 version_vector.push_back( |
137 base::MakeUnique<content::PepperPluginInfo>(info6_13)); | 137 base::MakeUnique<content::PepperPluginInfo>(info6_13)); |
138 version_vector.push_back( | 138 version_vector.push_back( |
139 base::MakeUnique<content::PepperPluginInfo>(info6_12)); | 139 base::MakeUnique<content::PepperPluginInfo>(info6_12)); |
140 version_vector.push_back(base::MakeUnique<content::PepperPluginInfo>(info5)); | 140 version_vector.push_back(base::MakeUnique<content::PepperPluginInfo>(info5)); |
141 | 141 |
142 most_recent = ChromeContentClient::FindMostRecentPlugin(version_vector); | 142 most_recent = ChromeContentClient::FindMostRecentPlugin(version_vector); |
143 EXPECT_EQ("6.0.0.13", most_recent->version); | 143 EXPECT_EQ("6.0.0.13", most_recent->version); |
144 | 144 |
145 // Test real scenarios. | 145 // Test real scenarios. |
146 content::PepperPluginInfo bundled_flash; | 146 content::PepperPluginInfo component_flash; |
147 bundled_flash.version = "4.3.2.1"; | 147 component_flash.version = "4.3.2.1"; |
148 bundled_flash.is_external = false; | 148 component_flash.is_external = false; |
149 bundled_flash.is_debug = false; | 149 component_flash.name = "component_flash"; |
150 bundled_flash.is_on_local_drive = true; | |
151 bundled_flash.is_bundled = true; | |
152 bundled_flash.name = "bundled_flash"; | |
153 | |
154 content::PepperPluginInfo local_component_flash; | |
155 local_component_flash.version = "4.3.2.1"; | |
156 local_component_flash.is_external = false; | |
157 local_component_flash.is_debug = false; | |
158 local_component_flash.is_on_local_drive = true; | |
159 local_component_flash.is_bundled = false; | |
160 local_component_flash.name = "local_component_flash"; | |
161 | |
162 content::PepperPluginInfo network_component_flash; | |
163 network_component_flash.version = "4.3.2.1"; | |
164 network_component_flash.is_external = false; | |
165 network_component_flash.is_debug = false; | |
166 network_component_flash.is_on_local_drive = false; | |
167 network_component_flash.is_bundled = false; | |
168 network_component_flash.name = "network_component_flash"; | |
169 | 150 |
170 content::PepperPluginInfo system_flash; | 151 content::PepperPluginInfo system_flash; |
171 system_flash.version = "4.3.2.1"; | 152 system_flash.version = "4.3.2.1"; |
172 system_flash.is_external = true; | 153 system_flash.is_external = true; |
173 system_flash.is_debug = false; | |
174 system_flash.is_on_local_drive = true; | |
175 system_flash.is_bundled = false; | |
176 system_flash.name = "system_flash"; | 154 system_flash.name = "system_flash"; |
177 | 155 |
178 content::PepperPluginInfo system_debug_flash; | |
179 system_debug_flash.version = "4.3.2.1"; | |
180 system_debug_flash.is_external = true; | |
181 system_debug_flash.is_debug = true; | |
182 system_debug_flash.is_on_local_drive = false; | |
183 system_debug_flash.is_bundled = false; | |
184 system_debug_flash.name = "system_debug_flash"; | |
185 | |
186 // The order here should be: | 156 // The order here should be: |
187 // 1. Debug System Flash. | 157 // 1. System Flash. |
188 // 2. Bundled. | 158 // 2. Component update. |
189 // 3. Component update on a local drive. | |
190 // 4. System Flash. | |
191 // 5. Component update on a network drive. | |
192 | |
193 // Debug beats bundled. | |
194 version_vector.clear(); | |
195 version_vector.push_back( | |
196 base::MakeUnique<content::PepperPluginInfo>(system_debug_flash)); | |
197 version_vector.push_back( | |
198 base::MakeUnique<content::PepperPluginInfo>(bundled_flash)); | |
199 | |
200 most_recent = ChromeContentClient::FindMostRecentPlugin(version_vector); | |
201 EXPECT_STREQ("system_debug_flash", most_recent->name.c_str()); | |
202 | |
203 // Bundled beats component updated. | |
204 version_vector.clear(); | |
205 version_vector.push_back( | |
206 base::MakeUnique<content::PepperPluginInfo>(bundled_flash)); | |
207 version_vector.push_back( | |
208 base::MakeUnique<content::PepperPluginInfo>(local_component_flash)); | |
209 | |
210 most_recent = ChromeContentClient::FindMostRecentPlugin(version_vector); | |
211 EXPECT_STREQ("bundled_flash", most_recent->name.c_str()); | |
212 | |
213 // Bundled beats System flash | |
214 version_vector.clear(); | |
215 version_vector.push_back( | |
216 base::MakeUnique<content::PepperPluginInfo>(bundled_flash)); | |
217 version_vector.push_back( | |
218 base::MakeUnique<content::PepperPluginInfo>(system_flash)); | |
219 | |
220 most_recent = ChromeContentClient::FindMostRecentPlugin(version_vector); | |
221 EXPECT_STREQ("bundled_flash", most_recent->name.c_str()); | |
222 | |
223 // Local component updated beats System Flash. | |
224 version_vector.clear(); | 159 version_vector.clear(); |
225 version_vector.push_back( | 160 version_vector.push_back( |
226 base::MakeUnique<content::PepperPluginInfo>(system_flash)); | 161 base::MakeUnique<content::PepperPluginInfo>(system_flash)); |
227 version_vector.push_back( | 162 version_vector.push_back( |
228 base::MakeUnique<content::PepperPluginInfo>(local_component_flash)); | 163 base::MakeUnique<content::PepperPluginInfo>(component_flash)); |
229 | |
230 most_recent = ChromeContentClient::FindMostRecentPlugin(version_vector); | |
231 EXPECT_STREQ("local_component_flash", most_recent->name.c_str()); | |
232 | |
233 // System Flash beats component update on network drive. | |
234 version_vector.clear(); | |
235 version_vector.push_back( | |
236 base::MakeUnique<content::PepperPluginInfo>(network_component_flash)); | |
237 version_vector.push_back( | |
238 base::MakeUnique<content::PepperPluginInfo>(system_flash)); | |
239 | |
240 most_recent = ChromeContentClient::FindMostRecentPlugin(version_vector); | 164 most_recent = ChromeContentClient::FindMostRecentPlugin(version_vector); |
241 EXPECT_STREQ("system_flash", most_recent->name.c_str()); | 165 EXPECT_STREQ("system_flash", most_recent->name.c_str()); |
242 } | 166 } |
243 #endif // defined(ENABLE_PLUGINS) | 167 #endif // defined(ENABLE_PLUGINS) |
244 | 168 |
245 TEST(ChromeContentClientTest, AdditionalSchemes) { | 169 TEST(ChromeContentClientTest, AdditionalSchemes) { |
246 EXPECT_TRUE(url::IsStandard( | 170 EXPECT_TRUE(url::IsStandard( |
247 extensions::kExtensionScheme, | 171 extensions::kExtensionScheme, |
248 url::Component(0, strlen(extensions::kExtensionScheme)))); | 172 url::Component(0, strlen(extensions::kExtensionScheme)))); |
249 | 173 |
250 GURL extension_url( | 174 GURL extension_url( |
251 "chrome-extension://abcdefghijklmnopqrstuvwxyzabcdef/foo.html"); | 175 "chrome-extension://abcdefghijklmnopqrstuvwxyzabcdef/foo.html"); |
252 url::Origin origin(extension_url); | 176 url::Origin origin(extension_url); |
253 EXPECT_EQ("chrome-extension://abcdefghijklmnopqrstuvwxyzabcdef", | 177 EXPECT_EQ("chrome-extension://abcdefghijklmnopqrstuvwxyzabcdef", |
254 origin.Serialize()); | 178 origin.Serialize()); |
255 } | 179 } |
256 | 180 |
257 } // namespace chrome_common | 181 } // namespace chrome_common |
OLD | NEW |