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

Side by Side Diff: chrome/browser/ui/host_desktop.cc

Issue 11030017: Add context to gfx::Screen calls in support of simultaneous desktop+ash (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tidy 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
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 force_ = false;
15 HostDesktopType force_type_ = HOST_DESKTOP_TYPE_COUNT;
16
17 } // namespace
18
19 ScopedForceDesktopType::ScopedForceDesktopType(HostDesktopType type)
20 : previous_type_(force_type_),
21 previous_force_(force_) {
22 force_type_ = type;
23 force_ = true;
24 }
25
26 ScopedForceDesktopType::~ScopedForceDesktopType() {
27 force_type_ = previous_type_;
28 force_ = previous_force_;
29 }
30
31 HostDesktopType GetHostDesktopTypeForNativeView(gfx::NativeView native_view) {
32 if (force_)
33 return force_type_;
34 return IsNativeViewInAsh(native_view) ?
35 HOST_DESKTOP_TYPE_ASH :
36 HOST_DESKTOP_TYPE_NATIVE;
37 }
38
39 HostDesktopType GetHostDesktopTypeForNativeWindow(
40 gfx::NativeWindow native_window) {
41 if (force_)
42 return force_type_;
43 return IsNativeWindowInAsh(native_window) ?
44 HOST_DESKTOP_TYPE_ASH :
45 HOST_DESKTOP_TYPE_NATIVE;
46 }
47
48 HostDesktopType GetHostDesktopTypeForBrowser(const Browser* browser) {
49 if (force_)
50 return force_type_;
51 for (HostDesktopType type = HOST_DESKTOP_TYPE_FIRST;
52 type < HOST_DESKTOP_TYPE_COUNT;
53 type = static_cast<HostDesktopType>(type + 1)) {
54 BrowserListImpl::const_iterator begin =
55 BrowserListImpl::GetInstance(type)->begin();
56 BrowserListImpl::const_iterator end =
57 BrowserListImpl::GetInstance(type)->end();
58 if (find(begin, end, browser) != end)
59 return type;
60 }
61 return HOST_DESKTOP_TYPE_NATIVE;
62 }
63
64 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698