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 "stdafx.h" | 5 #include "stdafx.h" |
6 #include "chrome_url_launch_handler.h" | 6 #include "chrome_url_launch_handler.h" |
7 #include "chrome_app_view.h" | 7 #include "chrome_app_view.h" |
8 | 8 |
9 #include <assert.h> | 9 #include <assert.h> |
10 #include <shellapi.h> | 10 #include <shellapi.h> |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 // navigation. In all other cases navigate right away. | 95 // navigation. In all other cases navigate right away. |
96 if (!globals.is_initial_activation) | 96 if (!globals.is_initial_activation) |
97 InitiateNavigationOrSearchRequest(globals.navigation_url.c_str(), 0); | 97 InitiateNavigationOrSearchRequest(globals.navigation_url.c_str(), 0); |
98 } | 98 } |
99 | 99 |
100 // |launch_args| is an encoded command line, minus the executable name. To | 100 // |launch_args| is an encoded command line, minus the executable name. To |
101 // find the URL to launch the first argument is used. If any other parameters | 101 // find the URL to launch the first argument is used. If any other parameters |
102 // are encoded in |launch_args| they are ignored. | 102 // are encoded in |launch_args| they are ignored. |
103 string16 ChromeUrlLaunchHandler::GetUrlFromLaunchArgs( | 103 string16 ChromeUrlLaunchHandler::GetUrlFromLaunchArgs( |
104 const string16& launch_args) { | 104 const string16& launch_args) { |
| 105 if (launch_args == L"opennewwindow") { |
| 106 VLOG(1) << "Returning new tab url"; |
| 107 return L"chrome://newtab"; |
| 108 } |
105 string16 dummy_command_line(L"dummy.exe "); | 109 string16 dummy_command_line(L"dummy.exe "); |
106 dummy_command_line.append(launch_args); | 110 dummy_command_line.append(launch_args); |
107 CommandLine command_line = CommandLine::FromString(dummy_command_line); | 111 CommandLine command_line = CommandLine::FromString(dummy_command_line); |
108 CommandLine::StringVector args = command_line.GetArgs(); | 112 CommandLine::StringVector args = command_line.GetArgs(); |
109 if (args.size() > 0) | 113 if (args.size() > 0) |
110 return args[0]; | 114 return args[0]; |
111 | 115 |
112 return string16(); | 116 return string16(); |
113 } | 117 } |
114 | 118 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 const wchar_t* url, const wchar_t* search_string) { | 176 const wchar_t* url, const wchar_t* search_string) { |
173 DVLOG(1) << __FUNCTION__; | 177 DVLOG(1) << __FUNCTION__; |
174 if (!url && !search_string) { | 178 if (!url && !search_string) { |
175 NOTREACHED(); | 179 NOTREACHED(); |
176 return; | 180 return; |
177 } | 181 } |
178 | 182 |
179 DVLOG(1) << (url ? url : L"NULL url"); | 183 DVLOG(1) << (url ? url : L"NULL url"); |
180 DVLOG(1) << (search_string ? search_string : L"NULL search string"); | 184 DVLOG(1) << (search_string ? search_string : L"NULL search string"); |
181 | 185 |
| 186 if (globals.host_windows.empty()) { |
| 187 DVLOG(1) << "No chrome windows registered. Ignoring nav request"; |
| 188 return; |
| 189 } |
| 190 |
182 // Custom registered message to navigate or search in chrome. WPARAM | 191 // Custom registered message to navigate or search in chrome. WPARAM |
183 // points to the URL and LPARAM contains the search string. They are | 192 // points to the URL and LPARAM contains the search string. They are |
184 // mutually exclusive. | 193 // mutually exclusive. |
185 static const UINT navigation_search_message = | 194 static const UINT navigation_search_message = |
186 RegisterWindowMessage(kMetroNavigationAndSearchMessage); | 195 RegisterWindowMessage(kMetroNavigationAndSearchMessage); |
187 | 196 |
188 if (url) { | 197 if (url) { |
189 VLOG(1) << "Posting url:" << url; | 198 VLOG(1) << "Posting url:" << url; |
190 PostMessage(globals.host_windows.front().first, navigation_search_message, | 199 PostMessage(globals.host_windows.front().first, navigation_search_message, |
191 reinterpret_cast<WPARAM>(url), 0); | 200 reinterpret_cast<WPARAM>(url), 0); |
192 } else { | 201 } else { |
193 VLOG(1) << "Posting search string:" << search_string; | 202 VLOG(1) << "Posting search string:" << search_string; |
194 PostMessage(globals.host_windows.front().first, navigation_search_message, | 203 PostMessage(globals.host_windows.front().first, navigation_search_message, |
195 0, reinterpret_cast<LPARAM>(search_string)); | 204 0, reinterpret_cast<LPARAM>(search_string)); |
196 } | 205 } |
197 } | 206 } |
OLD | NEW |