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 // static |
| 21 WindowController::TypeFilter WindowController::GetAllWindowFilter() { |
| 22 // This needs to be updated if there is a change to |
| 23 // extensions::api::windows:WindowType. |
| 24 COMPILE_ASSERT(api::windows::WINDOW_TYPE_LAST == 5, |
| 25 Update_extensions_WindowController_to_match_WindowType); |
| 26 return ((1 << api::windows::WINDOW_TYPE_NORMAL) | |
| 27 (1 << api::windows::WINDOW_TYPE_PANEL) | |
| 28 (1 << api::windows::WINDOW_TYPE_POPUP) | |
| 29 (1 << api::windows::WINDOW_TYPE_APP) | |
| 30 (1 << api::windows::WINDOW_TYPE_DEVTOOLS)); |
| 31 } |
| 32 |
| 33 // static |
| 34 WindowController::TypeFilter WindowController::GetDefaultWindowFilter() { |
| 35 return ((1 << api::windows::WINDOW_TYPE_NORMAL) | |
| 36 (1 << api::windows::WINDOW_TYPE_PANEL) | |
| 37 (1 << api::windows::WINDOW_TYPE_POPUP)); |
| 38 } |
| 39 |
| 40 WindowController::TypeFilter WindowController::GetFilterFromWindowTypes( |
| 41 const std::vector<api::windows::WindowType>& types) { |
| 42 WindowController::TypeFilter filter = 0; |
| 43 for (auto& window_type : types) |
| 44 filter |= 1 << window_type; |
| 45 return filter; |
| 46 } |
| 47 |
19 WindowController::WindowController(ui::BaseWindow* window, Profile* profile) | 48 WindowController::WindowController(ui::BaseWindow* window, Profile* profile) |
20 : window_(window), profile_(profile) { | 49 : window_(window), profile_(profile) { |
21 } | 50 } |
22 | 51 |
23 WindowController::~WindowController() { | 52 WindowController::~WindowController() { |
24 } | 53 } |
25 | 54 |
26 Browser* WindowController::GetBrowser() const { | 55 Browser* WindowController::GetBrowser() const { |
27 return NULL; | 56 return NULL; |
28 } | 57 } |
(...skipping 27 matching lines...) Expand all Loading... |
56 else | 85 else |
57 bounds = window()->GetBounds(); | 86 bounds = window()->GetBounds(); |
58 result->SetInteger(keys::kLeftKey, bounds.x()); | 87 result->SetInteger(keys::kLeftKey, bounds.x()); |
59 result->SetInteger(keys::kTopKey, bounds.y()); | 88 result->SetInteger(keys::kTopKey, bounds.y()); |
60 result->SetInteger(keys::kWidthKey, bounds.width()); | 89 result->SetInteger(keys::kWidthKey, bounds.width()); |
61 result->SetInteger(keys::kHeightKey, bounds.height()); | 90 result->SetInteger(keys::kHeightKey, bounds.height()); |
62 | 91 |
63 return result; | 92 return result; |
64 } | 93 } |
65 | 94 |
| 95 bool WindowController::MatchesFilter(TypeFilter filter) const { |
| 96 TypeFilter type = 1 << api::windows::ParseWindowType(GetWindowTypeText()); |
| 97 return (type & filter) != 0; |
| 98 } |
| 99 |
66 } // namespace extensions | 100 } // namespace extensions |
OLD | NEW |