Skip to content

Commit

Permalink
[Installer] Moving GetRegistrationDataCommandKey() to setup_util.
Browse files Browse the repository at this point in the history
This is a small refactoring that's needed for removal of legacy App Launcher
installer code (will need to use GetRegistrationDataCommandKey outside of
install_workers.cc).

Review URL: https://codereview.chromium.org/800353002

Cr-Commit-Position: refs/heads/master@{#308604}
  • Loading branch information
samuelhuang authored and Commit bot committed Dec 16, 2014
1 parent f00a4d4 commit 4ccde74
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
11 changes: 0 additions & 11 deletions chrome/installer/setup/install_worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -187,17 +187,6 @@ void AddInstallerCopyTasks(const InstallerState& installer_state,
}
}

base::string16 GetRegistrationDataCommandKey(
const AppRegistrationData& reg_data,
const wchar_t* name) {
base::string16 cmd_key(reg_data.GetVersionKey());
cmd_key.append(1, base::FilePath::kSeparators[0])
.append(google_update::kRegCommandsKey)
.append(1, base::FilePath::kSeparators[0])
.append(name);
return cmd_key;
}

base::string16 GetRegCommandKey(BrowserDistribution* dist,
const wchar_t* name) {
return GetRegistrationDataCommandKey(dist->GetAppRegistrationData(), name);
Expand Down
12 changes: 12 additions & 0 deletions chrome/installer/setup/setup_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "base/win/registry.h"
#include "base/win/windows_version.h"
#include "chrome/installer/setup/setup_constants.h"
#include "chrome/installer/util/app_registration_data.h"
#include "chrome/installer/util/copy_tree_work_item.h"
#include "chrome/installer/util/google_update_constants.h"
#include "chrome/installer/util/installation_state.h"
Expand Down Expand Up @@ -455,6 +456,17 @@ bool IsProcessorSupported() {
return base::CPU().has_sse2();
}

base::string16 GetRegistrationDataCommandKey(
const AppRegistrationData& reg_data,
const wchar_t* name) {
base::string16 cmd_key(reg_data.GetVersionKey());
cmd_key.append(1, base::FilePath::kSeparators[0])
.append(google_update::kRegCommandsKey)
.append(1, base::FilePath::kSeparators[0])
.append(name);
return cmd_key;
}

ScopedTokenPrivilege::ScopedTokenPrivilege(const wchar_t* privilege_name)
: is_enabled_(false) {
HANDLE temp_handle;
Expand Down
7 changes: 7 additions & 0 deletions chrome/installer/setup/setup_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "chrome/installer/util/browser_distribution.h"
#include "chrome/installer/util/util_constants.h"

class AppRegistrationData;

namespace base {
class CommandLine;
class FilePath;
Expand Down Expand Up @@ -115,6 +117,11 @@ bool ContainsUnsupportedSwitch(const base::CommandLine& cmd_line);
// Returns true if the processor is supported by chrome.
bool IsProcessorSupported();

// Returns the "...\\Commands\\|name|" registry key for a product's |reg_data|.
base::string16 GetRegistrationDataCommandKey(
const AppRegistrationData& reg_data,
const wchar_t* name);

// This class will enable the privilege defined by |privilege_name| on the
// current process' token. The privilege will be disabled upon the
// ScopedTokenPrivilege's destruction (unless it was already enabled when the
Expand Down
10 changes: 10 additions & 0 deletions chrome/installer/setup/setup_util_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "base/process/kill.h"
#include "base/process/launch.h"
#include "base/process/process_handle.h"
#include "base/strings/string_util.h"
#include "base/test/test_reg_util_win.h"
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
Expand All @@ -26,6 +27,7 @@
#include "chrome/installer/util/google_update_constants.h"
#include "chrome/installer/util/installation_state.h"
#include "chrome/installer/util/installer_state.h"
#include "chrome/installer/util/updating_app_registration_data.h"
#include "chrome/installer/util/util_constants.h"
#include "testing/gtest/include/gtest/gtest.h"

Expand Down Expand Up @@ -494,3 +496,11 @@ TEST(SetupUtilTest, ContainsUnsupportedSwitch) {
EXPECT_TRUE(installer::ContainsUnsupportedSwitch(
CommandLine::FromString(L"foo.exe --chrome-frame")));
}

TEST(SetupUtilTest, GetRegistrationDataCommandKey) {
base::string16 app_guid = L"{AAAAAAAA-BBBB-1111-0123-456789ABCDEF}";
UpdatingAppRegistrationData reg_data(app_guid);
base::string16 key =
installer::GetRegistrationDataCommandKey(reg_data, L"test_name");
EXPECT_TRUE(EndsWith(key, app_guid + L"\\Commands\\test_name", true));
}

0 comments on commit 4ccde74

Please sign in to comment.