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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 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.
4
5 #include "chrome/browser/ui/host_desktop.h"
6
7 #include "chrome/browser/ui/ash/ash_util.h"
8 #include "chrome/browser/ui/browser_list_impl.h"
9
10 namespace chrome {
11
12 namespace {
13
14 bool g_force_ = false;
15 HostDesktopType g_force_type_ = HOST_DESKTOP_TYPE_COUNT;
16
17 } // namespace
18
19 ScopedForceDesktopType::ScopedForceDesktopType(HostDesktopType type)
20 : previous_type_(g_force_type_),
21 previous_force_(g_force_) {
22 g_force_type_ = type;
23 g_force_ = true;
24 }
25
26 ScopedForceDesktopType::~ScopedForceDesktopType() {
27 g_force_type_ = previous_type_;
28 g_force_ = previous_force_;
29 }
30
31 HostDesktopType GetHostDesktopTypeForNativeView(gfx::NativeView native_view) {
32 if (g_force_)
33 return g_force_type_;
34 #if defined(USE_ASH)
35 return IsNativeViewInAsh(native_view) ?
36 HOST_DESKTOP_TYPE_ASH :
37 HOST_DESKTOP_TYPE_NATIVE;
38 #else
39 return HOST_DESKTOP_TYPE_ASH;
40 #endif
41 }
42
43 HostDesktopType GetHostDesktopTypeForNativeWindow(
44 gfx::NativeWindow native_window) {
45 if (g_force_)
46 return g_force_type_;
47 #if defined(USE_ASH)
48 return IsNativeWindowInAsh(native_window) ?
49 HOST_DESKTOP_TYPE_ASH :
50 HOST_DESKTOP_TYPE_NATIVE;
51 #else
52 return HOST_DESKTOP_TYPE_NATIVE;
53 #endif
54 }
55
56 HostDesktopType GetHostDesktopTypeForBrowser(const Browser* browser) {
57 if (g_force_)
58 return g_force_type_;
59 for (HostDesktopType type = HOST_DESKTOP_TYPE_FIRST;
60 type < HOST_DESKTOP_TYPE_COUNT;
61 type = static_cast<HostDesktopType>(type + 1)) {
62 BrowserListImpl::const_iterator begin =
63 BrowserListImpl::GetInstance(type)->begin();
64 BrowserListImpl::const_iterator end =
65 BrowserListImpl::GetInstance(type)->end();
66 if (std::find(begin, end, browser) != end)
67 return type;
68 }
69 return HOST_DESKTOP_TYPE_NATIVE;
70 }
71
72 } // namespace chrome
OLDNEW
« 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