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

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: Abandoning the use of ON_OS_UPGRADE_SUCCESSFUL installer message. 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 namespace {
15
16 // Helper: Add an optional boolean registry value, specified by value_data.
grt (UTC plus 2) 2012/08/30 04:15:25 The sentence beginning with "In the registry, ..."
huangs 2012/08/30 17:13:07 Done.
17 // In the registry, a non-zero value is "true", and a missing or zero value
18 // is "false". If value_data == true, add a SetRegValueWorkItem that sets
19 // registry value of 1 with REG_DWORD type. Otherwise add a
20 // DeleteRegValueWorkItem that deletes the registry value.
21 WorkItem* AddSetOptionalBoolRegValueWorkItem(
22 WorkItemList* item_list,
grt (UTC plus 2) 2012/08/30 04:15:25 chromium style: out params go at the end
huangs 2012/08/30 17:13:07 Done.
23 HKEY predefined_root,
24 const string16& key_path,
25 const string16& value_name,
26 bool value_data) {
27 if (value_data) {
28 return item_list->AddSetRegValueWorkItem(predefined_root,
grt (UTC plus 2) 2012/08/30 04:15:25 get rid of the cast by adding: const DWORD kOn
gab 2012/08/30 14:24:32 Interesting, I've never it this way in Chromium, b
grt (UTC plus 2) 2012/08/30 17:06:08 from the compiler's point of view, the two are equ
huangs 2012/08/30 17:13:07 Done.
huangs 2012/08/30 17:13:07 Conflicting reviews... Going with my personal pre
gab 2012/08/30 17:15:50 I disagree that this is more readbable, when one s
grt (UTC plus 2) 2012/08/30 19:10:18 i disagree. in my religious text, good code has n
29 key_path,
30 value_name,
31 static_cast<DWORD>(1),
32 true);
33 } else {
34 return item_list->AddDeleteRegValueWorkItem(predefined_root,
35 key_path,
36 value_name);
37 }
38 }
39
40 } // namespace
41
14 AppCommand::AppCommand() 42 AppCommand::AppCommand()
15 : sends_pings_(false), 43 : sends_pings_(false),
16 is_web_accessible_(false) { 44 is_web_accessible_(false),
45 is_auto_run_on_os_upgrade_(false) {
17 } 46 }
18 47
19 AppCommand::AppCommand(const std::wstring& command_line, 48 AppCommand::AppCommand(const string16& command_line)
20 bool sends_pings,
21 bool is_web_accessible)
22 : command_line_(command_line), 49 : command_line_(command_line),
23 sends_pings_(sends_pings), 50 sends_pings_(false),
24 is_web_accessible_(is_web_accessible) { 51 is_web_accessible_(false),
52 is_auto_run_on_os_upgrade_(false) {
25 } 53 }
26 54
27 bool AppCommand::Initialize(const base::win::RegKey& key) { 55 bool AppCommand::Initialize(const base::win::RegKey& key) {
28 if (!key.Valid()) { 56 if (!key.Valid()) {
29 LOG(DFATAL) << "Cannot initialize an AppCommand from an invalid key."; 57 LOG(DFATAL) << "Cannot initialize an AppCommand from an invalid key.";
30 return false; 58 return false;
31 } 59 }
32 60
33 LONG result = ERROR_SUCCESS; 61 LONG result = ERROR_SUCCESS;
34 std::wstring cmd_line; 62 string16 cmd_line;
35 DWORD sends_pings = 0; 63 DWORD sends_pings = 0;
36 DWORD is_web_acc = 0; 64 DWORD is_web_acc = 0;
65 DWORD is_auto_run_on_os_upgrade = 0;
37 66
38 result = key.ReadValue(google_update::kRegCommandLineField, &cmd_line); 67 result = key.ReadValue(google_update::kRegCommandLineField, &cmd_line);
39 if (result != ERROR_SUCCESS) { 68 if (result != ERROR_SUCCESS) {
40 LOG(WARNING) << "Error reading " << google_update::kRegCommandLineField 69 LOG(WARNING) << "Error reading " << google_update::kRegCommandLineField
41 << " value from registry: " << result; 70 << " value from registry: " << result;
42 return false; 71 return false;
43 } 72 }
44 73
74 // For the following calls, if result != ERROR_SUCCESS, then the
grt (UTC plus 2) 2012/08/30 04:15:25 I don't think this comment is needed. If you feel
huangs 2012/08/30 17:13:07 Done. So refer to functions by "ReadValueDW", not
75 // value of the output variable (e.g. sends_pings) remains at 0.
45 result = key.ReadValueDW(google_update::kRegSendsPingsField, &sends_pings); 76 result = key.ReadValueDW(google_update::kRegSendsPingsField, &sends_pings);
grt (UTC plus 2) 2012/08/30 04:15:25 remove "result = " here and below
huangs 2012/08/30 17:13:07 Done (embarrassed).
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); 77 result = key.ReadValueDW(google_update::kRegWebAccessibleField, &is_web_acc);
53 if (result != ERROR_SUCCESS) { 78 result = key.ReadValueDW(google_update::kRegAutoRunOnOSUpgrade,
54 LOG(WARNING) << "Error reading " << google_update::kRegWebAccessibleField 79 &is_auto_run_on_os_upgrade);
55 << " value from registry: " << result;
56 return false;
57 }
58 80
59 command_line_.swap(cmd_line); 81 command_line_.swap(cmd_line);
60 sends_pings_ = (sends_pings != 0); 82 sends_pings_ = (sends_pings != 0);
61 is_web_accessible_ = (is_web_acc != 0); 83 is_web_accessible_ = (is_web_acc != 0);
84 is_auto_run_on_os_upgrade_ = (is_auto_run_on_os_upgrade != 0);
62 85
63 return true; 86 return true;
64 } 87 }
65 88
66 void AppCommand::AddWorkItems(HKEY predefined_root, 89 void AppCommand::AddWorkItems(HKEY predefined_root,
67 const std::wstring& command_path, 90 const string16& command_path,
68 WorkItemList* item_list) const { 91 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) 92 item_list->AddCreateRegKeyWorkItem(predefined_root, command_path)
73 ->set_log_message("creating quick-enable-cf command registry key"); 93 ->set_log_message("creating AppCommand command registry key");
grt (UTC plus 2) 2012/08/30 04:15:25 "AppCommand command" -> "AppCommand"
huangs 2012/08/30 17:13:07 Done.
74 item_list->AddSetRegValueWorkItem(predefined_root, command_path, 94 item_list->AddSetRegValueWorkItem(predefined_root, command_path,
75 google_update::kRegCommandLineField, 95 google_update::kRegCommandLineField,
76 command_line_, true) 96 command_line_, true)
77 ->set_log_message("setting quick-enable-cf CommandLine registry value"); 97 ->set_log_message("setting AppCommand CommandLine registry value");
78 item_list->AddSetRegValueWorkItem(predefined_root, command_path, 98 AddSetOptionalBoolRegValueWorkItem(item_list,
79 google_update::kRegSendsPingsField, 99 predefined_root,
80 sends_pings, true) 100 command_path,
81 ->set_log_message("setting quick-enable-cf SendsPings registry value"); 101 google_update::kRegSendsPingsField,
82 item_list->AddSetRegValueWorkItem(predefined_root, command_path, 102 sends_pings_)
83 google_update::kRegWebAccessibleField, 103 ->set_log_message("setting AppCommand SendsPings registry value");
84 is_web_accessible, true) 104 AddSetOptionalBoolRegValueWorkItem(item_list,
85 ->set_log_message("setting quick-enable-cf WebAccessible registry value"); 105 predefined_root,
106 command_path,
107 google_update::kRegWebAccessibleField,
108 is_web_accessible_)
109 ->set_log_message("setting AppCommand WebAccessible registry value");
110 AddSetOptionalBoolRegValueWorkItem(item_list,
111 predefined_root,
112 command_path,
113 google_update::kRegAutoRunOnOSUpgrade,
114 is_auto_run_on_os_upgrade_)
115 ->set_log_message("setting AppCommand AutoRunOnOSUpgrade registry value");
86 } 116 }
87 117
88 } // namespace installer 118 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698