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

Side by Side Diff: chrome/browser/ui/browser_init_win.cc

Issue 10383114: Rename BrowserInit to StartupBrowserCreator, and move into startup subdir. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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
« no previous file with comments | « chrome/browser/ui/browser_init_win.h ('k') | chrome/browser/ui/panels/panel_app_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "chrome/browser/ui/browser_init_win.h"
6
7 #include "base/logging.h"
8 #include "base/win/metro.h"
9
10 #include "chrome/browser/search_engines/template_url.h"
11 #include "chrome/browser/search_engines/template_url_service.h"
12 #include "chrome/browser/search_engines/template_url_service_factory.h"
13
14 namespace browser {
15
16 // Metro driver exports for getting the launch type, initial url, initial
17 // search term, etc.
18 extern "C" {
19 typedef const wchar_t* (*GetInitialUrl)();
20 typedef const wchar_t* (*GetInitialSearchString)();
21 typedef base::win::MetroLaunchType (*GetLaunchType)(
22 base::win::MetroPreviousExecutionState* previous_state);
23 }
24
25 GURL GetURLToOpen(Profile* profile) {
26 HMODULE metro = base::win::GetMetroModule();
27 if (!metro)
28 return GURL();
29
30 GetLaunchType get_launch_type = reinterpret_cast<GetLaunchType>(
31 ::GetProcAddress(metro, "GetLaunchType"));
32 DCHECK(get_launch_type);
33
34 base::win::MetroLaunchType launch_type = get_launch_type(NULL);
35
36 if (launch_type == base::win::PROTOCOL) {
37 GetInitialUrl initial_metro_url = reinterpret_cast<GetInitialUrl>(
38 ::GetProcAddress(metro, "GetInitialUrl"));
39 DCHECK(initial_metro_url);
40 const wchar_t* initial_url = initial_metro_url();
41 if (initial_url)
42 return GURL(initial_url);
43 } else if (launch_type == base::win::SEARCH) {
44 GetInitialSearchString initial_search_string =
45 reinterpret_cast<GetInitialSearchString>(
46 ::GetProcAddress(metro, "GetInitialSearchString"));
47 DCHECK(initial_search_string);
48 string16 search_string = initial_search_string();
49
50 const TemplateURL* default_provider =
51 TemplateURLServiceFactory::GetForProfile(profile)->
52 GetDefaultSearchProvider();
53 if (default_provider) {
54 const TemplateURLRef& search_url = default_provider->url_ref();
55 DCHECK(search_url.SupportsReplacement());
56 return GURL(search_url.ReplaceSearchTerms(search_string,
57 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16()));
58 }
59 }
60 return GURL();
61 }
62
63 } // namespace browser
64
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_init_win.h ('k') | chrome/browser/ui/panels/panel_app_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698