Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / browser_window_cocoa.h
blobaf7c13a19a4f6d0244a37c2a8e6cc7875cf11052
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/signin_header_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 WebContentsFocused(content::WebContents* contents) 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 Cut() override;
149 void Copy() override;
150 void Paste() override;
151 WindowOpenDisposition GetDispositionForPopupBounds(
152 const gfx::Rect& bounds) override;
153 FindBar* CreateFindBar() override;
154 web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost()
155 override;
156 void ShowAvatarBubbleFromAvatarButton(
157 AvatarBubbleMode mode,
158 const signin::ManageAccountsParams& manage_accounts_params) override;
159 int GetRenderViewHeightInsetWithDetachedBookmarkBar() override;
160 void ExecuteExtensionCommand(const extensions::Extension* extension,
161 const extensions::Command& command) override;
162 ExclusiveAccessContext* GetExclusiveAccessContext() override;
164 // ExclusiveAccessContext interface
165 Profile* GetProfile() override;
166 content::WebContents* GetActiveWebContents() override;
167 void UnhideDownloadShelf() override;
168 void HideDownloadShelf() override;
170 // Overridden from ExtensionKeybindingRegistry::Delegate:
171 extensions::ActiveTabPermissionGranter* GetActiveTabPermissionGranter()
172 override;
174 // Overridden from SearchModelObserver:
175 void ModelChanged(const SearchModel::State& old_state,
176 const SearchModel::State& new_state) override;
178 // Adds the given FindBar cocoa controller to this browser window.
179 void AddFindBar(FindBarCocoaController* find_bar_cocoa_controller);
181 // Returns the cocoa-world BrowserWindowController
182 BrowserWindowController* cocoa_controller() { return controller_; }
184 protected:
185 void DestroyBrowser() override;
187 private:
188 NSWindow* window() const; // Accessor for the (current) |NSWindow|.
190 Browser* browser_; // weak, owned by controller
191 BrowserWindowController* controller_; // weak, owns us
192 base::scoped_nsobject<NSString> pending_window_title_;
193 ui::WindowShowState initial_show_state_;
194 NSInteger attention_request_id_; // identifier from requestUserAttention
197 #endif // CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_COCOA_H_