| 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/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 // static | 49 // static |
| 50 bool ShellIntegration::IsRunningInAppMode() { | 50 bool ShellIntegration::IsRunningInAppMode() { |
| 51 return gAppModeInfo != NULL; | 51 return gAppModeInfo != NULL; |
| 52 } | 52 } |
| 53 | 53 |
| 54 // static | 54 // static |
| 55 CommandLine ShellIntegration::CommandLineArgsForLauncher( | 55 CommandLine ShellIntegration::CommandLineArgsForLauncher( |
| 56 const GURL& url, | 56 const GURL& url, |
| 57 const std::string& extension_app_id, | 57 const std::string& extension_app_id, |
| 58 bool is_platform_app, | |
| 59 const FilePath& profile_path) { | 58 const FilePath& profile_path) { |
| 60 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); | 59 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); |
| 61 CommandLine new_cmd_line(CommandLine::NO_PROGRAM); | 60 CommandLine new_cmd_line(CommandLine::NO_PROGRAM); |
| 62 | 61 |
| 63 // Use the same UserDataDir for new launches that we currently have set. | 62 // Use the same UserDataDir for new launches that we currently have set. |
| 64 FilePath user_data_dir = cmd_line.GetSwitchValuePath(switches::kUserDataDir); | 63 FilePath user_data_dir = cmd_line.GetSwitchValuePath(switches::kUserDataDir); |
| 65 if (!user_data_dir.empty()) { | 64 if (!user_data_dir.empty()) { |
| 66 // Make sure user_data_dir is an absolute path. | 65 // Make sure user_data_dir is an absolute path. |
| 67 if (file_util::AbsolutePath(&user_data_dir) && | 66 if (file_util::AbsolutePath(&user_data_dir) && |
| 68 file_util::PathExists(user_data_dir)) { | 67 file_util::PathExists(user_data_dir)) { |
| 69 new_cmd_line.AppendSwitchPath(switches::kUserDataDir, user_data_dir); | 68 new_cmd_line.AppendSwitchPath(switches::kUserDataDir, user_data_dir); |
| 70 } | 69 } |
| 71 } | 70 } |
| 72 | 71 |
| 73 #if defined(OS_CHROMEOS) | 72 #if defined(OS_CHROMEOS) |
| 74 FilePath profile = cmd_line.GetSwitchValuePath(switches::kLoginProfile); | 73 FilePath profile = cmd_line.GetSwitchValuePath(switches::kLoginProfile); |
| 75 if (!profile.empty()) | 74 if (!profile.empty()) |
| 76 new_cmd_line.AppendSwitchPath(switches::kLoginProfile, profile); | 75 new_cmd_line.AppendSwitchPath(switches::kLoginProfile, profile); |
| 77 #else | 76 #else |
| 78 if (!profile_path.empty() && !extension_app_id.empty()) | 77 if (!profile_path.empty() && !extension_app_id.empty()) |
| 79 new_cmd_line.AppendSwitchPath(switches::kProfileDirectory, | 78 new_cmd_line.AppendSwitchPath(switches::kProfileDirectory, |
| 80 profile_path.BaseName()); | 79 profile_path.BaseName()); |
| 81 #endif | 80 #endif |
| 82 | 81 |
| 83 // If |extension_app_id| is present, we use the kAppId switch rather than | 82 // If |extension_app_id| is present, we use the kAppId switch rather than |
| 84 // the kApp switch (the launch url will be read from the extension app | 83 // the kApp switch (the launch url will be read from the extension app |
| 85 // during launch. | 84 // during launch. |
| 86 if (!extension_app_id.empty()) { | 85 if (!extension_app_id.empty()) { |
| 87 new_cmd_line.AppendSwitchASCII(switches::kAppId, extension_app_id); | 86 new_cmd_line.AppendSwitchASCII(switches::kAppId, extension_app_id); |
| 88 if (is_platform_app) | |
| 89 new_cmd_line.AppendSwitch(switches::kEnableExperimentalExtensionApis); | |
| 90 } else { | 87 } else { |
| 91 // Use '--app=url' instead of just 'url' to launch the browser with minimal | 88 // Use '--app=url' instead of just 'url' to launch the browser with minimal |
| 92 // chrome. | 89 // chrome. |
| 93 // Note: Do not change this flag! Old Gears shortcuts will break if you do! | 90 // Note: Do not change this flag! Old Gears shortcuts will break if you do! |
| 94 new_cmd_line.AppendSwitchASCII(switches::kApp, url.spec()); | 91 new_cmd_line.AppendSwitchASCII(switches::kApp, url.spec()); |
| 95 } | 92 } |
| 96 return new_cmd_line; | 93 return new_cmd_line; |
| 97 } | 94 } |
| 98 | 95 |
| 99 #if !defined(OS_WIN) | 96 #if !defined(OS_WIN) |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 | 260 |
| 264 ShellIntegration::DefaultWebClientState | 261 ShellIntegration::DefaultWebClientState |
| 265 ShellIntegration::DefaultProtocolClientWorker::CheckIsDefault() { | 262 ShellIntegration::DefaultProtocolClientWorker::CheckIsDefault() { |
| 266 return ShellIntegration::IsDefaultProtocolClient(protocol_); | 263 return ShellIntegration::IsDefaultProtocolClient(protocol_); |
| 267 } | 264 } |
| 268 | 265 |
| 269 bool ShellIntegration::DefaultProtocolClientWorker::SetAsDefault( | 266 bool ShellIntegration::DefaultProtocolClientWorker::SetAsDefault( |
| 270 bool interactive_permitted) { | 267 bool interactive_permitted) { |
| 271 return ShellIntegration::SetAsDefaultProtocolClient(protocol_); | 268 return ShellIntegration::SetAsDefaultProtocolClient(protocol_); |
| 272 } | 269 } |
| OLD | NEW |