Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(365)

Side by Side Diff: chrome/installer/util/app_command.cc

Issue 10823437: Callback flow to register Chrome and update shortcuts after OS upgrade to Windows 8 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reimplementing registry changes using AppCommand; adding checks in InstallationValidator. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 "chrome/installer/util/app_command.h" 5 #include "chrome/installer/util/app_command.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/win/registry.h" 8 #include "base/win/registry.h"
9 #include "chrome/installer/util/google_update_constants.h" 9 #include "chrome/installer/util/google_update_constants.h"
10 #include "chrome/installer/util/work_item_list.h" 10 #include "chrome/installer/util/work_item_list.h"
11 11
12 namespace installer { 12 namespace installer {
13 13
14 AppCommand::AppCommand() 14 AppCommand::AppCommand()
15 : sends_pings_(false), 15 : sends_pings_(false),
16 is_web_accessible_(false) { 16 is_web_accessible_(false) {
grt (UTC plus 2) 2012/08/28 19:35:39 add is_auto_run_on_os_upgrade_(false) to the initi
huangs 2012/08/29 17:02:54 Done.
17 } 17 }
18 18
19 AppCommand::AppCommand(const std::wstring& command_line, 19 AppCommand::AppCommand(const std::wstring& command_line,
20 bool sends_pings, 20 bool sends_pings,
21 bool is_web_accessible,
22 bool is_auto_run_on_os_upgrade)
23 : command_line_(command_line),
24 sends_pings_(sends_pings),
25 is_web_accessible_(is_web_accessible),
26 is_auto_run_on_os_upgrade_(is_auto_run_on_os_upgrade) {
27 }
28
29 AppCommand::AppCommand(const std::wstring& command_line,
30 bool sends_pings,
21 bool is_web_accessible) 31 bool is_web_accessible)
22 : command_line_(command_line), 32 : command_line_(command_line),
23 sends_pings_(sends_pings), 33 sends_pings_(sends_pings),
24 is_web_accessible_(is_web_accessible) { 34 is_web_accessible_(is_web_accessible),
35 is_auto_run_on_os_upgrade_(false) {
25 } 36 }
26 37
27 bool AppCommand::Initialize(const base::win::RegKey& key) { 38 bool AppCommand::Initialize(const base::win::RegKey& key) {
28 if (!key.Valid()) { 39 if (!key.Valid()) {
29 LOG(DFATAL) << "Cannot initialize an AppCommand from an invalid key."; 40 LOG(DFATAL) << "Cannot initialize an AppCommand from an invalid key.";
30 return false; 41 return false;
31 } 42 }
32 43
33 LONG result = ERROR_SUCCESS; 44 LONG result = ERROR_SUCCESS;
34 std::wstring cmd_line; 45 std::wstring cmd_line;
35 DWORD sends_pings = 0; 46 DWORD sends_pings = 0;
36 DWORD is_web_acc = 0; 47 DWORD is_web_acc = 0;
48 DWORD is_auto_run_on_os_upgrade = 0;
37 49
38 result = key.ReadValue(google_update::kRegCommandLineField, &cmd_line); 50 result = key.ReadValue(google_update::kRegCommandLineField, &cmd_line);
39 if (result != ERROR_SUCCESS) { 51 if (result != ERROR_SUCCESS) {
40 LOG(WARNING) << "Error reading " << google_update::kRegCommandLineField 52 LOG(WARNING) << "Error reading " << google_update::kRegCommandLineField
41 << " value from registry: " << result; 53 << " value from registry: " << result;
42 return false; 54 return false;
43 } 55 }
44 56
45 result = key.ReadValueDW(google_update::kRegSendsPingsField, &sends_pings); 57 result = key.ReadValueDW(google_update::kRegSendsPingsField, &sends_pings);
46 if (result != ERROR_SUCCESS) { 58 if (result != ERROR_SUCCESS) {
grt (UTC plus 2) 2012/08/28 19:35:39 ReadValueDW only modifies its out_value on success
huangs 2012/08/29 17:02:54 Done, also added comment.
47 LOG(WARNING) << "Error reading " << google_update::kRegSendsPingsField 59 sends_pings = 0;
48 << " value from registry: " << result;
49 return false;
50 } 60 }
51 61
52 result = key.ReadValueDW(google_update::kRegWebAccessibleField, &is_web_acc); 62 result = key.ReadValueDW(google_update::kRegWebAccessibleField, &is_web_acc);
53 if (result != ERROR_SUCCESS) { 63 if (result != ERROR_SUCCESS) {
54 LOG(WARNING) << "Error reading " << google_update::kRegWebAccessibleField 64 is_web_acc = 0;
55 << " value from registry: " << result; 65 }
56 return false; 66
67 result = key.ReadValueDW(google_update::kRegAutoRunOnOSUpgrade,
68 &is_auto_run_on_os_upgrade);
69 if (result != ERROR_SUCCESS) {
70 is_auto_run_on_os_upgrade = 0;
57 } 71 }
58 72
59 command_line_.swap(cmd_line); 73 command_line_.swap(cmd_line);
60 sends_pings_ = (sends_pings != 0); 74 sends_pings_ = (sends_pings != 0);
61 is_web_accessible_ = (is_web_acc != 0); 75 is_web_accessible_ = (is_web_acc != 0);
76 is_auto_run_on_os_upgrade_ = (is_auto_run_on_os_upgrade != 0);
62 77
63 return true; 78 return true;
64 } 79 }
65 80
66 void AppCommand::AddWorkItems(HKEY predefined_root, 81 void AppCommand::AddWorkItems(HKEY predefined_root,
67 const std::wstring& command_path, 82 const std::wstring& command_path,
68 WorkItemList* item_list) const { 83 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) 84 item_list->AddCreateRegKeyWorkItem(predefined_root, command_path)
73 ->set_log_message("creating quick-enable-cf command registry key"); 85 ->set_log_message("creating AppCommand command registry key");
74 item_list->AddSetRegValueWorkItem(predefined_root, command_path, 86 item_list->AddSetRegValueWorkItem(predefined_root, command_path,
75 google_update::kRegCommandLineField, 87 google_update::kRegCommandLineField,
76 command_line_, true) 88 command_line_, true)
77 ->set_log_message("setting quick-enable-cf CommandLine registry value"); 89 ->set_log_message("setting AppCommand CommandLine registry value");
78 item_list->AddSetRegValueWorkItem(predefined_root, command_path, 90 item_list->AddSetOptionalBoolRegValueWorkItem(
79 google_update::kRegSendsPingsField, 91 predefined_root, command_path, google_update::kRegSendsPingsField,
grt (UTC plus 2) 2012/08/28 19:35:39 can these be wrapped like line 87 and 88 (as they
huangs 2012/08/29 17:02:54 Done, convenient since AddSetOptionalBoolRegValueW
80 sends_pings, true) 92 sends_pings_)
81 ->set_log_message("setting quick-enable-cf SendsPings registry value"); 93 ->set_log_message("setting AppCommand SendsPings registry value");
82 item_list->AddSetRegValueWorkItem(predefined_root, command_path, 94 item_list->AddSetOptionalBoolRegValueWorkItem(
83 google_update::kRegWebAccessibleField, 95 predefined_root, command_path, google_update::kRegWebAccessibleField,
84 is_web_accessible, true) 96 is_web_accessible_)
85 ->set_log_message("setting quick-enable-cf WebAccessible registry value"); 97 ->set_log_message("setting AppCommand WebAccessible registry value");
98 item_list->AddSetOptionalBoolRegValueWorkItem(
99 predefined_root, command_path, google_update::kRegAutoRunOnOSUpgrade,
100 is_auto_run_on_os_upgrade_)
101 ->set_log_message("setting AppCommand AutoRunOnOSUpgrade registry value");
86 } 102 }
87 103
88 } // namespace installer 104 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698