Add ICU message format support
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / browser_window_cocoa.h
blob304c999292b2f9d12ff022043a04f41d96bb25bb
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 void ToolbarSizeChanged(bool is_animating) override;
99 void FocusAppMenu() override;
100 void FocusBookmarksToolbar() override;
101 void FocusInfobars() override;
102 void RotatePaneFocus(bool forwards) override;
103 bool IsBookmarkBarVisible() const override;
104 bool IsBookmarkBarAnimating() const override;
105 bool IsTabStripEditable() const override;
106 bool IsToolbarVisible() const override;
107 gfx::Rect GetRootWindowResizerRect() const override;
108 void ConfirmAddSearchProvider(TemplateURL* template_url,
109 Profile* profile) override;
110 void ShowUpdateChromeDialog() override;
111 void ShowBookmarkBubble(const GURL& url, bool already_bookmarked) override;
112 void ShowBookmarkAppBubble(
113 const WebApplicationInfo& web_app_info,
114 const ShowBookmarkAppBubbleCallback& callback) override;
115 void ShowTranslateBubble(content::WebContents* contents,
116 translate::TranslateStep step,
117 translate::TranslateErrors::Type error_type,
118 bool is_user_gesture) override;
119 bool ShowSessionCrashedBubble() override;
120 bool IsProfileResetBubbleSupported() const override;
121 GlobalErrorBubbleViewBase* ShowProfileResetBubble(
122 const base::WeakPtr<ProfileResetGlobalError>& global_error) override;
123 #if defined(ENABLE_ONE_CLICK_SIGNIN)
124 void ShowOneClickSigninBubble(
125 OneClickSigninBubbleType type,
126 const base::string16& email,
127 const base::string16& error_message,
128 const StartSyncCallback& start_sync_callback) override;
129 #endif
130 bool IsDownloadShelfVisible() const override;
131 DownloadShelf* GetDownloadShelf() override;
132 void ConfirmBrowserCloseWithPendingDownloads(
133 int download_count,
134 Browser::DownloadClosePreventionType dialog_type,
135 bool app_modal,
136 const base::Callback<void(bool)>& callback) override;
137 void UserChangedTheme() override;
138 void ShowWebsiteSettings(Profile* profile,
139 content::WebContents* web_contents,
140 const GURL& url,
141 const content::SSLStatus& ssl) override;
142 void ShowAppMenu() override;
143 bool PreHandleKeyboardEvent(const content::NativeWebKeyboardEvent& event,
144 bool* is_keyboard_shortcut) override;
145 void HandleKeyboardEvent(
146 const content::NativeWebKeyboardEvent& event) override;
147 void CutCopyPaste(int command_id) override;
148 WindowOpenDisposition GetDispositionForPopupBounds(
149 const gfx::Rect& bounds) override;
150 FindBar* CreateFindBar() override;
151 web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost()
152 override;
153 void ShowAvatarBubbleFromAvatarButton(
154 AvatarBubbleMode mode,
155 const signin::ManageAccountsParams& manage_accounts_params) override;
156 int GetRenderViewHeightInsetWithDetachedBookmarkBar() override;
157 void ExecuteExtensionCommand(const extensions::Extension* extension,
158 const extensions::Command& command) override;
159 ExclusiveAccessContext* GetExclusiveAccessContext() override;
161 // ExclusiveAccessContext interface
162 Profile* GetProfile() override;
163 content::WebContents* GetActiveWebContents() override;
164 void UnhideDownloadShelf() override;
165 void HideDownloadShelf() override;
167 // Overridden from ExtensionKeybindingRegistry::Delegate:
168 extensions::ActiveTabPermissionGranter* GetActiveTabPermissionGranter()
169 override;
171 // Overridden from SearchModelObserver:
172 void ModelChanged(const SearchModel::State& old_state,
173 const SearchModel::State& new_state) override;
175 // Adds the given FindBar cocoa controller to this browser window.
176 void AddFindBar(FindBarCocoaController* find_bar_cocoa_controller);
178 // Returns the cocoa-world BrowserWindowController
179 BrowserWindowController* cocoa_controller() { return controller_; }
181 protected:
182 void DestroyBrowser() override;
184 private:
185 NSWindow* window() const; // Accessor for the (current) |NSWindow|.
187 Browser* browser_; // weak, owned by controller
188 BrowserWindowController* controller_; // weak, owns us
189 base::scoped_nsobject<NSString> pending_window_title_;
190 ui::WindowShowState initial_show_state_;
191 NSInteger attention_request_id_; // identifier from requestUserAttention
194 #endif // CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_COCOA_H_