Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / browser_window_cocoa.h
blob0b9295b242f74342edf121f116ede83b3305fec4
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/extensions/extension_keybinding_registry.h"
11 #include "chrome/browser/signin/chrome_signin_helper.h"
12 #include "chrome/browser/ui/browser_window.h"
13 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h"
14 #include "chrome/browser/ui/search/search_model_observer.h"
15 #include "components/bookmarks/browser/bookmark_model.h"
16 #include "ui/base/ui_base_types.h"
18 class Browser;
19 @class BrowserWindowController;
20 @class FindBarCocoaController;
21 @class NSEvent;
22 @class NSMenu;
23 @class NSWindow;
25 namespace extensions {
26 class ActiveTabPermissionGranter;
27 class Command;
28 class Extension;
31 // An implementation of BrowserWindow for Cocoa. Bridges between C++ and
32 // the Cocoa NSWindow. Cross-platform code will interact with this object when
33 // it needs to manipulate the window.
35 class BrowserWindowCocoa
36 : public BrowserWindow,
37 public ExclusiveAccessContext,
38 public extensions::ExtensionKeybindingRegistry::Delegate,
39 public SearchModelObserver {
40 public:
41 BrowserWindowCocoa(Browser* browser,
42 BrowserWindowController* controller);
43 ~BrowserWindowCocoa() override;
45 // Overridden from BrowserWindow
46 void Show() override;
47 void ShowInactive() override;
48 void Hide() override;
49 void SetBounds(const gfx::Rect& bounds) override;
50 void Close() override;
51 void Activate() override;
52 void Deactivate() override;
53 bool IsActive() const override;
54 void FlashFrame(bool flash) override;
55 bool IsAlwaysOnTop() const override;
56 void SetAlwaysOnTop(bool always_on_top) override;
57 gfx::NativeWindow GetNativeWindow() const override;
58 StatusBubble* GetStatusBubble() override;
59 void UpdateTitleBar() override;
60 void BookmarkBarStateChanged(
61 BookmarkBar::AnimateChangeType change_type) override;
62 void UpdateDevTools() override;
63 void UpdateLoadingAnimations(bool should_animate) override;
64 void SetStarredState(bool is_starred) override;
65 void SetTranslateIconToggled(bool is_lit) override;
66 void OnActiveTabChanged(content::WebContents* old_contents,
67 content::WebContents* new_contents,
68 int index,
69 int reason) override;
70 void ZoomChangedForActiveTab(bool can_show_bubble) override;
71 gfx::Rect GetRestoredBounds() const override;
72 ui::WindowShowState GetRestoredState() const override;
73 gfx::Rect GetBounds() const override;
74 bool IsMaximized() const override;
75 bool IsMinimized() const override;
76 void Maximize() override;
77 void Minimize() override;
78 void Restore() override;
79 void EnterFullscreen(const GURL& url,
80 ExclusiveAccessBubbleType type,
81 bool with_toolbar) override;
82 void ExitFullscreen() override;
83 void UpdateExclusiveAccessExitBubbleContent(
84 const GURL& url,
85 ExclusiveAccessBubbleType bubble_type) override;
86 bool ShouldHideUIForFullscreen() const override;
87 bool IsFullscreen() const override;
88 bool IsFullscreenBubbleVisible() const override;
89 bool SupportsFullscreenWithToolbar() const override;
90 void UpdateFullscreenWithToolbar(bool with_toolbar) override;
91 bool IsFullscreenWithToolbar() const override;
92 LocationBar* GetLocationBar() const override;
93 void SetFocusToLocationBar(bool select_all) override;
94 void UpdateReloadStopState(bool is_loading, bool force) override;
95 void UpdateToolbar(content::WebContents* contents) override;
96 void ResetToolbarTabState(content::WebContents* contents) override;
97 void FocusToolbar() override;
98 ToolbarActionsBar* GetToolbarActionsBar() override;
99 void ToolbarSizeChanged(bool is_animating) override;
100 void FocusAppMenu() override;
101 void FocusBookmarksToolbar() override;
102 void FocusInfobars() override;
103 void RotatePaneFocus(bool forwards) override;
104 bool IsBookmarkBarVisible() const override;
105 bool IsBookmarkBarAnimating() const override;
106 bool IsTabStripEditable() const override;
107 bool IsToolbarVisible() const override;
108 gfx::Rect GetRootWindowResizerRect() const override;
109 void ConfirmAddSearchProvider(TemplateURL* template_url,
110 Profile* profile) override;
111 void ShowUpdateChromeDialog() override;
112 void ShowBookmarkBubble(const GURL& url, bool already_bookmarked) override;
113 void ShowBookmarkAppBubble(
114 const WebApplicationInfo& web_app_info,
115 const ShowBookmarkAppBubbleCallback& callback) override;
116 void ShowTranslateBubble(content::WebContents* contents,
117 translate::TranslateStep step,
118 translate::TranslateErrors::Type error_type,
119 bool is_user_gesture) override;
120 bool ShowSessionCrashedBubble() override;
121 bool IsProfileResetBubbleSupported() const override;
122 GlobalErrorBubbleViewBase* ShowProfileResetBubble(
123 const base::WeakPtr<ProfileResetGlobalError>& global_error) override;
124 #if defined(ENABLE_ONE_CLICK_SIGNIN)
125 void ShowOneClickSigninBubble(
126 OneClickSigninBubbleType type,
127 const base::string16& email,
128 const base::string16& error_message,
129 const StartSyncCallback& start_sync_callback) override;
130 #endif
131 bool IsDownloadShelfVisible() const override;
132 DownloadShelf* GetDownloadShelf() override;
133 void ConfirmBrowserCloseWithPendingDownloads(
134 int download_count,
135 Browser::DownloadClosePreventionType dialog_type,
136 bool app_modal,
137 const base::Callback<void(bool)>& callback) override;
138 void UserChangedTheme() override;
139 void ShowWebsiteSettings(Profile* profile,
140 content::WebContents* web_contents,
141 const GURL& url,
142 const content::SSLStatus& ssl) override;
143 void ShowAppMenu() override;
144 bool PreHandleKeyboardEvent(const content::NativeWebKeyboardEvent& event,
145 bool* is_keyboard_shortcut) override;
146 void HandleKeyboardEvent(
147 const content::NativeWebKeyboardEvent& event) override;
148 void CutCopyPaste(int command_id) override;
149 WindowOpenDisposition GetDispositionForPopupBounds(
150 const gfx::Rect& bounds) override;
151 FindBar* CreateFindBar() override;
152 web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost()
153 override;
154 void ShowAvatarBubbleFromAvatarButton(
155 AvatarBubbleMode mode,
156 const signin::ManageAccountsParams& manage_accounts_params) override;
157 int GetRenderViewHeightInsetWithDetachedBookmarkBar() override;
158 void ExecuteExtensionCommand(const extensions::Extension* extension,
159 const extensions::Command& command) override;
160 ExclusiveAccessContext* GetExclusiveAccessContext() override;
162 // ExclusiveAccessContext interface
163 Profile* GetProfile() override;
164 content::WebContents* GetActiveWebContents() override;
165 void UnhideDownloadShelf() override;
166 void HideDownloadShelf() override;
168 // Overridden from ExtensionKeybindingRegistry::Delegate:
169 extensions::ActiveTabPermissionGranter* GetActiveTabPermissionGranter()
170 override;
172 // Overridden from SearchModelObserver:
173 void ModelChanged(const SearchModel::State& old_state,
174 const SearchModel::State& new_state) override;
176 // Adds the given FindBar cocoa controller to this browser window.
177 void AddFindBar(FindBarCocoaController* find_bar_cocoa_controller);
179 // Returns the cocoa-world BrowserWindowController
180 BrowserWindowController* cocoa_controller() { return controller_; }
182 protected:
183 void DestroyBrowser() override;
185 private:
186 NSWindow* window() const; // Accessor for the (current) |NSWindow|.
188 Browser* browser_; // weak, owned by controller
189 BrowserWindowController* controller_; // weak, owns us
190 base::scoped_nsobject<NSString> pending_window_title_;
191 ui::WindowShowState initial_show_state_;
192 NSInteger attention_request_id_; // identifier from requestUserAttention
195 #endif // CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_COCOA_H_