1a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// found in the LICENSE file. 490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 5a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#ifndef CHROME_BROWSER_EXTENSIONS_WINDOW_CONTROLLER_H_ 690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#define CHROME_BROWSER_EXTENSIONS_WINDOW_CONTROLLER_H_ 790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include <string> 990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 1090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "base/basictypes.h" 1190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "base/compiler_specific.h" 12868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 13a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)class Browser; // TODO(stevenjb) eliminate this dependency. 1490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)class GURL; 1590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)class Profile; 1690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)class SessionID; 1790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 181320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccinamespace base { 197d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)class DictionaryValue; 207d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)} 217d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 227d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)namespace gfx { 237d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)class Rect; 247d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)} 2590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 2690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)namespace ui { 2790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)class BaseWindow; 2890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} 2990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 3090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)namespace extensions { 3190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)class Extension; 3290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 3390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// This API needs to be implemented by any window that might be accessed 3490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// through chrome.windows or chrome.tabs (e.g. browser windows and panels). 3590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Subclasses must add/remove themselves from the WindowControllerList 3690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// upon construction/destruction. 3790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)class WindowController { 3890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) public: 3990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) enum Reason { 4090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) REASON_NONE, 4190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) REASON_NOT_EDITABLE, 42a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) }; 43a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 44a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) WindowController(ui::BaseWindow* window, Profile* profile); 45a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) virtual ~WindowController(); 46a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 47a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) ui::BaseWindow* window() const { return window_; } 48a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 49a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) Profile* profile() const { return profile_; } 50a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 51a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Return an id uniquely identifying the window. 52a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) virtual int GetWindowId() const = 0; 53a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 54a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // Return the type name for the window. 55a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) virtual std::string GetWindowTypeText() const = 0; 56a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 57a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // Populates a dictionary for the Window object. Override this to set 58a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // implementation specific properties (call the base implementation first to 59a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // set common properties). 6090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) virtual base::DictionaryValue* CreateWindowValue() const; 613551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) 62a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // Populates a dictionary for the Window object, including a list of tabs. 633551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) virtual base::DictionaryValue* CreateWindowValueWithTabs( 643551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) const extensions::Extension* extension) const = 0; 653551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) 66a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) virtual base::DictionaryValue* CreateTabValue( 67a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const extensions::Extension* extension, int tab_index) const = 0; 683551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) 693551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) // Returns false if the window is in a state where closing the window is not 703551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) // permitted and sets |reason| if not NULL. 713551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) virtual bool CanClose(Reason* reason) const = 0; 72a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 73a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Set the window's fullscreen state. |extension_url| provides the url 74a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // associated with the extension (used by FullscreenController). 75a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) virtual void SetFullscreenMode(bool is_fullscreen, 7690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const GURL& extension_url) const = 0; 775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 7890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Returns a Browser if available. Defaults to returning NULL. 7990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // TODO(stevenjb): Temporary workaround. Eliminate this. 800529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch virtual Browser* GetBrowser() const; 810529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch 8290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Extension/window visibility and ownership is window-specific, subclasses 8390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // need to define this behavior. 8490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) virtual bool IsVisibleToExtension(const Extension* extension) const = 0; 8590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 8690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) private: 8790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) ui::BaseWindow* window_; 8890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) Profile* profile_; 8990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 9090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(WindowController); 9190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)}; 9290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 9390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} // namespace extensions 94116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 95116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#endif // CHROME_BROWSER_EXTENSIONS_WINDOW_CONTROLLER_H_ 9690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)