Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 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" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 22 | 22 |
| 23 #include "base/basictypes.h" | 23 #include "base/basictypes.h" |
| 24 #include "base/file_path.h" | 24 #include "base/file_path.h" |
| 25 #include "base/file_util.h" | 25 #include "base/file_util.h" |
| 26 #include "base/string_number_conversions.h" | 26 #include "base/string_number_conversions.h" |
| 27 #include "base/time.h" | 27 #include "base/time.h" |
| 28 #include "base/win/registry.h" | 28 #include "base/win/registry.h" |
| 29 #include "base/win/scoped_com_initializer.h" | 29 #include "base/win/scoped_com_initializer.h" |
| 30 #include "base/win/scoped_comptr.h" | 30 #include "base/win/scoped_comptr.h" |
| 31 #include "base/win/scoped_handle.h" | 31 #include "base/win/scoped_handle.h" |
| 32 #include "chrome/installer/gcapi/gcapi_reactivation.h" | |
| 32 #include "chrome/installer/util/google_update_constants.h" | 33 #include "chrome/installer/util/google_update_constants.h" |
| 33 #include "chrome/installer/util/util_constants.h" | 34 #include "chrome/installer/util/util_constants.h" |
| 34 | 35 |
| 35 #include "google_update_idl.h" // NOLINT | 36 #include "google_update_idl.h" // NOLINT |
| 36 | 37 |
| 37 using base::Time; | 38 using base::Time; |
| 38 using base::TimeDelta; | 39 using base::TimeDelta; |
| 39 using base::win::RegKey; | 40 using base::win::RegKey; |
| 40 using base::win::ScopedCOMInitializer; | 41 using base::win::ScopedCOMInitializer; |
| 41 using base::win::ScopedComPtr; | 42 using base::win::ScopedComPtr; |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 539 } | 540 } |
| 540 } | 541 } |
| 541 } | 542 } |
| 542 | 543 |
| 543 if (days_since_last_run == std::numeric_limits<int>::max()) { | 544 if (days_since_last_run == std::numeric_limits<int>::max()) { |
| 544 days_since_last_run = -1; | 545 days_since_last_run = -1; |
| 545 } | 546 } |
| 546 | 547 |
| 547 return days_since_last_run; | 548 return days_since_last_run; |
| 548 } | 549 } |
| 550 | |
| 551 BOOL __stdcall CanOfferReactivation(const wchar_t* brand_code, | |
| 552 int previous_brand_codes_length, | |
| 553 const wchar_t** previous_brand_codes, | |
| 554 DWORD* error_code) { | |
| 555 DCHECK(error_code); | |
| 556 | |
| 557 if (!brand_code || | |
| 558 (previous_brand_codes_length > 0 && previous_brand_codes == NULL)) { | |
| 559 if (error_code) | |
| 560 *error_code = REACTIVATE_ERROR_INVALID_INPUT; | |
| 561 return FALSE; | |
| 562 } | |
| 563 | |
| 564 bool has_system_install = IsChromeInstalled(HKEY_LOCAL_MACHINE); | |
| 565 bool has_user_install = IsChromeInstalled(HKEY_CURRENT_USER); | |
| 566 | |
| 567 if (!has_system_install && !has_user_install) { | |
| 568 if (error_code) | |
| 569 *error_code = REACTIVATE_ERROR_NOTINSTALLED; | |
| 570 return FALSE; | |
| 571 } | |
| 572 | |
| 573 int days_since_last_run = GoogleChromeDaysSinceLastRun(); | |
| 574 if (days_since_last_run > 0 && | |
| 575 days_since_last_run < kReactivationMinDaysDormant) { | |
| 576 if (error_code) | |
| 577 *error_code = REACTIVATE_ERROR_NOTDORMANT; | |
| 578 return FALSE; | |
| 579 } | |
| 580 | |
| 581 // Make sure we haven't previously been reactivated by this brand code | |
| 582 // or any of the previous brand codes from this partner. | |
| 583 std::vector<std::wstring> reactivation_brands; | |
| 584 reactivation_brands.push_back(brand_code); | |
| 585 if (previous_brand_codes_length > 0 && previous_brand_codes != NULL) { | |
| 586 std::copy(previous_brand_codes, | |
| 587 previous_brand_codes + previous_brand_codes_length, | |
| 588 std::back_inserter(reactivation_brands)); | |
| 589 } | |
| 590 if (HasBeenReactivatedByBrandCodes(reactivation_brands)) { | |
| 591 if (error_code) | |
| 592 *error_code = REACTIVATE_ERROR_ALREADY_REACTIVATED; | |
| 593 return FALSE; | |
| 594 } | |
| 595 | |
| 596 return TRUE; | |
| 597 } | |
| 598 | |
| 599 BOOL __stdcall ReactivateChrome(wchar_t* brand_code, | |
| 600 int previous_brand_codes_length, | |
| 601 const wchar_t** previous_brand_codes, | |
| 602 DWORD* error_code) { | |
| 603 BOOL result = FALSE; | |
| 604 if (CanOfferReactivation(brand_code, | |
| 605 previous_brand_codes_length, | |
| 606 previous_brand_codes, | |
| 607 error_code)) { | |
| 608 if (SetReactivationBrandCode(brand_code)) { | |
| 609 // Set Omaha reg key to add experiment label for tracking 7DA. | |
| 610 // SetOmahaExptLabel (ReacBrandCode, weekNumber); | |
|
Roger Tawa OOO till Jul 10th
2012/01/29 16:32:42
should this have been commented out?
robertshield
2012/01/30 02:40:39
Yes, actually I meant to make that a TODO and do i
| |
| 611 result = TRUE; | |
| 612 } else { | |
| 613 if (error_code) | |
| 614 *error_code = REACTIVATE_ERROR_REACTIVATION_FAILED; | |
| 615 } | |
| 616 } | |
| 617 | |
| 618 return result; | |
| 619 } | |
| 620 | |
| OLD | NEW |