| 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_frame/test/chrome_frame_test_utils.h" | 5 #include "chrome_frame/test/chrome_frame_test_utils.h" |
| 6 | 6 |
| 7 #include <atlapp.h> | 7 #include <atlapp.h> |
| 8 #include <atlmisc.h> | 8 #include <atlmisc.h> |
| 9 #include <iepmapi.h> | 9 #include <iepmapi.h> |
| 10 #include <sddl.h> | 10 #include <sddl.h> |
| 11 #include <shlobj.h> | 11 #include <shlobj.h> |
| 12 #include <winsock2.h> | 12 #include <winsock2.h> |
| 13 | 13 |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/file_path.h" | 15 #include "base/file_path.h" |
| 16 #include "base/file_util.h" | 16 #include "base/file_util.h" |
| 17 #include "base/file_version_info.h" | 17 #include "base/file_version_info.h" |
| 18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
| 19 #include "base/path_service.h" | 19 #include "base/path_service.h" |
| 20 #include "base/process.h" | 20 #include "base/process.h" |
| 21 #include "base/process_util.h" | 21 #include "base/process_util.h" |
| 22 #include "base/string_number_conversions.h" |
| 23 #include "base/string_piece.h" |
| 22 #include "base/string_util.h" | 24 #include "base/string_util.h" |
| 23 #include "base/stringprintf.h" | 25 #include "base/stringprintf.h" |
| 24 #include "base/utf_string_conversions.h" | 26 #include "base/utf_string_conversions.h" |
| 25 #include "base/win/registry.h" | 27 #include "base/win/registry.h" |
| 26 #include "base/win/scoped_handle.h" | 28 #include "base/win/scoped_handle.h" |
| 27 #include "base/win/windows_version.h" | 29 #include "base/win/windows_version.h" |
| 28 #include "chrome/common/chrome_paths.h" | 30 #include "chrome/common/chrome_paths.h" |
| 29 #include "chrome/common/chrome_paths_internal.h" | 31 #include "chrome/common/chrome_paths_internal.h" |
| 30 #include "chrome/common/chrome_switches.h" | 32 #include "chrome/common/chrome_switches.h" |
| 31 #include "chrome_frame/utils.h" | 33 #include "chrome_frame/utils.h" |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 return hr; | 415 return hr; |
| 414 } | 416 } |
| 415 | 417 |
| 416 std::wstring GetExeVersion(const std::wstring& exe_path) { | 418 std::wstring GetExeVersion(const std::wstring& exe_path) { |
| 417 scoped_ptr<FileVersionInfo> ie_version_info( | 419 scoped_ptr<FileVersionInfo> ie_version_info( |
| 418 FileVersionInfo::CreateFileVersionInfo(FilePath(exe_path))); | 420 FileVersionInfo::CreateFileVersionInfo(FilePath(exe_path))); |
| 419 return ie_version_info->product_version(); | 421 return ie_version_info->product_version(); |
| 420 } | 422 } |
| 421 | 423 |
| 422 IEVersion GetInstalledIEVersion() { | 424 IEVersion GetInstalledIEVersion() { |
| 423 std::wstring path = chrome_frame_test::GetExecutableAppPath(kIEImageName); | 425 std::wstring path(chrome_frame_test::GetExecutableAppPath(kIEImageName)); |
| 424 std::wstring version = GetExeVersion(path); | 426 std::wstring version(GetExeVersion(path)); |
| 427 size_t first_dot = version.find(L'.'); |
| 428 int major_version = 0; |
| 429 if (!base::StringToInt(base::StringPiece16( |
| 430 version.data(), |
| 431 first_dot == std::wstring::npos ? version.size() : first_dot), |
| 432 &major_version)) { |
| 433 return IE_UNSUPPORTED; |
| 434 } |
| 425 | 435 |
| 426 switch (version[0]) { | 436 switch (major_version) { |
| 427 case '6': | 437 case 6: |
| 428 return IE_6; | 438 return IE_6; |
| 429 case '7': | 439 case 7: |
| 430 return IE_7; | 440 return IE_7; |
| 431 case '8': | 441 case 8: |
| 432 return IE_8; | 442 return IE_8; |
| 433 case '9': | 443 case 9: |
| 434 return IE_9; | 444 return IE_9; |
| 435 case '10': | 445 case 10: |
| 436 return IE_10; | 446 return IE_10; |
| 437 default: | 447 default: |
| 438 break; | 448 break; |
| 439 } | 449 } |
| 440 | 450 |
| 441 return IE_UNSUPPORTED; | 451 return IE_UNSUPPORTED; |
| 442 } | 452 } |
| 443 | 453 |
| 444 FilePath GetProfilePathForIE() { | 454 FilePath GetProfilePathForIE() { |
| 445 FilePath profile_path; | 455 FilePath profile_path; |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 if (address.empty()) { | 708 if (address.empty()) { |
| 699 LOG(ERROR) << "Failed to find a non-loopback IP_V4 address. Tests will be " | 709 LOG(ERROR) << "Failed to find a non-loopback IP_V4 address. Tests will be " |
| 700 << "run over the loopback adapter, which may result in hangs."; | 710 << "run over the loopback adapter, which may result in hangs."; |
| 701 address.assign("127.0.0.1"); | 711 address.assign("127.0.0.1"); |
| 702 } | 712 } |
| 703 | 713 |
| 704 return address; | 714 return address; |
| 705 } | 715 } |
| 706 | 716 |
| 707 } // namespace chrome_frame_test | 717 } // namespace chrome_frame_test |
| OLD | NEW |