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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 DVLOG(1) << "OnQuerySubmitted"; | 65 DVLOG(1) << "OnQuerySubmitted"; |
66 HandleSearchRequest(args); | 66 HandleSearchRequest(args); |
67 return S_OK; | 67 return S_OK; |
68 } | 68 } |
69 | 69 |
70 template<class T> | 70 template<class T> |
71 void ChromeUrlLaunchHandler::HandleSearchRequest(T* args) { | 71 void ChromeUrlLaunchHandler::HandleSearchRequest(T* args) { |
72 DVLOG(1) << __FUNCTION__; | 72 DVLOG(1) << __FUNCTION__; |
73 mswrw::HString search_string; | 73 mswrw::HString search_string; |
74 args->get_QueryText(search_string.GetAddressOf()); | 74 args->get_QueryText(search_string.GetAddressOf()); |
75 string16 search_text(MakeStdWString(search_string.Get())); | 75 base::string16 search_text(MakeStdWString(search_string.Get())); |
76 globals.search_string = search_text; | 76 globals.search_string = search_text; |
77 DVLOG(1) << search_text.c_str(); | 77 DVLOG(1) << search_text.c_str(); |
78 // If this is the initial activation then we wait for Chrome to initiate the | 78 // If this is the initial activation then we wait for Chrome to initiate the |
79 // navigation. In all other cases navigate right away. | 79 // navigation. In all other cases navigate right away. |
80 if (!globals.is_initial_activation) | 80 if (!globals.is_initial_activation) |
81 InitiateNavigationOrSearchRequest(NULL, globals.search_string.c_str()); | 81 InitiateNavigationOrSearchRequest(NULL, globals.search_string.c_str()); |
82 } | 82 } |
83 | 83 |
84 void ChromeUrlLaunchHandler::HandleProtocolLaunch( | 84 void ChromeUrlLaunchHandler::HandleProtocolLaunch( |
85 winapp::Activation::IProtocolActivatedEventArgs* args) { | 85 winapp::Activation::IProtocolActivatedEventArgs* args) { |
86 DVLOG(1) << __FUNCTION__; | 86 DVLOG(1) << __FUNCTION__; |
87 mswr::ComPtr<winfoundtn::IUriRuntimeClass> uri; | 87 mswr::ComPtr<winfoundtn::IUriRuntimeClass> uri; |
88 args->get_Uri(&uri); | 88 args->get_Uri(&uri); |
89 mswrw::HString url; | 89 mswrw::HString url; |
90 uri->get_AbsoluteUri(url.GetAddressOf()); | 90 uri->get_AbsoluteUri(url.GetAddressOf()); |
91 string16 actual_url(MakeStdWString(url.Get())); | 91 base::string16 actual_url(MakeStdWString(url.Get())); |
92 globals.navigation_url = actual_url; | 92 globals.navigation_url = actual_url; |
93 | 93 |
94 // If this is the initial activation then we wait for Chrome to initiate the | 94 // If this is the initial activation then we wait for Chrome to initiate the |
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 base::string16 ChromeUrlLaunchHandler::GetUrlFromLaunchArgs( |
104 const string16& launch_args) { | 104 const base::string16& launch_args) { |
105 if (launch_args == L"opennewwindow") { | 105 if (launch_args == L"opennewwindow") { |
106 VLOG(1) << "Returning new tab url"; | 106 VLOG(1) << "Returning new tab url"; |
107 return L"chrome://newtab"; | 107 return L"chrome://newtab"; |
108 } | 108 } |
109 string16 dummy_command_line(L"dummy.exe "); | 109 base::string16 dummy_command_line(L"dummy.exe "); |
110 dummy_command_line.append(launch_args); | 110 dummy_command_line.append(launch_args); |
111 CommandLine command_line = CommandLine::FromString(dummy_command_line); | 111 CommandLine command_line = CommandLine::FromString(dummy_command_line); |
112 CommandLine::StringVector args = command_line.GetArgs(); | 112 CommandLine::StringVector args = command_line.GetArgs(); |
113 if (args.size() > 0) | 113 if (args.size() > 0) |
114 return args[0]; | 114 return args[0]; |
115 | 115 |
116 return string16(); | 116 return base::string16(); |
117 } | 117 } |
118 | 118 |
119 void ChromeUrlLaunchHandler::HandleLaunch( | 119 void ChromeUrlLaunchHandler::HandleLaunch( |
120 winapp::Activation::ILaunchActivatedEventArgs* args) { | 120 winapp::Activation::ILaunchActivatedEventArgs* args) { |
121 mswrw::HString launch_args; | 121 mswrw::HString launch_args; |
122 args->get_Arguments(launch_args.GetAddressOf()); | 122 args->get_Arguments(launch_args.GetAddressOf()); |
123 string16 actual_launch_args(MakeStdWString(launch_args.Get())); | 123 base::string16 actual_launch_args(MakeStdWString(launch_args.Get())); |
124 globals.navigation_url = GetUrlFromLaunchArgs(actual_launch_args); | 124 globals.navigation_url = GetUrlFromLaunchArgs(actual_launch_args); |
125 DVLOG(1) << __FUNCTION__ << ", launch_args=" << actual_launch_args | 125 DVLOG(1) << __FUNCTION__ << ", launch_args=" << actual_launch_args |
126 << ", url=" << globals.navigation_url | 126 << ", url=" << globals.navigation_url |
127 << ", is_initial_activation=" << globals.is_initial_activation; | 127 << ", is_initial_activation=" << globals.is_initial_activation; |
128 | 128 |
129 // If this is the initial launch then we wait for Chrome to initiate the | 129 // If this is the initial launch then we wait for Chrome to initiate the |
130 // navigation. In all other cases navigate right away. | 130 // navigation. In all other cases navigate right away. |
131 if (!globals.is_initial_activation) | 131 if (!globals.is_initial_activation) |
132 InitiateNavigationOrSearchRequest(globals.navigation_url.c_str(), 0); | 132 InitiateNavigationOrSearchRequest(globals.navigation_url.c_str(), 0); |
133 } | 133 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 if (url) { | 197 if (url) { |
198 VLOG(1) << "Posting url:" << url; | 198 VLOG(1) << "Posting url:" << url; |
199 PostMessage(globals.host_windows.front().first, navigation_search_message, | 199 PostMessage(globals.host_windows.front().first, navigation_search_message, |
200 reinterpret_cast<WPARAM>(url), 0); | 200 reinterpret_cast<WPARAM>(url), 0); |
201 } else { | 201 } else { |
202 VLOG(1) << "Posting search string:" << search_string; | 202 VLOG(1) << "Posting search string:" << search_string; |
203 PostMessage(globals.host_windows.front().first, navigation_search_message, | 203 PostMessage(globals.host_windows.front().first, navigation_search_message, |
204 0, reinterpret_cast<LPARAM>(search_string)); | 204 0, reinterpret_cast<LPARAM>(search_string)); |
205 } | 205 } |
206 } | 206 } |
OLD | NEW |