| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/chromeos/login/hwid_checker.h" | 5 #include "chrome/browser/chromeos/login/hwid_checker.h" |
| 6 | 6 |
| 7 #include <cstdio> | 7 #include <cstdio> |
| 8 | 8 |
| 9 #include "base/chromeos/chromeos_version.h" | |
| 10 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 11 #include "base/logging.h" | 10 #include "base/logging.h" |
| 12 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/sys_info.h" |
| 13 #include "chrome/browser/chromeos/system/statistics_provider.h" | 13 #include "chrome/browser/chromeos/system/statistics_provider.h" |
| 14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 15 #include "chromeos/chromeos_switches.h" | 15 #include "chromeos/chromeos_switches.h" |
| 16 #include "third_party/re2/re2/re2.h" | 16 #include "third_party/re2/re2/re2.h" |
| 17 #include "third_party/zlib/zlib.h" | 17 #include "third_party/zlib/zlib.h" |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 unsigned CalculateCRC32(const std::string& data) { | 21 unsigned CalculateCRC32(const std::string& data) { |
| 22 return static_cast<unsigned>(crc32( | 22 return static_cast<unsigned>(crc32( |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 } | 109 } |
| 110 | 110 |
| 111 bool IsMachineHWIDCorrect() { | 111 bool IsMachineHWIDCorrect() { |
| 112 #if !defined(GOOGLE_CHROME_BUILD) | 112 #if !defined(GOOGLE_CHROME_BUILD) |
| 113 return true; | 113 return true; |
| 114 #endif | 114 #endif |
| 115 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 115 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 116 if (cmd_line->HasSwitch(::switches::kTestType) || | 116 if (cmd_line->HasSwitch(::switches::kTestType) || |
| 117 cmd_line->HasSwitch(chromeos::switches::kSkipHWIDCheck)) | 117 cmd_line->HasSwitch(chromeos::switches::kSkipHWIDCheck)) |
| 118 return true; | 118 return true; |
| 119 if (!base::chromeos::IsRunningOnChromeOS()) | 119 if (!base::SysInfo::IsRunningOnChromeOS()) |
| 120 return true; | 120 return true; |
| 121 std::string hwid; | 121 std::string hwid; |
| 122 chromeos::system::StatisticsProvider* stats = | 122 chromeos::system::StatisticsProvider* stats = |
| 123 chromeos::system::StatisticsProvider::GetInstance(); | 123 chromeos::system::StatisticsProvider::GetInstance(); |
| 124 if (!stats->GetMachineStatistic(chromeos::system::kHardwareClass, &hwid)) { | 124 if (!stats->GetMachineStatistic(chromeos::system::kHardwareClass, &hwid)) { |
| 125 LOG(ERROR) << "Couldn't get machine statistic 'hardware_class'."; | 125 LOG(ERROR) << "Couldn't get machine statistic 'hardware_class'."; |
| 126 return false; | 126 return false; |
| 127 } | 127 } |
| 128 if (!chromeos::IsHWIDCorrect(hwid)) { | 128 if (!chromeos::IsHWIDCorrect(hwid)) { |
| 129 LOG(ERROR) << "Machine has malformed HWID '" << hwid << "'."; | 129 LOG(ERROR) << "Machine has malformed HWID '" << hwid << "'."; |
| 130 return false; | 130 return false; |
| 131 } | 131 } |
| 132 return true; | 132 return true; |
| 133 } | 133 } |
| 134 | 134 |
| 135 } // namespace chromeos | 135 } // namespace chromeos |
| 136 | |
| OLD | NEW |