Make default apps cache multiprofile friendly
[chromium-blink-merge.git] / chrome / browser / extensions / window_controller.h
blobf21a0fa83086e54d5c13b7a1531b0c2dfdb55b40
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_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
13 class Browser; // TODO(stevenjb) eliminate this dependency.
14 class GURL;
15 class Profile;
16 class SessionID;
18 namespace base {
19 class DictionaryValue;
22 namespace gfx {
23 class Rect;
26 namespace ui {
27 class BaseWindow;
30 namespace extensions {
31 class Extension;
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 {
38 public:
39 enum Reason {
40 REASON_NONE,
41 REASON_NOT_EDITABLE,
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;
86 private:
87 ui::BaseWindow* window_;
88 Profile* profile_;
90 DISALLOW_COPY_AND_ASSIGN(WindowController);
93 } // namespace extensions
95 #endif // CHROME_BROWSER_EXTENSIONS_WINDOW_CONTROLLER_H_