Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "chrome/browser/shell_integration.h" | 5 #include "chrome/browser/shell_integration.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.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/path_service.h" | |
| 10 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 11 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/threading/thread_restrictions.h" | 14 #include "base/threading/thread_restrictions.h" |
| 14 #include "chrome/browser/policy/policy_path_parser.h" | 15 #include "chrome/browser/policy/policy_path_parser.h" |
| 15 #include "chrome/common/chrome_paths.h" | 16 #include "chrome/common/chrome_paths.h" |
| 16 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
| 17 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 18 | 19 |
| 19 #if defined(OS_CHROMEOS) | 20 #if defined(OS_CHROMEOS) |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 // Note: Do not change this flag! Old Gears shortcuts will break if you do! | 76 // Note: Do not change this flag! Old Gears shortcuts will break if you do! |
| 76 new_cmd_line.AppendSwitchASCII(switches::kApp, url.spec()); | 77 new_cmd_line.AppendSwitchASCII(switches::kApp, url.spec()); |
| 77 } | 78 } |
| 78 return new_cmd_line; | 79 return new_cmd_line; |
| 79 } | 80 } |
| 80 | 81 |
| 81 // static | 82 // static |
| 82 void ShellIntegration::AppendProfileArgs(const base::FilePath& profile_path, | 83 void ShellIntegration::AppendProfileArgs(const base::FilePath& profile_path, |
| 83 base::CommandLine* command_line) { | 84 base::CommandLine* command_line) { |
| 84 DCHECK(command_line); | 85 DCHECK(command_line); |
| 85 const base::CommandLine& cmd_line = *base::CommandLine::ForCurrentProcess(); | |
| 86 | 86 |
| 87 // Use the same UserDataDir for new launches that we currently have set. | 87 // Use the same UserDataDir for new launches that we currently have set. |
| 88 base::FilePath user_data_dir = | 88 base::FilePath user_data_dir; |
| 89 cmd_line.GetSwitchValuePath(switches::kUserDataDir); | 89 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
| 90 #if defined(OS_MACOSX) || defined(OS_WIN) | 90 #if defined(OS_MACOSX) || defined(OS_WIN) |
| 91 policy::path_parser::CheckUserDataDirPolicy(&user_data_dir); | 91 policy::path_parser::CheckUserDataDirPolicy(&user_data_dir); |
|
grt (UTC plus 2)
2015/03/26 18:36:22
this isn't needed now, is it?
noms (inactive)
2015/03/30 14:06:32
Done.
| |
| 92 #endif | 92 #endif |
| 93 if (!user_data_dir.empty()) { | 93 if (!user_data_dir.empty()) { |
| 94 // Make sure user_data_dir is an absolute path. | 94 // Make sure user_data_dir is an absolute path. |
| 95 user_data_dir = base::MakeAbsoluteFilePath(user_data_dir); | 95 user_data_dir = base::MakeAbsoluteFilePath(user_data_dir); |
| 96 if (!user_data_dir.empty() && base::PathExists(user_data_dir)) | 96 if (!user_data_dir.empty() && base::PathExists(user_data_dir)) |
| 97 command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir); | 97 command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir); |
| 98 } | 98 } |
| 99 | 99 |
| 100 #if defined(OS_CHROMEOS) | 100 #if defined(OS_CHROMEOS) |
| 101 const base::CommandLine& cmd_line = *base::CommandLine::ForCurrentProcess(); | |
| 101 base::FilePath profile = cmd_line.GetSwitchValuePath( | 102 base::FilePath profile = cmd_line.GetSwitchValuePath( |
| 102 chromeos::switches::kLoginProfile); | 103 chromeos::switches::kLoginProfile); |
| 103 if (!profile.empty()) | 104 if (!profile.empty()) |
| 104 command_line->AppendSwitchPath(chromeos::switches::kLoginProfile, profile); | 105 command_line->AppendSwitchPath(chromeos::switches::kLoginProfile, profile); |
| 105 #else | 106 #else |
| 106 if (!profile_path.empty()) | 107 if (!profile_path.empty()) |
| 107 command_line->AppendSwitchPath(switches::kProfileDirectory, | 108 command_line->AppendSwitchPath(switches::kProfileDirectory, |
| 108 profile_path.BaseName()); | 109 profile_path.BaseName()); |
| 109 #endif | 110 #endif |
| 110 } | 111 } |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 305 case ShellIntegration::SET_DEFAULT_INTERACTIVE: | 306 case ShellIntegration::SET_DEFAULT_INTERACTIVE: |
| 306 if (interactive_permitted) { | 307 if (interactive_permitted) { |
| 307 result = ShellIntegration::SetAsDefaultProtocolClientInteractive( | 308 result = ShellIntegration::SetAsDefaultProtocolClientInteractive( |
| 308 protocol_); | 309 protocol_); |
| 309 } | 310 } |
| 310 break; | 311 break; |
| 311 } | 312 } |
| 312 | 313 |
| 313 return result; | 314 return result; |
| 314 } | 315 } |
| OLD | NEW |