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

Side by Side Diff: webkit/glue/plugins/plugin_list_win.cc

Issue 3056029: Move the number conversions from string_util to a new file.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "webkit/glue/plugins/plugin_list.h" 5 #include "webkit/glue/plugins/plugin_list.h"
6 6
7 #include <tchar.h> 7 #include <tchar.h>
8 8
9 #include <set> 9 #include <set>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/file_util.h" 13 #include "base/file_util.h"
14 #include "base/path_service.h" 14 #include "base/path_service.h"
15 #include "base/registry.h" 15 #include "base/registry.h"
16 #include "base/scoped_ptr.h" 16 #include "base/scoped_ptr.h"
17 #include "base/string_number_conversions.h"
17 #include "base/string_util.h" 18 #include "base/string_util.h"
18 #include "webkit/glue/plugins/plugin_constants_win.h" 19 #include "webkit/glue/plugins/plugin_constants_win.h"
19 #include "webkit/glue/plugins/plugin_lib.h" 20 #include "webkit/glue/plugins/plugin_lib.h"
20 #include "webkit/glue/webkit_glue.h" 21 #include "webkit/glue/webkit_glue.h"
21 22
22 namespace { 23 namespace {
23 24
24 const TCHAR kRegistryApps[] = 25 const TCHAR kRegistryApps[] =
25 _T("Software\\Microsoft\\Windows\\CurrentVersion\\App Paths"); 26 _T("Software\\Microsoft\\Windows\\CurrentVersion\\App Paths");
26 const TCHAR kRegistryFirefox[] = _T("firefox.exe"); 27 const TCHAR kRegistryFirefox[] = _T("firefox.exe");
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 SplitString(b, ',', &b_ver); 307 SplitString(b, ',', &b_ver);
307 if (a_ver.size() == 1 && b_ver.size() == 1) { 308 if (a_ver.size() == 1 && b_ver.size() == 1) {
308 a_ver.clear(); 309 a_ver.clear();
309 b_ver.clear(); 310 b_ver.clear();
310 SplitString(a, '.', &a_ver); 311 SplitString(a, '.', &a_ver);
311 SplitString(b, '.', &b_ver); 312 SplitString(b, '.', &b_ver);
312 } 313 }
313 if (a_ver.size() != b_ver.size()) 314 if (a_ver.size() != b_ver.size())
314 return false; 315 return false;
315 for (size_t i = 0; i < a_ver.size(); i++) { 316 for (size_t i = 0; i < a_ver.size(); i++) {
316 int cur_a = StringToInt(a_ver[i]); 317 int cur_a, cur_b;
317 int cur_b = StringToInt(b_ver[i]); 318 base::StringToInt(a_ver[i], &cur_a);
319 base::StringToInt(b_ver[i], &cur_b);
320
318 if (cur_a > cur_b) 321 if (cur_a > cur_b)
319 return false; 322 return false;
320 if (cur_a < cur_b) 323 if (cur_a < cur_b)
321 return true; 324 return true;
322 } 325 }
323 return false; 326 return false;
324 } 327 }
325 328
326 bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info, 329 bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info,
327 std::vector<WebPluginInfo>* plugins) { 330 std::vector<WebPluginInfo>* plugins) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 if (filename == kWanWangProtocolHandlerPlugin) 366 if (filename == kWanWangProtocolHandlerPlugin)
364 return false; 367 return false;
365 368
366 // We only work with newer versions of the Java plugin which use NPAPI only 369 // We only work with newer versions of the Java plugin which use NPAPI only
367 // and don't depend on XPCOM. 370 // and don't depend on XPCOM.
368 if (filename == kJavaPlugin1 || filename == kJavaPlugin2) { 371 if (filename == kJavaPlugin1 || filename == kJavaPlugin2) {
369 std::vector<std::wstring> ver; 372 std::vector<std::wstring> ver;
370 SplitString(info.version, '.', &ver); 373 SplitString(info.version, '.', &ver);
371 int major, minor, update; 374 int major, minor, update;
372 if (ver.size() == 4 && 375 if (ver.size() == 4 &&
373 StringToInt(ver[0], &major) && 376 base::StringToInt(ver[0], &major) &&
374 StringToInt(ver[1], &minor) && 377 base::StringToInt(ver[1], &minor) &&
375 StringToInt(ver[2], &update)) { 378 base::StringToInt(ver[2], &update)) {
376 if (major == 6 && minor == 0 && update < 120) 379 if (major == 6 && minor == 0 && update < 120)
377 return false; // Java SE6 Update 11 or older. 380 return false; // Java SE6 Update 11 or older.
378 } 381 }
379 } 382 }
380 383
381 // Special WMP handling 384 // Special WMP handling
382 385
383 // If both the new and old WMP plugins exist, only load the new one. 386 // If both the new and old WMP plugins exist, only load the new one.
384 if (filename == kNewWMPPlugin) { 387 if (filename == kNewWMPPlugin) {
385 if (dont_load_new_wmp_) 388 if (dont_load_new_wmp_)
386 return false; 389 return false;
387 390
388 for (size_t i = 0; i < plugins->size(); ++i) { 391 for (size_t i = 0; i < plugins->size(); ++i) {
389 if ((*plugins)[i].path.BaseName().value() == kOldWMPPlugin) { 392 if ((*plugins)[i].path.BaseName().value() == kOldWMPPlugin) {
390 plugins->erase(plugins->begin() + i); 393 plugins->erase(plugins->begin() + i);
391 break; 394 break;
392 } 395 }
393 } 396 }
394 } else if (filename == kOldWMPPlugin) { 397 } else if (filename == kOldWMPPlugin) {
395 for (size_t i = 0; i < plugins->size(); ++i) { 398 for (size_t i = 0; i < plugins->size(); ++i) {
396 if ((*plugins)[i].path.BaseName().value() == kNewWMPPlugin) 399 if ((*plugins)[i].path.BaseName().value() == kNewWMPPlugin)
397 return false; 400 return false;
398 } 401 }
399 } 402 }
400 403
401 return true; 404 return true;
402 } 405 }
403 406
404 } // namespace NPAPI 407 } // namespace NPAPI
OLDNEW
« no previous file with comments | « webkit/glue/plugins/plugin_instance.cc ('k') | webkit/glue/plugins/webplugin_delegate_impl_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698