Skip to content

Commit

Permalink
Exctracted small setup executable.
Browse files Browse the repository at this point in the history
R=gene

Review URL: https://chromiumcodereview.appspot.com/14098008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@196007 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
vitalybuka@chromium.org committed Apr 24, 2013
1 parent 1ff45ce commit f9cd748
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 23 deletions.
1 change: 1 addition & 0 deletions cloud_print/cloud_print.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
'sources': [
'service/win/cloud_print_service_exe.ver',
'service/win/cloud_print_service_config_exe.ver',
'service/win/cloud_print_service_setup_exe.ver',
'virtual_driver/win/gcp_portmon64_dll.ver',
'virtual_driver/win/gcp_portmon_dll.ver',
'virtual_driver/win/install/virtual_driver_setup_exe.ver',
Expand Down
27 changes: 25 additions & 2 deletions cloud_print/service/service.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@
'sources': [
'<(SHARED_INTERMEDIATE_DIR)/cloud_print/cloud_print_service_config_exe_version.rc',
'win/cloud_print_service_config.cc',
'win/installer.cc',
'win/installer.h',
],
'includes': [
'win/service_resources.gypi'
Expand All @@ -151,5 +149,30 @@
},
},
},
{
'target_name': 'cloud_print_service_setup',
'type': 'executable',
'sources': [
'<(SHARED_INTERMEDIATE_DIR)/cloud_print/cloud_print_service_setup_exe_version.rc',
'win/installer.cc',
'win/installer.h',
],
'includes': [
'win/service_resources.gypi'
],
'dependencies': [
'<(DEPTH)/cloud_print/common/common.gyp:cloud_print_install_lib',
'cloud_print_service_lib',
],
'msvs_settings': {
'VCLinkerTool': {
'SubSystem': '1', # Set /SUBSYSTEM:CONSOLE
'UACExecutionLevel': '2', # /level='requireAdministrator'
'AdditionalDependencies': [
'secur32.lib',
],
},
},
},
],
}
15 changes: 3 additions & 12 deletions cloud_print/service/win/chrome_launcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "chrome/installer/launcher_support/chrome_launcher_support.h"
#include "cloud_print/common/win/cloud_print_utils.h"
#include "cloud_print/service/service_constants.h"
#include "cloud_print/service/win/service_utils.h"
#include "google_apis/gaia/gaia_urls.h"
#include "googleurl/src/gurl.h"
#include "net/base/url_util.h"
Expand Down Expand Up @@ -183,7 +184,7 @@ void ChromeLauncher::Run() {

if (!chrome_path.empty()) {
CommandLine cmd(chrome_path);
CopySwitchesFromCurrent(&cmd);
CopyChromeSwitchesFromCurrentProcess(&cmd);

// Required switches.
cmd.AppendSwitchASCII(switches::kProcessType, switches::kServiceProcess);
Expand Down Expand Up @@ -231,16 +232,6 @@ void ChromeLauncher::Run() {
}
}

void ChromeLauncher::CopySwitchesFromCurrent(CommandLine* destination) {
static const char* const kSwitchesToCopy[] = {
switches::kEnableLogging,
switches::kV,
};
destination->CopySwitchesFrom(*CommandLine::ForCurrentProcess(),
kSwitchesToCopy,
arraysize(kSwitchesToCopy));
}

std::string ChromeLauncher::CreateServiceStateFile(
const std::string& proxy_id,
const std::vector<std::string>& printers) {
Expand Down Expand Up @@ -274,7 +265,7 @@ std::string ChromeLauncher::CreateServiceStateFile(
}

CommandLine cmd(chrome_path);
CopySwitchesFromCurrent(&cmd);
CopyChromeSwitchesFromCurrentProcess(&cmd);
cmd.AppendSwitchPath(switches::kUserDataDir, temp_user_data.path());
cmd.AppendSwitchPath(switches::kCloudPrintSetupProxy, printers_file);
cmd.AppendSwitch(switches::kNoServiceAutorun);
Expand Down
3 changes: 0 additions & 3 deletions cloud_print/service/win/chrome_launcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ class ChromeLauncher : public base::DelegateSimpleThread::Delegate {

virtual void Run() OVERRIDE;

// Copy additional chrome switches.
static void CopySwitchesFromCurrent(CommandLine* destination);

static std::string CreateServiceStateFile(
const std::string& proxy_id,
const std::vector<std::string>& printers);
Expand Down
5 changes: 0 additions & 5 deletions cloud_print/service/win/cloud_print_service_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "cloud_print/resources.h"
#include "cloud_print/service/service_state.h"
#include "cloud_print/service/win/chrome_launcher.h"
#include "cloud_print/service/win/installer.h"
#include "cloud_print/service/win/service_controller.h"
#include "cloud_print/service/win/service_utils.h"
#include "cloud_print/service/win/setup_listener.h"
Expand Down Expand Up @@ -428,10 +427,6 @@ int WINAPI WinMain(__in HINSTANCE hInstance,
base::AtExitManager at_exit;
CommandLine::Init(0, NULL);

HRESULT result = ProcessInstallerSwitches();
if (result != S_FALSE)
return result;

MessageLoopForUI loop;
scoped_refptr<SetupDialog> dialog(new SetupDialog());
dialog->Create(NULL);
Expand Down
3 changes: 3 additions & 0 deletions cloud_print/service/win/cloud_print_service_setup_exe.ver
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
INTERNAL_NAME=cloud_print_service_setup.exe
ORIGINAL_FILENAME=cloud_print_service_setup.exe
FILETYPE=0x1L
7 changes: 7 additions & 0 deletions cloud_print/service/win/installer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@

#include <winerror.h>

#include "base/at_exit.h"
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/path_service.h"
#include "base/win/scoped_com_initializer.h"
#include "base/win/shortcut.h"
#include "cloud_print/common/win/cloud_print_utils.h"
#include "cloud_print/common/win/install_utils.h"
#include "cloud_print/resources.h"
#include "cloud_print/service/service_constants.h"
#include "cloud_print/service/service_switches.h"
#include "cloud_print/service/win/service_controller.h"
Expand Down Expand Up @@ -123,3 +125,8 @@ HRESULT ProcessInstallerSwitches() {
return S_FALSE;
}

int main(int argc, char** argv) {
CommandLine::Init(argc, argv);
base::AtExitManager at_exit;
return ProcessInstallerSwitches();
}
4 changes: 3 additions & 1 deletion cloud_print/service/win/service_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "cloud_print/service/service_switches.h"
#include "cloud_print/service/win/chrome_launcher.h"
#include "cloud_print/service/win/local_security_policy.h"
#include "cloud_print/service/win/service_utils.h"

namespace {

Expand Down Expand Up @@ -170,7 +171,8 @@ HRESULT ServiceController::InstallService(const string16& user,
command_line.AppendSwitch(switches::kEnableLogging);
command_line.AppendSwitchASCII(switches::kV, "1");
}
ChromeLauncher::CopySwitchesFromCurrent(&command_line);

CopyChromeSwitchesFromCurrentProcess(&command_line);

LocalSecurityPolicy local_security_policy;
if (local_security_policy.Open()) {
Expand Down
11 changes: 11 additions & 0 deletions cloud_print/service/win/service_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
#include <windows.h>
#include <security.h> // NOLINT

#include "base/command_line.h"
#include "base/string_util.h"
#include "chrome/common/chrome_switches.h"

string16 GetLocalComputerName() {
DWORD size = 0;
Expand Down Expand Up @@ -44,4 +46,13 @@ string16 GetCurrentUserName() {
return result;
}

void CopyChromeSwitchesFromCurrentProcess(CommandLine* destination) {
static const char* const kSwitchesToCopy[] = {
switches::kEnableLogging,
switches::kV,
};
destination->CopySwitchesFrom(*CommandLine::ForCurrentProcess(),
kSwitchesToCopy,
arraysize(kSwitchesToCopy));
}

3 changes: 3 additions & 0 deletions cloud_print/service/win/service_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
#ifndef CLOUD_PRINT_SERVICE_SERVICE_UTILS_H_
#define CLOUD_PRINT_SERVICE_SERVICE_UTILS_H_

class CommandLine;

#include "base/string16.h"

string16 ReplaceLocalHostInName(const string16& user_name);
string16 GetCurrentUserName();
void CopyChromeSwitchesFromCurrentProcess(CommandLine* destination);

#endif // CLOUD_PRINT_SERVICE_SERVICE_UTILS_H_

0 comments on commit f9cd748

Please sign in to comment.