| 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 #ifndef CHROME_BROWSER_EXTENSIONS_WINDOW_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_WINDOW_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_WINDOW_CONTROLLER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_WINDOW_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "chrome/common/extensions/api/windows.h" |
| 12 | 13 |
| 13 class Browser; // TODO(stevenjb) eliminate this dependency. | 14 class Browser; // TODO(stevenjb) eliminate this dependency. |
| 14 class GURL; | 15 class GURL; |
| 15 class Profile; | 16 class Profile; |
| 16 class SessionID; | 17 class SessionID; |
| 17 | 18 |
| 18 namespace base { | 19 namespace base { |
| 19 class DictionaryValue; | 20 class DictionaryValue; |
| 20 } | 21 } |
| 21 | 22 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 34 // through chrome.windows or chrome.tabs (e.g. browser windows and panels). | 35 // through chrome.windows or chrome.tabs (e.g. browser windows and panels). |
| 35 // Subclasses must add/remove themselves from the WindowControllerList | 36 // Subclasses must add/remove themselves from the WindowControllerList |
| 36 // upon construction/destruction. | 37 // upon construction/destruction. |
| 37 class WindowController { | 38 class WindowController { |
| 38 public: | 39 public: |
| 39 enum Reason { | 40 enum Reason { |
| 40 REASON_NONE, | 41 REASON_NONE, |
| 41 REASON_NOT_EDITABLE, | 42 REASON_NOT_EDITABLE, |
| 42 }; | 43 }; |
| 43 | 44 |
| 45 // A bitmaks used as filter on window types. |
| 46 using TypeFilter = uint32_t; |
| 47 |
| 48 // Returns a filter allowing all window types to be manipulated |
| 49 // through the chrome.windows APIs. |
| 50 static TypeFilter GetAllWindowFilter(); |
| 51 |
| 52 // Returns the default filter to be used when operating on the windows |
| 53 // from WindowControllerList when using the chrome.windows APIs. |
| 54 static TypeFilter GetDefaultWindowFilter(); |
| 55 |
| 56 // Builds a filter out of a vector of window types. |
| 57 static TypeFilter GetFilterFromWindowTypes( |
| 58 const std::vector<api::windows::WindowType>& types); |
| 59 |
| 44 WindowController(ui::BaseWindow* window, Profile* profile); | 60 WindowController(ui::BaseWindow* window, Profile* profile); |
| 45 virtual ~WindowController(); | 61 virtual ~WindowController(); |
| 46 | 62 |
| 47 ui::BaseWindow* window() const { return window_; } | 63 ui::BaseWindow* window() const { return window_; } |
| 48 | 64 |
| 49 Profile* profile() const { return profile_; } | 65 Profile* profile() const { return profile_; } |
| 50 | 66 |
| 51 // Return an id uniquely identifying the window. | 67 // Return an id uniquely identifying the window. |
| 52 virtual int GetWindowId() const = 0; | 68 virtual int GetWindowId() const = 0; |
| 53 | 69 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 76 const GURL& extension_url) const = 0; | 92 const GURL& extension_url) const = 0; |
| 77 | 93 |
| 78 // Returns a Browser if available. Defaults to returning NULL. | 94 // Returns a Browser if available. Defaults to returning NULL. |
| 79 // TODO(stevenjb): Temporary workaround. Eliminate this. | 95 // TODO(stevenjb): Temporary workaround. Eliminate this. |
| 80 virtual Browser* GetBrowser() const; | 96 virtual Browser* GetBrowser() const; |
| 81 | 97 |
| 82 // Extension/window visibility and ownership is window-specific, subclasses | 98 // Extension/window visibility and ownership is window-specific, subclasses |
| 83 // need to define this behavior. | 99 // need to define this behavior. |
| 84 virtual bool IsVisibleToExtension(const Extension* extension) const = 0; | 100 virtual bool IsVisibleToExtension(const Extension* extension) const = 0; |
| 85 | 101 |
| 102 // Returns true if the window type of the controller matches the |filter|. |
| 103 bool MatchesFilter(TypeFilter filter) const; |
| 104 |
| 86 private: | 105 private: |
| 87 ui::BaseWindow* window_; | 106 ui::BaseWindow* window_; |
| 88 Profile* profile_; | 107 Profile* profile_; |
| 89 | 108 |
| 90 DISALLOW_COPY_AND_ASSIGN(WindowController); | 109 DISALLOW_COPY_AND_ASSIGN(WindowController); |
| 91 }; | 110 }; |
| 92 | 111 |
| 93 } // namespace extensions | 112 } // namespace extensions |
| 94 | 113 |
| 95 #endif // CHROME_BROWSER_EXTENSIONS_WINDOW_CONTROLLER_H_ | 114 #endif // CHROME_BROWSER_EXTENSIONS_WINDOW_CONTROLLER_H_ |
| OLD | NEW |