blob: 601c3bbbe295f41f0f2ed005f49ece3b6f8ca28b [file] [log] [blame]
[email protected]41d9faf2012-02-28 23:46:021// 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
3// found in the LICENSE file.
4
[email protected]44f4b132012-07-17 20:36:575#include "chrome/browser/extensions/window_controller.h"
[email protected]41d9faf2012-02-28 23:46:026
avia2f4804a2015-12-24 23:11:137#include <stddef.h>
8
dcheng85f24da2016-05-20 22:20:269#include <memory>
10
[email protected]41d9faf2012-02-28 23:46:0211#include "base/values.h"
[email protected]b19451b2012-06-08 17:36:1912#include "chrome/browser/extensions/api/tabs/tabs_constants.h"
[email protected]44f4b132012-07-17 20:36:5713#include "chrome/browser/extensions/window_controller_list.h"
[email protected]41d9faf2012-02-28 23:46:0214#include "chrome/browser/profiles/profile.h"
lionel.g.landwerlin56b2a722015-08-06 00:04:1015#include "chrome/common/extensions/api/windows.h"
Ivan Sandrkc30341b2017-11-09 19:13:2616
[email protected]44f4b132012-07-17 20:36:5717namespace extensions {
18
[email protected]41d9faf2012-02-28 23:46:0219///////////////////////////////////////////////////////////////////////////////
[email protected]44f4b132012-07-17 20:36:5720// WindowController
[email protected]41d9faf2012-02-28 23:46:0221
lionel.g.landwerlin56b2a722015-08-06 00:04:1022// static
23WindowController::TypeFilter WindowController::GetAllWindowFilter() {
24 // This needs to be updated if there is a change to
25 // extensions::api::windows:WindowType.
avi0cc1cac2015-11-24 19:12:1326 static_assert(api::windows::WINDOW_TYPE_LAST == 5,
27 "Update extensions WindowController to match WindowType");
lionel.g.landwerlin56b2a722015-08-06 00:04:1028 return ((1 << api::windows::WINDOW_TYPE_NORMAL) |
29 (1 << api::windows::WINDOW_TYPE_PANEL) |
30 (1 << api::windows::WINDOW_TYPE_POPUP) |
31 (1 << api::windows::WINDOW_TYPE_APP) |
32 (1 << api::windows::WINDOW_TYPE_DEVTOOLS));
33}
34
35// static
lionel.g.landwerlin56b2a722015-08-06 00:04:1036WindowController::TypeFilter WindowController::GetFilterFromWindowTypes(
37 const std::vector<api::windows::WindowType>& types) {
lionel.g.landwerlin63f0e25e2015-08-24 21:26:5738 WindowController::TypeFilter filter = kNoWindowFilter;
lionel.g.landwerlin56b2a722015-08-06 00:04:1039 for (auto& window_type : types)
40 filter |= 1 << window_type;
41 return filter;
42}
43
lionel.g.landwerlin63f0e25e2015-08-24 21:26:5744// static
45WindowController::TypeFilter WindowController::GetFilterFromWindowTypesValues(
46 const base::ListValue* types) {
47 WindowController::TypeFilter filter = WindowController::kNoWindowFilter;
48 if (!types)
49 return filter;
50 for (size_t i = 0; i < types->GetSize(); i++) {
51 std::string window_type;
52 if (types->GetString(i, &window_type))
53 filter |= 1 << api::windows::ParseWindowType(window_type);
54 }
55 return filter;
56}
57
[email protected]5f39adc2013-05-23 11:50:4658WindowController::WindowController(ui::BaseWindow* window, Profile* profile)
[email protected]44f4b132012-07-17 20:36:5759 : window_(window), profile_(profile) {
[email protected]41d9faf2012-02-28 23:46:0260}
61
[email protected]44f4b132012-07-17 20:36:5762WindowController::~WindowController() {
[email protected]41d9faf2012-02-28 23:46:0263}
64
[email protected]44f4b132012-07-17 20:36:5765Browser* WindowController::GetBrowser() const {
David Bienvenu27be7932020-08-20 20:41:2766 return nullptr;
[email protected]b51f35622012-05-05 22:01:4367}
68
lionel.g.landwerlin56b2a722015-08-06 00:04:1069bool WindowController::MatchesFilter(TypeFilter filter) const {
70 TypeFilter type = 1 << api::windows::ParseWindowType(GetWindowTypeText());
71 return (type & filter) != 0;
72}
73
Sangwoo Ko26256e922020-07-31 05:12:4074void WindowController::NotifyWindowBoundsChanged() {
75 WindowControllerList::GetInstance()->NotifyWindowBoundsChanged(this);
76}
77
[email protected]44f4b132012-07-17 20:36:5778} // namespace extensions