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.
5 #ifndef CHROME_BROWSER_EXTENSIONS_WINDOW_CONTROLLER_H_
6 #define CHROME_BROWSER_EXTENSIONS_WINDOW_CONTROLLER_H_
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
13 class Browser
; // TODO(stevenjb) eliminate this dependency.
19 class DictionaryValue
;
30 namespace extensions
{
33 // This API needs to be implemented by any window that might be accessed
34 // through chrome.windows or chrome.tabs (e.g. browser windows and panels).
35 // Subclasses must add/remove themselves from the WindowControllerList
36 // upon construction/destruction.
37 class WindowController
{
44 WindowController(ui::BaseWindow
* window
, Profile
* profile
);
45 virtual ~WindowController();
47 ui::BaseWindow
* window() const { return window_
; }
49 Profile
* profile() const { return profile_
; }
51 // Return an id uniquely identifying the window.
52 virtual int GetWindowId() const = 0;
54 // Return the type name for the window.
55 virtual std::string
GetWindowTypeText() const = 0;
57 // Populates a dictionary for the Window object. Override this to set
58 // implementation specific properties (call the base implementation first to
59 // set common properties).
60 virtual base::DictionaryValue
* CreateWindowValue() const;
62 // Populates a dictionary for the Window object, including a list of tabs.
63 virtual base::DictionaryValue
* CreateWindowValueWithTabs(
64 const extensions::Extension
* extension
) const = 0;
66 virtual base::DictionaryValue
* CreateTabValue(
67 const extensions::Extension
* extension
, int tab_index
) const = 0;
69 // Returns false if the window is in a state where closing the window is not
70 // permitted and sets |reason| if not NULL.
71 virtual bool CanClose(Reason
* reason
) const = 0;
73 // Set the window's fullscreen state. |extension_url| provides the url
74 // associated with the extension (used by FullscreenController).
75 virtual void SetFullscreenMode(bool is_fullscreen
,
76 const GURL
& extension_url
) const = 0;
78 // Returns a Browser if available. Defaults to returning NULL.
79 // TODO(stevenjb): Temporary workaround. Eliminate this.
80 virtual Browser
* GetBrowser() const;
82 // Extension/window visibility and ownership is window-specific, subclasses
83 // need to define this behavior.
84 virtual bool IsVisibleToExtension(const Extension
* extension
) const = 0;
87 ui::BaseWindow
* window_
;
90 DISALLOW_COPY_AND_ASSIGN(WindowController
);
93 } // namespace extensions
95 #endif // CHROME_BROWSER_EXTENSIONS_WINDOW_CONTROLLER_H_