| 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 |
| 11 #include "chrome/installer/gcapi/gcapi.h" | 11 #include "chrome/installer/gcapi/gcapi.h" |
| 12 | 12 |
| 13 #include <sddl.h> | 13 #include <sddl.h> |
| 14 #include <stddef.h> |
| 15 #include <stdint.h> |
| 16 #include <string.h> |
| 14 #define STRSAFE_NO_DEPRECATE | 17 #define STRSAFE_NO_DEPRECATE |
| 15 #include <windows.h> | 18 #include <windows.h> |
| 16 #include <strsafe.h> | 19 #include <strsafe.h> |
| 17 #include <tlhelp32.h> | 20 #include <tlhelp32.h> |
| 18 | 21 |
| 19 #include <cstdlib> | 22 #include <cstdlib> |
| 20 #include <iterator> | 23 #include <iterator> |
| 21 #include <limits> | 24 #include <limits> |
| 22 #include <set> | 25 #include <set> |
| 23 #include <string> | 26 #include <string> |
| 24 | 27 |
| 25 #include "base/basictypes.h" | |
| 26 #include "base/command_line.h" | 28 #include "base/command_line.h" |
| 27 #include "base/files/file_path.h" | 29 #include "base/files/file_path.h" |
| 30 #include "base/macros.h" |
| 28 #include "base/process/launch.h" | 31 #include "base/process/launch.h" |
| 29 #include "base/strings/string16.h" | 32 #include "base/strings/string16.h" |
| 30 #include "base/strings/string_number_conversions.h" | 33 #include "base/strings/string_number_conversions.h" |
| 31 #include "base/strings/string_util.h" | 34 #include "base/strings/string_util.h" |
| 32 #include "base/time/time.h" | 35 #include "base/time/time.h" |
| 33 #include "base/win/registry.h" | 36 #include "base/win/registry.h" |
| 34 #include "base/win/scoped_com_initializer.h" | 37 #include "base/win/scoped_com_initializer.h" |
| 35 #include "base/win/scoped_comptr.h" | 38 #include "base/win/scoped_comptr.h" |
| 36 #include "base/win/scoped_handle.h" | 39 #include "base/win/scoped_handle.h" |
| 37 #include "chrome/installer/gcapi/gcapi_omaha_experiment.h" | 40 #include "chrome/installer/gcapi/gcapi_omaha_experiment.h" |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 int __stdcall GoogleChromeDaysSinceLastRun() { | 599 int __stdcall GoogleChromeDaysSinceLastRun() { |
| 597 int days_since_last_run = std::numeric_limits<int>::max(); | 600 int days_since_last_run = std::numeric_limits<int>::max(); |
| 598 | 601 |
| 599 if (IsChromeInstalled(HKEY_LOCAL_MACHINE) || | 602 if (IsChromeInstalled(HKEY_LOCAL_MACHINE) || |
| 600 IsChromeInstalled(HKEY_CURRENT_USER)) { | 603 IsChromeInstalled(HKEY_CURRENT_USER)) { |
| 601 RegKey client_state(HKEY_CURRENT_USER, | 604 RegKey client_state(HKEY_CURRENT_USER, |
| 602 kChromeRegClientStateKey, | 605 kChromeRegClientStateKey, |
| 603 KEY_QUERY_VALUE | KEY_WOW64_32KEY); | 606 KEY_QUERY_VALUE | KEY_WOW64_32KEY); |
| 604 if (client_state.Valid()) { | 607 if (client_state.Valid()) { |
| 605 base::string16 last_run; | 608 base::string16 last_run; |
| 606 int64 last_run_value = 0; | 609 int64_t last_run_value = 0; |
| 607 if (client_state.ReadValue(google_update::kRegLastRunTimeField, | 610 if (client_state.ReadValue(google_update::kRegLastRunTimeField, |
| 608 &last_run) == ERROR_SUCCESS && | 611 &last_run) == ERROR_SUCCESS && |
| 609 base::StringToInt64(last_run, &last_run_value)) { | 612 base::StringToInt64(last_run, &last_run_value)) { |
| 610 Time last_run_time = Time::FromInternalValue(last_run_value); | 613 Time last_run_time = Time::FromInternalValue(last_run_value); |
| 611 TimeDelta difference = Time::NowFromSystemTime() - last_run_time; | 614 TimeDelta difference = Time::NowFromSystemTime() - last_run_time; |
| 612 | 615 |
| 613 // We can end up with negative numbers here, given changes in system | 616 // We can end up with negative numbers here, given changes in system |
| 614 // clock time or due to TimeDelta's int64 -> int truncation. | 617 // clock time or due to TimeDelta's int64_t -> int truncation. |
| 615 int new_days_since_last_run = difference.InDays(); | 618 int new_days_since_last_run = difference.InDays(); |
| 616 if (new_days_since_last_run >= 0 && | 619 if (new_days_since_last_run >= 0 && |
| 617 new_days_since_last_run < days_since_last_run) { | 620 new_days_since_last_run < days_since_last_run) { |
| 618 days_since_last_run = new_days_since_last_run; | 621 days_since_last_run = new_days_since_last_run; |
| 619 } | 622 } |
| 620 } | 623 } |
| 621 } | 624 } |
| 622 } | 625 } |
| 623 | 626 |
| 624 if (days_since_last_run == std::numeric_limits<int>::max()) { | 627 if (days_since_last_run == std::numeric_limits<int>::max()) { |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 key.WriteValue(kRelaunchAllowedAfterValue, | 789 key.WriteValue(kRelaunchAllowedAfterValue, |
| 787 FormatDateOffsetByMonths(6)) != ERROR_SUCCESS || | 790 FormatDateOffsetByMonths(6)) != ERROR_SUCCESS || |
| 788 !SetRelaunchExperimentLabels(relaunch_brandcode, shell_mode)) { | 791 !SetRelaunchExperimentLabels(relaunch_brandcode, shell_mode)) { |
| 789 if (error_code) | 792 if (error_code) |
| 790 *error_code = RELAUNCH_ERROR_RELAUNCH_FAILED; | 793 *error_code = RELAUNCH_ERROR_RELAUNCH_FAILED; |
| 791 return FALSE; | 794 return FALSE; |
| 792 } | 795 } |
| 793 | 796 |
| 794 return TRUE; | 797 return TRUE; |
| 795 } | 798 } |
| OLD | NEW |