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 "chrome/browser/ui/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | |
8 #include "base/win/metro.h" | |
9 #include "chrome/browser/bookmarks/bookmark_utils.h" | |
10 #include "chrome/browser/profiles/profile.h" | |
11 #include "chrome/browser/ui/browser_commands.h" | |
12 #include "chrome/browser/ui/browser_finder.h" | |
13 #include "chrome/browser/ui/browser_tabstrip.h" | |
14 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" | 7 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" |
15 #include "win8/util/win8_util.h" | |
16 | |
17 namespace { | |
18 | |
19 void NewWindowMaybeMetro(Browser* source_browser, Profile* profile) { | |
20 chrome::HostDesktopType host_desktop_type = | |
21 source_browser->host_desktop_type(); | |
22 if (win8::IsSingleWindowMetroMode()) { | |
23 typedef void (*FlipFrameWindows)(); | |
24 | |
25 static FlipFrameWindows flip_window_fn = reinterpret_cast<FlipFrameWindows>( | |
26 ::GetProcAddress(base::win::GetMetroModule(), "FlipFrameWindows")); | |
27 DCHECK(flip_window_fn); | |
28 | |
29 Browser* browser = chrome::FindTabbedBrowser(profile, false, | |
30 host_desktop_type); | |
31 | |
32 if (!browser) { | |
33 chrome::OpenEmptyWindow(profile, host_desktop_type); | |
34 return; | |
35 } | |
36 | |
37 chrome::NewTab(browser); | |
38 | |
39 if (browser != source_browser) { | |
40 // Tell the metro_driver to flip our window. This causes the current | |
41 // browser window to be hidden and the next window to be shown. | |
42 flip_window_fn(); | |
43 } | |
44 } else { | |
45 NewEmptyWindow(profile, host_desktop_type); | |
46 } | |
47 } | |
48 | |
49 } // namespace | |
50 | |
51 namespace chrome { | |
52 | |
53 void NewWindow(Browser* browser) { | |
54 NewWindowMaybeMetro(browser, browser->profile()->GetOriginalProfile()); | |
55 } | |
56 | |
57 void NewIncognitoWindow(Browser* browser) { | |
58 NewWindowMaybeMetro(browser, browser->profile()->GetOffTheRecordProfile()); | |
59 } | |
60 | |
61 } // namespace chrome | |
62 | 8 |
63 void Browser::SetMetroSnapMode(bool enable) { | 9 void Browser::SetMetroSnapMode(bool enable) { |
64 fullscreen_controller_->SetMetroSnapMode(enable); | 10 fullscreen_controller_->SetMetroSnapMode(enable); |
65 } | 11 } |
OLD | NEW |