| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/common/chrome_plugin_util.h" | 5 #include "chrome/common/chrome_plugin_util.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 std::string* arguments) { | 125 std::string* arguments) { |
| 126 const CommandLine cmd = *CommandLine::ForCurrentProcess(); | 126 const CommandLine cmd = *CommandLine::ForCurrentProcess(); |
| 127 std::wstring arguments_w; | 127 std::wstring arguments_w; |
| 128 | 128 |
| 129 // Use the same UserDataDir for new launches that we currently have set. | 129 // Use the same UserDataDir for new launches that we currently have set. |
| 130 std::wstring user_data_dir = cmd.GetSwitchValue(switches::kUserDataDir); | 130 std::wstring user_data_dir = cmd.GetSwitchValue(switches::kUserDataDir); |
| 131 if (!user_data_dir.empty()) { | 131 if (!user_data_dir.empty()) { |
| 132 // Make sure user_data_dir is an absolute path. | 132 // Make sure user_data_dir is an absolute path. |
| 133 if (file_util::AbsolutePath(&user_data_dir) && | 133 if (file_util::AbsolutePath(&user_data_dir) && |
| 134 file_util::PathExists(user_data_dir)) { | 134 file_util::PathExists(user_data_dir)) { |
| 135 arguments_w += std::wstring(L"--") + switches::kUserDataDir + | 135 // TODO(evanm): use CommandLine APIs instead of this. |
| 136 arguments_w += std::wstring(L"--") + ASCIIToWide(switches::kUserDataDir) + |
| 136 L"=\"" + user_data_dir + L"\" "; | 137 L"=\"" + user_data_dir + L"\" "; |
| 137 } | 138 } |
| 138 } | 139 } |
| 139 | 140 |
| 140 // Use '--app=url' instead of just 'url' to launch the browser with minimal | 141 // Use '--app=url' instead of just 'url' to launch the browser with minimal |
| 141 // chrome. | 142 // chrome. |
| 142 // Note: Do not change this flag! Old Gears shortcuts will break if you do! | 143 // Note: Do not change this flag! Old Gears shortcuts will break if you do! |
| 143 std::string url_string(url); | 144 std::string url_string(url); |
| 144 ReplaceSubstringsAfterOffset(&url_string, 0, "\"", "\\\""); | 145 ReplaceSubstringsAfterOffset(&url_string, 0, "\"", "\\\""); |
| 145 ReplaceSubstringsAfterOffset(&url_string, 0, "%", "%%"); | 146 ReplaceSubstringsAfterOffset(&url_string, 0, "%", "%%"); |
| 146 ReplaceSubstringsAfterOffset(&url_string, 0, ";", ""); | 147 ReplaceSubstringsAfterOffset(&url_string, 0, ";", ""); |
| 147 ReplaceSubstringsAfterOffset(&url_string, 0, "$", ""); | 148 ReplaceSubstringsAfterOffset(&url_string, 0, "$", ""); |
| 148 std::wstring url_w = UTF8ToWide(url_string); | 149 std::wstring url_w = UTF8ToWide(url_string); |
| 149 arguments_w += std::wstring(L"--") + switches::kApp + L"=\"" + url_w + L"\""; | 150 // TODO(evanm): use CommandLine APIs instead of this. |
| 151 arguments_w += std::wstring(L"--") + ASCIIToWide(switches::kApp) + |
| 152 L"=\"" + url_w + L"\""; |
| 150 | 153 |
| 151 *arguments = WideToUTF8(arguments_w); | 154 *arguments = WideToUTF8(arguments_w); |
| 152 | 155 |
| 153 return CPERR_SUCCESS; | 156 return CPERR_SUCCESS; |
| 154 } | 157 } |
| 155 | 158 |
| 156 // | 159 // |
| 157 // Host functions shared by browser and plugin processes | 160 // Host functions shared by browser and plugin processes |
| 158 // | 161 // |
| 159 | 162 |
| 160 void* STDCALL CPB_Alloc(uint32 size) { | 163 void* STDCALL CPB_Alloc(uint32 size) { |
| 161 return malloc(size); | 164 return malloc(size); |
| 162 } | 165 } |
| 163 | 166 |
| 164 void STDCALL CPB_Free(void* memory) { | 167 void STDCALL CPB_Free(void* memory) { |
| 165 free(memory); | 168 free(memory); |
| 166 } | 169 } |
| OLD | NEW |