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 5#ifndef CHROME_BROWSER_EXTENSIONS_WINDOW_CONTROLLER_H_ 6#define CHROME_BROWSER_EXTENSIONS_WINDOW_CONTROLLER_H_ 7 8#include <string> 9 10#include "base/basictypes.h" 11#include "base/compiler_specific.h" 12 13class Browser; // TODO(stevenjb) eliminate this dependency. 14class GURL; 15class Profile; 16class SessionID; 17 18namespace base { 19class DictionaryValue; 20} 21 22namespace gfx { 23class Rect; 24} 25 26namespace ui { 27class BaseWindow; 28} 29 30namespace extensions { 31class Extension; 32 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. 37class WindowController { 38 public: 39 enum Reason { 40 REASON_NONE, 41 REASON_NOT_EDITABLE, 42 }; 43 44 WindowController(ui::BaseWindow* window, Profile* profile); 45 virtual ~WindowController(); 46 47 ui::BaseWindow* window() const { return window_; } 48 49 Profile* profile() const { return profile_; } 50 51 // Return an id uniquely identifying the window. 52 virtual int GetWindowId() const = 0; 53 54 // Return the type name for the window. 55 virtual std::string GetWindowTypeText() const = 0; 56 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; 61 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; 65 66 virtual base::DictionaryValue* CreateTabValue( 67 const extensions::Extension* extension, int tab_index) const = 0; 68 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; 72 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; 77 78 // Returns a Browser if available. Defaults to returning NULL. 79 // TODO(stevenjb): Temporary workaround. Eliminate this. 80 virtual Browser* GetBrowser() const; 81 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; 85 86 private: 87 ui::BaseWindow* window_; 88 Profile* profile_; 89 90 DISALLOW_COPY_AND_ASSIGN(WindowController); 91}; 92 93} // namespace extensions 94 95#endif // CHROME_BROWSER_EXTENSIONS_WINDOW_CONTROLLER_H_ 96