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

Side by Side Diff: cloud_print/service/win/chrome_launcher.cc

Issue 1010923002: If possible, use the PathService instead of the --user-data-dir flag directly (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "cloud_print/service/win/chrome_launcher.h" 5 #include "cloud_print/service/win/chrome_launcher.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
11 #include "base/json/json_reader.h" 11 #include "base/json/json_reader.h"
12 #include "base/json/json_writer.h" 12 #include "base/json/json_writer.h"
13 #include "base/path_service.h"
13 #include "base/process/process.h" 14 #include "base/process/process.h"
14 #include "base/process/process.h" 15 #include "base/process/process.h"
15 #include "base/values.h" 16 #include "base/values.h"
16 #include "base/win/registry.h" 17 #include "base/win/registry.h"
17 #include "base/win/scoped_handle.h" 18 #include "base/win/scoped_handle.h"
18 #include "base/win/scoped_process_information.h" 19 #include "base/win/scoped_process_information.h"
19 #include "chrome/common/chrome_constants.h" 20 #include "chrome/common/chrome_constants.h"
21 #include "chrome/common/chrome_paths.h"
20 #include "chrome/common/chrome_switches.h" 22 #include "chrome/common/chrome_switches.h"
21 #include "chrome/common/pref_names.h" 23 #include "chrome/common/pref_names.h"
22 #include "chrome/installer/launcher_support/chrome_launcher_support.h" 24 #include "chrome/installer/launcher_support/chrome_launcher_support.h"
23 #include "cloud_print/common/win/cloud_print_utils.h" 25 #include "cloud_print/common/win/cloud_print_utils.h"
24 #include "cloud_print/service/service_constants.h" 26 #include "cloud_print/service/service_constants.h"
25 #include "cloud_print/service/win/service_utils.h" 27 #include "cloud_print/service/win/service_utils.h"
26 #include "components/cloud_devices/common/cloud_devices_urls.h" 28 #include "components/cloud_devices/common/cloud_devices_urls.h"
27 #include "google_apis/gaia/gaia_urls.h" 29 #include "google_apis/gaia/gaia_urls.h"
28 #include "net/base/url_util.h" 30 #include "net/base/url_util.h"
29 #include "url/gurl.h" 31 #include "url/gurl.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 base::FilePath abs_user_data_dir = base::MakeAbsoluteFilePath(user_data_dir); 150 base::FilePath abs_user_data_dir = base::MakeAbsoluteFilePath(user_data_dir);
149 151
150 { 152 {
151 base::win::RegistryValueIterator value(HKEY_CURRENT_USER, kAutoRunKeyPath); 153 base::win::RegistryValueIterator value(HKEY_CURRENT_USER, kAutoRunKeyPath);
152 for (; value.Valid(); ++value) { 154 for (; value.Valid(); ++value) {
153 if (value.Type() == REG_SZ && value.Value()) { 155 if (value.Type() == REG_SZ && value.Value()) {
154 base::CommandLine cmd = base::CommandLine::FromString(value.Value()); 156 base::CommandLine cmd = base::CommandLine::FromString(value.Value());
155 if (cmd.GetSwitchValueASCII(switches::kProcessType) == 157 if (cmd.GetSwitchValueASCII(switches::kProcessType) ==
156 switches::kServiceProcess && 158 switches::kServiceProcess &&
157 cmd.HasSwitch(switches::kUserDataDir)) { 159 cmd.HasSwitch(switches::kUserDataDir)) {
158 base::FilePath path_from_reg = base::MakeAbsoluteFilePath( 160 base::FilePath dir;
159 cmd.GetSwitchValuePath(switches::kUserDataDir)); 161 PathService::Get(chrome::DIR_USER_DATA, &dir);
grt (UTC plus 2) 2015/03/26 18:36:22 i wouldn't touch this one. it seems to me that clo
noms (inactive) 2015/03/30 14:06:33 Done.
162 base::FilePath path_from_reg = base::MakeAbsoluteFilePath(dir);
160 if (path_from_reg == abs_user_data_dir) { 163 if (path_from_reg == abs_user_data_dir) {
161 to_delete.push_back(value.Name()); 164 to_delete.push_back(value.Name());
162 } 165 }
163 } 166 }
164 } 167 }
165 } 168 }
166 } 169 }
167 170
168 for (size_t i = 0; i < to_delete.size(); ++i) { 171 for (size_t i = 0; i < to_delete.size(); ++i) {
169 key.DeleteValue(to_delete[i].c_str()); 172 key.DeleteValue(to_delete[i].c_str());
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 LOG(ERROR) << "Chrome launch failed."; 324 LOG(ERROR) << "Chrome launch failed.";
322 return std::string(); 325 return std::string();
323 } 326 }
324 if (!json.empty()) { 327 if (!json.empty()) {
325 // Close chrome because Service State is ready. 328 // Close chrome because Service State is ready.
326 CloseChrome(chrome_process.Pass(), thread_id); 329 CloseChrome(chrome_process.Pass(), thread_id);
327 return json; 330 return json;
328 } 331 }
329 } 332 }
330 } 333 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698