Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: chrome/browser/ui/views/frame/browser_view.cc

Issue 63173016: DevTools: place DevTools WebContents underneath inspected WebContents. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/frame/browser_view.h" 5 #include "chrome/browser/ui/views/frame/browser_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 #include "chrome/browser/ui/views/accessibility/invert_bubble_view.h" 61 #include "chrome/browser/ui/views/accessibility/invert_bubble_view.h"
62 #include "chrome/browser/ui/views/avatar_menu_bubble_view.h" 62 #include "chrome/browser/ui/views/avatar_menu_bubble_view.h"
63 #include "chrome/browser/ui/views/avatar_menu_button.h" 63 #include "chrome/browser/ui/views/avatar_menu_button.h"
64 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" 64 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
65 #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h" 65 #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h"
66 #include "chrome/browser/ui/views/browser_dialogs.h" 66 #include "chrome/browser/ui/views/browser_dialogs.h"
67 #include "chrome/browser/ui/views/download/download_in_progress_dialog_view.h" 67 #include "chrome/browser/ui/views/download/download_in_progress_dialog_view.h"
68 #include "chrome/browser/ui/views/download/download_shelf_view.h" 68 #include "chrome/browser/ui/views/download/download_shelf_view.h"
69 #include "chrome/browser/ui/views/frame/browser_view_layout.h" 69 #include "chrome/browser/ui/views/frame/browser_view_layout.h"
70 #include "chrome/browser/ui/views/frame/browser_view_layout_delegate.h" 70 #include "chrome/browser/ui/views/frame/browser_view_layout_delegate.h"
71 #include "chrome/browser/ui/views/frame/contents_container.h" 71 #include "chrome/browser/ui/views/frame/contents_layout_manager.h"
72 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" 72 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
73 #include "chrome/browser/ui/views/frame/native_browser_frame_factory.h" 73 #include "chrome/browser/ui/views/frame/native_browser_frame_factory.h"
74 #include "chrome/browser/ui/views/frame/top_container_view.h" 74 #include "chrome/browser/ui/views/frame/top_container_view.h"
75 #include "chrome/browser/ui/views/fullscreen_exit_bubble_views.h" 75 #include "chrome/browser/ui/views/fullscreen_exit_bubble_views.h"
76 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" 76 #include "chrome/browser/ui/views/infobars/infobar_container_view.h"
77 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 77 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
78 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" 78 #include "chrome/browser/ui/views/location_bar/location_icon_view.h"
79 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" 79 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h"
80 #include "chrome/browser/ui/views/password_generation_bubble_view.h" 80 #include "chrome/browser/ui/views/password_generation_bubble_view.h"
81 #include "chrome/browser/ui/views/profile_chooser_view.h" 81 #include "chrome/browser/ui/views/profile_chooser_view.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 #include "ui/base/hit_test.h" 114 #include "ui/base/hit_test.h"
115 #include "ui/base/l10n/l10n_util.h" 115 #include "ui/base/l10n/l10n_util.h"
116 #include "ui/base/resource/resource_bundle.h" 116 #include "ui/base/resource/resource_bundle.h"
117 #include "ui/base/theme_provider.h" 117 #include "ui/base/theme_provider.h"
118 #include "ui/events/event_utils.h" 118 #include "ui/events/event_utils.h"
119 #include "ui/gfx/canvas.h" 119 #include "ui/gfx/canvas.h"
120 #include "ui/gfx/color_utils.h" 120 #include "ui/gfx/color_utils.h"
121 #include "ui/gfx/rect_conversions.h" 121 #include "ui/gfx/rect_conversions.h"
122 #include "ui/gfx/sys_color_change_listener.h" 122 #include "ui/gfx/sys_color_change_listener.h"
123 #include "ui/views/controls/button/menu_button.h" 123 #include "ui/views/controls/button/menu_button.h"
124 #include "ui/views/controls/single_split_view.h"
125 #include "ui/views/controls/textfield/textfield.h" 124 #include "ui/views/controls/textfield/textfield.h"
126 #include "ui/views/controls/webview/webview.h" 125 #include "ui/views/controls/webview/webview.h"
127 #include "ui/views/focus/external_focus_tracker.h" 126 #include "ui/views/focus/external_focus_tracker.h"
128 #include "ui/views/focus/view_storage.h" 127 #include "ui/views/focus/view_storage.h"
129 #include "ui/views/layout/grid_layout.h" 128 #include "ui/views/layout/grid_layout.h"
130 #include "ui/views/widget/native_widget.h" 129 #include "ui/views/widget/native_widget.h"
131 #include "ui/views/widget/root_view.h" 130 #include "ui/views/widget/root_view.h"
132 #include "ui/views/widget/widget.h" 131 #include "ui/views/widget/widget.h"
133 #include "ui/views/window/dialog_delegate.h" 132 #include "ui/views/window/dialog_delegate.h"
134 133
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 last_focused_view_storage_id_( 408 last_focused_view_storage_id_(
410 views::ViewStorage::GetInstance()->CreateStorageID()), 409 views::ViewStorage::GetInstance()->CreateStorageID()),
411 frame_(NULL), 410 frame_(NULL),
412 top_container_(NULL), 411 top_container_(NULL),
413 tabstrip_(NULL), 412 tabstrip_(NULL),
414 toolbar_(NULL), 413 toolbar_(NULL),
415 window_switcher_button_(NULL), 414 window_switcher_button_(NULL),
416 find_bar_host_view_(NULL), 415 find_bar_host_view_(NULL),
417 infobar_container_(NULL), 416 infobar_container_(NULL),
418 contents_web_view_(NULL), 417 contents_web_view_(NULL),
419 devtools_container_(NULL),
420 contents_container_(NULL), 418 contents_container_(NULL),
421 contents_split_(NULL),
422 devtools_dock_side_(DEVTOOLS_DOCK_SIDE_BOTTOM),
423 devtools_window_(NULL), 419 devtools_window_(NULL),
424 initialized_(false), 420 initialized_(false),
425 in_process_fullscreen_(false), 421 in_process_fullscreen_(false),
426 #if defined(OS_WIN) && !defined(USE_AURA) 422 #if defined(OS_WIN) && !defined(USE_AURA)
427 hung_window_detector_(&hung_plugin_action_), 423 hung_window_detector_(&hung_plugin_action_),
428 ticker_(0), 424 ticker_(0),
429 #endif 425 #endif
430 force_location_bar_focus_(false), 426 force_location_bar_focus_(false),
431 immersive_mode_controller_(chrome::CreateImmersiveModeController()), 427 immersive_mode_controller_(chrome::CreateImmersiveModeController()),
432 #if defined(OS_CHROMEOS) 428 #if defined(OS_CHROMEOS)
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 reinterpret_cast<BrowserView*>(widget->GetNativeWindowProperty( 500 reinterpret_cast<BrowserView*>(widget->GetNativeWindowProperty(
505 kBrowserViewKey)) : NULL; 501 kBrowserViewKey)) : NULL;
506 } 502 }
507 503
508 // static 504 // static
509 BrowserView* BrowserView::GetBrowserViewForBrowser(const Browser* browser) { 505 BrowserView* BrowserView::GetBrowserViewForBrowser(const Browser* browser) {
510 return static_cast<BrowserView*>(browser->window()); 506 return static_cast<BrowserView*>(browser->window());
511 } 507 }
512 508
513 void BrowserView::InitStatusBubble() { 509 void BrowserView::InitStatusBubble() {
514 status_bubble_.reset(new StatusBubbleViews(contents_container_)); 510 status_bubble_.reset(new StatusBubbleViews(contents_web_view_));
515 } 511 }
516 512
517 gfx::Rect BrowserView::GetToolbarBounds() const { 513 gfx::Rect BrowserView::GetToolbarBounds() const {
518 gfx::Rect toolbar_bounds(toolbar_->bounds()); 514 gfx::Rect toolbar_bounds(toolbar_->bounds());
519 if (toolbar_bounds.IsEmpty()) 515 if (toolbar_bounds.IsEmpty())
520 return toolbar_bounds; 516 return toolbar_bounds;
521 // The apparent toolbar edges are outside the "real" toolbar edges. 517 // The apparent toolbar edges are outside the "real" toolbar edges.
522 toolbar_bounds.Inset(-views::NonClientFrameView::kClientEdgeThickness, 0); 518 toolbar_bounds.Inset(-views::NonClientFrameView::kClientEdgeThickness, 0);
523 return toolbar_bounds; 519 return toolbar_bounds;
524 } 520 }
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 if (detached_changed && immersive_mode_controller_->IsEnabled()) 777 if (detached_changed && immersive_mode_controller_->IsEnabled())
782 change_type = BookmarkBar::DONT_ANIMATE_STATE_CHANGE; 778 change_type = BookmarkBar::DONT_ANIMATE_STATE_CHANGE;
783 779
784 bookmark_bar_view_->SetBookmarkBarState(new_state, change_type); 780 bookmark_bar_view_->SetBookmarkBarState(new_state, change_type);
785 } 781 }
786 if (MaybeShowBookmarkBar(GetActiveWebContents())) 782 if (MaybeShowBookmarkBar(GetActiveWebContents()))
787 Layout(); 783 Layout();
788 } 784 }
789 785
790 void BrowserView::UpdateDevTools() { 786 void BrowserView::UpdateDevTools() {
791 UpdateDevToolsForContents(GetActiveWebContents()); 787 UpdateDevToolsForContents(GetActiveWebContents(), true);
792 Layout(); 788 Layout();
793 } 789 }
794 790
795 void BrowserView::UpdateLoadingAnimations(bool should_animate) { 791 void BrowserView::UpdateLoadingAnimations(bool should_animate) {
796 if (should_animate) { 792 if (should_animate) {
797 if (!loading_animation_timer_.IsRunning()) { 793 if (!loading_animation_timer_.IsRunning()) {
798 // Loads are happening, and the timer isn't running, so start it. 794 // Loads are happening, and the timer isn't running, so start it.
799 last_animation_time_ = base::TimeTicks::Now(); 795 last_animation_time_ = base::TimeTicks::Now();
800 loading_animation_timer_.Start(FROM_HERE, 796 loading_animation_timer_.Start(FROM_HERE,
801 TimeDelta::FromMilliseconds(kLoadingAnimationFrameTimeMs), this, 797 TimeDelta::FromMilliseconds(kLoadingAnimationFrameTimeMs), this,
(...skipping 29 matching lines...) Expand all
831 // the WebContents window. 827 // the WebContents window.
832 bool change_tab_contents = 828 bool change_tab_contents =
833 contents_web_view_->web_contents() != new_contents; 829 contents_web_view_->web_contents() != new_contents;
834 830
835 // Update various elements that are interested in knowing the current 831 // Update various elements that are interested in knowing the current
836 // WebContents. 832 // WebContents.
837 833
838 // When we toggle the NTP floating bookmarks bar and/or the info bar, 834 // When we toggle the NTP floating bookmarks bar and/or the info bar,
839 // we don't want any WebContents to be attached, so that we 835 // we don't want any WebContents to be attached, so that we
840 // avoid an unnecessary resize and re-layout of a WebContents. 836 // avoid an unnecessary resize and re-layout of a WebContents.
841 if (change_tab_contents) 837 if (change_tab_contents) {
842 contents_web_view_->SetWebContents(NULL); 838 contents_web_view_->SetWebContents(NULL);
839 devtools_web_view_->SetWebContents(NULL);
840 }
843 infobar_container_->ChangeInfoBarService( 841 infobar_container_->ChangeInfoBarService(
844 InfoBarService::FromWebContents(new_contents)); 842 InfoBarService::FromWebContents(new_contents));
845 if (bookmark_bar_view_.get()) { 843 if (bookmark_bar_view_.get()) {
846 bookmark_bar_view_->SetBookmarkBarState( 844 bookmark_bar_view_->SetBookmarkBarState(
847 browser_->bookmark_bar_state(), 845 browser_->bookmark_bar_state(),
848 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); 846 BookmarkBar::DONT_ANIMATE_STATE_CHANGE);
849 } 847 }
850 UpdateUIForContents(new_contents); 848 UpdateUIForContents(new_contents);
851 849
852 // Layout for DevTools _before_ setting the main WebContents to avoid 850 // Layout for DevTools _before_ setting the both main and devtools WebContents
853 // toggling the size of the main WebContents. 851 // to avoid toggling the size of any of them.
854 UpdateDevToolsForContents(new_contents); 852 UpdateDevToolsForContents(new_contents, !change_tab_contents);
855 853
856 if (change_tab_contents) 854 if (change_tab_contents) {
857 contents_web_view_->SetWebContents(new_contents); 855 contents_web_view_->SetWebContents(new_contents);
856 // The second layout update should be no-op. It will just set the
857 // DevTools WebContents.
858 UpdateDevToolsForContents(new_contents, true);
859 }
858 860
859 if (!browser_->tab_strip_model()->closing_all() && GetWidget()->IsActive() && 861 if (!browser_->tab_strip_model()->closing_all() && GetWidget()->IsActive() &&
860 GetWidget()->IsVisible()) { 862 GetWidget()->IsVisible()) {
861 // We only restore focus if our window is visible, to avoid invoking blur 863 // We only restore focus if our window is visible, to avoid invoking blur
862 // handlers when we are eventually shown. 864 // handlers when we are eventually shown.
863 new_contents->GetView()->RestoreFocus(); 865 new_contents->GetView()->RestoreFocus();
864 } 866 }
865 867
866 // Update all the UI bits. 868 // Update all the UI bits.
867 UpdateTitleBar(); 869 UpdateTitleBar();
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 } 1017 }
1016 1018
1017 // When transitioning from animating to not animating we need to make sure the 1019 // When transitioning from animating to not animating we need to make sure the
1018 // contents_container_ gets layed out. If we don't do this and the bounds 1020 // contents_container_ gets layed out. If we don't do this and the bounds
1019 // haven't changed contents_container_ won't get a Layout out and we'll end up 1021 // haven't changed contents_container_ won't get a Layout out and we'll end up
1020 // with a gray rect because the clip wasn't updated. Note that a reentrant 1022 // with a gray rect because the clip wasn't updated. Note that a reentrant
1021 // call never needs to do this, because after it returns, the normal call 1023 // call never needs to do this, because after it returns, the normal call
1022 // wrapping it will do it. 1024 // wrapping it will do it.
1023 if ((call_state == NORMAL) && !is_animating) { 1025 if ((call_state == NORMAL) && !is_animating) {
1024 contents_web_view_->InvalidateLayout(); 1026 contents_web_view_->InvalidateLayout();
1025 contents_split_->Layout(); 1027 contents_container_->Layout();
1026 } 1028 }
1027 } 1029 }
1028 1030
1029 LocationBar* BrowserView::GetLocationBar() const { 1031 LocationBar* BrowserView::GetLocationBar() const {
1030 return GetLocationBarView(); 1032 return GetLocationBarView();
1031 } 1033 }
1032 1034
1033 void BrowserView::SetFocusToLocationBar(bool select_all) { 1035 void BrowserView::SetFocusToLocationBar(bool select_all) {
1034 // On Windows, changing focus to the location bar causes the browser 1036 // On Windows, changing focus to the location bar causes the browser
1035 // window to become active. This can steal focus if the user has 1037 // window to become active. This can steal focus if the user has
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1285 1287
1286 int BrowserView::GetExtraRenderViewHeight() const { 1288 int BrowserView::GetExtraRenderViewHeight() const {
1287 // Currently this is only used on linux. 1289 // Currently this is only used on linux.
1288 return 0; 1290 return 0;
1289 } 1291 }
1290 1292
1291 void BrowserView::WebContentsFocused(WebContents* contents) { 1293 void BrowserView::WebContentsFocused(WebContents* contents) {
1292 if (contents_web_view_->GetWebContents() == contents) 1294 if (contents_web_view_->GetWebContents() == contents)
1293 contents_web_view_->OnWebContentsFocused(contents); 1295 contents_web_view_->OnWebContentsFocused(contents);
1294 else 1296 else
1295 devtools_container_->OnWebContentsFocused(contents); 1297 devtools_web_view_->OnWebContentsFocused(contents);
1296 } 1298 }
1297 1299
1298 void BrowserView::ShowWebsiteSettings(Profile* profile, 1300 void BrowserView::ShowWebsiteSettings(Profile* profile,
1299 content::WebContents* web_contents, 1301 content::WebContents* web_contents,
1300 const GURL& url, 1302 const GURL& url,
1301 const content::SSLStatus& ssl) { 1303 const content::SSLStatus& ssl) {
1302 WebsiteSettingsPopupView::ShowPopup( 1304 WebsiteSettingsPopupView::ShowPopup(
1303 GetLocationBarView()->GetLocationIconView(), profile, 1305 GetLocationBarView()->GetLocationIconView(), profile,
1304 web_contents, url, ssl, browser_.get()); 1306 web_contents, url, ssl, browser_.get());
1305 } 1307 }
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1470 void BrowserView::TabDetachedAt(WebContents* contents, int index) { 1472 void BrowserView::TabDetachedAt(WebContents* contents, int index) {
1471 // We use index here rather than comparing |contents| because by this time 1473 // We use index here rather than comparing |contents| because by this time
1472 // the model has already removed |contents| from its list, so 1474 // the model has already removed |contents| from its list, so
1473 // browser_->GetActiveWebContents() will return NULL or something else. 1475 // browser_->GetActiveWebContents() will return NULL or something else.
1474 if (index == browser_->tab_strip_model()->active_index()) { 1476 if (index == browser_->tab_strip_model()->active_index()) {
1475 // We need to reset the current tab contents to NULL before it gets 1477 // We need to reset the current tab contents to NULL before it gets
1476 // freed. This is because the focus manager performs some operations 1478 // freed. This is because the focus manager performs some operations
1477 // on the selected WebContents when it is removed. 1479 // on the selected WebContents when it is removed.
1478 contents_web_view_->SetWebContents(NULL); 1480 contents_web_view_->SetWebContents(NULL);
1479 infobar_container_->ChangeInfoBarService(NULL); 1481 infobar_container_->ChangeInfoBarService(NULL);
1480 UpdateDevToolsForContents(NULL); 1482 UpdateDevToolsForContents(NULL, true);
1481 } 1483 }
1482 } 1484 }
1483 1485
1484 void BrowserView::TabDeactivated(WebContents* contents) { 1486 void BrowserView::TabDeactivated(WebContents* contents) {
1485 // We do not store the focus when closing the tab to work-around bug 4633. 1487 // We do not store the focus when closing the tab to work-around bug 4633.
1486 // Some reports seem to show that the focus manager and/or focused view can 1488 // Some reports seem to show that the focus manager and/or focused view can
1487 // be garbage at that point, it is not clear why. 1489 // be garbage at that point, it is not clear why.
1488 if (!contents->IsBeingDestroyed()) 1490 if (!contents->IsBeingDestroyed())
1489 contents->GetView()->StoreFocus(); 1491 contents->GetView()->StoreFocus();
1490 } 1492 }
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1747 // invisible or has no focusable children, it will be automatically 1749 // invisible or has no focusable children, it will be automatically
1748 // skipped. 1750 // skipped.
1749 panes->push_back(toolbar_); 1751 panes->push_back(toolbar_);
1750 if (bookmark_bar_view_.get()) 1752 if (bookmark_bar_view_.get())
1751 panes->push_back(bookmark_bar_view_.get()); 1753 panes->push_back(bookmark_bar_view_.get());
1752 if (infobar_container_) 1754 if (infobar_container_)
1753 panes->push_back(infobar_container_); 1755 panes->push_back(infobar_container_);
1754 if (download_shelf_.get()) 1756 if (download_shelf_.get())
1755 panes->push_back(download_shelf_.get()); 1757 panes->push_back(download_shelf_.get());
1756 panes->push_back(GetTabContentsContainerView()); 1758 panes->push_back(GetTabContentsContainerView());
1757 if (devtools_container_->visible()) 1759 if (devtools_web_view_->visible())
1758 panes->push_back(devtools_container_); 1760 panes->push_back(devtools_web_view_);
1759 } 1761 }
1760 1762
1761 /////////////////////////////////////////////////////////////////////////////// 1763 ///////////////////////////////////////////////////////////////////////////////
1762 // BrowserView, views::ClientView overrides: 1764 // BrowserView, views::ClientView overrides:
1763 1765
1764 bool BrowserView::CanClose() { 1766 bool BrowserView::CanClose() {
1765 // You cannot close a frame for which there is an active originating drag 1767 // You cannot close a frame for which there is an active originating drag
1766 // session. 1768 // session.
1767 if (tabstrip_ && !tabstrip_->IsTabStripCloseable()) 1769 if (tabstrip_ && !tabstrip_->IsTabStripCloseable())
1768 return false; 1770 return false;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1907 1909
1908 bool BrowserView::DrawInfoBarArrows(int* x) const { 1910 bool BrowserView::DrawInfoBarArrows(int* x) const {
1909 if (x) { 1911 if (x) {
1910 gfx::Point anchor(toolbar_->location_bar()->GetLocationBarAnchorPoint()); 1912 gfx::Point anchor(toolbar_->location_bar()->GetLocationBarAnchorPoint());
1911 ConvertPointToTarget(toolbar_->location_bar(), this, &anchor); 1913 ConvertPointToTarget(toolbar_->location_bar(), this, &anchor);
1912 *x = anchor.x(); 1914 *x = anchor.x();
1913 } 1915 }
1914 return true; 1916 return true;
1915 } 1917 }
1916 1918
1917 bool BrowserView::SplitHandleMoved(views::SingleSplitView* sender) {
1918 for (int i = 0; i < sender->child_count(); ++i)
1919 sender->child_at(i)->InvalidateLayout();
1920 SchedulePaint();
1921 Layout();
1922 return false;
1923 }
1924
1925 void BrowserView::OnSysColorChange() { 1919 void BrowserView::OnSysColorChange() {
1926 chrome::MaybeShowInvertBubbleView(browser_.get(), contents_container_); 1920 chrome::MaybeShowInvertBubbleView(browser_.get(), contents_container_);
1927 } 1921 }
1928 1922
1929 void BrowserView::InitViews() { 1923 void BrowserView::InitViews() {
1930 GetWidget()->AddObserver(this); 1924 GetWidget()->AddObserver(this);
1931 1925
1932 // Stow a pointer to this object onto the window handle so that we can get at 1926 // Stow a pointer to this object onto the window handle so that we can get at
1933 // it later when all we have is a native view. 1927 // it later when all we have is a native view.
1934 GetWidget()->SetNativeWindowProperty(kBrowserViewKey, this); 1928 GetWidget()->SetNativeWindowProperty(kBrowserViewKey, this);
(...skipping 13 matching lines...) Expand all
1948 LoadAccelerators(); 1942 LoadAccelerators();
1949 1943
1950 infobar_container_ = new InfoBarContainerView(this); 1944 infobar_container_ = new InfoBarContainerView(this);
1951 AddChildView(infobar_container_); 1945 AddChildView(infobar_container_);
1952 1946
1953 contents_web_view_ = new views::WebView(browser_->profile()); 1947 contents_web_view_ = new views::WebView(browser_->profile());
1954 contents_web_view_->set_id(VIEW_ID_TAB_CONTAINER); 1948 contents_web_view_->set_id(VIEW_ID_TAB_CONTAINER);
1955 contents_web_view_->SetEmbedFullscreenWidgetMode( 1949 contents_web_view_->SetEmbedFullscreenWidgetMode(
1956 implicit_cast<content::WebContentsDelegate*>(browser_.get())-> 1950 implicit_cast<content::WebContentsDelegate*>(browser_.get())->
1957 EmbedsFullscreenWidget()); 1951 EmbedsFullscreenWidget());
1958 contents_container_ = new ContentsContainer(contents_web_view_);
1959 1952
1960 SkColor bg_color = GetWidget()->GetThemeProvider()-> 1953 devtools_web_view_ = new views::WebView(browser_->profile());
1961 GetColor(ThemeProperties::COLOR_TOOLBAR); 1954 devtools_web_view_->set_id(VIEW_ID_DEV_TOOLS_DOCKED);
1955 devtools_web_view_->SetVisible(false);
1962 1956
1963 devtools_container_ = new views::WebView(browser_->profile()); 1957 contents_container_ = new views::View();
1964 devtools_container_->set_id(VIEW_ID_DEV_TOOLS_DOCKED); 1958 contents_container_->set_background(views::Background::CreateSolidBackground(
1965 devtools_container_->SetVisible(false); 1959 ThemeProperties::GetDefaultColor(
1966 1960 ThemeProperties::COLOR_CONTROL_BACKGROUND)));
1967 views::View* contents_container_view = contents_container_; 1961 contents_container_->AddChildView(devtools_web_view_);
1968 1962 contents_container_->AddChildView(contents_web_view_);
1969 contents_split_ = new views::SingleSplitView( 1963 contents_container_->SetLayoutManager(new ContentsLayoutManager(
1970 contents_container_view, 1964 devtools_web_view_, contents_web_view_));
1971 devtools_container_, 1965 AddChildView(contents_container_);
1972 views::SingleSplitView::VERTICAL_SPLIT, 1966 set_contents_view(contents_container_);
1973 this);
1974 contents_split_->set_id(VIEW_ID_CONTENTS_SPLIT);
1975 contents_split_->SetAccessibleName(
1976 l10n_util::GetStringUTF16(IDS_ACCNAME_WEB_CONTENTS));
1977 contents_split_->set_background(
1978 views::Background::CreateSolidBackground(bg_color));
1979 AddChildView(contents_split_);
1980 set_contents_view(contents_split_);
1981 1967
1982 InitStatusBubble(); 1968 InitStatusBubble();
1983 1969
1984 // Top container holds tab strip and toolbar and lives at the front of the 1970 // Top container holds tab strip and toolbar and lives at the front of the
1985 // view hierarchy. 1971 // view hierarchy.
1986 top_container_ = new TopContainerView(this); 1972 top_container_ = new TopContainerView(this);
1987 AddChildView(top_container_); 1973 AddChildView(top_container_);
1988 1974
1989 // TabStrip takes ownership of the controller. 1975 // TabStrip takes ownership of the controller.
1990 BrowserTabStripController* tabstrip_controller = 1976 BrowserTabStripController* tabstrip_controller =
(...skipping 18 matching lines...) Expand all
2009 immersive_mode_controller_->Init(this); 1995 immersive_mode_controller_->Init(this);
2010 1996
2011 BrowserViewLayout* browser_view_layout = new BrowserViewLayout; 1997 BrowserViewLayout* browser_view_layout = new BrowserViewLayout;
2012 browser_view_layout->Init(new BrowserViewLayoutDelegateImpl(this), 1998 browser_view_layout->Init(new BrowserViewLayoutDelegateImpl(this),
2013 browser(), 1999 browser(),
2014 this, 2000 this,
2015 top_container_, 2001 top_container_,
2016 tabstrip_, 2002 tabstrip_,
2017 toolbar_, 2003 toolbar_,
2018 infobar_container_, 2004 infobar_container_,
2019 contents_split_,
2020 contents_container_, 2005 contents_container_,
2006 GetContentsLayoutManager(),
2021 immersive_mode_controller_.get()); 2007 immersive_mode_controller_.get());
2022 SetLayoutManager(browser_view_layout); 2008 SetLayoutManager(browser_view_layout);
2023 2009
2024 #if defined(OS_WIN) && !defined(USE_AURA) 2010 #if defined(OS_WIN) && !defined(USE_AURA)
2025 // Create a custom JumpList and add it to an observer of TabRestoreService 2011 // Create a custom JumpList and add it to an observer of TabRestoreService
2026 // so we can update the custom JumpList when a tab is added or removed. 2012 // so we can update the custom JumpList when a tab is added or removed.
2027 if (JumpList::Enabled()) { 2013 if (JumpList::Enabled()) {
2028 load_complete_listener_.reset(new LoadCompleteListener(this)); 2014 load_complete_listener_.reset(new LoadCompleteListener(this));
2029 } 2015 }
2030 #endif 2016 #endif
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2063 DCHECK(!jumplist_); 2049 DCHECK(!jumplist_);
2064 jumplist_ = new JumpList(); 2050 jumplist_ = new JumpList();
2065 jumplist_->AddObserver(browser_->profile()); 2051 jumplist_->AddObserver(browser_->profile());
2066 #endif 2052 #endif
2067 } 2053 }
2068 2054
2069 BrowserViewLayout* BrowserView::GetBrowserViewLayout() const { 2055 BrowserViewLayout* BrowserView::GetBrowserViewLayout() const {
2070 return static_cast<BrowserViewLayout*>(GetLayoutManager()); 2056 return static_cast<BrowserViewLayout*>(GetLayoutManager());
2071 } 2057 }
2072 2058
2059 ContentsLayoutManager* BrowserView::GetContentsLayoutManager() const {
2060 return static_cast<ContentsLayoutManager*>(
2061 contents_container_->GetLayoutManager());
2062 }
2063
2073 void BrowserView::LayoutStatusBubble() { 2064 void BrowserView::LayoutStatusBubble() {
2074 // In restored mode, the client area has a client edge between it and the 2065 // In restored mode, the client area has a client edge between it and the
2075 // frame. 2066 // frame.
2076 int overlap = StatusBubbleViews::kShadowThickness; 2067 int overlap = StatusBubbleViews::kShadowThickness;
2077 // The extra pixels defined by kClientEdgeThickness is only drawn in frame 2068 // The extra pixels defined by kClientEdgeThickness is only drawn in frame
2078 // content border on windows for non-aura build. 2069 // content border on windows for non-aura build.
2079 #if !defined(USE_ASH) 2070 #if !defined(USE_ASH)
2080 overlap += 2071 overlap +=
2081 IsMaximized() ? 0 : views::NonClientFrameView::kClientEdgeThickness; 2072 IsMaximized() ? 0 : views::NonClientFrameView::kClientEdgeThickness;
2082 #endif 2073 #endif
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
2146 } 2137 }
2147 } 2138 }
2148 2139
2149 bool BrowserView::MaybeShowInfoBar(WebContents* contents) { 2140 bool BrowserView::MaybeShowInfoBar(WebContents* contents) {
2150 // TODO(beng): Remove this function once the interface between 2141 // TODO(beng): Remove this function once the interface between
2151 // InfoBarContainer, DownloadShelfView and WebContents and this 2142 // InfoBarContainer, DownloadShelfView and WebContents and this
2152 // view is sorted out. 2143 // view is sorted out.
2153 return true; 2144 return true;
2154 } 2145 }
2155 2146
2156 void BrowserView::UpdateDevToolsForContents(WebContents* web_contents) { 2147 void BrowserView::UpdateDevToolsForContents(
2148 WebContents* web_contents, bool update_devtools_web_contents) {
2157 DevToolsWindow* new_devtools_window = web_contents ? 2149 DevToolsWindow* new_devtools_window = web_contents ?
2158 DevToolsWindow::GetDockedInstanceForInspectedTab(web_contents) : NULL; 2150 DevToolsWindow::GetDockedInstanceForInspectedTab(web_contents) : NULL;
2159 // Fast return in case of the same window having same orientation. 2151
2160 if (devtools_window_ == new_devtools_window) { 2152 // Replace devtools WebContents.
2161 if (!new_devtools_window || 2153 WebContents* new_contents = new_devtools_window ?
2162 (new_devtools_window->dock_side() == devtools_dock_side_)) { 2154 new_devtools_window->web_contents() : NULL;
2163 return; 2155 if (devtools_web_view_->web_contents() != new_contents &&
2164 } 2156 update_devtools_web_contents) {
2157 devtools_web_view_->SetWebContents(new_contents);
2165 } 2158 }
2166 2159
2167 // Replace tab contents. 2160 if (!devtools_window_ && new_devtools_window &&
2168 if (devtools_window_ != new_devtools_window) { 2161 !devtools_focus_tracker_.get()) {
2169 devtools_container_->SetWebContents(
2170 new_devtools_window ? new_devtools_window->web_contents() : NULL);
2171 }
2172
2173 // Store last used position.
2174 if (devtools_window_) {
2175 int split_size = contents_split_->GetDividerSize();
2176 if (devtools_dock_side_ == DEVTOOLS_DOCK_SIDE_RIGHT) {
2177 devtools_window_->SetWidth(contents_split_->width() -
2178 split_size - contents_split_->divider_offset());
2179 } else if (devtools_dock_side_ == DEVTOOLS_DOCK_SIDE_BOTTOM) {
2180 devtools_window_->SetHeight(contents_split_->height() -
2181 split_size - contents_split_->divider_offset());
2182 }
2183 }
2184
2185 // Show / hide container if necessary. Changing dock orientation is
2186 // hide + show.
2187 bool should_hide = devtools_window_ && (!new_devtools_window ||
2188 devtools_dock_side_ != new_devtools_window->dock_side());
2189 bool should_show = new_devtools_window && (!devtools_window_ || should_hide);
2190
2191 if (should_hide)
2192 HideDevToolsContainer();
2193
2194 devtools_window_ = new_devtools_window;
2195
2196 if (should_show) {
2197 devtools_dock_side_ = new_devtools_window->dock_side();
2198 ShowDevToolsContainer();
2199 } else if (new_devtools_window) {
2200 UpdateDevToolsSplitPosition();
2201 contents_split_->Layout();
2202 }
2203 }
2204
2205 void BrowserView::ShowDevToolsContainer() {
2206 if (!devtools_focus_tracker_.get()) {
2207 // Install devtools focus tracker when dev tools window is shown for the 2162 // Install devtools focus tracker when dev tools window is shown for the
2208 // first time. 2163 // first time.
2209 devtools_focus_tracker_.reset( 2164 devtools_focus_tracker_.reset(
2210 new views::ExternalFocusTracker(devtools_container_, 2165 new views::ExternalFocusTracker(devtools_web_view_,
2211 GetFocusManager())); 2166 GetFocusManager()));
2212 } 2167 }
2213 2168
2214 gfx::Size min_devtools_size(devtools_window_->GetMinimumWidth(), 2169 // Restore focus to the last focused view when hiding devtools window.
2215 devtools_window_->GetMinimumHeight()); 2170 if (devtools_window_ && !new_devtools_window &&
2216 devtools_container_->SetPreferredSize(min_devtools_size); 2171 devtools_focus_tracker_.get()) {
2172 devtools_focus_tracker_->FocusLastFocusedExternalView();
2173 devtools_focus_tracker_.reset();
2174 }
2217 2175
2218 devtools_container_->SetVisible(true); 2176 devtools_window_ = new_devtools_window;
2219 devtools_dock_side_ = devtools_window_->dock_side(); 2177 if (devtools_window_) {
2220 bool dock_to_right = devtools_dock_side_ == DEVTOOLS_DOCK_SIDE_RIGHT; 2178 devtools_web_view_->SetPreferredSize(devtools_window_->GetMinimumSize());
2221 contents_split_->set_orientation( 2179 devtools_web_view_->SetVisible(true);
2222 dock_to_right ? views::SingleSplitView::HORIZONTAL_SPLIT 2180 GetContentsLayoutManager()->SetContentsViewInsets(
2223 : views::SingleSplitView::VERTICAL_SPLIT); 2181 devtools_window_->GetContentsInsets());
2224 UpdateDevToolsSplitPosition();
2225 contents_split_->InvalidateLayout();
2226 Layout();
2227 }
2228
2229 void BrowserView::HideDevToolsContainer() {
2230 // Restore focus to the last focused view when hiding devtools window.
2231 devtools_focus_tracker_->FocusLastFocusedExternalView();
2232 devtools_container_->SetVisible(false);
2233 contents_split_->InvalidateLayout();
2234 Layout();
2235 }
2236
2237 void BrowserView::UpdateDevToolsSplitPosition() {
2238 contents_split_->set_resize_disabled(
2239 devtools_window_->dock_side() == DEVTOOLS_DOCK_SIDE_MINIMIZED);
2240 int split_size = contents_split_->GetDividerSize();
2241 if (devtools_window_->dock_side() == DEVTOOLS_DOCK_SIDE_RIGHT) {
2242 int split_offset = contents_split_->width() - split_size -
2243 devtools_window_->GetWidth(contents_split_->width());
2244 contents_split_->set_divider_offset(split_offset);
2245 } else { 2182 } else {
2246 int height = devtools_window_->dock_side() == DEVTOOLS_DOCK_SIDE_MINIMIZED ? 2183 devtools_web_view_->SetVisible(false);
2247 devtools_window_->GetMinimizedHeight() : 2184 GetContentsLayoutManager()->SetContentsViewInsets(gfx::Insets());
2248 devtools_window_->GetHeight(contents_split_->height());
2249 int split_offset = contents_split_->height() - split_size - height;
2250 contents_split_->set_divider_offset(split_offset);
2251 } 2185 }
2186 contents_container_->Layout();
2252 } 2187 }
2253 2188
2254 void BrowserView::UpdateUIForContents(WebContents* contents) { 2189 void BrowserView::UpdateUIForContents(WebContents* contents) {
2255 bool needs_layout = MaybeShowBookmarkBar(contents); 2190 bool needs_layout = MaybeShowBookmarkBar(contents);
2256 // TODO(jamescook): This function always returns true. Remove it and figure 2191 // TODO(jamescook): This function always returns true. Remove it and figure
2257 // out when layout is actually required. 2192 // out when layout is actually required.
2258 needs_layout |= MaybeShowInfoBar(contents); 2193 needs_layout |= MaybeShowInfoBar(contents);
2259 if (needs_layout) 2194 if (needs_layout)
2260 Layout(); 2195 Layout();
2261 } 2196 }
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
2672 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) { 2607 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) {
2673 gfx::Point icon_bottom( 2608 gfx::Point icon_bottom(
2674 toolbar_->location_bar()->GetLocationBarAnchorPoint()); 2609 toolbar_->location_bar()->GetLocationBarAnchorPoint());
2675 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); 2610 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom);
2676 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); 2611 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL));
2677 ConvertPointToTarget(infobar_container_, this, &infobar_top); 2612 ConvertPointToTarget(infobar_container_, this, &infobar_top);
2678 top_arrow_height = infobar_top.y() - icon_bottom.y(); 2613 top_arrow_height = infobar_top.y() - icon_bottom.y();
2679 } 2614 }
2680 return top_arrow_height; 2615 return top_arrow_height;
2681 } 2616 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.h ('k') | chrome/browser/ui/views/frame/browser_view_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698