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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 } | 114 } |
115 default: | 115 default: |
116 return CPERR_INVALID_VERSION; | 116 return CPERR_INVALID_VERSION; |
117 } | 117 } |
118 | 118 |
119 return CPERR_SUCCESS; | 119 return CPERR_SUCCESS; |
120 } | 120 } |
121 | 121 |
122 CPError CPB_GetCommandLineArgumentsCommon(const char* url, | 122 CPError CPB_GetCommandLineArgumentsCommon(const char* url, |
123 std::string* arguments) { | 123 std::string* arguments) { |
124 CommandLine cmd; | 124 const CommandLine cmd = *CommandLine::ForCurrentProcess(); |
125 std::wstring arguments_w; | 125 std::wstring arguments_w; |
126 | 126 |
127 // Use the same UserDataDir for new launches that we currently have set. | 127 // Use the same UserDataDir for new launches that we currently have set. |
128 std::wstring user_data_dir = cmd.GetSwitchValue(switches::kUserDataDir); | 128 std::wstring user_data_dir = cmd.GetSwitchValue(switches::kUserDataDir); |
129 if (!user_data_dir.empty()) { | 129 if (!user_data_dir.empty()) { |
130 // Make sure user_data_dir is an absolute path. | 130 // Make sure user_data_dir is an absolute path. |
131 wchar_t user_data_dir_full[MAX_PATH]; | 131 wchar_t user_data_dir_full[MAX_PATH]; |
132 if (_wfullpath(user_data_dir_full, user_data_dir.c_str(), MAX_PATH) && | 132 if (_wfullpath(user_data_dir_full, user_data_dir.c_str(), MAX_PATH) && |
133 file_util::PathExists(user_data_dir_full)) { | 133 file_util::PathExists(user_data_dir_full)) { |
134 CommandLine::AppendSwitchWithValue( | 134 arguments_w += std::wstring(L"--") + switches::kUserDataDir + |
135 &arguments_w, switches::kUserDataDir, user_data_dir_full); | 135 L'=' + user_data_dir_full; |
136 } | 136 } |
137 } | 137 } |
138 | 138 |
139 // Use '--app=url' instead of just 'url' to launch the browser with minimal | 139 // Use '--app=url' instead of just 'url' to launch the browser with minimal |
140 // chrome. | 140 // chrome. |
141 // Note: Do not change this flag! Old Gears shortcuts will break if you do! | 141 // Note: Do not change this flag! Old Gears shortcuts will break if you do! |
142 std::wstring url_w = UTF8ToWide(url); | 142 std::wstring url_w = UTF8ToWide(url); |
143 CommandLine::AppendSwitchWithValue(&arguments_w, switches::kApp, url_w); | 143 arguments_w += std::wstring(L"--") + switches::kApp + L'=' + url_w; |
144 | 144 |
145 *arguments = WideToUTF8(arguments_w); | 145 *arguments = WideToUTF8(arguments_w); |
146 | 146 |
147 return CPERR_SUCCESS; | 147 return CPERR_SUCCESS; |
148 } | 148 } |
149 | 149 |
150 // | 150 // |
151 // Host functions shared by browser and plugin processes | 151 // Host functions shared by browser and plugin processes |
152 // | 152 // |
153 | 153 |
154 void* STDCALL CPB_Alloc(uint32 size) { | 154 void* STDCALL CPB_Alloc(uint32 size) { |
155 return malloc(size); | 155 return malloc(size); |
156 } | 156 } |
157 | 157 |
158 void STDCALL CPB_Free(void* memory) { | 158 void STDCALL CPB_Free(void* memory) { |
159 free(memory); | 159 free(memory); |
160 } | 160 } |
161 | 161 |
OLD | NEW |