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 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 562 DWORD* error_code) { | 562 DWORD* error_code) { |
| 563 DCHECK(error_code); | 563 DCHECK(error_code); |
| 564 | 564 |
| 565 if (!brand_code || | 565 if (!brand_code || |
| 566 (previous_brand_codes_length > 0 && previous_brand_codes == NULL)) { | 566 (previous_brand_codes_length > 0 && previous_brand_codes == NULL)) { |
| 567 if (error_code) | 567 if (error_code) |
| 568 *error_code = REACTIVATE_ERROR_INVALID_INPUT; | 568 *error_code = REACTIVATE_ERROR_INVALID_INPUT; |
| 569 return FALSE; | 569 return FALSE; |
| 570 } | 570 } |
| 571 | 571 |
| 572 bool has_system_install = IsChromeInstalled(HKEY_LOCAL_MACHINE); | |
| 573 bool has_user_install = IsChromeInstalled(HKEY_CURRENT_USER); | |
| 574 | |
| 575 if (!has_system_install && !has_user_install) { | |
| 576 if (error_code) | |
| 577 *error_code = REACTIVATE_ERROR_NOTINSTALLED; | |
| 578 return FALSE; | |
| 579 } | |
| 580 | |
| 581 int days_since_last_run = GoogleChromeDaysSinceLastRun(); | 572 int days_since_last_run = GoogleChromeDaysSinceLastRun(); |
| 582 if (days_since_last_run >= 0 && | 573 if (days_since_last_run >= 0 && |
| 583 days_since_last_run < kReactivationMinDaysDormant) { | 574 days_since_last_run < kReactivationMinDaysDormant) { |
| 584 if (error_code) | 575 if (error_code) |
| 585 *error_code = REACTIVATE_ERROR_NOTDORMANT; | 576 *error_code = REACTIVATE_ERROR_NOTDORMANT; |
| 586 return FALSE; | 577 return FALSE; |
| 587 } | 578 } |
| 588 | 579 |
| 589 // Make sure we haven't previously been reactivated by this brand code | 580 // Only run the code below when this function is invoked from a standard, |
| 590 // or any of the previous brand codes from this partner. | 581 // non-elevated cmd shell. This is because this section of code looks at |
| 591 // Since this function is invoked by ReactivateChrome, and since | 582 // values in HKEY_CURRENT_USER, and we only want to look at the logged-in |
| 592 // ReactivateChrome is called first in non-elevated shell and | 583 // user's HKCU, not the admin user's HKCU. |
| 593 // second in UAC-elevated shell, we only want to execute this block | |
| 594 // of code the first time, in non-elevated mode. | |
| 595 if (shell_mode == GCAPI_INVOKED_STANDARD_SHELL) { | 584 if (shell_mode == GCAPI_INVOKED_STANDARD_SHELL) { |
| 585 bool has_system_install = IsChromeInstalled(HKEY_LOCAL_MACHINE); | |
| 586 bool has_user_install = IsChromeInstalled(HKEY_CURRENT_USER); | |
|
robertshield
2012/03/23 17:52:16
for brevity, consider deleting these temp variable
mgraboski
2012/03/23 21:40:35
Done.
| |
| 587 | |
| 588 if (!has_system_install && !has_user_install) { | |
| 589 if (error_code) | |
| 590 *error_code = REACTIVATE_ERROR_NOTINSTALLED; | |
| 591 return FALSE; | |
| 592 } | |
| 593 | |
| 596 std::vector<std::wstring> reactivation_brands; | 594 std::vector<std::wstring> reactivation_brands; |
| 597 reactivation_brands.push_back(brand_code); | 595 reactivation_brands.push_back(brand_code); |
| 598 if (previous_brand_codes_length > 0 && previous_brand_codes != NULL) { | 596 if (previous_brand_codes_length > 0 && previous_brand_codes != NULL) { |
| 599 std::copy(previous_brand_codes, | 597 std::copy(previous_brand_codes, |
| 600 previous_brand_codes + previous_brand_codes_length, | 598 previous_brand_codes + previous_brand_codes_length, |
| 601 std::back_inserter(reactivation_brands)); | 599 std::back_inserter(reactivation_brands)); |
| 602 } | 600 } |
|
robertshield
2012/03/23 17:52:16
you can delete the above 7 lines if reactivation_b
mgraboski
2012/03/23 21:40:35
Done.
| |
| 603 if (HasBeenReactivatedByBrandCodes(reactivation_brands)) { | 601 if (HasBeenReactivated()) { |
| 604 if (error_code) | 602 if (error_code) |
| 605 *error_code = REACTIVATE_ERROR_ALREADY_REACTIVATED; | 603 *error_code = REACTIVATE_ERROR_ALREADY_REACTIVATED; |
| 606 return FALSE; | 604 return FALSE; |
| 607 } | 605 } |
| 608 } | 606 } |
| 609 | 607 |
| 610 return TRUE; | 608 return TRUE; |
| 611 } | 609 } |
| 612 | 610 |
| 613 BOOL __stdcall ReactivateChrome(wchar_t* brand_code, | 611 BOOL __stdcall ReactivateChrome(wchar_t* brand_code, |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 629 result = TRUE; | 627 result = TRUE; |
| 630 } else { | 628 } else { |
| 631 if (error_code) | 629 if (error_code) |
| 632 *error_code = REACTIVATE_ERROR_REACTIVATION_FAILED; | 630 *error_code = REACTIVATE_ERROR_REACTIVATION_FAILED; |
| 633 } | 631 } |
| 634 } | 632 } |
| 635 | 633 |
| 636 return result; | 634 return result; |
| 637 } | 635 } |
| 638 | 636 |
| OLD | NEW |