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_VIEWS_FRAME_BROWSER_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_
12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/timer/timer.h"
15 #include "build/build_config.h"
16 #include "chrome/browser/devtools/devtools_window.h"
17 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/browser_window.h"
19 #include "chrome/browser/ui/omnibox/omnibox_popup_model_observer.h"
20 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
21 #include "chrome/browser/ui/views/frame/browser_frame.h"
22 #include "chrome/browser/ui/views/frame/contents_web_view.h"
23 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
24 #include "chrome/browser/ui/views/frame/scroll_end_effect_controller.h"
25 #include "chrome/browser/ui/views/frame/web_contents_close_handler.h"
26 #include "chrome/browser/ui/views/load_complete_listener.h"
27 #include "components/infobars/core/infobar_container.h"
28 #include "ui/base/accelerators/accelerator.h"
29 #include "ui/base/models/simple_menu_model.h"
30 #include "ui/gfx/native_widget_types.h"
31 #include "ui/views/controls/button/button.h"
32 #include "ui/views/controls/webview/unhandled_keyboard_event_handler.h"
33 #include "ui/views/widget/widget_delegate.h"
34 #include "ui/views/widget/widget_observer.h"
35 #include "ui/views/window/client_view.h"
38 #include "chrome/browser/hang_monitor/hung_plugin_action.h"
39 #include "chrome/browser/hang_monitor/hung_window_detector.h"
42 // NOTE: For more information about the objects and files in this directory,
43 // view: http://dev.chromium.org/developers/design-documents/browser-window
45 class BookmarkBarView
;
47 class BrowserViewLayout
;
48 class ContentsLayoutManager
;
49 class DownloadShelfView
;
50 class FullscreenExitBubbleViews
;
51 class InfoBarContainerView
;
52 class LocationBarView
;
53 class PermissionBubbleViewViews
;
54 class StatusBubbleViews
;
55 class SearchViewController
;
59 class TopContainerView
;
60 class WebContentsCloseHandler
;
67 class PasswordGenerator
;
71 class RenderFrameHost
;
74 namespace extensions
{
79 class AccessiblePaneView
;
80 class ExternalFocusTracker
;
84 ///////////////////////////////////////////////////////////////////////////////
87 // A ClientView subclass that provides the contents of a browser window,
88 // including the TabStrip, toolbars, download shelves, the content area etc.
90 class BrowserView
: public BrowserWindow
,
91 public BrowserWindowTesting
,
92 public TabStripModelObserver
,
93 public ui::AcceleratorProvider
,
94 public views::WidgetDelegate
,
95 public views::WidgetObserver
,
96 public views::ClientView
,
97 public infobars::InfoBarContainer::Delegate
,
98 public LoadCompleteListener::Delegate
,
99 public OmniboxPopupModelObserver
{
101 // The browser view's class name.
102 static const char kViewClassName
[];
105 virtual ~BrowserView();
107 // Takes ownership of |browser|.
108 void Init(Browser
* browser
);
110 void set_frame(BrowserFrame
* frame
) { frame_
= frame
; }
111 BrowserFrame
* frame() const { return frame_
; }
113 // Returns a pointer to the BrowserView* interface implementation (an
114 // instance of this object, typically) for a given native window, or NULL if
115 // there is no such association.
117 // Don't use this unless you only have a NativeWindow. In nearly all
118 // situations plumb through browser and use it.
119 static BrowserView
* GetBrowserViewForNativeWindow(gfx::NativeWindow window
);
121 // Returns the BrowserView used for the specified Browser.
122 static BrowserView
* GetBrowserViewForBrowser(const Browser
* browser
);
124 // Returns a Browser instance of this view.
125 Browser
* browser() { return browser_
.get(); }
126 const Browser
* browser() const { return browser_
.get(); }
128 // Initializes (or re-initializes) the status bubble. We try to only create
129 // the bubble once and re-use it for the life of the browser, but certain
130 // events (such as changing enabling/disabling Aero on Win) can force a need
131 // to change some of the bubble's creation parameters.
132 void InitStatusBubble();
134 // Initializes the permission bubble view. This class is intended to be
135 // created once and then re-used for the life of the browser window. The
136 // bubbles it creates will be associated with a single visible tab.
137 void InitPermissionBubbleView();
139 // Returns the apparent bounds of the toolbar, in BrowserView coordinates.
140 // These differ from |toolbar_.bounds()| in that they match where the toolbar
141 // background image is drawn -- slightly outside the "true" bounds
142 // horizontally. Note that this returns the bounds for the toolbar area.
143 gfx::Rect
GetToolbarBounds() const;
145 // Returns the constraining bounding box that should be used to lay out the
146 // FindBar within. This is _not_ the size of the find bar, just the bounding
147 // box it should be laid out within. The coordinate system of the returned
148 // rect is in the coordinate system of the frame, since the FindBar is a child
150 gfx::Rect
GetFindBarBoundingBox() const;
152 // Returns the preferred height of the TabStrip. Used to position the OTR
154 int GetTabStripHeight() const;
156 // Takes some view's origin (relative to this BrowserView) and offsets it such
157 // that it can be used as the source origin for seamlessly tiling the toolbar
158 // background image over that view.
159 gfx::Point
OffsetPointForToolbarBackgroundImage(
160 const gfx::Point
& point
) const;
162 // Container for the tabstrip, toolbar, etc.
163 TopContainerView
* top_container() { return top_container_
; }
165 // Accessor for the TabStrip.
166 TabStrip
* tabstrip() { return tabstrip_
; }
168 // Accessor for the Toolbar.
169 ToolbarView
* toolbar() { return toolbar_
; }
171 // Bookmark bar may be NULL, for example for pop-ups.
172 BookmarkBarView
* bookmark_bar() { return bookmark_bar_view_
.get(); }
174 // Returns the do-nothing view which controls the z-order of the find bar
175 // widget relative to views which paint into layers and views which have an
176 // associated NativeView. The presence / visibility of this view is not
177 // indicative of the visibility of the find bar widget or even whether
178 // FindBarController is initialized.
179 View
* find_bar_host_view() { return find_bar_host_view_
; }
181 // Accessor for the InfobarContainer.
182 InfoBarContainerView
* infobar_container() { return infobar_container_
; }
184 // Accessor for the FullscreenExitBubbleViews.
185 FullscreenExitBubbleViews
* fullscreen_exit_bubble() {
186 return fullscreen_bubble_
.get();
189 // Returns true if various window components are visible.
190 bool IsTabStripVisible() const;
192 // Returns true if the profile associated with this Browser window is
194 bool IsOffTheRecord() const;
196 // Returns true if the profile associated with this Browser window is
198 bool IsGuestSession() const;
200 // Returns true if the profile associated with this Browser window is
201 // not off the record or a guest session.
202 bool IsRegularOrGuestSession() const;
204 // Returns true if the non-client view should render an avatar icon.
205 bool ShouldShowAvatar() const;
207 // Provides the containing frame with the accelerator for the specified
208 // command id. This can be used to provide menu item shortcut hints etc.
209 // Returns true if an accelerator was found for the specified |cmd_id|, false
211 bool GetAccelerator(int cmd_id
, ui::Accelerator
* accelerator
);
213 // Returns true if the specificed |accelerator| is registered with this view.
214 bool IsAcceleratorRegistered(const ui::Accelerator
& accelerator
);
216 // Returns the active WebContents. Used by our NonClientView's
217 // TabIconView::TabContentsProvider implementations.
218 // TODO(beng): exposing this here is a bit bogus, since it's only used to
219 // determine loading state. It'd be nicer if we could change this to be
220 // bool IsSelectedTabLoading() const; or something like that. We could even
221 // move it to a WindowDelegate subclass.
222 content::WebContents
* GetActiveWebContents() const;
224 // Retrieves the icon to use in the frame to indicate an OTR window.
225 gfx::ImageSkia
GetOTRAvatarIcon() const;
227 // Returns true if the Browser object associated with this BrowserView is a
228 // tabbed-type window (i.e. a browser window, not an app or popup).
229 bool IsBrowserTypeNormal() const {
230 return browser_
->is_type_tabbed();
233 // See ImmersiveModeController for description.
234 ImmersiveModeController
* immersive_mode_controller() const {
235 return immersive_mode_controller_
.get();
238 // Restores the focused view. This is also used to set the initial focus
239 // when a new browser window is created.
242 void SetWindowSwitcherButton(views::Button
* button
);
244 views::Button
* window_switcher_button() {
245 return window_switcher_button_
;
248 // Called after the widget's fullscreen state is changed without going through
249 // FullscreenController. This method does any processing which was skipped.
250 // Only exiting fullscreen in this way is currently supported.
251 void FullscreenStateChanged();
253 // Called from BookmarkBarView/DownloadShelfView during their show/hide
255 void ToolbarSizeChanged(bool is_animating
);
257 // Overridden from BrowserWindow:
258 virtual void Show() OVERRIDE
;
259 virtual void ShowInactive() OVERRIDE
;
260 virtual void Hide() OVERRIDE
;
261 virtual void SetBounds(const gfx::Rect
& bounds
) OVERRIDE
;
262 virtual void Close() OVERRIDE
;
263 virtual void Activate() OVERRIDE
;
264 virtual void Deactivate() OVERRIDE
;
265 virtual bool IsActive() const OVERRIDE
;
266 virtual void FlashFrame(bool flash
) OVERRIDE
;
267 virtual bool IsAlwaysOnTop() const OVERRIDE
;
268 virtual void SetAlwaysOnTop(bool always_on_top
) OVERRIDE
;
269 virtual gfx::NativeWindow
GetNativeWindow() OVERRIDE
;
270 virtual BrowserWindowTesting
* GetBrowserWindowTesting() OVERRIDE
;
271 virtual StatusBubble
* GetStatusBubble() OVERRIDE
;
272 virtual void UpdateTitleBar() OVERRIDE
;
273 virtual void BookmarkBarStateChanged(
274 BookmarkBar::AnimateChangeType change_type
) OVERRIDE
;
275 virtual void UpdateDevTools() OVERRIDE
;
276 virtual void UpdateLoadingAnimations(bool should_animate
) OVERRIDE
;
277 virtual void SetStarredState(bool is_starred
) OVERRIDE
;
278 virtual void SetTranslateIconToggled(bool is_lit
) OVERRIDE
;
279 virtual void OnActiveTabChanged(content::WebContents
* old_contents
,
280 content::WebContents
* new_contents
,
282 int reason
) OVERRIDE
;
283 virtual void ZoomChangedForActiveTab(bool can_show_bubble
) OVERRIDE
;
284 virtual gfx::Rect
GetRestoredBounds() const OVERRIDE
;
285 virtual ui::WindowShowState
GetRestoredState() const OVERRIDE
;
286 virtual gfx::Rect
GetBounds() const OVERRIDE
;
287 virtual bool IsMaximized() const OVERRIDE
;
288 virtual bool IsMinimized() const OVERRIDE
;
289 virtual void Maximize() OVERRIDE
;
290 virtual void Minimize() OVERRIDE
;
291 virtual void Restore() OVERRIDE
;
292 virtual void EnterFullscreen(
293 const GURL
& url
, FullscreenExitBubbleType bubble_type
) OVERRIDE
;
294 virtual void ExitFullscreen() OVERRIDE
;
295 virtual void UpdateFullscreenExitBubbleContent(
297 FullscreenExitBubbleType bubble_type
) OVERRIDE
;
298 virtual bool ShouldHideUIForFullscreen() const OVERRIDE
;
299 virtual bool IsFullscreen() const OVERRIDE
;
300 virtual bool IsFullscreenBubbleVisible() const OVERRIDE
;
302 virtual void SetMetroSnapMode(bool enable
) OVERRIDE
;
303 virtual bool IsInMetroSnapMode() const OVERRIDE
;
305 virtual LocationBar
* GetLocationBar() const OVERRIDE
;
306 virtual void SetFocusToLocationBar(bool select_all
) OVERRIDE
;
307 virtual void UpdateReloadStopState(bool is_loading
, bool force
) OVERRIDE
;
308 virtual void UpdateToolbar(content::WebContents
* contents
) OVERRIDE
;
309 virtual void FocusToolbar() OVERRIDE
;
310 virtual void FocusAppMenu() OVERRIDE
;
311 virtual void FocusBookmarksToolbar() OVERRIDE
;
312 virtual void FocusInfobars() OVERRIDE
;
313 virtual void RotatePaneFocus(bool forwards
) OVERRIDE
;
314 virtual void DestroyBrowser() OVERRIDE
;
315 virtual bool IsBookmarkBarVisible() const OVERRIDE
;
316 virtual bool IsBookmarkBarAnimating() const OVERRIDE
;
317 virtual bool IsTabStripEditable() const OVERRIDE
;
318 virtual bool IsToolbarVisible() const OVERRIDE
;
319 virtual gfx::Rect
GetRootWindowResizerRect() const OVERRIDE
;
320 virtual void ConfirmAddSearchProvider(TemplateURL
* template_url
,
321 Profile
* profile
) OVERRIDE
;
322 virtual void ShowUpdateChromeDialog() OVERRIDE
;
323 virtual void ShowBookmarkBubble(const GURL
& url
,
324 bool already_bookmarked
) OVERRIDE
;
325 virtual void ShowBookmarkAppBubble(
326 const WebApplicationInfo
& web_app_info
,
327 const std::string
& extension_id
) OVERRIDE
;
328 virtual void ShowTranslateBubble(content::WebContents
* contents
,
329 translate::TranslateStep step
,
330 TranslateErrors::Type error_type
) OVERRIDE
;
331 #if defined(ENABLE_ONE_CLICK_SIGNIN)
332 virtual void ShowOneClickSigninBubble(
333 OneClickSigninBubbleType type
,
334 const base::string16
& email
,
335 const base::string16
& error_message
,
336 const StartSyncCallback
& start_sync_callback
) OVERRIDE
;
338 // TODO(beng): Not an override, move somewhere else.
339 void SetDownloadShelfVisible(bool visible
);
340 virtual bool IsDownloadShelfVisible() const OVERRIDE
;
341 virtual DownloadShelf
* GetDownloadShelf() OVERRIDE
;
342 virtual void ConfirmBrowserCloseWithPendingDownloads(
344 Browser::DownloadClosePreventionType dialog_type
,
346 const base::Callback
<void(bool)>& callback
) OVERRIDE
;
347 virtual void UserChangedTheme() OVERRIDE
;
348 virtual int GetExtraRenderViewHeight() const OVERRIDE
;
349 virtual void WebContentsFocused(content::WebContents
* contents
) OVERRIDE
;
350 virtual void ShowWebsiteSettings(Profile
* profile
,
351 content::WebContents
* web_contents
,
353 const content::SSLStatus
& ssl
) OVERRIDE
;
354 virtual void ShowAppMenu() OVERRIDE
;
355 virtual bool PreHandleKeyboardEvent(
356 const content::NativeWebKeyboardEvent
& event
,
357 bool* is_keyboard_shortcut
) OVERRIDE
;
358 virtual void HandleKeyboardEvent(
359 const content::NativeWebKeyboardEvent
& event
) OVERRIDE
;
360 virtual void Cut() OVERRIDE
;
361 virtual void Copy() OVERRIDE
;
362 virtual void Paste() OVERRIDE
;
363 virtual WindowOpenDisposition
GetDispositionForPopupBounds(
364 const gfx::Rect
& bounds
) OVERRIDE
;
365 virtual FindBar
* CreateFindBar() OVERRIDE
;
366 virtual web_modal::WebContentsModalDialogHost
*
367 GetWebContentsModalDialogHost() OVERRIDE
;
368 virtual void ShowAvatarBubble(content::WebContents
* web_contents
,
369 const gfx::Rect
& rect
) OVERRIDE
;
370 virtual void ShowAvatarBubbleFromAvatarButton(AvatarBubbleMode mode
) OVERRIDE
;
371 virtual void ShowPasswordGenerationBubble(
372 const gfx::Rect
& rect
,
373 const autofill::PasswordForm
& form
,
374 autofill::PasswordGenerator
* password_generator
) OVERRIDE
;
375 virtual void OverscrollUpdate(int delta_y
) OVERRIDE
;
376 virtual int GetRenderViewHeightInsetWithDetachedBookmarkBar() OVERRIDE
;
377 virtual void ExecuteExtensionCommand(
378 const extensions::Extension
* extension
,
379 const extensions::Command
& command
) OVERRIDE
;
380 virtual void ShowPageActionPopup(
381 const extensions::Extension
* extension
) OVERRIDE
;
382 virtual void ShowBrowserActionPopup(
383 const extensions::Extension
* extension
) OVERRIDE
;
385 // Overridden from BrowserWindowTesting:
386 virtual BookmarkBarView
* GetBookmarkBarView() const OVERRIDE
;
387 virtual LocationBarView
* GetLocationBarView() const OVERRIDE
;
388 virtual views::View
* GetTabContentsContainerView() const OVERRIDE
;
389 virtual ToolbarView
* GetToolbarView() const OVERRIDE
;
391 // Overridden from TabStripModelObserver:
392 virtual void TabInsertedAt(content::WebContents
* contents
,
394 bool foreground
) OVERRIDE
;
395 virtual void TabDetachedAt(content::WebContents
* contents
,
397 virtual void TabDeactivated(content::WebContents
* contents
) OVERRIDE
;
398 virtual void TabStripEmpty() OVERRIDE
;
399 virtual void WillCloseAllTabs() OVERRIDE
;
400 virtual void CloseAllTabsCanceled() OVERRIDE
;
402 // Overridden from ui::AcceleratorProvider:
403 virtual bool GetAcceleratorForCommandId(int command_id
,
404 ui::Accelerator
* accelerator
) OVERRIDE
;
406 // Overridden from views::WidgetDelegate:
407 virtual bool CanResize() const OVERRIDE
;
408 virtual bool CanMaximize() const OVERRIDE
;
409 virtual bool CanActivate() const OVERRIDE
;
410 virtual base::string16
GetWindowTitle() const OVERRIDE
;
411 virtual base::string16
GetAccessibleWindowTitle() const OVERRIDE
;
412 virtual views::View
* GetInitiallyFocusedView() OVERRIDE
;
413 virtual bool ShouldShowWindowTitle() const OVERRIDE
;
414 virtual gfx::ImageSkia
GetWindowAppIcon() OVERRIDE
;
415 virtual gfx::ImageSkia
GetWindowIcon() OVERRIDE
;
416 virtual bool ShouldShowWindowIcon() const OVERRIDE
;
417 virtual bool ExecuteWindowsCommand(int command_id
) OVERRIDE
;
418 virtual std::string
GetWindowName() const OVERRIDE
;
419 virtual void SaveWindowPlacement(const gfx::Rect
& bounds
,
420 ui::WindowShowState show_state
) OVERRIDE
;
421 virtual bool GetSavedWindowPlacement(
422 const views::Widget
* widget
,
424 ui::WindowShowState
* show_state
) const OVERRIDE
;
425 virtual views::View
* GetContentsView() OVERRIDE
;
426 virtual views::ClientView
* CreateClientView(views::Widget
* widget
) OVERRIDE
;
427 virtual void OnWindowBeginUserBoundsChange() OVERRIDE
;
428 virtual void OnWidgetMove() OVERRIDE
;
429 virtual views::Widget
* GetWidget() OVERRIDE
;
430 virtual const views::Widget
* GetWidget() const OVERRIDE
;
431 virtual void GetAccessiblePanes(std::vector
<View
*>* panes
) OVERRIDE
;
433 // Overridden from views::WidgetObserver:
434 virtual void OnWidgetActivationChanged(views::Widget
* widget
,
435 bool active
) OVERRIDE
;
437 // Overridden from views::ClientView:
438 virtual bool CanClose() OVERRIDE
;
439 virtual int NonClientHitTest(const gfx::Point
& point
) OVERRIDE
;
440 virtual gfx::Size
GetMinimumSize() OVERRIDE
;
442 // InfoBarContainer::Delegate overrides
443 virtual SkColor
GetInfoBarSeparatorColor() const OVERRIDE
;
444 virtual void InfoBarContainerStateChanged(bool is_animating
) OVERRIDE
;
445 virtual bool DrawInfoBarArrows(int* x
) const OVERRIDE
;
447 // Overridden from views::View:
448 virtual const char* GetClassName() const OVERRIDE
;
449 virtual void Layout() OVERRIDE
;
450 virtual void PaintChildren(gfx::Canvas
* canvas
) OVERRIDE
;
451 virtual void ViewHierarchyChanged(
452 const ViewHierarchyChangedDetails
& details
) OVERRIDE
;
453 virtual void ChildPreferredSizeChanged(View
* child
) OVERRIDE
;
454 virtual void GetAccessibleState(ui::AXViewState
* state
) OVERRIDE
;
455 virtual void OnNativeThemeChanged(const ui::NativeTheme
* theme
) OVERRIDE
;
457 // Overridden from ui::AcceleratorTarget:
458 virtual bool AcceleratorPressed(const ui::Accelerator
& accelerator
) OVERRIDE
;
460 // OmniboxPopupModelObserver overrides
461 virtual void OnOmniboxPopupShownOrHidden() OVERRIDE
;
463 // Testing interface:
464 views::View
* GetContentsContainerForTest() { return contents_container_
; }
465 views::WebView
* GetContentsWebViewForTest() { return contents_web_view_
; }
466 views::WebView
* GetDevToolsWebViewForTest() { return devtools_web_view_
; }
469 // Do not friend BrowserViewLayout. Use the BrowserViewLayoutDelegate
470 // interface to keep these two classes decoupled and testable.
471 friend class BrowserViewLayoutDelegateImpl
;
472 FRIEND_TEST_ALL_PREFIXES(BrowserViewTest
, BrowserView
);
473 FRIEND_TEST_ALL_PREFIXES(BrowserViewsAccessibilityTest
,
474 TestAboutChromeViewAccObj
);
476 enum FullscreenMode
{
478 METRO_SNAP_FULLSCREEN
481 // Appends to |toolbars| a pointer to each AccessiblePaneView that
482 // can be traversed using F6, in the order they should be traversed.
483 void GetAccessiblePanes(std::vector
<views::AccessiblePaneView
*>* panes
);
485 // Constructs and initializes the child views.
488 // Callback for the loading animation(s) associated with this view.
489 void LoadingAnimationCallback();
491 // LoadCompleteListener::Delegate implementation. Creates and initializes the
492 // |jumplist_| after the first page load.
493 virtual void OnLoadCompleted() OVERRIDE
;
495 // Returns the BrowserViewLayout.
496 BrowserViewLayout
* GetBrowserViewLayout() const;
498 // Returns the ContentsLayoutManager.
499 ContentsLayoutManager
* GetContentsLayoutManager() const;
501 // Prepare to show the Bookmark Bar for the specified WebContents.
502 // Returns true if the Bookmark Bar can be shown (i.e. it's supported for this
503 // Browser type) and there should be a subsequent re-layout to show it.
504 // |contents| can be NULL.
505 bool MaybeShowBookmarkBar(content::WebContents
* contents
);
507 // Moves the bookmark bar view to the specified parent, which may be NULL,
508 // |this|, or |top_container_|. Ensures that |top_container_| stays in front
509 // of |bookmark_bar_view_|.
510 void SetBookmarkBarParent(views::View
* new_parent
);
512 // Prepare to show an Info Bar for the specified WebContents. Returns
513 // true if there is an Info Bar to show and one is supported for this Browser
514 // type, and there should be a subsequent re-layout to show it.
515 // |contents| can be NULL.
516 bool MaybeShowInfoBar(content::WebContents
* contents
);
518 // Updates devtools window for given contents. This method will show docked
519 // devtools window for inspected |web_contents| that has docked devtools
520 // and hide it for NULL or not inspected |web_contents|. It will also make
521 // sure devtools window size and position are restored for given tab.
522 // This method will not update actual DevTools WebContents, if not
523 // |update_devtools_web_contents|. In this case, manual update is required.
524 void UpdateDevToolsForContents(content::WebContents
* web_contents
,
525 bool update_devtools_web_contents
);
527 // Updates various optional child Views, e.g. Bookmarks Bar, Info Bar or the
528 // Download Shelf in response to a change notification from the specified
529 // |contents|. |contents| can be NULL. In this case, all optional UI will be
531 void UpdateUIForContents(content::WebContents
* contents
);
533 // Invoked to update the necessary things when our fullscreen state changes
534 // to |fullscreen|. On Windows this is invoked immediately when we toggle the
535 // full screen state. On Linux changing the fullscreen state is async, so we
536 // ask the window to change its fullscreen state, then when we get
537 // notification that it succeeded this method is invoked.
538 // If |url| is not empty, it is the URL of the page that requested fullscreen
539 // (via the fullscreen JS API).
540 // |bubble_type| determines what should be shown in the fullscreen exit
542 void ProcessFullscreen(bool fullscreen
,
545 FullscreenExitBubbleType bubble_type
);
547 // Returns whether immmersive fullscreen should replace fullscreen. This
548 // should only occur for "browser-fullscreen" for tabbed-typed windows (not
549 // for tab-fullscreen and not for app/popup type windows).
550 bool ShouldUseImmersiveFullscreenForUrl(const GURL
& url
) const;
552 // Copy the accelerator table from the app resources into something we can
554 void LoadAccelerators();
556 // Retrieves the command id for the specified Windows app command.
557 int GetCommandIDForAppCommandID(int app_command_id
) const;
559 // Initialize the hung plugin detector.
560 void InitHangMonitor();
562 // Possibly records a user metrics action corresponding to the passed-in
563 // accelerator. Only implemented for Chrome OS, where we're interested in
564 // learning about how frequently the top-row keys are used.
565 void UpdateAcceleratorMetrics(const ui::Accelerator
& accelerator
,
568 // Calls |method| which is either WebContents::Cut, ::Copy, or ::Paste,
569 // first trying the content WebContents, then the devtools WebContents, and
570 // lastly the Views::Textfield if one is focused.
571 void DoCutCopyPaste(void (content::WebContents::*method
)(),
574 // Calls |method| which is either WebContents::Cut, ::Copy, or ::Paste on
575 // the given WebContents, returning true if it consumed the event.
576 bool DoCutCopyPasteForWebContents(
577 content::WebContents
* contents
,
578 void (content::WebContents::*method
)());
580 // Shows the next app-modal dialog box, if there is one to be shown, or moves
581 // an existing showing one to the front.
582 void ActivateAppModalDialog() const;
584 // Returns the max top arrow height for infobar.
585 int GetMaxTopInfoBarArrowHeight();
587 // Last focused view that issued a tab traversal.
588 int last_focused_view_storage_id_
;
590 // The BrowserFrame that hosts this view.
591 BrowserFrame
* frame_
;
593 // The Browser object we are associated with.
594 scoped_ptr
<Browser
> browser_
;
596 // BrowserView layout (LTR one is pictured here).
598 // --------------------------------------------------------------------
599 // | TopContainerView (top_container_) |
600 // | -------------------------------------------------------------- |
601 // | | Tabs (tabstrip_) | |
602 // | |------------------------------------------------------------| |
603 // | | Navigation buttons, address bar, menu (toolbar_) | |
604 // | -------------------------------------------------------------- |
605 // |------------------------------------------------------------------|
606 // | All infobars (infobar_container_) [1] |
607 // |------------------------------------------------------------------|
608 // | Bookmarks (bookmark_bar_view_) [1] |
609 // |------------------------------------------------------------------|
610 // | Contents container (contents_container_) |
611 // | -------------------------------------------------------------- |
612 // | | devtools_web_view_ | |
613 // | |------------------------------------------------------------| |
614 // | | contents_web_view_ | |
615 // | -------------------------------------------------------------- |
616 // |------------------------------------------------------------------|
617 // | Active downloads (download_shelf_) |
618 // --------------------------------------------------------------------
620 // [1] The bookmark bar and info bar are swapped when on the new tab page.
621 // Additionally when the bookmark bar is detached, contents_container_ is
622 // positioned on top of the bar while the tab's contents are placed below
623 // the bar. This allows the find bar to always align with the top of
624 // contents_container_ regardless if there's bookmark or info bars.
626 // The view that manages the tab strip, toolbar, and sometimes the bookmark
627 // bar. Stacked top in the view hiearachy so it can be used to slide out
628 // the top views in immersive fullscreen.
629 TopContainerView
* top_container_
;
634 // The Toolbar containing the navigation buttons, menus and the address bar.
635 ToolbarView
* toolbar_
;
637 // This button sits next to the tabs on the right hand side and it is used
638 // only in windows metro metro mode to allow the user to flip among browser
640 views::Button
* window_switcher_button_
;
642 // The Bookmark Bar View for this window. Lazily created. May be NULL for
643 // non-tabbed browsers like popups. May not be visible.
644 scoped_ptr
<BookmarkBarView
> bookmark_bar_view_
;
646 // The do-nothing view which controls the z-order of the find bar widget
647 // relative to views which paint into layers and views with an associated
649 View
* find_bar_host_view_
;
651 // The download shelf view (view at the bottom of the page).
652 scoped_ptr
<DownloadShelfView
> download_shelf_
;
654 // The InfoBarContainerView that contains InfoBars for the current tab.
655 InfoBarContainerView
* infobar_container_
;
657 // The view that contains the selected WebContents.
658 ContentsWebView
* contents_web_view_
;
660 // The view that contains devtools window for the selected WebContents.
661 views::WebView
* devtools_web_view_
;
663 // The view managing the devtools and contents positions.
664 // Handled by ContentsLayoutManager.
665 views::View
* contents_container_
;
667 // Docked devtools window instance. NULL when current tab is not inspected
668 // or is inspected with undocked version of DevToolsWindow.
669 DevToolsWindow
* devtools_window_
;
671 // Tracks and stores the last focused view which is not the
672 // devtools_web_view_ or any of its children. Used to restore focus once
673 // the devtools_web_view_ is hidden.
674 scoped_ptr
<views::ExternalFocusTracker
> devtools_focus_tracker_
;
676 // The Status information bubble that appears at the bottom of the window.
677 scoped_ptr
<StatusBubbleViews
> status_bubble_
;
679 // The permission bubble view is the toolkit-specific implementation of the
680 // interface used by the manager to display permissions bubbles.
681 scoped_ptr
<PermissionBubbleViewViews
> permission_bubble_view_
;
683 // A mapping between accelerators and commands.
684 std::map
<ui::Accelerator
, int> accelerator_table_
;
686 // True if we have already been initialized.
689 // True when in ProcessFullscreen(). The flag is used to avoid reentrance and
690 // to ignore requests to layout while in ProcessFullscreen() to reduce
692 bool in_process_fullscreen_
;
694 scoped_ptr
<FullscreenExitBubbleViews
> fullscreen_bubble_
;
697 // This object is used to perform periodic actions in a worker
698 // thread. It is currently used to monitor hung plugin windows.
699 WorkerThreadTicker ticker_
;
701 // This object is initialized with the frame window HWND. This
702 // object is also passed as a tick handler with the ticker_ object.
703 // It is used to periodically monitor for hung plugin windows
704 HungWindowDetector hung_window_detector_
;
706 // This object is invoked by hung_window_detector_ when it detects a hung
708 HungPluginAction hung_plugin_action_
;
710 // Helper class to listen for completion of first page load.
711 scoped_ptr
<LoadCompleteListener
> load_complete_listener_
;
713 // The custom JumpList for Windows 7.
714 scoped_refptr
<JumpList
> jumplist_
;
717 // The timer used to update frames for the Loading Animation.
718 base::RepeatingTimer
<BrowserView
> loading_animation_timer_
;
720 views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_
;
722 // Used to measure the loading spinner animation rate.
723 base::TimeTicks last_animation_time_
;
725 // If this flag is set then SetFocusToLocationBar() will set focus to the
726 // location bar even if the browser window is not active.
727 bool force_location_bar_focus_
;
729 scoped_ptr
<ImmersiveModeController
> immersive_mode_controller_
;
731 scoped_ptr
<ScrollEndEffectController
> scroll_end_effect_controller_
;
733 scoped_ptr
<WebContentsCloseHandler
> web_contents_close_handler_
;
735 mutable base::WeakPtrFactory
<BrowserView
> activate_modal_dialog_factory_
;
737 DISALLOW_COPY_AND_ASSIGN(BrowserView
);
740 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_