Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / startup / startup_browser_creator_win.cc
blobf946e774ca3a2a2f447cb8dccd58c6057e884b0d
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 #include "chrome/browser/ui/startup/startup_browser_creator_win.h"
7 #include "base/logging.h"
8 #include "base/win/metro.h"
9 #include "chrome/browser/search_engines/util.h"
10 #include "chrome/browser/ui/browser_finder.h"
11 #include "chrome/browser/ui/browser_window.h"
12 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h"
13 #include "chrome/common/url_constants.h"
14 #include "win8/util/win8_util.h"
16 namespace chrome {
18 GURL GetURLToOpen(Profile* profile) {
19 base::string16 params;
20 base::win::MetroLaunchType launch_type =
21 base::win::GetMetroLaunchParams(&params);
22 if ((launch_type == base::win::METRO_PROTOCOL) ||
23 (launch_type == base::win::METRO_LAUNCH))
24 return GURL(params);
25 return (launch_type == base::win::METRO_SEARCH) ?
26 GetDefaultSearchURLForSearchTerms(profile, params) : GURL();
29 } // namespace chrome
31 // static
32 bool StartupBrowserCreatorImpl::OpenStartupURLsInExistingBrowser(
33 Profile* profile,
34 const std::vector<GURL>& startup_urls) {
35 if (!win8::IsSingleWindowMetroMode())
36 return false;
38 // We activate an existing browser window if we are opening just the new tab
39 // page in metro mode.
40 if (startup_urls.size() > 1)
41 return false;
43 if (startup_urls[0] != GURL(chrome::kChromeUINewTabURL))
44 return false;
46 Browser* browser = chrome::FindBrowserWithProfile(
47 profile, chrome::HOST_DESKTOP_TYPE_NATIVE);
49 if (!browser)
50 return false;
52 browser->window()->Show();
53 return true;