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

Side by Side Diff: chrome/service/service_process.cc

Issue 3384001: The LSID for Cloud Print can now be supplied on the command line even if Clou... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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
« no previous file with comments | « chrome/service/service_process.h ('k') | chrome/service/service_process_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/service/service_process.h" 5 #include "chrome/service/service_process.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 static const int64 kShutdownDelay = 60000; 51 static const int64 kShutdownDelay = 60000;
52 52
53 ServiceProcess::ServiceProcess() 53 ServiceProcess::ServiceProcess()
54 : shutdown_event_(true, false), 54 : shutdown_event_(true, false),
55 main_message_loop_(NULL), 55 main_message_loop_(NULL),
56 enabled_services_(0) { 56 enabled_services_(0) {
57 DCHECK(!g_service_process); 57 DCHECK(!g_service_process);
58 g_service_process = this; 58 g_service_process = this;
59 } 59 }
60 60
61 bool ServiceProcess::Initialize(MessageLoop* message_loop) { 61 bool ServiceProcess::Initialize(MessageLoop* message_loop,
62 const CommandLine& command_line) {
62 main_message_loop_ = message_loop; 63 main_message_loop_ = message_loop;
63 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); 64 network_change_notifier_.reset(net::NetworkChangeNotifier::Create());
64 base::Thread::Options options; 65 base::Thread::Options options;
65 options.message_loop_type = MessageLoop::TYPE_IO; 66 options.message_loop_type = MessageLoop::TYPE_IO;
66 io_thread_.reset(new base::Thread("ServiceProcess_IO")); 67 io_thread_.reset(new base::Thread("ServiceProcess_IO"));
67 file_thread_.reset(new base::Thread("ServiceProcess_File")); 68 file_thread_.reset(new base::Thread("ServiceProcess_File"));
68 if (!io_thread_->StartWithOptions(options) || 69 if (!io_thread_->StartWithOptions(options) ||
69 !file_thread_->StartWithOptions(options)) { 70 !file_thread_->StartWithOptions(options)) {
70 NOTREACHED(); 71 NOTREACHED();
71 Teardown(); 72 Teardown();
72 return false; 73 return false;
73 } 74 }
75
76 // See if we have been suppiled an LSID in the command line. This LSID will
77 // override the credentials we use for Cloud Print.
78 std::string lsid = command_line.GetSwitchValueASCII(
79 switches::kServiceAccountLsid);
80
74 FilePath user_data_dir; 81 FilePath user_data_dir;
75 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); 82 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
76 FilePath pref_path = user_data_dir.Append(chrome::kServiceStateFileName); 83 FilePath pref_path = user_data_dir.Append(chrome::kServiceStateFileName);
77 service_prefs_.reset(new JsonPrefStore(pref_path, 84 service_prefs_.reset(new JsonPrefStore(pref_path,
78 file_thread_->message_loop_proxy())); 85 file_thread_->message_loop_proxy()));
79 service_prefs_->ReadPrefs(); 86 service_prefs_->ReadPrefs();
80 87
81 DictionaryValue* values = service_prefs_->prefs(); 88 DictionaryValue* values = service_prefs_->prefs();
82 bool remoting_host_enabled = false; 89 bool remoting_host_enabled = false;
83 90
84 // Check if remoting host is already enabled. 91 // Check if remoting host is already enabled.
85 if (values->GetBoolean(prefs::kRemotingHostEnabled, &remoting_host_enabled) && 92 if (values->GetBoolean(prefs::kRemotingHostEnabled, &remoting_host_enabled) &&
86 remoting_host_enabled) { 93 remoting_host_enabled) {
87 // If true then we start the host. 94 // If true then we start the host.
88 StartChromotingHost(); 95 StartChromotingHost();
89 } 96 }
97 // Enable Cloud Print if needed. First check the command-line.
98 bool cloud_print_proxy_enabled =
99 command_line.HasSwitch(switches::kEnableCloudPrintProxy);
100 if (!cloud_print_proxy_enabled) {
101 // Then check if the cloud print proxy was previously enabled.
102 values->GetBoolean(prefs::kCloudPrintProxyEnabled,
103 &cloud_print_proxy_enabled);
104 }
90 105
91 bool cloud_print_proxy_enabled = false; 106 if (cloud_print_proxy_enabled) {
92 107 GetCloudPrintProxy()->EnableForUser(lsid);
93 // Check if the cloud print proxy is already enabled.
94 if (values->GetBoolean(prefs::kCloudPrintProxyEnabled,
95 &cloud_print_proxy_enabled) &&
96 cloud_print_proxy_enabled) {
97 GetCloudPrintProxy()->EnableForUser(std::string());
98 } 108 }
99 109
100 LOG(INFO) << "Starting Service Process IPC Server"; 110 LOG(INFO) << "Starting Service Process IPC Server";
101 ipc_server_.reset(new ServiceIPCServer(GetServiceProcessChannelName())); 111 ipc_server_.reset(new ServiceIPCServer(GetServiceProcessChannelName()));
102 ipc_server_->Init(); 112 ipc_server_->Init();
103 113
104 // After the IPC server has started we signal that the service process is 114 // After the IPC server has started we signal that the service process is
105 // running. 115 // running.
106 SignalServiceProcessRunning(kServiceProcessCloudPrint); 116 SignalServiceProcessRunning(kServiceProcessCloudPrint);
107 return true; 117 return true;
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 #endif 390 #endif
381 391
382 ServiceProcess::~ServiceProcess() { 392 ServiceProcess::~ServiceProcess() {
383 Teardown(); 393 Teardown();
384 g_service_process = NULL; 394 g_service_process = NULL;
385 } 395 }
386 396
387 // Disable refcounting for runnable method because it is really not needed 397 // Disable refcounting for runnable method because it is really not needed
388 // when we post tasks on the main message loop. 398 // when we post tasks on the main message loop.
389 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcess); 399 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcess);
OLDNEW
« no previous file with comments | « chrome/service/service_process.h ('k') | chrome/service/service_process_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698