Chromium Code Reviews| 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 // NOTE: This code is a legacy utility API for partners to check whether | 5 // NOTE: This code is a legacy utility API for partners to check whether |
| 6 // Chrome can be installed and launched. Recent updates are being made | 6 // Chrome can be installed and launched. Recent updates are being made |
| 7 // to add new functionality. These updates use code from Chromium, the old | 7 // to add new functionality. These updates use code from Chromium, the old |
| 8 // coded against the win32 api directly. If you have an itch to shave a | 8 // coded against the win32 api directly. If you have an itch to shave a |
| 9 // yak, feel free to re-write the old code too. | 9 // yak, feel free to re-write the old code too. |
| 10 | 10 |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 595 | 595 |
| 596 int __stdcall GoogleChromeDaysSinceLastRun() { | 596 int __stdcall GoogleChromeDaysSinceLastRun() { |
| 597 int days_since_last_run = std::numeric_limits<int>::max(); | 597 int days_since_last_run = std::numeric_limits<int>::max(); |
| 598 | 598 |
| 599 if (IsChromeInstalled(HKEY_LOCAL_MACHINE) || | 599 if (IsChromeInstalled(HKEY_LOCAL_MACHINE) || |
| 600 IsChromeInstalled(HKEY_CURRENT_USER)) { | 600 IsChromeInstalled(HKEY_CURRENT_USER)) { |
| 601 RegKey client_state(HKEY_CURRENT_USER, | 601 RegKey client_state(HKEY_CURRENT_USER, |
| 602 kChromeRegClientStateKey, | 602 kChromeRegClientStateKey, |
| 603 KEY_QUERY_VALUE | KEY_WOW64_32KEY); | 603 KEY_QUERY_VALUE | KEY_WOW64_32KEY); |
| 604 if (client_state.Valid()) { | 604 if (client_state.Valid()) { |
| 605 std::wstring last_run; | 605 base::string16 last_run; |
| 606 int64 last_run_value = 0; | 606 int64 last_run_value = 0; |
| 607 if (client_state.ReadValue(google_update::kRegLastRunTimeField, | 607 if (client_state.ReadValue(google_update::kRegLastRunTimeField, |
| 608 &last_run) == ERROR_SUCCESS && | 608 &last_run) == ERROR_SUCCESS && |
|
huangs
2014/07/07 19:29:24
ReadValue() takes wstring, but I found other place
| |
| 609 base::StringToInt64(last_run, &last_run_value)) { | 609 base::StringToInt64(last_run, &last_run_value)) { |
| 610 Time last_run_time = Time::FromInternalValue(last_run_value); | 610 Time last_run_time = Time::FromInternalValue(last_run_value); |
| 611 TimeDelta difference = Time::NowFromSystemTime() - last_run_time; | 611 TimeDelta difference = Time::NowFromSystemTime() - last_run_time; |
| 612 | 612 |
| 613 // We can end up with negative numbers here, given changes in system | 613 // We can end up with negative numbers here, given changes in system |
| 614 // clock time or due to TimeDelta's int64 -> int truncation. | 614 // clock time or due to TimeDelta's int64 -> int truncation. |
| 615 int new_days_since_last_run = difference.InDays(); | 615 int new_days_since_last_run = difference.InDays(); |
| 616 if (new_days_since_last_run >= 0 && | 616 if (new_days_since_last_run >= 0 && |
| 617 new_days_since_last_run < days_since_last_run) { | 617 new_days_since_last_run < days_since_last_run) { |
| 618 days_since_last_run = new_days_since_last_run; | 618 days_since_last_run = new_days_since_last_run; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 708 if (!IsChromeInstalled(HKEY_LOCAL_MACHINE) && | 708 if (!IsChromeInstalled(HKEY_LOCAL_MACHINE) && |
| 709 (shell_mode != GCAPI_INVOKED_STANDARD_SHELL || | 709 (shell_mode != GCAPI_INVOKED_STANDARD_SHELL || |
| 710 !IsChromeInstalled(HKEY_CURRENT_USER))) { | 710 !IsChromeInstalled(HKEY_CURRENT_USER))) { |
| 711 if (error_code) | 711 if (error_code) |
| 712 *error_code = RELAUNCH_ERROR_NOTINSTALLED; | 712 *error_code = RELAUNCH_ERROR_NOTINSTALLED; |
| 713 return FALSE; | 713 return FALSE; |
| 714 } | 714 } |
| 715 | 715 |
| 716 // b) the installed brandcode should belong to that partner (in | 716 // b) the installed brandcode should belong to that partner (in |
| 717 // brandcode_list); | 717 // brandcode_list); |
| 718 std::wstring installed_brandcode; | 718 base::string16 installed_brandcode; |
| 719 bool valid_brandcode = false; | 719 bool valid_brandcode = false; |
| 720 if (GoogleUpdateSettings::GetBrand(&installed_brandcode)) { | 720 if (GoogleUpdateSettings::GetBrand(&installed_brandcode)) { |
| 721 for (int i = 0; i < partner_brandcode_list_length; ++i) { | 721 for (int i = 0; i < partner_brandcode_list_length; ++i) { |
| 722 if (!_wcsicmp(installed_brandcode.c_str(), partner_brandcode_list[i])) { | 722 if (!_wcsicmp(installed_brandcode.c_str(), partner_brandcode_list[i])) { |
|
huangs
2014/07/07 19:29:24
Found other instances in code where _wcsicmp() is
| |
| 723 valid_brandcode = true; | 723 valid_brandcode = true; |
| 724 break; | 724 break; |
| 725 } | 725 } |
| 726 } | 726 } |
| 727 } | 727 } |
| 728 | 728 |
| 729 if (!valid_brandcode) { | 729 if (!valid_brandcode) { |
| 730 if (error_code) | 730 if (error_code) |
| 731 *error_code = RELAUNCH_ERROR_INVALID_PARTNER; | 731 *error_code = RELAUNCH_ERROR_INVALID_PARTNER; |
| 732 return FALSE; | 732 return FALSE; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 786 key.WriteValue(kRelaunchAllowedAfterValue, | 786 key.WriteValue(kRelaunchAllowedAfterValue, |
| 787 FormatDateOffsetByMonths(6)) != ERROR_SUCCESS || | 787 FormatDateOffsetByMonths(6)) != ERROR_SUCCESS || |
| 788 !SetRelaunchExperimentLabels(relaunch_brandcode, shell_mode)) { | 788 !SetRelaunchExperimentLabels(relaunch_brandcode, shell_mode)) { |
| 789 if (error_code) | 789 if (error_code) |
| 790 *error_code = RELAUNCH_ERROR_RELAUNCH_FAILED; | 790 *error_code = RELAUNCH_ERROR_RELAUNCH_FAILED; |
| 791 return FALSE; | 791 return FALSE; |
| 792 } | 792 } |
| 793 | 793 |
| 794 return TRUE; | 794 return TRUE; |
| 795 } | 795 } |
| OLD | NEW |