Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / browser_window_cocoa.h
blob4091953093498a634ba921291e0ba30d0bb638ff
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_UI_COCOA_BROWSER_WINDOW_COCOA_H_
6 #define CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_COCOA_H_
8 #include "base/mac/scoped_nsobject.h"
9 #include "base/memory/weak_ptr.h"
10 #include "chrome/browser/bookmarks/bookmark_model.h"
11 #include "chrome/browser/extensions/extension_keybinding_registry.h"
12 #include "chrome/browser/ui/browser_window.h"
13 #include "chrome/browser/ui/search/search_model_observer.h"
14 #include "ui/base/ui_base_types.h"
16 class Browser;
17 @class BrowserWindowController;
18 @class FindBarCocoaController;
19 @class NSEvent;
20 @class NSMenu;
21 @class NSWindow;
23 namespace extensions {
24 class ActiveTabPermissionGranter;
25 class Extension;
28 // An implementation of BrowserWindow for Cocoa. Bridges between C++ and
29 // the Cocoa NSWindow. Cross-platform code will interact with this object when
30 // it needs to manipulate the window.
32 class BrowserWindowCocoa :
33 public BrowserWindow,
34 public extensions::ExtensionKeybindingRegistry::Delegate,
35 public SearchModelObserver {
36 public:
37 BrowserWindowCocoa(Browser* browser,
38 BrowserWindowController* controller);
39 virtual ~BrowserWindowCocoa();
41 // Overridden from BrowserWindow
42 virtual void Show() OVERRIDE;
43 virtual void ShowInactive() OVERRIDE;
44 virtual void Hide() OVERRIDE;
45 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
46 virtual void Close() OVERRIDE;
47 virtual void Activate() OVERRIDE;
48 virtual void Deactivate() OVERRIDE;
49 virtual bool IsActive() const OVERRIDE;
50 virtual void FlashFrame(bool flash) OVERRIDE;
51 virtual bool IsAlwaysOnTop() const OVERRIDE;
52 virtual void SetAlwaysOnTop(bool always_on_top) OVERRIDE;
53 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE;
54 virtual BrowserWindowTesting* GetBrowserWindowTesting() OVERRIDE;
55 virtual StatusBubble* GetStatusBubble() OVERRIDE;
56 virtual void UpdateTitleBar() OVERRIDE;
57 virtual void BookmarkBarStateChanged(
58 BookmarkBar::AnimateChangeType change_type) OVERRIDE;
59 virtual void UpdateDevTools() OVERRIDE;
60 virtual void UpdateLoadingAnimations(bool should_animate) OVERRIDE;
61 virtual void SetStarredState(bool is_starred) OVERRIDE;
62 virtual void SetTranslateIconToggled(bool is_lit) OVERRIDE;
63 virtual void OnActiveTabChanged(content::WebContents* old_contents,
64 content::WebContents* new_contents,
65 int index,
66 int reason) OVERRIDE;
67 virtual void ZoomChangedForActiveTab(bool can_show_bubble) OVERRIDE;
68 virtual gfx::Rect GetRestoredBounds() const OVERRIDE;
69 virtual ui::WindowShowState GetRestoredState() const OVERRIDE;
70 virtual gfx::Rect GetBounds() const OVERRIDE;
71 virtual bool IsMaximized() const OVERRIDE;
72 virtual bool IsMinimized() const OVERRIDE;
73 virtual void Maximize() OVERRIDE;
74 virtual void Minimize() OVERRIDE;
75 virtual void Restore() OVERRIDE;
76 virtual void EnterFullscreen(
77 const GURL& url, FullscreenExitBubbleType type) OVERRIDE;
78 virtual void ExitFullscreen() OVERRIDE;
79 virtual void UpdateFullscreenExitBubbleContent(
80 const GURL& url,
81 FullscreenExitBubbleType bubble_type) OVERRIDE;
82 virtual bool ShouldHideUIForFullscreen() const OVERRIDE;
83 virtual bool IsFullscreen() const OVERRIDE;
84 virtual bool IsFullscreenBubbleVisible() const OVERRIDE;
85 virtual LocationBar* GetLocationBar() const OVERRIDE;
86 virtual void SetFocusToLocationBar(bool select_all) OVERRIDE;
87 virtual void UpdateReloadStopState(bool is_loading, bool force) OVERRIDE;
88 virtual void UpdateToolbar(content::WebContents* contents) OVERRIDE;
89 virtual void FocusToolbar() OVERRIDE;
90 virtual void FocusAppMenu() OVERRIDE;
91 virtual void FocusBookmarksToolbar() OVERRIDE;
92 virtual void FocusInfobars() OVERRIDE;
93 virtual void RotatePaneFocus(bool forwards) OVERRIDE;
94 virtual bool IsBookmarkBarVisible() const OVERRIDE;
95 virtual bool IsBookmarkBarAnimating() const OVERRIDE;
96 virtual bool IsTabStripEditable() const OVERRIDE;
97 virtual bool IsToolbarVisible() const OVERRIDE;
98 virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE;
99 virtual void ConfirmAddSearchProvider(TemplateURL* template_url,
100 Profile* profile) OVERRIDE;
101 virtual void ShowUpdateChromeDialog() OVERRIDE;
102 virtual void ShowBookmarkBubble(const GURL& url,
103 bool already_bookmarked) OVERRIDE;
104 virtual void ShowTranslateBubble(
105 content::WebContents* contents,
106 TranslateBubbleModel::ViewState view_state,
107 TranslateErrors::Type error_type) OVERRIDE;
108 #if defined(ENABLE_ONE_CLICK_SIGNIN)
109 virtual void ShowOneClickSigninBubble(
110 OneClickSigninBubbleType type,
111 const base::string16& email,
112 const base::string16& error_message,
113 const StartSyncCallback& start_sync_callback) OVERRIDE;
114 #endif
115 virtual bool IsDownloadShelfVisible() const OVERRIDE;
116 virtual DownloadShelf* GetDownloadShelf() OVERRIDE;
117 virtual void ConfirmBrowserCloseWithPendingDownloads(
118 int download_count,
119 Browser::DownloadClosePreventionType dialog_type,
120 bool app_modal,
121 const base::Callback<void(bool)>& callback) OVERRIDE;
122 virtual void UserChangedTheme() OVERRIDE;
123 virtual int GetExtraRenderViewHeight() const OVERRIDE;
124 virtual void WebContentsFocused(content::WebContents* contents) OVERRIDE;
125 virtual void ShowWebsiteSettings(Profile* profile,
126 content::WebContents* web_contents,
127 const GURL& url,
128 const content::SSLStatus& ssl) OVERRIDE;
129 virtual void ShowAppMenu() OVERRIDE;
130 virtual bool PreHandleKeyboardEvent(
131 const content::NativeWebKeyboardEvent& event,
132 bool* is_keyboard_shortcut) OVERRIDE;
133 virtual void HandleKeyboardEvent(
134 const content::NativeWebKeyboardEvent& event) OVERRIDE;
135 virtual void Cut() OVERRIDE;
136 virtual void Copy() OVERRIDE;
137 virtual void Paste() OVERRIDE;
138 virtual void OpenTabpose() OVERRIDE;
139 virtual void EnterFullscreenWithChrome() OVERRIDE;
140 virtual bool IsFullscreenWithChrome() OVERRIDE;
141 virtual bool IsFullscreenWithoutChrome() OVERRIDE;
142 virtual WindowOpenDisposition GetDispositionForPopupBounds(
143 const gfx::Rect& bounds) OVERRIDE;
144 virtual FindBar* CreateFindBar() OVERRIDE;
145 virtual web_modal::WebContentsModalDialogHost*
146 GetWebContentsModalDialogHost() OVERRIDE;
147 virtual void ShowAvatarBubble(content::WebContents* web_contents,
148 const gfx::Rect& rect) OVERRIDE;
149 virtual void ShowAvatarBubbleFromAvatarButton() OVERRIDE;
150 virtual void ShowPasswordGenerationBubble(
151 const gfx::Rect& rect,
152 const autofill::PasswordForm& form,
153 autofill::PasswordGenerator* password_generator) OVERRIDE;
154 virtual int GetRenderViewHeightInsetWithDetachedBookmarkBar() OVERRIDE;
156 // Overridden from ExtensionKeybindingRegistry::Delegate:
157 virtual extensions::ActiveTabPermissionGranter*
158 GetActiveTabPermissionGranter() OVERRIDE;
160 // Overridden from SearchModelObserver:
161 virtual void ModelChanged(const SearchModel::State& old_state,
162 const SearchModel::State& new_state) OVERRIDE;
164 // Adds the given FindBar cocoa controller to this browser window.
165 void AddFindBar(FindBarCocoaController* find_bar_cocoa_controller);
167 // Returns the cocoa-world BrowserWindowController
168 BrowserWindowController* cocoa_controller() { return controller_; }
170 protected:
171 virtual void DestroyBrowser() OVERRIDE;
173 private:
174 NSWindow* window() const; // Accessor for the (current) |NSWindow|.
176 Browser* browser_; // weak, owned by controller
177 BrowserWindowController* controller_; // weak, owns us
178 base::scoped_nsobject<NSString> pending_window_title_;
179 ui::WindowShowState initial_show_state_;
180 NSInteger attention_request_id_; // identifier from requestUserAttention
183 #endif // CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_COCOA_H_