[email protected] | 41d9faf | 2012-02-28 23:46:02 | [diff] [blame] | 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 | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | 44f4b13 | 2012-07-17 20:36:57 | [diff] [blame^] | 5 | #ifndef CHROME_BROWSER_EXTENSIONS_WINDOW_CONTROLLER_H_ |
6 | #define CHROME_BROWSER_EXTENSIONS_WINDOW_CONTROLLER_H_ | ||||
[email protected] | 41d9faf | 2012-02-28 23:46:02 | [diff] [blame] | 7 | |
[email protected] | c80ed69 | 2012-04-18 19:51:10 | [diff] [blame] | 8 | #include <string> |
9 | |||||
[email protected] | 41d9faf | 2012-02-28 23:46:02 | [diff] [blame] | 10 | #include "base/basictypes.h" |
11 | #include "base/compiler_specific.h" | ||||
12 | |||||
13 | class BaseWindow; | ||||
[email protected] | b51f3562 | 2012-05-05 22:01:43 | [diff] [blame] | 14 | class Browser; // TODO(stevenjb) eliminate this dependency. |
[email protected] | 41d9faf | 2012-02-28 23:46:02 | [diff] [blame] | 15 | class GURL; |
16 | class Profile; | ||||
17 | class SessionID; | ||||
18 | |||||
19 | namespace base { | ||||
20 | class DictionaryValue; | ||||
21 | } | ||||
22 | |||||
23 | namespace gfx { | ||||
24 | class Rect; | ||||
25 | } | ||||
26 | |||||
[email protected] | 44f4b13 | 2012-07-17 20:36:57 | [diff] [blame^] | 27 | namespace extensions { |
28 | class Extension; | ||||
29 | |||||
[email protected] | 41d9faf | 2012-02-28 23:46:02 | [diff] [blame] | 30 | // This API needs to be implemented by any window that might be accessed |
31 | // through chrome.windows or chrome.tabs (e.g. browser windows and panels). | ||||
[email protected] | 44f4b13 | 2012-07-17 20:36:57 | [diff] [blame^] | 32 | class WindowController { |
[email protected] | 41d9faf | 2012-02-28 23:46:02 | [diff] [blame] | 33 | public: |
34 | enum Reason { | ||||
35 | REASON_NONE, | ||||
[email protected] | b51f3562 | 2012-05-05 22:01:43 | [diff] [blame] | 36 | REASON_NOT_EDITABLE, |
[email protected] | 41d9faf | 2012-02-28 23:46:02 | [diff] [blame] | 37 | }; |
[email protected] | b51f3562 | 2012-05-05 22:01:43 | [diff] [blame] | 38 | |
[email protected] | 44f4b13 | 2012-07-17 20:36:57 | [diff] [blame^] | 39 | WindowController(BaseWindow* window, Profile* profile); |
40 | virtual ~WindowController(); | ||||
[email protected] | 41d9faf | 2012-02-28 23:46:02 | [diff] [blame] | 41 | |
42 | BaseWindow* window() const { return window_; } | ||||
43 | |||||
[email protected] | b51f3562 | 2012-05-05 22:01:43 | [diff] [blame] | 44 | Profile* profile() const { return profile_; } |
45 | |||||
[email protected] | c80ed69 | 2012-04-18 19:51:10 | [diff] [blame] | 46 | // Return an id uniquely identifying the window. |
47 | virtual int GetWindowId() const = 0; | ||||
48 | |||||
49 | // Return the type name for the window. | ||||
50 | virtual std::string GetWindowTypeText() const = 0; | ||||
[email protected] | 41d9faf | 2012-02-28 23:46:02 | [diff] [blame] | 51 | |
[email protected] | b51f3562 | 2012-05-05 22:01:43 | [diff] [blame] | 52 | // Populates a dictionary for the Window object. Override this to set |
53 | // implementation specific properties (call the base implementation first to | ||||
54 | // set common properties). | ||||
55 | virtual base::DictionaryValue* CreateWindowValue() const; | ||||
56 | |||||
[email protected] | 41d9faf | 2012-02-28 23:46:02 | [diff] [blame] | 57 | // Populates a dictionary for the Window object, including a list of tabs. |
58 | virtual base::DictionaryValue* CreateWindowValueWithTabs() const = 0; | ||||
59 | |||||
60 | // Returns false if the window is in a state where closing the window is not | ||||
61 | // permitted and sets |reason| if not NULL. | ||||
62 | virtual bool CanClose(Reason* reason) const = 0; | ||||
63 | |||||
64 | // Set the window's fullscreen state. |extension_url| provides the url | ||||
65 | // associated with the extension (used by FullscreenController). | ||||
66 | virtual void SetFullscreenMode(bool is_fullscreen, | ||||
67 | const GURL& extension_url) const = 0; | ||||
68 | |||||
[email protected] | b51f3562 | 2012-05-05 22:01:43 | [diff] [blame] | 69 | // Returns a Browser if available. Defaults to returning NULL. |
70 | // TODO(stevenjb): Temporary workaround. Eliminate this. | ||||
71 | virtual Browser* GetBrowser() const; | ||||
72 | |||||
[email protected] | 31bdbfef | 2012-05-22 19:59:15 | [diff] [blame] | 73 | // Extension/window visibility and ownership is window-specific, subclasses |
74 | // need to define this behavior. | ||||
[email protected] | 44f4b13 | 2012-07-17 20:36:57 | [diff] [blame^] | 75 | virtual bool IsVisibleToExtension(const Extension* extension) const = 0; |
[email protected] | 31bdbfef | 2012-05-22 19:59:15 | [diff] [blame] | 76 | |
[email protected] | 41d9faf | 2012-02-28 23:46:02 | [diff] [blame] | 77 | private: |
78 | BaseWindow* window_; | ||||
79 | Profile* profile_; | ||||
80 | |||||
[email protected] | 44f4b13 | 2012-07-17 20:36:57 | [diff] [blame^] | 81 | DISALLOW_COPY_AND_ASSIGN(WindowController); |
[email protected] | 41d9faf | 2012-02-28 23:46:02 | [diff] [blame] | 82 | }; |
83 | |||||
[email protected] | 44f4b13 | 2012-07-17 20:36:57 | [diff] [blame^] | 84 | } // namespace extensions |
85 | |||||
86 | #endif // CHROME_BROWSER_EXTENSIONS_WINDOW_CONTROLLER_H_ |