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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_METRO_DRIVER_CHROME_URL_LAUNCH_HANDLER_H_
6 #define CHROME_BROWSER_UI_METRO_DRIVER_CHROME_URL_LAUNCH_HANDLER_H_
9 #include <windows.applicationmodel.core.h>
10 #include <Windows.applicationModel.search.h>
11 #include <windows.ui.core.h>
13 #include "winrt_utils.h"
15 // This class handles the various flavors of URL launches in metro, i.e.
16 // via the search charm, via a url being navigated from a metro app, etc.
17 class ChromeUrlLaunchHandler
{
19 ChromeUrlLaunchHandler();
20 ~ChromeUrlLaunchHandler();
24 // If metro chrome was launched due to a URL navigation/search request then
25 // the navigation should be done when the frame window is initialized. This
26 // function is called to complete the pending navigation when we receive a
27 // notification from chrome that the frame window is initialized.
28 void PerformPendingNavigation();
30 void Activate(winapp::Activation::IActivatedEventArgs
* args
);
33 // Invoked when we receive search notifications in metro chrome.
34 template<class T
> void HandleSearchRequest(T
* args
);
36 HRESULT
OnQuerySubmitted(
37 winapp::Search::ISearchPane
* search_pane
,
38 winapp::Search::ISearchPaneQuerySubmittedEventArgs
* args
);
40 base::string16
GetUrlFromLaunchArgs(const base::string16
& launch_args
);
42 // Invoked when a url is navigated from a metro app or in the metro
44 void HandleProtocolLaunch(
45 winapp::Activation::IProtocolActivatedEventArgs
* args
);
47 // Invoked when the app is launched normally
48 void HandleLaunch(winapp::Activation::ILaunchActivatedEventArgs
* args
);
50 // Helper function to initiate a navigation or search request in chrome.
51 void InitiateNavigationOrSearchRequest(const wchar_t* url
,
52 const wchar_t* search_string
);
54 Microsoft::WRL::ComPtr
<winapp::Search::ISearchPane
> search_pane_
;
55 EventRegistrationToken query_submitted_token_
;
58 #endif // CHROME_BROWSER_UI_METRO_DRIVER_CHROME_URL_LAUNCH_HANDLER_H_