OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/window_controller.h" | 5 #include "chrome/browser/extensions/window_controller.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 8 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
9 #include "chrome/browser/extensions/window_controller_list.h" | 9 #include "chrome/browser/extensions/window_controller_list.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/common/extensions/api/windows.h" | |
11 #include "ui/base/base_window.h" | 12 #include "ui/base/base_window.h" |
12 #include "ui/gfx/geometry/rect.h" | 13 #include "ui/gfx/geometry/rect.h" |
13 | 14 |
14 namespace extensions { | 15 namespace extensions { |
15 | 16 |
16 /////////////////////////////////////////////////////////////////////////////// | 17 /////////////////////////////////////////////////////////////////////////////// |
17 // WindowController | 18 // WindowController |
18 | 19 |
20 // A set bitmask values to be used as a WindowTypeFilter. This enum | |
21 // needs to stay in sync with extensions::api::windows::WindowType. | |
22 enum WindowTypeFilterValues { | |
not at google - send to devlin
2015/08/05 17:33:25
Actually why do you even need this; can you use th
llandwerlin-old
2015/08/05 18:12:02
Done.
| |
23 WINDOW_TYPE_FILTER_NONE = 0, | |
24 WINDOW_TYPE_FILTER_NORMAL = 1 << 1, | |
25 WINDOW_TYPE_FILTER_POPUP = 1 << 2, | |
26 WINDOW_TYPE_FILTER_PANEL = 1 << 3, | |
27 WINDOW_TYPE_FILTER_APP = 1 << 4, | |
28 WINDOW_TYPE_FILTER_DEVTOOLS = 1 << 5 | |
29 }; | |
30 | |
31 // static | |
32 WindowTypeFilter WindowController::GetAllWindowFilter() { | |
33 // extensions::WindowTypeFilterValues needs to be updated if there | |
34 // is a change to extensions::api::windows:WindowType. | |
35 COMPILE_ASSERT( | |
36 api::windows::WINDOW_TYPE_LAST == api::windows::WINDOW_TYPE_DEVTOOLS, | |
37 Update_WindowControllerList_to_match_WindowType); | |
not at google - send to devlin
2015/08/05 17:33:25
I think this COMPILE_ASSERT can be left out. This
llandwerlin-old
2015/08/05 18:12:02
I want make sure that if someone adds a new window
not at google - send to devlin
2015/08/05 18:17:39
That makes sense.
| |
38 COMPILE_ASSERT( | |
39 (1 << api::windows::WINDOW_TYPE_DEVTOOLS) == WINDOW_TYPE_FILTER_DEVTOOLS, | |
40 Update_WindowControllerList_to_match_WindowType); | |
41 return (WINDOW_TYPE_FILTER_NORMAL | WINDOW_TYPE_FILTER_PANEL | | |
42 WINDOW_TYPE_FILTER_POPUP | WINDOW_TYPE_FILTER_APP | | |
43 WINDOW_TYPE_FILTER_DEVTOOLS); | |
44 } | |
45 | |
46 // static | |
47 WindowTypeFilter WindowController::GetDefaultWindowFilter() { | |
48 return (WINDOW_TYPE_FILTER_NORMAL | WINDOW_TYPE_FILTER_PANEL | | |
49 WINDOW_TYPE_FILTER_POPUP); | |
50 } | |
51 | |
19 WindowController::WindowController(ui::BaseWindow* window, Profile* profile) | 52 WindowController::WindowController(ui::BaseWindow* window, Profile* profile) |
20 : window_(window), profile_(profile) { | 53 : window_(window), profile_(profile) { |
21 } | 54 } |
22 | 55 |
23 WindowController::~WindowController() { | 56 WindowController::~WindowController() { |
24 } | 57 } |
25 | 58 |
26 Browser* WindowController::GetBrowser() const { | 59 Browser* WindowController::GetBrowser() const { |
27 return NULL; | 60 return NULL; |
28 } | 61 } |
(...skipping 27 matching lines...) Expand all Loading... | |
56 else | 89 else |
57 bounds = window()->GetBounds(); | 90 bounds = window()->GetBounds(); |
58 result->SetInteger(keys::kLeftKey, bounds.x()); | 91 result->SetInteger(keys::kLeftKey, bounds.x()); |
59 result->SetInteger(keys::kTopKey, bounds.y()); | 92 result->SetInteger(keys::kTopKey, bounds.y()); |
60 result->SetInteger(keys::kWidthKey, bounds.width()); | 93 result->SetInteger(keys::kWidthKey, bounds.width()); |
61 result->SetInteger(keys::kHeightKey, bounds.height()); | 94 result->SetInteger(keys::kHeightKey, bounds.height()); |
62 | 95 |
63 return result; | 96 return result; |
64 } | 97 } |
65 | 98 |
99 bool WindowController::MatchesFilter(WindowTypeFilter filter) const { | |
100 WindowTypeFilter type = 1 | |
101 << api::windows::ParseWindowType(GetWindowTypeText()); | |
102 return (type & filter) != 0; | |
103 } | |
104 | |
66 } // namespace extensions | 105 } // namespace extensions |
OLD | NEW |