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
) const;
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 // Called after the widget's fullscreen state is changed without going through
243 // FullscreenController. This method does any processing which was skipped.
244 // Only exiting fullscreen in this way is currently supported.
245 void FullscreenStateChanged();
247 // Called from BookmarkBarView/DownloadShelfView during their show/hide
249 void ToolbarSizeChanged(bool is_animating
);
251 // Overridden from BrowserWindow:
252 virtual void Show() OVERRIDE
;
253 virtual void ShowInactive() OVERRIDE
;
254 virtual void Hide() OVERRIDE
;
255 virtual void SetBounds(const gfx::Rect
& bounds
) OVERRIDE
;
256 virtual void Close() OVERRIDE
;
257 virtual void Activate() OVERRIDE
;
258 virtual void Deactivate() OVERRIDE
;
259 virtual bool IsActive() const OVERRIDE
;
260 virtual void FlashFrame(bool flash
) OVERRIDE
;
261 virtual bool IsAlwaysOnTop() const OVERRIDE
;
262 virtual void SetAlwaysOnTop(bool always_on_top
) OVERRIDE
;
263 virtual gfx::NativeWindow
GetNativeWindow() OVERRIDE
;
264 virtual BrowserWindowTesting
* GetBrowserWindowTesting() OVERRIDE
;
265 virtual StatusBubble
* GetStatusBubble() OVERRIDE
;
266 virtual void UpdateTitleBar() OVERRIDE
;
267 virtual void BookmarkBarStateChanged(
268 BookmarkBar::AnimateChangeType change_type
) OVERRIDE
;
269 virtual void UpdateDevTools() OVERRIDE
;
270 virtual void UpdateLoadingAnimations(bool should_animate
) OVERRIDE
;
271 virtual void SetStarredState(bool is_starred
) OVERRIDE
;
272 virtual void SetTranslateIconToggled(bool is_lit
) OVERRIDE
;
273 virtual void OnActiveTabChanged(content::WebContents
* old_contents
,
274 content::WebContents
* new_contents
,
276 int reason
) OVERRIDE
;
277 virtual void ZoomChangedForActiveTab(bool can_show_bubble
) OVERRIDE
;
278 virtual gfx::Rect
GetRestoredBounds() const OVERRIDE
;
279 virtual ui::WindowShowState
GetRestoredState() const OVERRIDE
;
280 virtual gfx::Rect
GetBounds() const OVERRIDE
;
281 virtual bool IsMaximized() const OVERRIDE
;
282 virtual bool IsMinimized() const OVERRIDE
;
283 virtual void Maximize() OVERRIDE
;
284 virtual void Minimize() OVERRIDE
;
285 virtual void Restore() OVERRIDE
;
286 virtual void EnterFullscreen(
287 const GURL
& url
, FullscreenExitBubbleType bubble_type
) OVERRIDE
;
288 virtual void ExitFullscreen() OVERRIDE
;
289 virtual void UpdateFullscreenExitBubbleContent(
291 FullscreenExitBubbleType bubble_type
) OVERRIDE
;
292 virtual bool ShouldHideUIForFullscreen() const OVERRIDE
;
293 virtual bool IsFullscreen() const OVERRIDE
;
294 virtual bool IsFullscreenBubbleVisible() const OVERRIDE
;
296 virtual void SetMetroSnapMode(bool enable
) OVERRIDE
;
297 virtual bool IsInMetroSnapMode() const OVERRIDE
;
299 virtual LocationBar
* GetLocationBar() const OVERRIDE
;
300 virtual void SetFocusToLocationBar(bool select_all
) OVERRIDE
;
301 virtual void UpdateReloadStopState(bool is_loading
, bool force
) OVERRIDE
;
302 virtual void UpdateToolbar(content::WebContents
* contents
) OVERRIDE
;
303 virtual void FocusToolbar() OVERRIDE
;
304 virtual void FocusAppMenu() OVERRIDE
;
305 virtual void FocusBookmarksToolbar() OVERRIDE
;
306 virtual void FocusInfobars() OVERRIDE
;
307 virtual void RotatePaneFocus(bool forwards
) OVERRIDE
;
308 virtual void DestroyBrowser() OVERRIDE
;
309 virtual bool IsBookmarkBarVisible() const OVERRIDE
;
310 virtual bool IsBookmarkBarAnimating() const OVERRIDE
;
311 virtual bool IsTabStripEditable() const OVERRIDE
;
312 virtual bool IsToolbarVisible() const OVERRIDE
;
313 virtual gfx::Rect
GetRootWindowResizerRect() const OVERRIDE
;
314 virtual void ConfirmAddSearchProvider(TemplateURL
* template_url
,
315 Profile
* profile
) OVERRIDE
;
316 virtual void ShowUpdateChromeDialog() OVERRIDE
;
317 virtual void ShowBookmarkBubble(const GURL
& url
,
318 bool already_bookmarked
) OVERRIDE
;
319 virtual void ShowBookmarkAppBubble(
320 const WebApplicationInfo
& web_app_info
,
321 const std::string
& extension_id
) OVERRIDE
;
322 virtual void ShowTranslateBubble(content::WebContents
* contents
,
323 translate::TranslateStep step
,
324 TranslateErrors::Type error_type
) OVERRIDE
;
325 #if defined(ENABLE_ONE_CLICK_SIGNIN)
326 virtual void ShowOneClickSigninBubble(
327 OneClickSigninBubbleType type
,
328 const base::string16
& email
,
329 const base::string16
& error_message
,
330 const StartSyncCallback
& start_sync_callback
) OVERRIDE
;
332 // TODO(beng): Not an override, move somewhere else.
333 void SetDownloadShelfVisible(bool visible
);
334 virtual bool IsDownloadShelfVisible() const OVERRIDE
;
335 virtual DownloadShelf
* GetDownloadShelf() OVERRIDE
;
336 virtual void ConfirmBrowserCloseWithPendingDownloads(
338 Browser::DownloadClosePreventionType dialog_type
,
340 const base::Callback
<void(bool)>& callback
) OVERRIDE
;
341 virtual void UserChangedTheme() OVERRIDE
;
342 virtual int GetExtraRenderViewHeight() const OVERRIDE
;
343 virtual void WebContentsFocused(content::WebContents
* contents
) OVERRIDE
;
344 virtual void ShowWebsiteSettings(Profile
* profile
,
345 content::WebContents
* web_contents
,
347 const content::SSLStatus
& ssl
) OVERRIDE
;
348 virtual void ShowAppMenu() OVERRIDE
;
349 virtual bool PreHandleKeyboardEvent(
350 const content::NativeWebKeyboardEvent
& event
,
351 bool* is_keyboard_shortcut
) OVERRIDE
;
352 virtual void HandleKeyboardEvent(
353 const content::NativeWebKeyboardEvent
& event
) OVERRIDE
;
354 virtual void Cut() OVERRIDE
;
355 virtual void Copy() OVERRIDE
;
356 virtual void Paste() OVERRIDE
;
357 virtual WindowOpenDisposition
GetDispositionForPopupBounds(
358 const gfx::Rect
& bounds
) OVERRIDE
;
359 virtual FindBar
* CreateFindBar() OVERRIDE
;
360 virtual web_modal::WebContentsModalDialogHost
*
361 GetWebContentsModalDialogHost() OVERRIDE
;
362 virtual void ShowAvatarBubble(content::WebContents
* web_contents
,
363 const gfx::Rect
& rect
) OVERRIDE
;
364 virtual void ShowAvatarBubbleFromAvatarButton(AvatarBubbleMode mode
) OVERRIDE
;
365 virtual void ShowPasswordGenerationBubble(
366 const gfx::Rect
& rect
,
367 const autofill::PasswordForm
& form
,
368 autofill::PasswordGenerator
* password_generator
) OVERRIDE
;
369 virtual void OverscrollUpdate(int delta_y
) OVERRIDE
;
370 virtual int GetRenderViewHeightInsetWithDetachedBookmarkBar() OVERRIDE
;
371 virtual void ExecuteExtensionCommand(
372 const extensions::Extension
* extension
,
373 const extensions::Command
& command
) OVERRIDE
;
374 virtual void ShowPageActionPopup(
375 const extensions::Extension
* extension
) OVERRIDE
;
376 virtual void ShowBrowserActionPopup(
377 const extensions::Extension
* extension
) OVERRIDE
;
379 // Overridden from BrowserWindowTesting:
380 virtual BookmarkBarView
* GetBookmarkBarView() const OVERRIDE
;
381 virtual LocationBarView
* GetLocationBarView() const OVERRIDE
;
382 virtual views::View
* GetTabContentsContainerView() const OVERRIDE
;
383 virtual ToolbarView
* GetToolbarView() const OVERRIDE
;
385 // Overridden from TabStripModelObserver:
386 virtual void TabInsertedAt(content::WebContents
* contents
,
388 bool foreground
) OVERRIDE
;
389 virtual void TabDetachedAt(content::WebContents
* contents
,
391 virtual void TabDeactivated(content::WebContents
* contents
) OVERRIDE
;
392 virtual void TabStripEmpty() OVERRIDE
;
393 virtual void WillCloseAllTabs() OVERRIDE
;
394 virtual void CloseAllTabsCanceled() OVERRIDE
;
396 // Overridden from ui::AcceleratorProvider:
397 virtual bool GetAcceleratorForCommandId(int command_id
,
398 ui::Accelerator
* accelerator
) OVERRIDE
;
400 // Overridden from views::WidgetDelegate:
401 virtual bool CanResize() const OVERRIDE
;
402 virtual bool CanMaximize() const OVERRIDE
;
403 virtual bool CanActivate() const OVERRIDE
;
404 virtual base::string16
GetWindowTitle() const OVERRIDE
;
405 virtual base::string16
GetAccessibleWindowTitle() const OVERRIDE
;
406 virtual views::View
* GetInitiallyFocusedView() OVERRIDE
;
407 virtual bool ShouldShowWindowTitle() const OVERRIDE
;
408 virtual gfx::ImageSkia
GetWindowAppIcon() OVERRIDE
;
409 virtual gfx::ImageSkia
GetWindowIcon() OVERRIDE
;
410 virtual bool ShouldShowWindowIcon() const OVERRIDE
;
411 virtual bool ExecuteWindowsCommand(int command_id
) OVERRIDE
;
412 virtual std::string
GetWindowName() const OVERRIDE
;
413 virtual void SaveWindowPlacement(const gfx::Rect
& bounds
,
414 ui::WindowShowState show_state
) OVERRIDE
;
415 virtual bool GetSavedWindowPlacement(
416 const views::Widget
* widget
,
418 ui::WindowShowState
* show_state
) const OVERRIDE
;
419 virtual views::View
* GetContentsView() OVERRIDE
;
420 virtual views::ClientView
* CreateClientView(views::Widget
* widget
) OVERRIDE
;
421 virtual void OnWindowBeginUserBoundsChange() OVERRIDE
;
422 virtual void OnWidgetMove() OVERRIDE
;
423 virtual views::Widget
* GetWidget() OVERRIDE
;
424 virtual const views::Widget
* GetWidget() const OVERRIDE
;
425 virtual void GetAccessiblePanes(std::vector
<View
*>* panes
) OVERRIDE
;
427 // Overridden from views::WidgetObserver:
428 virtual void OnWidgetActivationChanged(views::Widget
* widget
,
429 bool active
) OVERRIDE
;
431 // Overridden from views::ClientView:
432 virtual bool CanClose() OVERRIDE
;
433 virtual int NonClientHitTest(const gfx::Point
& point
) OVERRIDE
;
434 virtual gfx::Size
GetMinimumSize() const OVERRIDE
;
436 // InfoBarContainer::Delegate overrides
437 virtual SkColor
GetInfoBarSeparatorColor() const OVERRIDE
;
438 virtual void InfoBarContainerStateChanged(bool is_animating
) OVERRIDE
;
439 virtual bool DrawInfoBarArrows(int* x
) const OVERRIDE
;
441 // Overridden from views::View:
442 virtual const char* GetClassName() const OVERRIDE
;
443 virtual void Layout() OVERRIDE
;
444 virtual void PaintChildren(gfx::Canvas
* canvas
,
445 const views::CullSet
& cull_set
) OVERRIDE
;
446 virtual void ViewHierarchyChanged(
447 const ViewHierarchyChangedDetails
& details
) OVERRIDE
;
448 virtual void ChildPreferredSizeChanged(View
* child
) OVERRIDE
;
449 virtual void GetAccessibleState(ui::AXViewState
* state
) OVERRIDE
;
450 virtual void OnNativeThemeChanged(const ui::NativeTheme
* theme
) OVERRIDE
;
452 // Overridden from ui::AcceleratorTarget:
453 virtual bool AcceleratorPressed(const ui::Accelerator
& accelerator
) OVERRIDE
;
455 // OmniboxPopupModelObserver overrides
456 virtual void OnOmniboxPopupShownOrHidden() OVERRIDE
;
458 // Testing interface:
459 views::View
* GetContentsContainerForTest() { return contents_container_
; }
460 views::WebView
* GetContentsWebViewForTest() { return contents_web_view_
; }
461 views::WebView
* GetDevToolsWebViewForTest() { return devtools_web_view_
; }
464 // Do not friend BrowserViewLayout. Use the BrowserViewLayoutDelegate
465 // interface to keep these two classes decoupled and testable.
466 friend class BrowserViewLayoutDelegateImpl
;
467 FRIEND_TEST_ALL_PREFIXES(BrowserViewTest
, BrowserView
);
468 FRIEND_TEST_ALL_PREFIXES(BrowserViewsAccessibilityTest
,
469 TestAboutChromeViewAccObj
);
471 enum FullscreenMode
{
473 METRO_SNAP_FULLSCREEN
476 // Appends to |toolbars| a pointer to each AccessiblePaneView that
477 // can be traversed using F6, in the order they should be traversed.
478 void GetAccessiblePanes(std::vector
<views::AccessiblePaneView
*>* panes
);
480 // Constructs and initializes the child views.
483 // Callback for the loading animation(s) associated with this view.
484 void LoadingAnimationCallback();
486 // LoadCompleteListener::Delegate implementation. Creates and initializes the
487 // |jumplist_| after the first page load.
488 virtual void OnLoadCompleted() OVERRIDE
;
490 // Returns the BrowserViewLayout.
491 BrowserViewLayout
* GetBrowserViewLayout() const;
493 // Returns the ContentsLayoutManager.
494 ContentsLayoutManager
* GetContentsLayoutManager() const;
496 // Prepare to show the Bookmark Bar for the specified WebContents.
497 // Returns true if the Bookmark Bar can be shown (i.e. it's supported for this
498 // Browser type) and there should be a subsequent re-layout to show it.
499 // |contents| can be NULL.
500 bool MaybeShowBookmarkBar(content::WebContents
* contents
);
502 // Moves the bookmark bar view to the specified parent, which may be NULL,
503 // |this|, or |top_container_|. Ensures that |top_container_| stays in front
504 // of |bookmark_bar_view_|.
505 void SetBookmarkBarParent(views::View
* new_parent
);
507 // Prepare to show an Info Bar for the specified WebContents. Returns
508 // true if there is an Info Bar to show and one is supported for this Browser
509 // type, and there should be a subsequent re-layout to show it.
510 // |contents| can be NULL.
511 bool MaybeShowInfoBar(content::WebContents
* contents
);
513 // Updates devtools window for given contents. This method will show docked
514 // devtools window for inspected |web_contents| that has docked devtools
515 // and hide it for NULL or not inspected |web_contents|. It will also make
516 // sure devtools window size and position are restored for given tab.
517 // This method will not update actual DevTools WebContents, if not
518 // |update_devtools_web_contents|. In this case, manual update is required.
519 void UpdateDevToolsForContents(content::WebContents
* web_contents
,
520 bool update_devtools_web_contents
);
522 // Updates various optional child Views, e.g. Bookmarks Bar, Info Bar or the
523 // Download Shelf in response to a change notification from the specified
524 // |contents|. |contents| can be NULL. In this case, all optional UI will be
526 void UpdateUIForContents(content::WebContents
* contents
);
528 // Invoked to update the necessary things when our fullscreen state changes
529 // to |fullscreen|. On Windows this is invoked immediately when we toggle the
530 // full screen state. On Linux changing the fullscreen state is async, so we
531 // ask the window to change its fullscreen state, then when we get
532 // notification that it succeeded this method is invoked.
533 // If |url| is not empty, it is the URL of the page that requested fullscreen
534 // (via the fullscreen JS API).
535 // |bubble_type| determines what should be shown in the fullscreen exit
537 void ProcessFullscreen(bool fullscreen
,
540 FullscreenExitBubbleType bubble_type
);
542 // Returns whether immmersive fullscreen should replace fullscreen. This
543 // should only occur for "browser-fullscreen" for tabbed-typed windows (not
544 // for tab-fullscreen and not for app/popup type windows).
545 bool ShouldUseImmersiveFullscreenForUrl(const GURL
& url
) const;
547 // Copy the accelerator table from the app resources into something we can
549 void LoadAccelerators();
551 // Retrieves the command id for the specified Windows app command.
552 int GetCommandIDForAppCommandID(int app_command_id
) const;
554 // Initialize the hung plugin detector.
555 void InitHangMonitor();
557 // Possibly records a user metrics action corresponding to the passed-in
558 // accelerator. Only implemented for Chrome OS, where we're interested in
559 // learning about how frequently the top-row keys are used.
560 void UpdateAcceleratorMetrics(const ui::Accelerator
& accelerator
,
563 // Calls |method| which is either WebContents::Cut, ::Copy, or ::Paste,
564 // first trying the content WebContents, then the devtools WebContents, and
565 // lastly the Views::Textfield if one is focused.
566 void DoCutCopyPaste(void (content::WebContents::*method
)(),
569 // Calls |method| which is either WebContents::Cut, ::Copy, or ::Paste on
570 // the given WebContents, returning true if it consumed the event.
571 bool DoCutCopyPasteForWebContents(
572 content::WebContents
* contents
,
573 void (content::WebContents::*method
)());
575 // Shows the next app-modal dialog box, if there is one to be shown, or moves
576 // an existing showing one to the front.
577 void ActivateAppModalDialog() const;
579 // Returns the max top arrow height for infobar.
580 int GetMaxTopInfoBarArrowHeight();
582 // Last focused view that issued a tab traversal.
583 int last_focused_view_storage_id_
;
585 // The BrowserFrame that hosts this view.
586 BrowserFrame
* frame_
;
588 // The Browser object we are associated with.
589 scoped_ptr
<Browser
> browser_
;
591 // BrowserView layout (LTR one is pictured here).
593 // --------------------------------------------------------------------
594 // | TopContainerView (top_container_) |
595 // | -------------------------------------------------------------- |
596 // | | Tabs (tabstrip_) | |
597 // | |------------------------------------------------------------| |
598 // | | Navigation buttons, address bar, menu (toolbar_) | |
599 // | -------------------------------------------------------------- |
600 // |------------------------------------------------------------------|
601 // | All infobars (infobar_container_) [1] |
602 // |------------------------------------------------------------------|
603 // | Bookmarks (bookmark_bar_view_) [1] |
604 // |------------------------------------------------------------------|
605 // | Contents container (contents_container_) |
606 // | -------------------------------------------------------------- |
607 // | | devtools_web_view_ | |
608 // | |------------------------------------------------------------| |
609 // | | contents_web_view_ | |
610 // | -------------------------------------------------------------- |
611 // |------------------------------------------------------------------|
612 // | Active downloads (download_shelf_) |
613 // --------------------------------------------------------------------
615 // [1] The bookmark bar and info bar are swapped when on the new tab page.
616 // Additionally when the bookmark bar is detached, contents_container_ is
617 // positioned on top of the bar while the tab's contents are placed below
618 // the bar. This allows the find bar to always align with the top of
619 // contents_container_ regardless if there's bookmark or info bars.
621 // The view that manages the tab strip, toolbar, and sometimes the bookmark
622 // bar. Stacked top in the view hiearachy so it can be used to slide out
623 // the top views in immersive fullscreen.
624 TopContainerView
* top_container_
;
629 // The Toolbar containing the navigation buttons, menus and the address bar.
630 ToolbarView
* toolbar_
;
632 // The Bookmark Bar View for this window. Lazily created. May be NULL for
633 // non-tabbed browsers like popups. May not be visible.
634 scoped_ptr
<BookmarkBarView
> bookmark_bar_view_
;
636 // The do-nothing view which controls the z-order of the find bar widget
637 // relative to views which paint into layers and views with an associated
639 View
* find_bar_host_view_
;
641 // The download shelf view (view at the bottom of the page).
642 scoped_ptr
<DownloadShelfView
> download_shelf_
;
644 // The InfoBarContainerView that contains InfoBars for the current tab.
645 InfoBarContainerView
* infobar_container_
;
647 // The view that contains the selected WebContents.
648 ContentsWebView
* contents_web_view_
;
650 // The view that contains devtools window for the selected WebContents.
651 views::WebView
* devtools_web_view_
;
653 // The view managing the devtools and contents positions.
654 // Handled by ContentsLayoutManager.
655 views::View
* contents_container_
;
657 // Docked devtools window instance. NULL when current tab is not inspected
658 // or is inspected with undocked version of DevToolsWindow.
659 DevToolsWindow
* devtools_window_
;
661 // Tracks and stores the last focused view which is not the
662 // devtools_web_view_ or any of its children. Used to restore focus once
663 // the devtools_web_view_ is hidden.
664 scoped_ptr
<views::ExternalFocusTracker
> devtools_focus_tracker_
;
666 // The Status information bubble that appears at the bottom of the window.
667 scoped_ptr
<StatusBubbleViews
> status_bubble_
;
669 // The permission bubble view is the toolkit-specific implementation of the
670 // interface used by the manager to display permissions bubbles.
671 scoped_ptr
<PermissionBubbleViewViews
> permission_bubble_view_
;
673 // A mapping between accelerators and commands.
674 std::map
<ui::Accelerator
, int> accelerator_table_
;
676 // True if we have already been initialized.
679 // True when in ProcessFullscreen(). The flag is used to avoid reentrance and
680 // to ignore requests to layout while in ProcessFullscreen() to reduce
682 bool in_process_fullscreen_
;
684 scoped_ptr
<FullscreenExitBubbleViews
> fullscreen_bubble_
;
687 // This object is used to perform periodic actions in a worker
688 // thread. It is currently used to monitor hung plugin windows.
689 WorkerThreadTicker ticker_
;
691 // This object is initialized with the frame window HWND. This
692 // object is also passed as a tick handler with the ticker_ object.
693 // It is used to periodically monitor for hung plugin windows
694 HungWindowDetector hung_window_detector_
;
696 // This object is invoked by hung_window_detector_ when it detects a hung
698 HungPluginAction hung_plugin_action_
;
700 // Helper class to listen for completion of first page load.
701 scoped_ptr
<LoadCompleteListener
> load_complete_listener_
;
703 // The custom JumpList for Windows 7.
704 scoped_refptr
<JumpList
> jumplist_
;
707 // The timer used to update frames for the Loading Animation.
708 base::RepeatingTimer
<BrowserView
> loading_animation_timer_
;
710 views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_
;
712 // Used to measure the loading spinner animation rate.
713 base::TimeTicks last_animation_time_
;
715 // If this flag is set then SetFocusToLocationBar() will set focus to the
716 // location bar even if the browser window is not active.
717 bool force_location_bar_focus_
;
719 scoped_ptr
<ImmersiveModeController
> immersive_mode_controller_
;
721 scoped_ptr
<ScrollEndEffectController
> scroll_end_effect_controller_
;
723 scoped_ptr
<WebContentsCloseHandler
> web_contents_close_handler_
;
725 mutable base::WeakPtrFactory
<BrowserView
> activate_modal_dialog_factory_
;
727 DISALLOW_COPY_AND_ASSIGN(BrowserView
);
730 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_