Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1202)

Side by Side Diff: chrome/browser/ui/startup/startup_browser_creator_win.cc

Issue 10824387: Implement forwarding of search queries for metro mode (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/browser/ui/startup/startup_browser_creator_win.h" 5 #include "chrome/browser/ui/startup/startup_browser_creator_win.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/win/metro.h" 8 #include "base/win/metro.h"
9 #include "chrome/browser/search_engines/template_url.h" 9 #include "chrome/browser/search_engines/template_url.h"
10 #include "chrome/browser/search_engines/template_url_service.h" 10 #include "chrome/browser/search_engines/template_url_service.h"
11 #include "chrome/browser/search_engines/template_url_service_factory.h" 11 #include "chrome/browser/search_engines/template_url_service_factory.h"
12 12
13 namespace chrome { 13 namespace chrome {
14 14
15 // Metro driver exports for getting the launch type, initial url, initial 15 GURL GetURLToOpen(Profile* profile) {
16 // search term, etc. 16 string16 params;
17 extern "C" { 17 base::win::MetroLaunchType launch_type =
18 typedef const wchar_t* (*GetInitialUrl)(); 18 base::win::GetMetroLaunchParams(&params);
19 typedef const wchar_t* (*GetInitialSearchString)();
20 typedef base::win::MetroLaunchType (*GetLaunchType)(
21 base::win::MetroPreviousExecutionState* previous_state);
22 }
23 19
24 GURL GetURLToOpen(Profile* profile) { 20 if ((launch_type == base::win::METRO_PROTOCOL) ||
25 HMODULE metro = base::win::GetMetroModule(); 21 (launch_type == base::win::METRO_LAUNCH)) {
26 if (!metro) 22 return GURL(params);
27 return GURL(); 23 } else if (launch_type == base::win::METRO_SEARCH) {
28
29 GetLaunchType get_launch_type = reinterpret_cast<GetLaunchType>(
30 ::GetProcAddress(metro, "GetLaunchType"));
31 DCHECK(get_launch_type);
32
33 base::win::MetroLaunchType launch_type = get_launch_type(NULL);
34
35 if (launch_type == base::win::PROTOCOL || launch_type == base::win::LAUNCH) {
36 GetInitialUrl initial_metro_url = reinterpret_cast<GetInitialUrl>(
37 ::GetProcAddress(metro, "GetInitialUrl"));
38 DCHECK(initial_metro_url);
39 const wchar_t* initial_url = initial_metro_url();
40 if (initial_url)
41 return GURL(initial_url);
42 } else if (launch_type == base::win::SEARCH) {
43 GetInitialSearchString initial_search_string =
44 reinterpret_cast<GetInitialSearchString>(
45 ::GetProcAddress(metro, "GetInitialSearchString"));
46 DCHECK(initial_search_string);
47 string16 search_string = initial_search_string();
48
49 const TemplateURL* default_provider = 24 const TemplateURL* default_provider =
50 TemplateURLServiceFactory::GetForProfile(profile)-> 25 TemplateURLServiceFactory::GetForProfile(profile)->
51 GetDefaultSearchProvider(); 26 GetDefaultSearchProvider();
52 if (default_provider) { 27 if (default_provider) {
53 const TemplateURLRef& search_url = default_provider->url_ref(); 28 const TemplateURLRef& search_url = default_provider->url_ref();
54 DCHECK(search_url.SupportsReplacement()); 29 DCHECK(search_url.SupportsReplacement());
55 return GURL(search_url.ReplaceSearchTerms( 30 return GURL(search_url.ReplaceSearchTerms(
56 TemplateURLRef::SearchTermsArgs(search_string))); 31 TemplateURLRef::SearchTermsArgs(params)));
57 } 32 }
58 } 33 }
59 return GURL(); 34 return GURL();
60 } 35 }
61 36
62 } // namespace chrome 37 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698