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