blob: eb1e2f6843cdf86716926939ba1c4bdc498b3e37 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/browser.h"
#include "base/utf_string_conversions.h"
#include "base/win/metro.h"
#include "chrome/browser/bookmarks/bookmark_utils.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
namespace {
void NewMetroWindow(Browser* source_browser, Profile* profile) {
typedef void (*FlipFrameWindows)();
static FlipFrameWindows flip_window_fn = reinterpret_cast<FlipFrameWindows>(
::GetProcAddress(base::win::GetMetroModule(), "FlipFrameWindows"));
DCHECK(flip_window_fn);
Browser* browser = browser::FindTabbedBrowser(profile, false);
if (!browser) {
Browser::OpenEmptyWindow(profile);
return;
}
browser->NewTab();
if (browser != source_browser) {
// Tell the metro_driver to flip our window. This causes the current
// browser window to be hidden and the next window to be shown.
flip_window_fn();
}
}
} // namespace
void Browser::NewWindow() {
if (base::win::GetMetroModule()) {
NewMetroWindow(this, profile_->GetOriginalProfile());
return;
}
NewEmptyWindow(profile_->GetOriginalProfile());
}
void Browser::NewIncognitoWindow() {
if (base::win::GetMetroModule()) {
NewMetroWindow(this, profile_->GetOffTheRecordProfile());
return;
}
NewEmptyWindow(profile_->GetOffTheRecordProfile());
}
void Browser::PinCurrentPageToStartScreen() {
HMODULE metro_module = base::win::GetMetroModule();
if (metro_module) {
GURL url;
string16 title;
TabContents* tab = GetActiveTabContents();
bookmark_utils::GetURLAndTitleToBookmark(tab->web_contents(), &url, &title);
typedef BOOL (*MetroPinUrlToStartScreen)(string16, string16);
MetroPinUrlToStartScreen metro_pin_url_to_start_screen =
reinterpret_cast<MetroPinUrlToStartScreen>(
::GetProcAddress(metro_module, "MetroPinUrlToStartScreen"));
if (!metro_pin_url_to_start_screen) {
NOTREACHED();
return;
}
VLOG(1) << __FUNCTION__ << " calling pin with title: " << title
<< " and url " << UTF8ToUTF16(url.spec());
metro_pin_url_to_start_screen(title, UTF8ToUTF16(url.spec()));
return;
}
}
|