blob: 6e82bed8860cb248c1b1b1735e84a41c2f91faa0 [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#ifndef CHROME_BROWSER_EXTENSIONS_WINDOW_CONTROLLER_H_
6#define CHROME_BROWSER_EXTENSIONS_WINDOW_CONTROLLER_H_
[email protected]41d9faf2012-02-28 23:46:027
[email protected]c80ed692012-04-18 19:51:108#include <string>
9
[email protected]41d9faf2012-02-28 23:46:0210#include "base/basictypes.h"
11#include "base/compiler_specific.h"
12
13class BaseWindow;
[email protected]b51f35622012-05-05 22:01:4314class Browser; // TODO(stevenjb) eliminate this dependency.
[email protected]41d9faf2012-02-28 23:46:0215class GURL;
16class Profile;
17class SessionID;
18
19namespace base {
20class DictionaryValue;
21}
22
23namespace gfx {
24class Rect;
25}
26
[email protected]44f4b132012-07-17 20:36:5727namespace extensions {
28class Extension;
29
[email protected]41d9faf2012-02-28 23:46:0230// 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]44f4b132012-07-17 20:36:5732class WindowController {
[email protected]41d9faf2012-02-28 23:46:0233 public:
34 enum Reason {
35 REASON_NONE,
[email protected]b51f35622012-05-05 22:01:4336 REASON_NOT_EDITABLE,
[email protected]41d9faf2012-02-28 23:46:0237 };
[email protected]b51f35622012-05-05 22:01:4338
[email protected]44f4b132012-07-17 20:36:5739 WindowController(BaseWindow* window, Profile* profile);
40 virtual ~WindowController();
[email protected]41d9faf2012-02-28 23:46:0241
42 BaseWindow* window() const { return window_; }
43
[email protected]b51f35622012-05-05 22:01:4344 Profile* profile() const { return profile_; }
45
[email protected]c80ed692012-04-18 19:51:1046 // 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]41d9faf2012-02-28 23:46:0251
[email protected]b51f35622012-05-05 22:01:4352 // 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]41d9faf2012-02-28 23:46:0257 // 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]b51f35622012-05-05 22:01:4369 // Returns a Browser if available. Defaults to returning NULL.
70 // TODO(stevenjb): Temporary workaround. Eliminate this.
71 virtual Browser* GetBrowser() const;
72
[email protected]31bdbfef2012-05-22 19:59:1573 // Extension/window visibility and ownership is window-specific, subclasses
74 // need to define this behavior.
[email protected]44f4b132012-07-17 20:36:5775 virtual bool IsVisibleToExtension(const Extension* extension) const = 0;
[email protected]31bdbfef2012-05-22 19:59:1576
[email protected]41d9faf2012-02-28 23:46:0277 private:
78 BaseWindow* window_;
79 Profile* profile_;
80
[email protected]44f4b132012-07-17 20:36:5781 DISALLOW_COPY_AND_ASSIGN(WindowController);
[email protected]41d9faf2012-02-28 23:46:0282};
83
[email protected]44f4b132012-07-17 20:36:5784} // namespace extensions
85
86#endif // CHROME_BROWSER_EXTENSIONS_WINDOW_CONTROLLER_H_