OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #if defined(TOOLKIT_USES_GTK) | 7 #if defined(TOOLKIT_USES_GTK) |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "chrome/browser/instant/instant_controller.h" | 29 #include "chrome/browser/instant/instant_controller.h" |
30 #include "chrome/browser/native_window_notification_source.h" | 30 #include "chrome/browser/native_window_notification_source.h" |
31 #include "chrome/browser/ntp_background_util.h" | 31 #include "chrome/browser/ntp_background_util.h" |
32 #include "chrome/browser/prefs/pref_service.h" | 32 #include "chrome/browser/prefs/pref_service.h" |
33 #include "chrome/browser/profiles/avatar_menu_model.h" | 33 #include "chrome/browser/profiles/avatar_menu_model.h" |
34 #include "chrome/browser/profiles/profile.h" | 34 #include "chrome/browser/profiles/profile.h" |
35 #include "chrome/browser/profiles/profile_info_cache.h" | 35 #include "chrome/browser/profiles/profile_info_cache.h" |
36 #include "chrome/browser/profiles/profile_manager.h" | 36 #include "chrome/browser/profiles/profile_manager.h" |
37 #include "chrome/browser/sessions/tab_restore_service.h" | 37 #include "chrome/browser/sessions/tab_restore_service.h" |
38 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 38 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
39 #include "chrome/browser/sidebar/sidebar_container.h" | |
40 #include "chrome/browser/sidebar/sidebar_manager.h" | |
41 #include "chrome/browser/tabs/tab_strip_model.h" | 39 #include "chrome/browser/tabs/tab_strip_model.h" |
42 #include "chrome/browser/themes/theme_service.h" | 40 #include "chrome/browser/themes/theme_service.h" |
43 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" | 41 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" |
44 #include "chrome/browser/ui/browser.h" | 42 #include "chrome/browser/ui/browser.h" |
45 #include "chrome/browser/ui/browser_dialogs.h" | 43 #include "chrome/browser/ui/browser_dialogs.h" |
46 #include "chrome/browser/ui/browser_list.h" | 44 #include "chrome/browser/ui/browser_list.h" |
47 #include "chrome/browser/ui/dialog_style.h" | 45 #include "chrome/browser/ui/dialog_style.h" |
48 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 46 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
49 #include "chrome/browser/ui/tabs/tab_menu_model.h" | 47 #include "chrome/browser/ui/tabs/tab_menu_model.h" |
50 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" | 48 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 BrowserView::BrowserView(Browser* browser) | 309 BrowserView::BrowserView(Browser* browser) |
312 : views::ClientView(NULL, NULL), | 310 : views::ClientView(NULL, NULL), |
313 last_focused_view_storage_id_( | 311 last_focused_view_storage_id_( |
314 views::ViewStorage::GetInstance()->CreateStorageID()), | 312 views::ViewStorage::GetInstance()->CreateStorageID()), |
315 frame_(NULL), | 313 frame_(NULL), |
316 browser_(browser), | 314 browser_(browser), |
317 active_bookmark_bar_(NULL), | 315 active_bookmark_bar_(NULL), |
318 tabstrip_(NULL), | 316 tabstrip_(NULL), |
319 toolbar_(NULL), | 317 toolbar_(NULL), |
320 infobar_container_(NULL), | 318 infobar_container_(NULL), |
321 sidebar_container_(NULL), | |
322 sidebar_split_(NULL), | |
323 contents_container_(NULL), | 319 contents_container_(NULL), |
324 devtools_container_(NULL), | 320 devtools_container_(NULL), |
325 preview_container_(NULL), | 321 preview_container_(NULL), |
326 contents_(NULL), | 322 contents_(NULL), |
327 contents_split_(NULL), | 323 contents_split_(NULL), |
328 devtools_dock_side_(DEVTOOLS_DOCK_SIDE_BOTTOM), | 324 devtools_dock_side_(DEVTOOLS_DOCK_SIDE_BOTTOM), |
329 initialized_(false), | 325 initialized_(false), |
330 ignore_layout_(true), | 326 ignore_layout_(true), |
331 #if defined(OS_WIN) && !defined(USE_AURA) | 327 #if defined(OS_WIN) && !defined(USE_AURA) |
332 hung_window_detector_(&hung_plugin_action_), | 328 hung_window_detector_(&hung_plugin_action_), |
333 ticker_(0), | 329 ticker_(0), |
334 #endif | 330 #endif |
335 force_location_bar_focus_(false) { | 331 force_location_bar_focus_(false) { |
336 browser_->tabstrip_model()->AddObserver(this); | 332 browser_->tabstrip_model()->AddObserver(this); |
337 | |
338 registrar_.Add( | |
339 this, | |
340 chrome::NOTIFICATION_SIDEBAR_CHANGED, | |
341 content::Source<SidebarManager>(SidebarManager::GetInstance())); | |
342 } | 333 } |
343 | 334 |
344 BrowserView::~BrowserView() { | 335 BrowserView::~BrowserView() { |
345 #if defined(USE_AURA) | 336 #if defined(USE_AURA) |
346 // Destroy LauncherIconUpdater early on as it listens to the TabstripModel, | 337 // Destroy LauncherIconUpdater early on as it listens to the TabstripModel, |
347 // which is destroyed by the browser. | 338 // which is destroyed by the browser. |
348 icon_updater_.reset(); | 339 icon_updater_.reset(); |
349 #endif | 340 #endif |
350 | 341 |
351 browser_->tabstrip_model()->RemoveObserver(this); | 342 browser_->tabstrip_model()->RemoveObserver(this); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 gfx::Point BrowserView::OffsetPointForToolbarBackgroundImage( | 426 gfx::Point BrowserView::OffsetPointForToolbarBackgroundImage( |
436 const gfx::Point& point) const { | 427 const gfx::Point& point) const { |
437 // The background image starts tiling horizontally at the window left edge and | 428 // The background image starts tiling horizontally at the window left edge and |
438 // vertically at the top edge of the horizontal tab strip (or where it would | 429 // vertically at the top edge of the horizontal tab strip (or where it would |
439 // be). We expect our parent's origin to be the window origin. | 430 // be). We expect our parent's origin to be the window origin. |
440 gfx::Point window_point(point.Add(GetMirroredPosition())); | 431 gfx::Point window_point(point.Add(GetMirroredPosition())); |
441 window_point.Offset(0, -frame_->GetHorizontalTabStripVerticalOffset(false)); | 432 window_point.Offset(0, -frame_->GetHorizontalTabStripVerticalOffset(false)); |
442 return window_point; | 433 return window_point; |
443 } | 434 } |
444 | 435 |
445 int BrowserView::GetSidebarWidth() const { | |
446 if (!sidebar_container_ || !sidebar_container_->visible()) | |
447 return 0; | |
448 return sidebar_split_->divider_offset(); | |
449 } | |
450 | |
451 bool BrowserView::IsTabStripVisible() const { | 436 bool BrowserView::IsTabStripVisible() const { |
452 return browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP); | 437 return browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP); |
453 } | 438 } |
454 | 439 |
455 bool BrowserView::IsOffTheRecord() const { | 440 bool BrowserView::IsOffTheRecord() const { |
456 return browser_->profile()->IsOffTheRecord(); | 441 return browser_->profile()->IsOffTheRecord(); |
457 } | 442 } |
458 | 443 |
459 bool BrowserView::IsGuestSession() const { | 444 bool BrowserView::IsGuestSession() const { |
460 return browser_->profile()->IsGuestSession(); | 445 return browser_->profile()->IsGuestSession(); |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 // with NULL to represent the tab contents getting focus. If one of these | 949 // with NULL to represent the tab contents getting focus. If one of these |
965 // is currently invisible or has no focusable children it will be | 950 // is currently invisible or has no focusable children it will be |
966 // automatically skipped. | 951 // automatically skipped. |
967 std::vector<views::AccessiblePaneView*> accessible_panes; | 952 std::vector<views::AccessiblePaneView*> accessible_panes; |
968 GetAccessiblePanes(&accessible_panes); | 953 GetAccessiblePanes(&accessible_panes); |
969 int pane_count = static_cast<int>(accessible_panes.size()); | 954 int pane_count = static_cast<int>(accessible_panes.size()); |
970 | 955 |
971 std::vector<views::View*> accessible_views( | 956 std::vector<views::View*> accessible_views( |
972 accessible_panes.begin(), accessible_panes.end()); | 957 accessible_panes.begin(), accessible_panes.end()); |
973 accessible_views.push_back(GetTabContentsContainerView()); | 958 accessible_views.push_back(GetTabContentsContainerView()); |
974 if (sidebar_container_ && sidebar_container_->visible()) | |
975 accessible_views.push_back(GetSidebarContainerView()); | |
976 if (devtools_container_->visible()) | 959 if (devtools_container_->visible()) |
977 accessible_views.push_back(devtools_container_->GetFocusView()); | 960 accessible_views.push_back(devtools_container_->GetFocusView()); |
978 int count = static_cast<int>(accessible_views.size()); | 961 int count = static_cast<int>(accessible_views.size()); |
979 | 962 |
980 // Figure out which view (if any) currently has the focus. | 963 // Figure out which view (if any) currently has the focus. |
981 const views::View* focused_view = GetFocusManager()->GetFocusedView(); | 964 const views::View* focused_view = GetFocusManager()->GetFocusedView(); |
982 int index = -1; | 965 int index = -1; |
983 if (focused_view) { | 966 if (focused_view) { |
984 for (int i = 0; i < count; ++i) { | 967 for (int i = 0; i < count; ++i) { |
985 if (accessible_views[i] == focused_view || | 968 if (accessible_views[i] == focused_view || |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1367 } | 1350 } |
1368 | 1351 |
1369 LocationBarView* BrowserView::GetLocationBarView() const { | 1352 LocationBarView* BrowserView::GetLocationBarView() const { |
1370 return toolbar_ ? toolbar_->location_bar() : NULL; | 1353 return toolbar_ ? toolbar_->location_bar() : NULL; |
1371 } | 1354 } |
1372 | 1355 |
1373 views::View* BrowserView::GetTabContentsContainerView() const { | 1356 views::View* BrowserView::GetTabContentsContainerView() const { |
1374 return contents_container_->GetFocusView(); | 1357 return contents_container_->GetFocusView(); |
1375 } | 1358 } |
1376 | 1359 |
1377 views::View* BrowserView::GetSidebarContainerView() const { | |
1378 if (!sidebar_container_) | |
1379 return NULL; | |
1380 return sidebar_container_->GetFocusView(); | |
1381 } | |
1382 | |
1383 ToolbarView* BrowserView::GetToolbarView() const { | 1360 ToolbarView* BrowserView::GetToolbarView() const { |
1384 return toolbar_; | 1361 return toolbar_; |
1385 } | 1362 } |
1386 | 1363 |
1387 /////////////////////////////////////////////////////////////////////////////// | 1364 /////////////////////////////////////////////////////////////////////////////// |
1388 // BrowserView, content::NotificationObserver implementation: | |
1389 | |
1390 void BrowserView::Observe(int type, | |
1391 const content::NotificationSource& source, | |
1392 const content::NotificationDetails& details) { | |
1393 switch (type) { | |
1394 case chrome::NOTIFICATION_SIDEBAR_CHANGED: | |
1395 if (content::Details<SidebarContainer>(details)->tab_contents() == | |
1396 browser_->GetSelectedWebContents()) { | |
1397 UpdateSidebar(); | |
1398 } | |
1399 break; | |
1400 | |
1401 default: | |
1402 NOTREACHED() << "Got a notification we didn't register for!"; | |
1403 break; | |
1404 } | |
1405 } | |
1406 | |
1407 /////////////////////////////////////////////////////////////////////////////// | |
1408 // BrowserView, TabStripModelObserver implementation: | 1365 // BrowserView, TabStripModelObserver implementation: |
1409 | 1366 |
1410 void BrowserView::TabDetachedAt(TabContentsWrapper* contents, int index) { | 1367 void BrowserView::TabDetachedAt(TabContentsWrapper* contents, int index) { |
1411 // We use index here rather than comparing |contents| because by this time | 1368 // We use index here rather than comparing |contents| because by this time |
1412 // the model has already removed |contents| from its list, so | 1369 // the model has already removed |contents| from its list, so |
1413 // browser_->GetSelectedWebContents() will return NULL or something else. | 1370 // browser_->GetSelectedWebContents() will return NULL or something else. |
1414 if (index == browser_->tabstrip_model()->active_index()) { | 1371 if (index == browser_->tabstrip_model()->active_index()) { |
1415 // We need to reset the current tab contents to NULL before it gets | 1372 // We need to reset the current tab contents to NULL before it gets |
1416 // freed. This is because the focus manager performs some operations | 1373 // freed. This is because the focus manager performs some operations |
1417 // on the selected TabContents when it is removed. | 1374 // on the selected TabContents when it is removed. |
1418 contents_container_->ChangeWebContents(NULL); | 1375 contents_container_->ChangeWebContents(NULL); |
1419 infobar_container_->ChangeTabContents(NULL); | 1376 infobar_container_->ChangeTabContents(NULL); |
1420 UpdateSidebarForContents(NULL); | |
1421 UpdateDevToolsForContents(NULL); | 1377 UpdateDevToolsForContents(NULL); |
1422 } | 1378 } |
1423 } | 1379 } |
1424 | 1380 |
1425 void BrowserView::TabDeactivated(TabContentsWrapper* contents) { | 1381 void BrowserView::TabDeactivated(TabContentsWrapper* contents) { |
1426 // We do not store the focus when closing the tab to work-around bug 4633. | 1382 // We do not store the focus when closing the tab to work-around bug 4633. |
1427 // Some reports seem to show that the focus manager and/or focused view can | 1383 // Some reports seem to show that the focus manager and/or focused view can |
1428 // be garbage at that point, it is not clear why. | 1384 // be garbage at that point, it is not clear why. |
1429 if (!contents->web_contents()->IsBeingDestroyed()) | 1385 if (!contents->web_contents()->IsBeingDestroyed()) |
1430 contents->web_contents()->GetView()->StoreFocus(); | 1386 contents->web_contents()->GetView()->StoreFocus(); |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1908 | 1864 |
1909 infobar_container_ = new InfoBarContainerView(this); | 1865 infobar_container_ = new InfoBarContainerView(this); |
1910 AddChildView(infobar_container_); | 1866 AddChildView(infobar_container_); |
1911 | 1867 |
1912 contents_container_ = new TabContentsContainer; | 1868 contents_container_ = new TabContentsContainer; |
1913 contents_ = new ContentsContainer(contents_container_); | 1869 contents_ = new ContentsContainer(contents_container_); |
1914 | 1870 |
1915 SkColor bg_color = GetWidget()->GetThemeProvider()-> | 1871 SkColor bg_color = GetWidget()->GetThemeProvider()-> |
1916 GetColor(ThemeService::COLOR_TOOLBAR); | 1872 GetColor(ThemeService::COLOR_TOOLBAR); |
1917 | 1873 |
1918 bool sidebar_allowed = SidebarManager::IsSidebarAllowed(); | |
1919 if (sidebar_allowed) { | |
1920 sidebar_container_ = new TabContentsContainer; | |
1921 sidebar_container_->set_id(VIEW_ID_SIDE_BAR_CONTAINER); | |
1922 sidebar_container_->SetVisible(false); | |
1923 | |
1924 sidebar_split_ = new views::SingleSplitView( | |
1925 contents_, | |
1926 sidebar_container_, | |
1927 views::SingleSplitView::HORIZONTAL_SPLIT, | |
1928 this); | |
1929 sidebar_split_->set_id(VIEW_ID_SIDE_BAR_SPLIT); | |
1930 sidebar_split_->SetAccessibleName( | |
1931 l10n_util::GetStringUTF16(IDS_ACCNAME_SIDE_BAR)); | |
1932 sidebar_split_->set_background( | |
1933 views::Background::CreateSolidBackground(bg_color)); | |
1934 } | |
1935 | |
1936 devtools_container_ = new TabContentsContainer; | 1874 devtools_container_ = new TabContentsContainer; |
1937 devtools_container_->set_id(VIEW_ID_DEV_TOOLS_DOCKED); | 1875 devtools_container_->set_id(VIEW_ID_DEV_TOOLS_DOCKED); |
1938 devtools_container_->SetVisible(false); | 1876 devtools_container_->SetVisible(false); |
1939 | 1877 |
1940 views::View* contents_view = contents_; | 1878 views::View* contents_view = contents_; |
1941 if (sidebar_allowed) | |
1942 contents_view = sidebar_split_; | |
1943 | 1879 |
1944 contents_split_ = new views::SingleSplitView( | 1880 contents_split_ = new views::SingleSplitView( |
1945 contents_view, | 1881 contents_view, |
1946 devtools_container_, | 1882 devtools_container_, |
1947 views::SingleSplitView::VERTICAL_SPLIT, | 1883 views::SingleSplitView::VERTICAL_SPLIT, |
1948 this); | 1884 this); |
1949 contents_split_->set_id(VIEW_ID_CONTENTS_SPLIT); | 1885 contents_split_->set_id(VIEW_ID_CONTENTS_SPLIT); |
1950 contents_split_->SetAccessibleName( | 1886 contents_split_->SetAccessibleName( |
1951 l10n_util::GetStringUTF16(IDS_ACCNAME_WEB_CONTENTS)); | 1887 l10n_util::GetStringUTF16(IDS_ACCNAME_WEB_CONTENTS)); |
1952 contents_split_->set_background( | 1888 contents_split_->set_background( |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2072 return UpdateChildViewAndLayout(new_bookmark_bar_view, &active_bookmark_bar_); | 2008 return UpdateChildViewAndLayout(new_bookmark_bar_view, &active_bookmark_bar_); |
2073 } | 2009 } |
2074 | 2010 |
2075 bool BrowserView::MaybeShowInfoBar(TabContentsWrapper* contents) { | 2011 bool BrowserView::MaybeShowInfoBar(TabContentsWrapper* contents) { |
2076 // TODO(beng): Remove this function once the interface between | 2012 // TODO(beng): Remove this function once the interface between |
2077 // InfoBarContainer, DownloadShelfView and TabContents and this | 2013 // InfoBarContainer, DownloadShelfView and TabContents and this |
2078 // view is sorted out. | 2014 // view is sorted out. |
2079 return true; | 2015 return true; |
2080 } | 2016 } |
2081 | 2017 |
2082 void BrowserView::UpdateSidebar() { | |
2083 UpdateSidebarForContents(GetSelectedTabContentsWrapper()); | |
2084 Layout(); | |
2085 } | |
2086 | |
2087 void BrowserView::UpdateSidebarForContents(TabContentsWrapper* tab_contents) { | |
2088 if (!sidebar_container_) | |
2089 return; // Happens when sidebar is not allowed. | |
2090 if (!SidebarManager::GetInstance()) | |
2091 return; // Happens only in tests. | |
2092 | |
2093 TabContents* sidebar_contents = NULL; | |
2094 if (tab_contents) { | |
2095 SidebarContainer* client_host = SidebarManager::GetInstance()-> | |
2096 GetActiveSidebarContainerFor( | |
2097 static_cast<TabContents*>(tab_contents->web_contents())); | |
2098 if (client_host) | |
2099 sidebar_contents = client_host->sidebar_contents(); | |
2100 } | |
2101 | |
2102 bool visible = NULL != sidebar_contents && | |
2103 browser_->SupportsWindowFeature(Browser::FEATURE_SIDEBAR); | |
2104 | |
2105 bool should_show = visible && !sidebar_container_->visible(); | |
2106 bool should_hide = !visible && sidebar_container_->visible(); | |
2107 | |
2108 // Update sidebar content. | |
2109 TabContents* old_contents = | |
2110 static_cast<TabContents*>(sidebar_container_->web_contents()); | |
2111 sidebar_container_->ChangeWebContents(sidebar_contents); | |
2112 SidebarManager::GetInstance()-> | |
2113 NotifyStateChanges(old_contents, sidebar_contents); | |
2114 | |
2115 // Update sidebar UI width. | |
2116 if (should_show) { | |
2117 // Restore split offset. | |
2118 int sidebar_width = g_browser_process->local_state()->GetInteger( | |
2119 prefs::kExtensionSidebarWidth); | |
2120 if (sidebar_width < 0) { | |
2121 // Initial load, set to default value. | |
2122 sidebar_width = sidebar_split_->width() / 7; | |
2123 } | |
2124 // Make sure user can see both panes. | |
2125 int min_sidebar_width = sidebar_split_->GetMinimumSize().width(); | |
2126 sidebar_width = std::min(sidebar_split_->width() - min_sidebar_width, | |
2127 std::max(min_sidebar_width, sidebar_width)); | |
2128 | |
2129 sidebar_split_->set_divider_offset( | |
2130 sidebar_split_->width() - sidebar_width); | |
2131 | |
2132 sidebar_container_->SetVisible(true); | |
2133 sidebar_split_->InvalidateLayout(); | |
2134 Layout(); | |
2135 } else if (should_hide) { | |
2136 // Store split offset when hiding sidebar only. | |
2137 g_browser_process->local_state()->SetInteger( | |
2138 prefs::kExtensionSidebarWidth, | |
2139 sidebar_split_->width() - sidebar_split_->divider_offset()); | |
2140 | |
2141 sidebar_container_->SetVisible(false); | |
2142 sidebar_split_->InvalidateLayout(); | |
2143 Layout(); | |
2144 } | |
2145 } | |
2146 | |
2147 void BrowserView::UpdateDevToolsForContents(TabContentsWrapper* wrapper) { | 2018 void BrowserView::UpdateDevToolsForContents(TabContentsWrapper* wrapper) { |
2148 WebContents* devtools_contents = NULL; | 2019 WebContents* devtools_contents = NULL; |
2149 if (wrapper) { | 2020 if (wrapper) { |
2150 TabContentsWrapper* devtools_contents_wrapper = | 2021 TabContentsWrapper* devtools_contents_wrapper = |
2151 DevToolsWindow::GetDevToolsContents(wrapper->web_contents()); | 2022 DevToolsWindow::GetDevToolsContents(wrapper->web_contents()); |
2152 if (devtools_contents_wrapper) | 2023 if (devtools_contents_wrapper) |
2153 devtools_contents = devtools_contents_wrapper->web_contents(); | 2024 devtools_contents = devtools_contents_wrapper->web_contents(); |
2154 } | 2025 } |
2155 | 2026 |
2156 bool should_show = devtools_contents && !devtools_container_->visible(); | 2027 bool should_show = devtools_contents && !devtools_container_->visible(); |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2597 contents_container_->ChangeWebContents(NULL); | 2468 contents_container_->ChangeWebContents(NULL); |
2598 infobar_container_->ChangeTabContents(new_contents->infobar_tab_helper()); | 2469 infobar_container_->ChangeTabContents(new_contents->infobar_tab_helper()); |
2599 if (bookmark_bar_view_.get()) { | 2470 if (bookmark_bar_view_.get()) { |
2600 bookmark_bar_view_->SetBookmarkBarState( | 2471 bookmark_bar_view_->SetBookmarkBarState( |
2601 browser_->bookmark_bar_state(), | 2472 browser_->bookmark_bar_state(), |
2602 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); | 2473 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); |
2603 } | 2474 } |
2604 UpdateUIForContents(new_contents); | 2475 UpdateUIForContents(new_contents); |
2605 if (change_tab_contents) | 2476 if (change_tab_contents) |
2606 contents_container_->ChangeWebContents(new_contents->web_contents()); | 2477 contents_container_->ChangeWebContents(new_contents->web_contents()); |
2607 UpdateSidebarForContents(new_contents); | |
2608 | 2478 |
2609 UpdateDevToolsForContents(new_contents); | 2479 UpdateDevToolsForContents(new_contents); |
2610 // TODO(beng): This should be called automatically by ChangeWebContents, but I | 2480 // TODO(beng): This should be called automatically by ChangeWebContents, but I |
2611 // am striving for parity now rather than cleanliness. This is | 2481 // am striving for parity now rather than cleanliness. This is |
2612 // required to make features like Duplicate Tab, Undo Close Tab, | 2482 // required to make features like Duplicate Tab, Undo Close Tab, |
2613 // etc not result in sad tab. | 2483 // etc not result in sad tab. |
2614 new_contents->web_contents()->DidBecomeSelected(); | 2484 new_contents->web_contents()->DidBecomeSelected(); |
2615 if (BrowserList::GetLastActive() == browser_ && | 2485 if (BrowserList::GetLastActive() == browser_ && |
2616 !browser_->tabstrip_model()->closing_all() && GetWidget()->IsVisible()) { | 2486 !browser_->tabstrip_model()->closing_all() && GetWidget()->IsVisible()) { |
2617 // We only restore focus if our window is visible, to avoid invoking blur | 2487 // We only restore focus if our window is visible, to avoid invoking blur |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2665 browser::CreateViewsBubble(bubble); | 2535 browser::CreateViewsBubble(bubble); |
2666 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); | 2536 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); |
2667 bubble->Show(); | 2537 bubble->Show(); |
2668 } | 2538 } |
2669 | 2539 |
2670 void BrowserView::ShowAvatarBubbleFromAvatarButton() { | 2540 void BrowserView::ShowAvatarBubbleFromAvatarButton() { |
2671 AvatarMenuButton* button = frame_->GetAvatarMenuButton(); | 2541 AvatarMenuButton* button = frame_->GetAvatarMenuButton(); |
2672 if (button) | 2542 if (button) |
2673 button->ShowAvatarBubble(); | 2543 button->ShowAvatarBubble(); |
2674 } | 2544 } |
OLD | NEW |