| 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/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 const struct ShellIntegration::AppModeInfo* ShellIntegration::AppModeInfo() { | 46 const struct ShellIntegration::AppModeInfo* ShellIntegration::AppModeInfo() { |
| 47 return gAppModeInfo; | 47 return gAppModeInfo; |
| 48 } | 48 } |
| 49 | 49 |
| 50 // static | 50 // static |
| 51 bool ShellIntegration::IsRunningInAppMode() { | 51 bool ShellIntegration::IsRunningInAppMode() { |
| 52 return gAppModeInfo != NULL; | 52 return gAppModeInfo != NULL; |
| 53 } | 53 } |
| 54 | 54 |
| 55 // static | 55 // static |
| 56 CommandLine ShellIntegration::CommandLineArgsForLauncher( | 56 base::CommandLine ShellIntegration::CommandLineArgsForLauncher( |
| 57 const GURL& url, | 57 const GURL& url, |
| 58 const std::string& extension_app_id, | 58 const std::string& extension_app_id, |
| 59 const base::FilePath& profile_path) { | 59 const base::FilePath& profile_path) { |
| 60 base::ThreadRestrictions::AssertIOAllowed(); | 60 base::ThreadRestrictions::AssertIOAllowed(); |
| 61 CommandLine new_cmd_line(CommandLine::NO_PROGRAM); | 61 base::CommandLine new_cmd_line(base::CommandLine::NO_PROGRAM); |
| 62 | 62 |
| 63 AppendProfileArgs( | 63 AppendProfileArgs( |
| 64 extension_app_id.empty() ? base::FilePath() : profile_path, | 64 extension_app_id.empty() ? base::FilePath() : profile_path, |
| 65 &new_cmd_line); | 65 &new_cmd_line); |
| 66 | 66 |
| 67 // If |extension_app_id| is present, we use the kAppId switch rather than | 67 // If |extension_app_id| is present, we use the kAppId switch rather than |
| 68 // the kApp switch (the launch url will be read from the extension app | 68 // the kApp switch (the launch url will be read from the extension app |
| 69 // during launch. | 69 // during launch. |
| 70 if (!extension_app_id.empty()) { | 70 if (!extension_app_id.empty()) { |
| 71 new_cmd_line.AppendSwitchASCII(switches::kAppId, extension_app_id); | 71 new_cmd_line.AppendSwitchASCII(switches::kAppId, extension_app_id); |
| 72 } else { | 72 } else { |
| 73 // Use '--app=url' instead of just 'url' to launch the browser with minimal | 73 // Use '--app=url' instead of just 'url' to launch the browser with minimal |
| 74 // chrome. | 74 // chrome. |
| 75 // Note: Do not change this flag! Old Gears shortcuts will break if you do! | 75 // Note: Do not change this flag! Old Gears shortcuts will break if you do! |
| 76 new_cmd_line.AppendSwitchASCII(switches::kApp, url.spec()); | 76 new_cmd_line.AppendSwitchASCII(switches::kApp, url.spec()); |
| 77 } | 77 } |
| 78 return new_cmd_line; | 78 return new_cmd_line; |
| 79 } | 79 } |
| 80 | 80 |
| 81 // static | 81 // static |
| 82 void ShellIntegration::AppendProfileArgs( | 82 void ShellIntegration::AppendProfileArgs(const base::FilePath& profile_path, |
| 83 const base::FilePath& profile_path, | 83 base::CommandLine* command_line) { |
| 84 CommandLine* command_line) { | |
| 85 DCHECK(command_line); | 84 DCHECK(command_line); |
| 86 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); | 85 const base::CommandLine& cmd_line = *base::CommandLine::ForCurrentProcess(); |
| 87 | 86 |
| 88 // 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. |
| 89 base::FilePath user_data_dir = | 88 base::FilePath user_data_dir = |
| 90 cmd_line.GetSwitchValuePath(switches::kUserDataDir); | 89 cmd_line.GetSwitchValuePath(switches::kUserDataDir); |
| 91 #if defined(OS_MACOSX) || defined(OS_WIN) | 90 #if defined(OS_MACOSX) || defined(OS_WIN) |
| 92 policy::path_parser::CheckUserDataDirPolicy(&user_data_dir); | 91 policy::path_parser::CheckUserDataDirPolicy(&user_data_dir); |
| 93 #endif | 92 #endif |
| 94 if (!user_data_dir.empty()) { | 93 if (!user_data_dir.empty()) { |
| 95 // Make sure user_data_dir is an absolute path. | 94 // Make sure user_data_dir is an absolute path. |
| 96 user_data_dir = base::MakeAbsoluteFilePath(user_data_dir); | 95 user_data_dir = base::MakeAbsoluteFilePath(user_data_dir); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 case ShellIntegration::SET_DEFAULT_INTERACTIVE: | 305 case ShellIntegration::SET_DEFAULT_INTERACTIVE: |
| 307 if (interactive_permitted) { | 306 if (interactive_permitted) { |
| 308 result = ShellIntegration::SetAsDefaultProtocolClientInteractive( | 307 result = ShellIntegration::SetAsDefaultProtocolClientInteractive( |
| 309 protocol_); | 308 protocol_); |
| 310 } | 309 } |
| 311 break; | 310 break; |
| 312 } | 311 } |
| 313 | 312 |
| 314 return result; | 313 return result; |
| 315 } | 314 } |
| OLD | NEW |