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 #include <map> | 5 #include <map> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 | 47 |
| 48 enum Vehicle { | 48 enum Vehicle { |
| 49 GOOGLE_UPDATE, | 49 GOOGLE_UPDATE, |
| 50 MSI | 50 MSI |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 enum ChannelModifier { | 53 enum ChannelModifier { |
| 54 CM_MULTI = 0x01, | 54 CM_MULTI = 0x01, |
| 55 CM_CHROME = 0x02, | 55 CM_CHROME = 0x02, |
| 56 CM_CHROME_FRAME = 0x04, | 56 CM_CHROME_FRAME = 0x04, |
| 57 CM_READY_MODE = 0x08, | 57 CM_FULL = 0x08 |
|
robertshield
2013/12/11 20:56:49
is it necessary / a good idea to give CM_FULL a ne
grt (UTC plus 2)
2013/12/11 22:13:55
To my knowledge these values aren't persisted. I t
robertshield
2013/12/11 22:19:14
Not a concrete one, just more of a general reactio
| |
| 58 CM_FULL = 0x10 | |
| 59 }; | 58 }; |
| 60 | 59 |
| 61 const wchar_t* const kChromeChannels[] = { | 60 const wchar_t* const kChromeChannels[] = { |
| 62 L"", | 61 L"", |
| 63 L"1.1-beta", | 62 L"1.1-beta", |
| 64 L"2.0-dev" | 63 L"2.0-dev" |
| 65 }; | 64 }; |
| 66 | 65 |
| 67 const wchar_t* const kChromeFrameChannels[] = { | 66 const wchar_t* const kChromeFrameChannels[] = { |
| 68 L"", | 67 L"", |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 return install_level == USER_LEVEL ? user_products_ : system_products_; | 136 return install_level == USER_LEVEL ? user_products_ : system_products_; |
| 138 } | 137 } |
| 139 }; | 138 }; |
| 140 | 139 |
| 141 // static | 140 // static |
| 142 const FakeProductState::ChannelMethodForModifier | 141 const FakeProductState::ChannelMethodForModifier |
| 143 FakeProductState::kChannelMethods[] = { | 142 FakeProductState::kChannelMethods[] = { |
| 144 { CM_MULTI, &ChannelInfo::SetMultiInstall }, | 143 { CM_MULTI, &ChannelInfo::SetMultiInstall }, |
| 145 { CM_CHROME, &ChannelInfo::SetChrome }, | 144 { CM_CHROME, &ChannelInfo::SetChrome }, |
| 146 { CM_CHROME_FRAME, &ChannelInfo::SetChromeFrame }, | 145 { CM_CHROME_FRAME, &ChannelInfo::SetChromeFrame }, |
| 147 { CM_READY_MODE, &ChannelInfo::SetReadyMode }, | |
| 148 { CM_FULL, &ChannelInfo::SetFullSuffix } | 146 { CM_FULL, &ChannelInfo::SetFullSuffix } |
| 149 }; | 147 }; |
| 150 | 148 |
| 151 // static | 149 // static |
| 152 base::FilePath FakeProductState::GetSetupPath( | 150 base::FilePath FakeProductState::GetSetupPath( |
| 153 BrowserDistribution::Type dist_type, | 151 BrowserDistribution::Type dist_type, |
| 154 Level install_level, | 152 Level install_level, |
| 155 int channel_modifiers) { | 153 int channel_modifiers) { |
| 156 const bool is_multi_install = (channel_modifiers & CM_MULTI) != 0; | 154 const bool is_multi_install = (channel_modifiers & CM_MULTI) != 0; |
| 157 return installer::GetChromeInstallPath( | 155 return installer::GetChromeInstallPath( |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 DCHECK(version); | 195 DCHECK(version); |
| 198 | 196 |
| 199 const bool is_multi_install = (channel_modifiers & CM_MULTI) != 0; | 197 const bool is_multi_install = (channel_modifiers & CM_MULTI) != 0; |
| 200 uninstall_command_ = CommandLine(GetSetupExePath(dist_type, install_level, | 198 uninstall_command_ = CommandLine(GetSetupExePath(dist_type, install_level, |
| 201 version, channel_modifiers)); | 199 version, channel_modifiers)); |
| 202 uninstall_command_.AppendSwitch(installer::switches::kUninstall); | 200 uninstall_command_.AppendSwitch(installer::switches::kUninstall); |
| 203 if (install_level == SYSTEM_LEVEL) | 201 if (install_level == SYSTEM_LEVEL) |
| 204 uninstall_command_.AppendSwitch(installer::switches::kSystemLevel); | 202 uninstall_command_.AppendSwitch(installer::switches::kSystemLevel); |
| 205 if (is_multi_install) { | 203 if (is_multi_install) { |
| 206 uninstall_command_.AppendSwitch(installer::switches::kMultiInstall); | 204 uninstall_command_.AppendSwitch(installer::switches::kMultiInstall); |
| 207 if (dist_type == BrowserDistribution::CHROME_BROWSER) { | 205 if (dist_type == BrowserDistribution::CHROME_BROWSER) |
| 208 uninstall_command_.AppendSwitch(installer::switches::kChrome); | 206 uninstall_command_.AppendSwitch(installer::switches::kChrome); |
| 209 if ((channel_modifiers & CM_READY_MODE) != 0) { | 207 else if (dist_type == BrowserDistribution::CHROME_FRAME) |
| 210 uninstall_command_.AppendSwitch(installer::switches::kChromeFrame); | |
| 211 uninstall_command_.AppendSwitch( | |
| 212 installer::switches::kChromeFrameReadyMode); | |
| 213 } | |
| 214 } else if (dist_type == BrowserDistribution::CHROME_FRAME) { | |
| 215 uninstall_command_.AppendSwitch(installer::switches::kChromeFrame); | 208 uninstall_command_.AppendSwitch(installer::switches::kChromeFrame); |
| 216 if ((channel_modifiers & CM_READY_MODE) != 0) { | |
| 217 uninstall_command_.AppendSwitch( | |
| 218 installer::switches::kChromeFrameReadyMode); | |
| 219 } | |
| 220 } | |
| 221 } else if (dist_type == BrowserDistribution::CHROME_FRAME) { | 209 } else if (dist_type == BrowserDistribution::CHROME_FRAME) { |
| 222 uninstall_command_.AppendSwitch(installer::switches::kChromeFrame); | 210 uninstall_command_.AppendSwitch(installer::switches::kChromeFrame); |
| 223 } | 211 } |
| 224 if (vehicle == MSI) | 212 if (vehicle == MSI) |
| 225 uninstall_command_.AppendSwitch(installer::switches::kMsi); | 213 uninstall_command_.AppendSwitch(installer::switches::kMsi); |
| 226 } | 214 } |
| 227 | 215 |
| 228 // Adds the "install-extension" Google Update product command. | 216 // Adds the "install-extension" Google Update product command. |
| 229 void FakeProductState::AddInstallExtensionCommand( | 217 void FakeProductState::AddInstallExtensionCommand( |
| 230 BrowserDistribution::Type dist_type, | 218 BrowserDistribution::Type dist_type, |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 426 ttm[InstallationValidator::NO_PRODUCTS] = 0; | 414 ttm[InstallationValidator::NO_PRODUCTS] = 0; |
| 427 ttm[InstallationValidator::CHROME_SINGLE] = 0; | 415 ttm[InstallationValidator::CHROME_SINGLE] = 0; |
| 428 ttm[InstallationValidator::CHROME_MULTI] = CM_MULTI | CM_CHROME; | 416 ttm[InstallationValidator::CHROME_MULTI] = CM_MULTI | CM_CHROME; |
| 429 ttm[InstallationValidator::CHROME_FRAME_SINGLE] = 0; | 417 ttm[InstallationValidator::CHROME_FRAME_SINGLE] = 0; |
| 430 ttm[InstallationValidator::CHROME_FRAME_SINGLE_CHROME_SINGLE] = 0; | 418 ttm[InstallationValidator::CHROME_FRAME_SINGLE_CHROME_SINGLE] = 0; |
| 431 ttm[InstallationValidator::CHROME_FRAME_SINGLE_CHROME_MULTI] = | 419 ttm[InstallationValidator::CHROME_FRAME_SINGLE_CHROME_MULTI] = |
| 432 CM_MULTI | CM_CHROME; | 420 CM_MULTI | CM_CHROME; |
| 433 ttm[InstallationValidator::CHROME_FRAME_MULTI] = CM_MULTI | CM_CHROME_FRAME; | 421 ttm[InstallationValidator::CHROME_FRAME_MULTI] = CM_MULTI | CM_CHROME_FRAME; |
| 434 ttm[InstallationValidator::CHROME_FRAME_MULTI_CHROME_MULTI] = | 422 ttm[InstallationValidator::CHROME_FRAME_MULTI_CHROME_MULTI] = |
| 435 CM_MULTI | CM_CHROME_FRAME | CM_CHROME; | 423 CM_MULTI | CM_CHROME_FRAME | CM_CHROME; |
| 436 ttm[InstallationValidator::CHROME_FRAME_READY_MODE_CHROME_MULTI] = | |
| 437 CM_MULTI | CM_CHROME_FRAME | CM_CHROME | CM_READY_MODE; | |
| 438 } | 424 } |
| 439 | 425 |
| 440 // static | 426 // static |
| 441 void InstallationValidatorTest::TearDownTestCase() { | 427 void InstallationValidatorTest::TearDownTestCase() { |
| 442 logging::SetLogMessageHandler(old_log_message_handler_); | 428 logging::SetLogMessageHandler(old_log_message_handler_); |
| 443 old_log_message_handler_ = NULL; | 429 old_log_message_handler_ = NULL; |
| 444 | 430 |
| 445 delete type_to_modifiers_; | 431 delete type_to_modifiers_; |
| 446 type_to_modifiers_ = NULL; | 432 type_to_modifiers_ = NULL; |
| 447 } | 433 } |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 477 | 463 |
| 478 // static | 464 // static |
| 479 void InstallationValidatorTest::set_validation_error_recipient( | 465 void InstallationValidatorTest::set_validation_error_recipient( |
| 480 ValidationErrorRecipient* recipient) { | 466 ValidationErrorRecipient* recipient) { |
| 481 validation_error_recipient_ = recipient; | 467 validation_error_recipient_ = recipient; |
| 482 } | 468 } |
| 483 | 469 |
| 484 // static | 470 // static |
| 485 // Populates |state| with the state of a valid installation of product | 471 // Populates |state| with the state of a valid installation of product |
| 486 // |prod_type|. |inst_type| dictates properties of the installation | 472 // |prod_type|. |inst_type| dictates properties of the installation |
| 487 // (multi-install, ready-mode, etc). | 473 // (multi-install, etc). |
| 488 void InstallationValidatorTest::MakeProductState( | 474 void InstallationValidatorTest::MakeProductState( |
| 489 BrowserDistribution::Type prod_type, | 475 BrowserDistribution::Type prod_type, |
| 490 InstallationValidator::InstallationType inst_type, | 476 InstallationValidator::InstallationType inst_type, |
| 491 Level install_level, | 477 Level install_level, |
| 492 Channel channel, | 478 Channel channel, |
| 493 Vehicle vehicle, | 479 Vehicle vehicle, |
| 494 FakeProductState* state) { | 480 FakeProductState* state) { |
| 495 DCHECK(state); | 481 DCHECK(state); |
| 496 | 482 |
| 497 const bool is_multi_install = | 483 const bool is_multi_install = |
| 498 prod_type == BrowserDistribution::CHROME_BINARIES || | 484 prod_type == BrowserDistribution::CHROME_BINARIES || |
| 499 (prod_type == BrowserDistribution::CHROME_BROWSER && | 485 (prod_type == BrowserDistribution::CHROME_BROWSER && |
| 500 (inst_type & InstallationValidator::ProductBits::CHROME_MULTI) != 0) || | 486 (inst_type & InstallationValidator::ProductBits::CHROME_MULTI) != 0) || |
| 501 (prod_type == BrowserDistribution::CHROME_FRAME && | 487 (prod_type == BrowserDistribution::CHROME_FRAME && |
| 502 (inst_type & | 488 (inst_type & |
| 503 (InstallationValidator::ProductBits::CHROME_FRAME_MULTI | | 489 InstallationValidator::ProductBits::CHROME_FRAME_MULTI) != 0); |
| 504 InstallationValidator::ProductBits::CHROME_FRAME_READY_MODE)) != 0); | |
| 505 | 490 |
| 506 const wchar_t* const* channels = &kChromeChannels[0]; | 491 const wchar_t* const* channels = &kChromeChannels[0]; |
| 507 if (prod_type == BrowserDistribution::CHROME_FRAME && !is_multi_install) | 492 if (prod_type == BrowserDistribution::CHROME_FRAME && !is_multi_install) |
| 508 channels = &kChromeFrameChannels[0]; // SxS GCF has its own channel names. | 493 channels = &kChromeFrameChannels[0]; // SxS GCF has its own channel names. |
| 509 const int channel_modifiers = | 494 const int channel_modifiers = |
| 510 is_multi_install ? GetChannelModifiers(inst_type) : 0; | 495 is_multi_install ? GetChannelModifiers(inst_type) : 0; |
| 511 | 496 |
| 512 state->Clear(); | 497 state->Clear(); |
| 513 state->SetChannel(channels[channel], channel_modifiers); | 498 state->SetChannel(channels[channel], channel_modifiers); |
| 514 state->SetVersion(chrome::kChromeVersion); | 499 state->SetVersion(chrome::kChromeVersion); |
| 515 state->SetUninstallCommand(prod_type, install_level, chrome::kChromeVersion, | 500 state->SetUninstallCommand(prod_type, install_level, chrome::kChromeVersion, |
| 516 channel_modifiers, vehicle); | 501 channel_modifiers, vehicle); |
| 517 state->set_multi_install(is_multi_install); | 502 state->set_multi_install(is_multi_install); |
| 518 if (prod_type == BrowserDistribution::CHROME_BINARIES) { | 503 if (prod_type == BrowserDistribution::CHROME_BINARIES) { |
| 519 if (inst_type == InstallationValidator::CHROME_MULTI || | 504 if (inst_type == InstallationValidator::CHROME_MULTI) { |
| 520 inst_type == | |
| 521 InstallationValidator::CHROME_FRAME_READY_MODE_CHROME_MULTI) { | |
| 522 state->AddQuickEnableCfCommand(prod_type, install_level, | 505 state->AddQuickEnableCfCommand(prod_type, install_level, |
| 523 chrome::kChromeVersion, channel_modifiers); | 506 chrome::kChromeVersion, channel_modifiers); |
| 524 } | 507 } |
| 525 state->AddQueryEULAAcceptanceCommand(prod_type, | 508 state->AddQueryEULAAcceptanceCommand(prod_type, |
| 526 install_level, | 509 install_level, |
| 527 chrome::kChromeVersion, | 510 chrome::kChromeVersion, |
| 528 channel_modifiers); | 511 channel_modifiers); |
| 529 } | 512 } |
| 530 if (prod_type == BrowserDistribution::CHROME_BINARIES) { | 513 if (prod_type == BrowserDistribution::CHROME_BINARIES) { |
| 531 state->AddQuickEnableApplicationHostCommand(prod_type, | 514 state->AddQuickEnableApplicationHostCommand(prod_type, |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 553 Channel channel, | 536 Channel channel, |
| 554 Vehicle vehicle, | 537 Vehicle vehicle, |
| 555 FakeInstallationState* state) { | 538 FakeInstallationState* state) { |
| 556 DCHECK(state); | 539 DCHECK(state); |
| 557 | 540 |
| 558 static const int kChromeMask = | 541 static const int kChromeMask = |
| 559 (InstallationValidator::ProductBits::CHROME_SINGLE | | 542 (InstallationValidator::ProductBits::CHROME_SINGLE | |
| 560 InstallationValidator::ProductBits::CHROME_MULTI); | 543 InstallationValidator::ProductBits::CHROME_MULTI); |
| 561 static const int kChromeFrameMask = | 544 static const int kChromeFrameMask = |
| 562 (InstallationValidator::ProductBits::CHROME_FRAME_SINGLE | | 545 (InstallationValidator::ProductBits::CHROME_FRAME_SINGLE | |
| 563 InstallationValidator::ProductBits::CHROME_FRAME_MULTI | | 546 InstallationValidator::ProductBits::CHROME_FRAME_MULTI); |
| 564 InstallationValidator::ProductBits::CHROME_FRAME_READY_MODE); | |
| 565 static const int kBinariesMask = | 547 static const int kBinariesMask = |
| 566 (InstallationValidator::ProductBits::CHROME_MULTI | | 548 (InstallationValidator::ProductBits::CHROME_MULTI | |
| 567 InstallationValidator::ProductBits::CHROME_FRAME_MULTI | | 549 InstallationValidator::ProductBits::CHROME_FRAME_MULTI); |
| 568 InstallationValidator::ProductBits::CHROME_FRAME_READY_MODE); | |
| 569 | 550 |
| 570 FakeProductState prod_state; | 551 FakeProductState prod_state; |
| 571 | 552 |
| 572 if ((inst_type & kChromeMask) != 0) { | 553 if ((inst_type & kChromeMask) != 0) { |
| 573 MakeProductState(BrowserDistribution::CHROME_BROWSER, inst_type, | 554 MakeProductState(BrowserDistribution::CHROME_BROWSER, inst_type, |
| 574 install_level, channel, vehicle, &prod_state); | 555 install_level, channel, vehicle, &prod_state); |
| 575 state->SetProductState(BrowserDistribution::CHROME_BROWSER, install_level, | 556 state->SetProductState(BrowserDistribution::CHROME_BROWSER, install_level, |
| 576 prod_state); | 557 prod_state); |
| 577 } | 558 } |
| 578 | 559 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 615 INSTANTIATE_TEST_CASE_P( | 596 INSTANTIATE_TEST_CASE_P( |
| 616 AllValidInstallations, | 597 AllValidInstallations, |
| 617 InstallationValidatorTest, | 598 InstallationValidatorTest, |
| 618 Values(InstallationValidator::NO_PRODUCTS, | 599 Values(InstallationValidator::NO_PRODUCTS, |
| 619 InstallationValidator::CHROME_SINGLE, | 600 InstallationValidator::CHROME_SINGLE, |
| 620 InstallationValidator::CHROME_MULTI, | 601 InstallationValidator::CHROME_MULTI, |
| 621 InstallationValidator::CHROME_FRAME_SINGLE, | 602 InstallationValidator::CHROME_FRAME_SINGLE, |
| 622 InstallationValidator::CHROME_FRAME_SINGLE_CHROME_SINGLE, | 603 InstallationValidator::CHROME_FRAME_SINGLE_CHROME_SINGLE, |
| 623 InstallationValidator::CHROME_FRAME_SINGLE_CHROME_MULTI, | 604 InstallationValidator::CHROME_FRAME_SINGLE_CHROME_MULTI, |
| 624 InstallationValidator::CHROME_FRAME_MULTI, | 605 InstallationValidator::CHROME_FRAME_MULTI, |
| 625 InstallationValidator::CHROME_FRAME_MULTI_CHROME_MULTI, | 606 InstallationValidator::CHROME_FRAME_MULTI_CHROME_MULTI)); |
| 626 InstallationValidator::CHROME_FRAME_READY_MODE_CHROME_MULTI)); | |
| OLD | NEW |