Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / chrome / browser / ui / browser_window.h
blob142a44a8be4e3486aa615b5ebc6108b9b97dcb71
1 // Copyright 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_BROWSER_WINDOW_H_
6 #define CHROME_BROWSER_UI_BROWSER_WINDOW_H_
8 #include "base/callback_forward.h"
9 #include "chrome/browser/lifetime/browser_close_manager.h"
10 #include "chrome/browser/signin/signin_header_helper.h"
11 #include "chrome/browser/translate/chrome_translate_client.h"
12 #include "chrome/browser/ui/bookmarks/bookmark_bar.h"
13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/exclusive_access/exclusive_access_bubble_type.h"
15 #include "chrome/browser/ui/host_desktop.h"
16 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h"
17 #include "components/content_settings/core/common/content_settings_types.h"
18 #include "components/translate/core/common/translate_errors.h"
19 #include "ui/base/base_window.h"
20 #include "ui/base/window_open_disposition.h"
21 #include "ui/gfx/native_widget_types.h"
23 class Browser;
24 class DownloadShelf;
25 class ExclusiveAccessContext;
26 class FindBar;
27 class GlobalErrorBubbleViewBase;
28 class GURL;
29 class LocationBar;
30 class Profile;
31 class ProfileResetGlobalError;
32 class StatusBubble;
33 class TemplateURL;
35 struct WebApplicationInfo;
37 namespace content {
38 class WebContents;
39 struct NativeWebKeyboardEvent;
40 struct SSLStatus;
43 namespace extensions {
44 class Command;
45 class Extension;
48 namespace gfx {
49 class Rect;
50 class Size;
53 namespace web_modal {
54 class WebContentsModalDialogHost;
57 ////////////////////////////////////////////////////////////////////////////////
58 // BrowserWindow interface
59 // An interface implemented by the "view" of the Browser window.
60 // This interface includes ui::BaseWindow methods as well as Browser window
61 // specific methods.
63 // NOTE: All getters may return NULL.
65 class BrowserWindow : public ui::BaseWindow {
66 public:
67 virtual ~BrowserWindow() {}
69 //////////////////////////////////////////////////////////////////////////////
70 // ui::BaseWindow interface notes:
72 // Closes the window as soon as possible. If the window is not in a drag
73 // session, it will close immediately; otherwise, it will move offscreen (so
74 // events are still fired) until the drag ends, then close. This assumes
75 // that the Browser is not immediately destroyed, but will be eventually
76 // destroyed by other means (eg, the tab strip going to zero elements).
77 // Bad things happen if the Browser dtor is called directly as a result of
78 // invoking this method.
79 // virtual void Close() = 0;
81 // Browser::OnWindowDidShow should be called after showing the window.
82 // virtual void Show() = 0;
84 //////////////////////////////////////////////////////////////////////////////
85 // Browser specific methods:
87 // Return the status bubble associated with the frame
88 virtual StatusBubble* GetStatusBubble() = 0;
90 // Inform the frame that the selected tab favicon or title has changed. Some
91 // frames may need to refresh their title bar.
92 virtual void UpdateTitleBar() = 0;
94 // Invoked when the state of the bookmark bar changes. This is only invoked if
95 // the state changes for the current tab, it is not sent when switching tabs.
96 virtual void BookmarkBarStateChanged(
97 BookmarkBar::AnimateChangeType change_type) = 0;
99 // Inform the frame that the dev tools window for the selected tab has
100 // changed.
101 virtual void UpdateDevTools() = 0;
103 // Update any loading animations running in the window. |should_animate| is
104 // true if there are tabs loading and the animations should continue, false
105 // if there are no active loads and the animations should end.
106 virtual void UpdateLoadingAnimations(bool should_animate) = 0;
108 // Sets the starred state for the current tab.
109 virtual void SetStarredState(bool is_starred) = 0;
111 // Sets whether the translate icon is lit for the current tab.
112 virtual void SetTranslateIconToggled(bool is_lit) = 0;
114 // Called when the active tab changes. Subclasses which implement
115 // TabStripModelObserver should implement this instead of ActiveTabChanged();
116 // the Browser will call this method while processing that one.
117 virtual void OnActiveTabChanged(content::WebContents* old_contents,
118 content::WebContents* new_contents,
119 int index,
120 int reason) = 0;
122 // Called to force the zoom state to for the active tab to be recalculated.
123 // |can_show_bubble| is true when a user presses the zoom up or down keyboard
124 // shortcuts and will be false in other cases (e.g. switching tabs, "clicking"
125 // + or - in the wrench menu to change zoom).
126 virtual void ZoomChangedForActiveTab(bool can_show_bubble) = 0;
128 // Methods that change fullscreen state.
129 // On Mac, the tab strip and toolbar will be shown if |with_toolbar| is true,
130 // |with_toolbar| is ignored on other platforms.
131 virtual void EnterFullscreen(const GURL& url,
132 ExclusiveAccessBubbleType bubble_type,
133 bool with_toolbar) = 0;
134 virtual void ExitFullscreen() = 0;
135 virtual void UpdateExclusiveAccessExitBubbleContent(
136 const GURL& url,
137 ExclusiveAccessBubbleType bubble_type) = 0;
139 // Windows and GTK remove the top controls in fullscreen, but Mac and Ash
140 // keep the controls in a slide-down panel.
141 virtual bool ShouldHideUIForFullscreen() const = 0;
143 // Returns true if the fullscreen bubble is visible.
144 virtual bool IsFullscreenBubbleVisible() const = 0;
146 // Show or hide the tab strip, toolbar and bookmark bar when in browser
147 // fullscreen.
148 // Currently only supported on Mac.
149 virtual bool SupportsFullscreenWithToolbar() const = 0;
150 virtual void UpdateFullscreenWithToolbar(bool with_toolbar) = 0;
151 virtual bool IsFullscreenWithToolbar() const = 0;
153 #if defined(OS_WIN)
154 // Sets state for entering or exiting Win8 Metro snap mode.
155 virtual void SetMetroSnapMode(bool enable) = 0;
157 // Returns whether the window is currently in Win8 Metro snap mode.
158 virtual bool IsInMetroSnapMode() const = 0;
159 #endif
161 // Returns the location bar.
162 virtual LocationBar* GetLocationBar() const = 0;
164 // Tries to focus the location bar. Clears the window focus (to avoid
165 // inconsistent state) if this fails.
166 virtual void SetFocusToLocationBar(bool select_all) = 0;
168 // Informs the view whether or not a load is in progress for the current tab.
169 // The view can use this notification to update the reload/stop button.
170 virtual void UpdateReloadStopState(bool is_loading, bool force) = 0;
172 // Updates the toolbar with the state for the specified |contents|.
173 virtual void UpdateToolbar(content::WebContents* contents) = 0;
175 // Resets the toolbar's tab state for |contents|.
176 virtual void ResetToolbarTabState(content::WebContents* contents) = 0;
178 // Focuses the toolbar (for accessibility).
179 virtual void FocusToolbar() = 0;
181 // Called from toolbar subviews during their show/hide animations.
182 virtual void ToolbarSizeChanged(bool is_animating) = 0;
184 // Focuses the app menu like it was a menu bar.
186 // Not used on the Mac, which has a "normal" menu bar.
187 virtual void FocusAppMenu() = 0;
189 // Focuses the bookmarks toolbar (for accessibility).
190 virtual void FocusBookmarksToolbar() = 0;
192 // Focuses an infobar, if shown (for accessibility).
193 virtual void FocusInfobars() = 0;
195 // Moves keyboard focus to the next pane.
196 virtual void RotatePaneFocus(bool forwards) = 0;
198 // Returns whether the bookmark bar is visible or not.
199 virtual bool IsBookmarkBarVisible() const = 0;
201 // Returns whether the bookmark bar is animating or not.
202 virtual bool IsBookmarkBarAnimating() const = 0;
204 // Returns whether the tab strip is editable (for extensions).
205 virtual bool IsTabStripEditable() const = 0;
207 // Returns whether the tool bar is visible or not.
208 virtual bool IsToolbarVisible() const = 0;
210 // Returns the rect where the resize corner should be drawn by the render
211 // widget host view (on top of what the renderer returns). We return an empty
212 // rect to identify that there shouldn't be a resize corner (in the cases
213 // where we take care of it ourselves at the browser level).
214 virtual gfx::Rect GetRootWindowResizerRect() const = 0;
216 // Shows a confirmation dialog box for adding a search engine described by
217 // |template_url|. Takes ownership of |template_url|.
218 virtual void ConfirmAddSearchProvider(TemplateURL* template_url,
219 Profile* profile) = 0;
221 // Shows the Update Recommended dialog box.
222 virtual void ShowUpdateChromeDialog() = 0;
224 // Shows the Bookmark bubble. |url| is the URL being bookmarked,
225 // |already_bookmarked| is true if the url is already bookmarked.
226 virtual void ShowBookmarkBubble(const GURL& url, bool already_bookmarked) = 0;
228 // Callback type used with the ShowBookmarkAppBubble() method. The boolean
229 // parameter is true when the user accepts the dialog. The WebApplicationInfo
230 // parameter contains the WebApplicationInfo as edited by the user.
231 typedef base::Callback<void(bool, const WebApplicationInfo&)>
232 ShowBookmarkAppBubbleCallback;
234 // Shows the Bookmark App bubble.
235 // See Extension::InitFromValueFlags::FROM_BOOKMARK for a description of
236 // bookmark apps.
238 // |web_app_info| is the WebApplicationInfo being converted into an app.
239 virtual void ShowBookmarkAppBubble(
240 const WebApplicationInfo& web_app_info,
241 const ShowBookmarkAppBubbleCallback& callback) = 0;
243 // Shows the translate bubble.
245 // |is_user_gesture| is true when the bubble is shown on the user's deliberate
246 // action.
247 virtual void ShowTranslateBubble(
248 content::WebContents* contents,
249 translate::TranslateStep step,
250 translate::TranslateErrors::Type error_type,
251 bool is_user_gesture) = 0;
253 // Create a session recovery bubble if the last session crashed. It also
254 // offers the option to enable metrics reporting if it's not already enabled.
255 // Returns true if a bubble is created, returns false if nothing is created.
256 virtual bool ShowSessionCrashedBubble() = 0;
258 // Shows the profile reset bubble on the platforms that support it.
259 virtual bool IsProfileResetBubbleSupported() const = 0;
260 virtual GlobalErrorBubbleViewBase* ShowProfileResetBubble(
261 const base::WeakPtr<ProfileResetGlobalError>& global_error) = 0;
263 #if defined(ENABLE_ONE_CLICK_SIGNIN)
264 enum OneClickSigninBubbleType {
265 ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE,
266 ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG,
267 ONE_CLICK_SIGNIN_BUBBLE_TYPE_SAML_MODAL_DIALOG
270 // Callback type used with the ShowOneClickSigninBubble() method. If the
271 // user chooses to accept the sign in, the callback is called to start the
272 // sync process.
273 typedef base::Callback<void(OneClickSigninSyncStarter::StartSyncMode)>
274 StartSyncCallback;
276 // Shows the one-click sign in bubble. |email| holds the full email address
277 // of the account that has signed in.
278 virtual void ShowOneClickSigninBubble(
279 OneClickSigninBubbleType type,
280 const base::string16& email,
281 const base::string16& error_message,
282 const StartSyncCallback& start_sync_callback) = 0;
283 #endif
285 // Whether or not the shelf view is visible.
286 virtual bool IsDownloadShelfVisible() const = 0;
288 // Returns the DownloadShelf.
289 virtual DownloadShelf* GetDownloadShelf() = 0;
291 // Shows the confirmation dialog box warning that the browser is closing with
292 // in-progress downloads.
293 // This method should call |callback| with the user's response.
294 virtual void ConfirmBrowserCloseWithPendingDownloads(
295 int download_count,
296 Browser::DownloadClosePreventionType dialog_type,
297 bool app_modal,
298 const base::Callback<void(bool)>& callback) = 0;
300 // ThemeService calls this when a user has changed his or her theme,
301 // indicating that it's time to redraw everything.
302 virtual void UserChangedTheme() = 0;
304 // Shows the website settings using the specified information. |url| is the
305 // url of the page/frame the info applies to, |ssl| is the SSL information for
306 // that page/frame. If |show_history| is true, a section showing how many
307 // times that URL has been visited is added to the page info.
308 virtual void ShowWebsiteSettings(Profile* profile,
309 content::WebContents* web_contents,
310 const GURL& url,
311 const content::SSLStatus& ssl) = 0;
313 // Shows the app menu (for accessibility).
314 virtual void ShowAppMenu() = 0;
316 // Allows the BrowserWindow object to handle the specified keyboard event
317 // before sending it to the renderer.
318 // Returns true if the |event| was handled. Otherwise, if the |event| would
319 // be handled in HandleKeyboardEvent() method as a normal keyboard shortcut,
320 // |*is_keyboard_shortcut| should be set to true.
321 virtual bool PreHandleKeyboardEvent(
322 const content::NativeWebKeyboardEvent& event,
323 bool* is_keyboard_shortcut) = 0;
325 // Allows the BrowserWindow object to handle the specified keyboard event,
326 // if the renderer did not process it.
327 virtual void HandleKeyboardEvent(
328 const content::NativeWebKeyboardEvent& event) = 0;
330 // Clipboard commands applied to the whole browser window.
331 virtual void CutCopyPaste(int command_id) = 0;
333 // Return the correct disposition for a popup window based on |bounds|.
334 virtual WindowOpenDisposition GetDispositionForPopupBounds(
335 const gfx::Rect& bounds) = 0;
337 // Construct a FindBar implementation for the |browser|.
338 virtual FindBar* CreateFindBar() = 0;
340 // Return the WebContentsModalDialogHost for use in positioning web contents
341 // modal dialogs within the browser window. This can sometimes be NULL (for
342 // instance during tab drag on Views/Win32).
343 virtual web_modal::WebContentsModalDialogHost*
344 GetWebContentsModalDialogHost() = 0;
346 // Invoked when the preferred size of the contents in current tab has been
347 // changed. We might choose to update the window size to accomodate this
348 // change.
349 // Note that this won't be fired if we change tabs.
350 virtual void UpdatePreferredSize(content::WebContents* web_contents,
351 const gfx::Size& pref_size) {}
353 // Invoked when the contents auto-resized and the container should match it.
354 virtual void ResizeDueToAutoResize(content::WebContents* web_contents,
355 const gfx::Size& new_size) {}
357 // Construct a BrowserWindow implementation for the specified |browser|.
358 static BrowserWindow* CreateBrowserWindow(Browser* browser);
360 // Returns a HostDesktopType that is compatible with the current Chrome window
361 // configuration. On Windows with Ash, this is always HOST_DESKTOP_TYPE_ASH
362 // while Chrome is running in Metro mode. Otherwise returns |desktop_type|.
363 static chrome::HostDesktopType AdjustHostDesktopType(
364 chrome::HostDesktopType desktop_type);
366 // Shows the avatar bubble on the window frame off of the avatar button with
367 // the given mode. The Service Type specified by GAIA is provided as well.
368 enum AvatarBubbleMode {
369 AVATAR_BUBBLE_MODE_DEFAULT,
370 AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT,
371 AVATAR_BUBBLE_MODE_SIGNIN,
372 AVATAR_BUBBLE_MODE_ADD_ACCOUNT,
373 AVATAR_BUBBLE_MODE_REAUTH,
374 AVATAR_BUBBLE_MODE_CONFIRM_SIGNIN,
375 AVATAR_BUBBLE_MODE_SHOW_ERROR,
376 AVATAR_BUBBLE_MODE_FAST_USER_SWITCH,
378 virtual void ShowAvatarBubbleFromAvatarButton(AvatarBubbleMode mode,
379 const signin::ManageAccountsParams& manage_accounts_params) = 0;
381 // Closes the avatar bubble on the window frame.
382 virtual void CloseAvatarBubbleFromAvatarButton() = 0;
384 // Returns the height inset for RenderView when detached bookmark bar is
385 // shown. Invoked when a new RenderHostView is created for a non-NTP
386 // navigation entry and the bookmark bar is detached.
387 virtual int GetRenderViewHeightInsetWithDetachedBookmarkBar() = 0;
389 // Executes |command| registered by |extension|.
390 virtual void ExecuteExtensionCommand(const extensions::Extension* extension,
391 const extensions::Command& command) = 0;
393 // Returns object implementing ExclusiveAccessContext interface.
394 virtual ExclusiveAccessContext* GetExclusiveAccessContext() = 0;
396 protected:
397 friend class BrowserCloseManager;
398 friend class BrowserView;
399 virtual void DestroyBrowser() = 0;
402 #endif // CHROME_BROWSER_UI_BROWSER_WINDOW_H_