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