OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/installer/util/product_command.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "base/win/registry.h" |
| 9 #include "chrome/installer/util/google_update_constants.h" |
| 10 #include "chrome/installer/util/work_item_list.h" |
| 11 |
| 12 namespace installer { |
| 13 |
| 14 ProductCommand::ProductCommand() |
| 15 : sends_pings_(false), |
| 16 is_web_accessible_(false) { |
| 17 } |
| 18 |
| 19 ProductCommand::ProductCommand(const std::wstring& command_line, |
| 20 bool sends_pings, |
| 21 bool is_web_accessible) |
| 22 : command_line_(command_line), |
| 23 sends_pings_(sends_pings), |
| 24 is_web_accessible_(is_web_accessible) { |
| 25 } |
| 26 |
| 27 bool ProductCommand::Initialize(const base::win::RegKey& key) { |
| 28 if (!key.Valid()) { |
| 29 LOG(DFATAL) << "Cannot initialize a ProductCommand from an invalid key."; |
| 30 return false; |
| 31 } |
| 32 |
| 33 LONG result = ERROR_SUCCESS; |
| 34 std::wstring cmd_line; |
| 35 DWORD sends_pings = 0; |
| 36 DWORD is_web_acc = 0; |
| 37 |
| 38 result = key.ReadValue(google_update::kRegCommandLineField, &cmd_line); |
| 39 if (result != ERROR_SUCCESS) { |
| 40 LOG(WARNING) << "Error reading " << google_update::kRegCommandLineField |
| 41 << " value from registry: " << result; |
| 42 return false; |
| 43 } |
| 44 |
| 45 result = key.ReadValueDW(google_update::kRegSendsPingsField, &sends_pings); |
| 46 if (result != ERROR_SUCCESS) { |
| 47 LOG(WARNING) << "Error reading " << google_update::kRegSendsPingsField |
| 48 << " value from registry: " << result; |
| 49 return false; |
| 50 } |
| 51 |
| 52 result = key.ReadValueDW(google_update::kRegWebAccessibleField, &is_web_acc); |
| 53 if (result != ERROR_SUCCESS) { |
| 54 LOG(WARNING) << "Error reading " << google_update::kRegWebAccessibleField |
| 55 << " value from registry: " << result; |
| 56 return false; |
| 57 } |
| 58 |
| 59 command_line_.swap(cmd_line); |
| 60 sends_pings_ = (sends_pings != 0); |
| 61 is_web_accessible_ = (is_web_acc != 0); |
| 62 |
| 63 return true; |
| 64 } |
| 65 |
| 66 void ProductCommand::AddWorkItems(HKEY predefined_root, |
| 67 const std::wstring& command_path, |
| 68 WorkItemList* item_list) const { |
| 69 const DWORD sends_pings = sends_pings_ ? 1U : 0U; |
| 70 const DWORD is_web_accessible = is_web_accessible_ ? 1U : 0U; |
| 71 |
| 72 item_list->AddCreateRegKeyWorkItem(predefined_root, command_path) |
| 73 ->set_log_message("creating quick-enable-cf command registry key"); |
| 74 item_list->AddSetRegValueWorkItem(predefined_root, command_path, |
| 75 google_update::kRegCommandLineField, |
| 76 command_line_, true) |
| 77 ->set_log_message("setting quick-enable-cf CommandLine registry value"); |
| 78 item_list->AddSetRegValueWorkItem(predefined_root, command_path, |
| 79 google_update::kRegSendsPingsField, |
| 80 sends_pings, true) |
| 81 ->set_log_message("setting quick-enable-cf SendsPings registry value"); |
| 82 item_list->AddSetRegValueWorkItem(predefined_root, command_path, |
| 83 google_update::kRegWebAccessibleField, |
| 84 is_web_accessible, true) |
| 85 ->set_log_message("setting quick-enable-cf WebAccessible registry value"); |
| 86 } |
| 87 |
| 88 } // namespace installer |
OLD | NEW |