12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_BROWSER_UI_GTK_BROWSER_WINDOW_GTK_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_BROWSER_UI_GTK_BROWSER_WINDOW_GTK_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <gtk/gtk.h> 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string> 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/basictypes.h" 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/compiler_specific.h" 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/scoped_ptr.h" 152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/prefs/pref_member.h" 16eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "base/timer/timer.h" 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "build/build_config.h" 182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/devtools/devtools_window.h" 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/extensions/extension_keybinding_registry.h" 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/infobars/infobar_container.h" 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/browser_window.h" 222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/ui/host_desktop.h" 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/tabs/tab_strip_model_observer.h" 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/base/gtk/gtk_signal.h" 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/base/ui_base_types.h" 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/base/x/active_window_watcher_x_observer.h" 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/base/x/x11_util.h" 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/gfx/rect.h" 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class BookmarkBarGtk; 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Browser; 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class BrowserTitlebar; 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class BrowserToolbarGtk; 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class DevToolsWindow; 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class DownloadShelfGtk; 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ExtensionKeybindingRegistryGtk; 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class FindBarGtk; 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class FullscreenExitBubbleGtk; 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class GlobalMenuBar; 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class InfoBarContainerGtk; 412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class InstantOverlayControllerGtk; 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class LocationBar; 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class StatusBubbleGtk; 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class TabContentsContainerGtk; 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class TabStripGtk; 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace autofill { 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class PasswordGenerator; 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace extensions { 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ActiveTabPermissionGranter; 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Extension; 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 56c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)namespace user_prefs { 57c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)class PrefRegistrySyncable; 58c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} 59c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 60c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// An implementation of BrowserWindow for GTK. Cross-platform code will interact 61c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// with this object when it needs to manipulate the window. 62b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)class BrowserWindowGtk 63b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) : public BrowserWindow, 64b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) public content::NotificationObserver, 65b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) public TabStripModelObserver, 66b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) public ui::ActiveWindowWatcherXObserver, 67b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) public InfoBarContainer::Delegate, 68b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) public extensions::ExtensionKeybindingRegistry::Delegate { 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) explicit BrowserWindowGtk(Browser* browser); 715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual ~BrowserWindowGtk(); 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Separating initialization from constructor. 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void Init(); 755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Overridden from BrowserWindow: 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void Show() OVERRIDE; 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ShowInactive() OVERRIDE; 795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void Hide() OVERRIDE; 805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; 815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void Close() OVERRIDE; 825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void Activate() OVERRIDE; 835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void Deactivate() OVERRIDE; 845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool IsActive() const OVERRIDE; 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void FlashFrame(bool flash) OVERRIDE; 865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool IsAlwaysOnTop() const OVERRIDE; 875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual gfx::NativeWindow GetNativeWindow() OVERRIDE; 885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual BrowserWindowTesting* GetBrowserWindowTesting() OVERRIDE; 895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual StatusBubble* GetStatusBubble() OVERRIDE; 905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void UpdateTitleBar() OVERRIDE; 915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void BookmarkBarStateChanged( 925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) BookmarkBar::AnimateChangeType change_type) OVERRIDE; 935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void UpdateDevTools() OVERRIDE; 945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void UpdateLoadingAnimations(bool should_animate) OVERRIDE; 955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void SetStarredState(bool is_starred) OVERRIDE; 965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ZoomChangedForActiveTab(bool can_show_bubble) OVERRIDE; 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual gfx::Rect GetRestoredBounds() const OVERRIDE; 98b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) virtual ui::WindowShowState GetRestoredState() const OVERRIDE; 995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual gfx::Rect GetBounds() const OVERRIDE; 1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool IsMaximized() const OVERRIDE; 1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool IsMinimized() const OVERRIDE; 1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void Maximize() OVERRIDE; 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void Minimize() OVERRIDE; 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void Restore() OVERRIDE; 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void EnterFullscreen( 1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const GURL& url, FullscreenExitBubbleType type) OVERRIDE; 1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ExitFullscreen() OVERRIDE; 1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void UpdateFullscreenExitBubbleContent( 1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const GURL& url, 1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) FullscreenExitBubbleType bubble_type) OVERRIDE; 1112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual bool ShouldHideUIForFullscreen() const OVERRIDE; 1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool IsFullscreen() const OVERRIDE; 1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool IsFullscreenBubbleVisible() const OVERRIDE; 1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual LocationBar* GetLocationBar() const OVERRIDE; 1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void SetFocusToLocationBar(bool select_all) OVERRIDE; 1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void UpdateReloadStopState(bool is_loading, bool force) OVERRIDE; 1172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void UpdateToolbar(content::WebContents* contents, 1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool should_restore_state) OVERRIDE; 1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void FocusToolbar() OVERRIDE; 1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void FocusAppMenu() OVERRIDE; 1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void FocusBookmarksToolbar() OVERRIDE; 122c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) virtual void FocusInfobars() OVERRIDE; 1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void RotatePaneFocus(bool forwards) OVERRIDE; 1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool IsBookmarkBarVisible() const OVERRIDE; 1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool IsBookmarkBarAnimating() const OVERRIDE; 1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool IsTabStripEditable() const OVERRIDE; 1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool IsToolbarVisible() const OVERRIDE; 1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE; 1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ConfirmAddSearchProvider(TemplateURL* template_url, 1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Profile* profile) OVERRIDE; 1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ToggleBookmarkBar() OVERRIDE; 1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ShowUpdateChromeDialog() OVERRIDE; 1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ShowBookmarkBubble(const GURL& url, 1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool already_bookmarked) OVERRIDE; 1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(ENABLE_ONE_CLICK_SIGNIN) 1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ShowOneClickSigninBubble( 1372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) OneClickSigninBubbleType type, 138c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) const string16& email, 139c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) const string16& error_message, 1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const StartSyncCallback& start_sync_callback) OVERRIDE; 1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif 1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool IsDownloadShelfVisible() const OVERRIDE; 1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual DownloadShelf* GetDownloadShelf() OVERRIDE; 1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ConfirmBrowserCloseWithPendingDownloads() OVERRIDE; 1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void UserChangedTheme() OVERRIDE; 1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual int GetExtraRenderViewHeight() const OVERRIDE; 1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void WebContentsFocused(content::WebContents* contents) OVERRIDE; 1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ShowWebsiteSettings(Profile* profile, 1492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) content::WebContents* web_contents, 1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const GURL& url, 1517dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch const content::SSLStatus& ssl) OVERRIDE; 1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ShowAppMenu() OVERRIDE; 1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool PreHandleKeyboardEvent( 1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const content::NativeWebKeyboardEvent& event, 1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool* is_keyboard_shortcut) OVERRIDE; 1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void HandleKeyboardEvent( 1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const content::NativeWebKeyboardEvent& event) OVERRIDE; 1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ShowCreateChromeAppShortcutsDialog( 1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Profile* profile, 1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const extensions::Extension* app) OVERRIDE; 1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void Cut() OVERRIDE; 1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void Copy() OVERRIDE; 1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void Paste() OVERRIDE; 1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual WindowOpenDisposition GetDispositionForPopupBounds( 1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const gfx::Rect& bounds) OVERRIDE; 1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual FindBar* CreateFindBar() OVERRIDE; 16790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) virtual web_modal::WebContentsModalDialogHost* 16890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) GetWebContentsModalDialogHost() OVERRIDE; 1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ShowAvatarBubble(content::WebContents* web_contents, 1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const gfx::Rect& rect) OVERRIDE; 1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ShowAvatarBubbleFromAvatarButton() OVERRIDE; 1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ShowPasswordGenerationBubble( 1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const gfx::Rect& rect, 1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const content::PasswordForm& form, 1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) autofill::PasswordGenerator* password_generator) OVERRIDE; 1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Overridden from NotificationObserver: 1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void Observe(int type, 1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const content::NotificationSource& source, 1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const content::NotificationDetails& details) OVERRIDE; 1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Overridden from TabStripModelObserver: 1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void TabDetachedAt(content::WebContents* contents, 1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int index) OVERRIDE; 1852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void ActiveTabChanged(content::WebContents* old_contents, 1862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) content::WebContents* new_contents, 1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int index, 188c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) int reason) OVERRIDE; 1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Overridden from ActiveWindowWatcherXObserver. 1915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ActiveWindowChanged(GdkWindow* active_window) OVERRIDE; 1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Overridden from InfoBarContainer::Delegate: 1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual SkColor GetInfoBarSeparatorColor() const OVERRIDE; 1955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void InfoBarContainerStateChanged(bool is_animating) OVERRIDE; 1965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool DrawInfoBarArrows(int* x) const OVERRIDE; 1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Overridden from ExtensionKeybindingRegistry::Delegate: 1995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual extensions::ActiveTabPermissionGranter* 2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GetActiveTabPermissionGranter() OVERRIDE; 2015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Accessor for the tab strip. 2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TabStripGtk* tabstrip() const { return tabstrip_.get(); } 2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void OnDebouncedBoundsChanged(); 2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Request the underlying window to unmaximize. 2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void UnMaximize(); 2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns false if we're not ready to close yet. E.g., a tab may have an 2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // onbeforeunload handler that prevents us from closing. 2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool CanClose() const; 2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns whether to draw the content drop shadow on the sides and bottom 2155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // of the browser window. When false, we still draw a shadow on the top of 2165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the toolbar (under the tab strip), but do not round the top corners. 2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool ShouldDrawContentDropShadow() const; 2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool ShouldShowWindowIcon() const; 2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Add the find bar widget to the window hierarchy. 2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void AddFindBar(FindBarGtk* findbar); 2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Reset the mouse cursor to the default cursor if it was set to something 2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // else for the custom frame. 2265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void ResetCustomFrameCursor(); 2275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the BrowserWindowGtk registered with |window|. 2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static BrowserWindowGtk* GetBrowserWindowForNativeWindow( 2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::NativeWindow window); 2315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Retrieves the GtkWindow associated with |xid|, which is the X Window 2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // ID of the top-level X window of this object. 2345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static GtkWindow* GetBrowserWindowForXID(XID xid); 2355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Browser* browser() const { return browser_.get(); } 2375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GtkWindow* window() const { return window_; } 2395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) BrowserTitlebar* titlebar() const { return titlebar_.get(); } 2415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GtkWidget* titlebar_widget() const; 2435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) BrowserToolbarGtk* GetToolbar() { return toolbar_.get(); } 2455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect bounds() const { return bounds_; } 2475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the tab we're currently displaying in the tab contents container. 2492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) content::WebContents* GetDisplayedTab(); 2505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2517dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 2525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Tells GTK that the toolbar area is invalidated and needs redrawing. We 2545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // have this method as a hack because GTK doesn't queue the toolbar area for 2555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // redraw when it should. 2565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void QueueToolbarRedraw(); 2575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Get the position where the infobar arrow should be anchored in 2595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // |relative_to| coordinates. This is the middle of the omnibox location icon. 2605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int GetXPositionOfLocationIcon(GtkWidget* relative_to); 2615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Show or hide the bookmark bar. 2635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void MaybeShowBookmarkBar(bool animate); 2645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) protected: 2665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void DestroyBrowser() OVERRIDE; 2675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Checks to see if the mouse pointer at |x|, |y| is over the border of the 2695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // custom frame (a spot that should trigger a window resize). Returns true if 2705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // it should and sets |edge|. 2715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool GetWindowEdge(int x, int y, GdkWindowEdge* edge); 2725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the window shape for the window with |width| and |height|. 2745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The caller is responsible for destroying the region if non-null region is 2755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // returned. 2765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GdkRegion* GetWindowShape(int width, int height) const; 2775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Save the window position in the prefs. 2795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SaveWindowPosition(); 2805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Sets the default size for the window and the way the user is allowed to 2825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // resize it. 2835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetGeometryHints(); 2845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns |true| if we should use the custom frame. 2865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool UseCustomFrame() const; 2875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Invalidate window to force repaint. 2895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void InvalidateWindow(); 2905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Top level window. NULL after the window starts closing. 2925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GtkWindow* window_; 2935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Determines whether window was shown. 2945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool window_has_shown_; 2955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // GtkAlignment that holds the interior components of the chromium window. 2962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // This is used to draw the custom frame border and content shadow. Owned by 2972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // window_. 2985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GtkWidget* window_container_; 2995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // VBox that holds everything (tabs, toolbar, bookmarks bar, tab contents). 3002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Owned by window_container_. 3015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GtkWidget* window_vbox_; 3022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // VBox that holds everything below the toolbar. Owned by 3032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // render_area_floating_container_. 3045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GtkWidget* render_area_vbox_; 3055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Floating container that holds the render area. It is needed to position 3062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // the findbar. Owned by render_area_event_box_. 3075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GtkWidget* render_area_floating_container_; 3082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // EventBox that holds render_area_floating_container_. Owned by window_vbox_. 3095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GtkWidget* render_area_event_box_; 3102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Border between toolbar and render area. Owned by render_area_vbox_. 3115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GtkWidget* toolbar_border_; 3125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<Browser> browser_; 3145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private: 3165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Connect to signals on |window_|. 3175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void ConnectHandlersToSignals(); 3185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Create the various UI components. 3205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void InitWidgets(); 3215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Set up background color of the window (depends on if we're incognito or 3235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // not). 3245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetBackgroundColor(); 3255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Applies the window shape to if we're in custom drawing mode. 3275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void UpdateWindowShape(int width, int height); 3285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Connect accelerators that aren't connected to menu items (like ctrl-o, 3305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // ctrl-l, etc.). 3315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void ConnectAccelerators(); 3325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Whether we should draw the tab background instead of the theme_frame 3345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // background because this window is a popup. 3355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool UsingCustomPopupFrame() const; 3365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Draws the normal custom frame using theme_frame. 3385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void DrawCustomFrame(cairo_t* cr, GtkWidget* widget, GdkEventExpose* event); 3395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Draws the tab image as the frame so we can write legible text. 3415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void DrawPopupFrame(cairo_t* cr, GtkWidget* widget, GdkEventExpose* event); 3425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Draws the border, including resizable corners, for the custom frame. 3445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void DrawCustomFrameBorder(GtkWidget* widget); 3455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Change whether we're showing the custom blue frame. 3475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Must be called once at startup. 3485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Triggers relayout of the content. 3495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void UpdateCustomFrame(); 3505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Set the bounds of the current window. If |exterior| is true, set the size 3525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // of the window itself, otherwise set the bounds of the web contents. 3535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If |move| is true, set the position of the window, otherwise leave the 3545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // position to the WM. 3555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetBoundsImpl(const gfx::Rect& bounds, bool exterior, bool move); 3565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CHROMEGTK_CALLBACK_1(BrowserWindowGtk, gboolean, OnConfigure, 3585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GdkEventConfigure*); 3595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CHROMEGTK_CALLBACK_1(BrowserWindowGtk, gboolean, OnWindowState, 3605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GdkEventWindowState*); 3615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CHROMEGTK_CALLBACK_1(BrowserWindowGtk, gboolean, OnMainWindowDeleteEvent, 3625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GdkEvent*); 3635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CHROMEGTK_CALLBACK_0(BrowserWindowGtk, void, OnMainWindowDestroy); 3645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Callback for when the custom frame alignment needs to be redrawn. 3655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The content area includes the toolbar and web page but not the tab strip. 3665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CHROMEGTK_CALLBACK_1(BrowserWindowGtk, gboolean, OnCustomFrameExpose, 3675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GdkEventExpose*); 3685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // A helper method that draws the shadow above the toolbar and in the frame 3705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // border during an expose. 3715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void DrawContentShadow(cairo_t* cr); 3725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The background frame image needs to be offset by the size of the top of 3745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the window to the top of the tabs when the full skyline isn't displayed 3755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // for some reason. 3765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int GetVerticalOffset(); 3775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns which frame image we should use based on the window's current 3795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // activation state / incognito state. 3805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int GetThemeFrameResource(); 3815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Invalidate all the widgets that need to redraw when the infobar draw state 3835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // has changed. 3845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void InvalidateInfoBarBits(); 3855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // When the location icon moves, we have to redraw the arrow. 3875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CHROMEGTK_CALLBACK_1(BrowserWindowGtk, void, OnLocationIconSizeAllocate, 3885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GtkAllocation*); 3895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Used to draw the infobar arrow and drop shadow. This is connected to 3915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // multiple widgets' expose events because it overlaps several widgets. 3925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CHROMEGTK_CALLBACK_1(BrowserWindowGtk, gboolean, OnExposeDrawInfobarBits, 3935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GdkEventExpose*); 3945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Used to draw the infobar bits for the bookmark bar. When the bookmark 3965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // bar is in floating mode, it has to draw a drop shadow only; otherwise 3975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // it is responsible for its portion of the arrow as well as some shadowing. 3985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CHROMEGTK_CALLBACK_1(BrowserWindowGtk, gboolean, OnBookmarkBarExpose, 3995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GdkEventExpose*); 4005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Callback for "size-allocate" signal on bookmark bar; this is relevant 4025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // because when the bookmark bar changes dimensions, the infobar arrow has to 4035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // change its shape, and we need to queue appropriate redraws. 4045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CHROMEGTK_CALLBACK_1(BrowserWindowGtk, void, OnBookmarkBarSizeAllocate, 4055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GtkAllocation*); 4065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Callback for accelerator activation. |user_data| stores the command id 4085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // of the matched accelerator. 4095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static gboolean OnGtkAccelerator(GtkAccelGroup* accel_group, 4105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GObject* acceleratable, 4115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) guint keyval, 4125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GdkModifierType modifier, 4135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void* user_data); 4145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Key press event callback. 4165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CHROMEGTK_CALLBACK_1(BrowserWindowGtk, gboolean, OnKeyPress, GdkEventKey*); 4175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Mouse move and mouse button press callbacks. 4195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CHROMEGTK_CALLBACK_1(BrowserWindowGtk, gboolean, OnMouseMoveEvent, 4205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GdkEventMotion*); 4215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CHROMEGTK_CALLBACK_1(BrowserWindowGtk, gboolean, OnButtonPressEvent, 4225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GdkEventButton*); 4235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Tracks focus state of browser. 4255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CHROMEGTK_CALLBACK_1(BrowserWindowGtk, gboolean, OnFocusIn, 4265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GdkEventFocus*); 4275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CHROMEGTK_CALLBACK_1(BrowserWindowGtk, gboolean, OnFocusOut, 4285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GdkEventFocus*); 4295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Callback for the loading animation(s) associated with this window. 4315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void LoadingAnimationCallback(); 4325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Shows UI elements for supported window features. 4345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void ShowSupportedWindowFeatures(); 4355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Hides UI elements for unsupported window features. 4375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void HideUnsupportedWindowFeatures(); 4385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Helper functions that query |browser_| concerning support for UI features 4405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // in this window. (For example, a popup window might not support a tabstrip). 4415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool IsTabStripSupported() const; 4425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool IsToolbarSupported() const; 4435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool IsBookmarkBarSupported() const; 4445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Put the bookmark bar where it belongs. 4465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void PlaceBookmarkBar(bool is_floating); 4475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Decides if we should draw the frame as if the window is active. 4495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool DrawFrameAsActive() const; 4505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Updates devtools window for given contents. This method will show docked 4525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // devtools window for inspected |contents| that has docked devtools 4535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // and hide it for NULL or not inspected |contents|. It will also make 4545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // sure devtools window size and position are restored for given tab. 4555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void UpdateDevToolsForContents(content::WebContents* contents); 4565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Shows docked devtools. 4585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void ShowDevToolsContainer(); 4595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Hides docked devtools. 4615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void HideDevToolsContainer(); 4625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Reads split position from the current tab's devtools window and applies 4645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // it to the devtools split. 4655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void UpdateDevToolsSplitPosition(); 4665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Called when the preference changes. 4682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void OnUseCustomChromeFrameChanged(); 4692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Determine whether we use should default to native decorations or the custom 4715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // frame based on the currently-running window manager. 4725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static bool GetCustomFramePrefDefault(); 4735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The position and size of the current window. 4755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect bounds_; 4765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The configure bounds of the current window, used to figure out whether to 4785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // ignore later configure events. See OnConfigure() for more information. 4795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect configure_bounds_; 4805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The position and size of the non-maximized, non-fullscreen window. 4825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect restored_bounds_; 4835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GdkWindowState state_; 4855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Controls a hidden GtkMenuBar that we keep updated so GNOME can take a look 4875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // inside "our menu bar" and present it in the top panel, akin to Mac OS. 4885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<GlobalMenuBar> global_menu_bar_; 4895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The container for the titlebar + tab strip. 4915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<BrowserTitlebar> titlebar_; 4925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The object that manages all of the widgets in the toolbar. 4945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<BrowserToolbarGtk> toolbar_; 4955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The object that manages the bookmark bar. This will be NULL if the 4975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // bookmark bar is not supported. 4985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<BookmarkBarGtk> bookmark_bar_; 4995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The download shelf view (view at the bottom of the page). 5015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<DownloadShelfGtk> download_shelf_; 5025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The status bubble manager. Always non-NULL. 5045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<StatusBubbleGtk> status_bubble_; 5055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // A container that manages the GtkWidget*s that are the webpage display 5075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // (along with associated infobars, shelves, and other things that are part 5085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // of the content area). 5095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<TabContentsContainerGtk> contents_container_; 5105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // A container that manages the GtkWidget*s of developer tools for the 5125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // selected tab contents. 5135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<TabContentsContainerGtk> devtools_container_; 5145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The Extension Keybinding Registry responsible for registering listeners for 5165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // accelerators that are sent to the window, that are destined to be turned 5175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // into events and sent to the extension. 5185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<ExtensionKeybindingRegistryGtk> extension_keybinding_registry_; 5195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DevToolsDockSide devtools_dock_side_; 5215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Docked devtools window instance. NULL when current tab is not inspected 5235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // or is inspected with undocked version of DevToolsWindow. 5245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DevToolsWindow* devtools_window_; 5255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Split pane containing the contents_container_ and the devtools_container_. 5272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Owned by contents_vsplit_. 5285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GtkWidget* contents_hsplit_; 5295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Split pane containing the contents_hsplit_ and the devtools_container_. 5312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Owned by render_area_vbox_. 5325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GtkWidget* contents_vsplit_; 5335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The tab strip. Always non-NULL. 5355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<TabStripGtk> tabstrip_; 5365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The container for info bars. Always non-NULL. 5385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<InfoBarContainerGtk> infobar_container_; 5395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The timer used to update frames for the Loading Animation. 5415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) base::RepeatingTimer<BrowserWindowGtk> loading_animation_timer_; 5425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The timer used to save the window position for session restore. 5445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) base::OneShotTimer<BrowserWindowGtk> window_configure_debounce_timer_; 5455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Whether the custom chrome frame pref is set. Normally you want to use 5475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // UseCustomFrame() above to determine whether to use the custom frame or 5485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // not. 5495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) BooleanPrefMember use_custom_frame_pref_; 5505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The current window cursor. We set it to a resize cursor when over the 5525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // custom frame border. We set it to NULL if we want the default cursor. 5535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GdkCursor* frame_cursor_; 5545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // True if the window manager thinks the window is active. Not all window 5565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // managers keep track of this state (_NET_ACTIVE_WINDOW), in which case 5575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // this will always be true. 5585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool is_active_; 5595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Optionally maximize or minimize the window after we call 5615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // BrowserWindow::Show for the first time. This is to work around a compiz 5625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // bug. 5635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ui::WindowShowState show_state_after_show_; 5645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If true, don't call gdk_window_raise() when we get a click in the title 5665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // bar or window border. This is to work around a compiz bug. 5675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool suppress_window_raise_; 5685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The accelerator group used to handle accelerators, owned by this object. 5705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GtkAccelGroup* accel_group_; 5715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<FullscreenExitBubbleGtk> fullscreen_exit_bubble_; 5735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) FullscreenExitBubbleType fullscreen_exit_bubble_type_; 5755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content::NotificationRegistrar registrar_; 5775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(BrowserWindowGtk); 5795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 5805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // CHROME_BROWSER_UI_GTK_BROWSER_WINDOW_GTK_H_ 582