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

Unified Diff: chrome/browser/ui/host_desktop.cc

Issue 11146023: Work on separate browser contexts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: another busted command line flag Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/host_desktop.h ('k') | chrome/browser/ui/toolbar/wrench_menu_model.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/host_desktop.cc
diff --git a/chrome/browser/ui/host_desktop.cc b/chrome/browser/ui/host_desktop.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b1cdd1e40a01ee5cb3b635445000dde6b813625d
--- /dev/null
+++ b/chrome/browser/ui/host_desktop.cc
@@ -0,0 +1,72 @@
+// Copyright 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/host_desktop.h"
+
+#include "chrome/browser/ui/ash/ash_util.h"
+#include "chrome/browser/ui/browser_list_impl.h"
+
+namespace chrome {
+
+namespace {
+
+bool g_force_ = false;
+HostDesktopType g_force_type_ = HOST_DESKTOP_TYPE_COUNT;
+
+} // namespace
+
+ScopedForceDesktopType::ScopedForceDesktopType(HostDesktopType type)
+ : previous_type_(g_force_type_),
+ previous_force_(g_force_) {
+ g_force_type_ = type;
+ g_force_ = true;
+}
+
+ScopedForceDesktopType::~ScopedForceDesktopType() {
+ g_force_type_ = previous_type_;
+ g_force_ = previous_force_;
+}
+
+HostDesktopType GetHostDesktopTypeForNativeView(gfx::NativeView native_view) {
+ if (g_force_)
+ return g_force_type_;
+#if defined(USE_ASH)
+ return IsNativeViewInAsh(native_view) ?
+ HOST_DESKTOP_TYPE_ASH :
+ HOST_DESKTOP_TYPE_NATIVE;
+#else
+ return HOST_DESKTOP_TYPE_ASH;
+#endif
+}
+
+HostDesktopType GetHostDesktopTypeForNativeWindow(
+ gfx::NativeWindow native_window) {
+ if (g_force_)
+ return g_force_type_;
+#if defined(USE_ASH)
+ return IsNativeWindowInAsh(native_window) ?
+ HOST_DESKTOP_TYPE_ASH :
+ HOST_DESKTOP_TYPE_NATIVE;
+#else
+ return HOST_DESKTOP_TYPE_NATIVE;
+#endif
+}
+
+HostDesktopType GetHostDesktopTypeForBrowser(const Browser* browser) {
+ if (g_force_)
+ return g_force_type_;
+ for (HostDesktopType type = HOST_DESKTOP_TYPE_FIRST;
+ type < HOST_DESKTOP_TYPE_COUNT;
+ type = static_cast<HostDesktopType>(type + 1)) {
+ BrowserListImpl::const_iterator begin =
+ BrowserListImpl::GetInstance(type)->begin();
+ BrowserListImpl::const_iterator end =
+ BrowserListImpl::GetInstance(type)->end();
+ if (std::find(begin, end, browser) != end)
+ return type;
+ }
+ return HOST_DESKTOP_TYPE_NATIVE;
+}
+
+} // namespace chrome
« no previous file with comments | « chrome/browser/ui/host_desktop.h ('k') | chrome/browser/ui/toolbar/wrench_menu_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698