diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-31 18:13:20 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-31 18:13:20 +0000 |
commit | 8daec68f1b4acf5ecc760232daed383c0b0d81cf (patch) | |
tree | 7c8344456a720022d1c879781ac8b40ffc5b907f /chrome/browser/ui/browser_win.cc | |
parent | f0725be61ccb6a524a2219352763b9c57380d18c (diff) | |
download | chromium_src-8daec68f1b4acf5ecc760232daed383c0b0d81cf.zip chromium_src-8daec68f1b4acf5ecc760232daed383c0b0d81cf.tar.gz chromium_src-8daec68f1b4acf5ecc760232daed383c0b0d81cf.tar.bz2 |
In metro chrome we want to prevent creation of new browser windows. This change hooks the new window/new incognito
window operations which are triggered via the wrench and the Ctrl+N/Ctrl+Shift+N accelerators and attempts to create
regular/incognito tabs instead.
Changes to the context menu and bookmark manager to follow.
BUG=124404
R=sky
Review URL: https://chromiumcodereview.appspot.com/10447098
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139819 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/browser_win.cc')
-rw-r--r-- | chrome/browser/ui/browser_win.cc | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/chrome/browser/ui/browser_win.cc b/chrome/browser/ui/browser_win.cc new file mode 100644 index 0000000..c4181a8 --- /dev/null +++ b/chrome/browser/ui/browser_win.cc @@ -0,0 +1,51 @@ +// 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/win/metro.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/browser_finder.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()); +} |