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

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

Issue 3105004: Adds support for showing the match preview on views. It's behind the (Closed)
Patch Set: Addressed review comments Created 10 years, 4 months 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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/views/frame/browser_view.h" 5 #include "chrome/browser/views/frame/browser_view.h"
6 6
7 #if defined(OS_LINUX) 7 #if defined(OS_LINUX)
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #endif 9 #endif
10 10
11 #include "app/l10n_util.h" 11 #include "app/l10n_util.h"
12 #include "app/resource_bundle.h" 12 #include "app/resource_bundle.h"
13 #include "base/i18n/rtl.h" 13 #include "base/i18n/rtl.h"
14 #include "base/string_number_conversions.h" 14 #include "base/string_number_conversions.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "chrome/app/chrome_dll_resource.h" 16 #include "chrome/app/chrome_dll_resource.h"
17 #include "chrome/browser/app_modal_dialog_queue.h" 17 #include "chrome/browser/app_modal_dialog_queue.h"
18 #include "chrome/browser/autocomplete/autocomplete_popup_model.h"
19 #include "chrome/browser/autocomplete/autocomplete_popup_view.h"
18 #include "chrome/browser/automation/ui_controls.h" 20 #include "chrome/browser/automation/ui_controls.h"
19 #include "chrome/browser/bookmarks/bookmark_utils.h" 21 #include "chrome/browser/bookmarks/bookmark_utils.h"
20 #include "chrome/browser/browser_list.h" 22 #include "chrome/browser/browser_list.h"
21 #include "chrome/browser/browser_process.h" 23 #include "chrome/browser/browser_process.h"
22 #include "chrome/browser/browser_theme_provider.h" 24 #include "chrome/browser/browser_theme_provider.h"
23 #include "chrome/browser/debugger/devtools_window.h" 25 #include "chrome/browser/debugger/devtools_window.h"
24 #include "chrome/browser/download/download_manager.h" 26 #include "chrome/browser/download/download_manager.h"
25 #include "chrome/browser/ntp_background_util.h" 27 #include "chrome/browser/ntp_background_util.h"
26 #include "chrome/browser/page_info_window.h" 28 #include "chrome/browser/page_info_window.h"
27 #include "chrome/browser/pref_service.h" 29 #include "chrome/browser/pref_service.h"
28 #include "chrome/browser/profile.h" 30 #include "chrome/browser/profile.h"
29 #include "chrome/browser/sessions/tab_restore_service.h" 31 #include "chrome/browser/sessions/tab_restore_service.h"
32 #include "chrome/browser/tab_contents/match_preview.h"
30 #include "chrome/browser/tab_contents/tab_contents.h" 33 #include "chrome/browser/tab_contents/tab_contents.h"
31 #include "chrome/browser/tab_contents/tab_contents_view.h" 34 #include "chrome/browser/tab_contents/tab_contents_view.h"
32 #include "chrome/browser/view_ids.h" 35 #include "chrome/browser/view_ids.h"
33 #include "chrome/browser/views/accessible_view_helper.h" 36 #include "chrome/browser/views/accessible_view_helper.h"
34 #include "chrome/browser/views/bookmark_bar_view.h" 37 #include "chrome/browser/views/bookmark_bar_view.h"
35 #include "chrome/browser/views/browser_dialogs.h" 38 #include "chrome/browser/views/browser_dialogs.h"
36 #include "chrome/browser/views/download_shelf_view.h" 39 #include "chrome/browser/views/download_shelf_view.h"
37 #include "chrome/browser/views/extensions/extension_shelf.h" 40 #include "chrome/browser/views/extensions/extension_shelf.h"
38 #include "chrome/browser/views/frame/browser_view_layout.h" 41 #include "chrome/browser/views/frame/browser_view_layout.h"
39 #include "chrome/browser/views/fullscreen_exit_bubble.h" 42 #include "chrome/browser/views/fullscreen_exit_bubble.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 profile ? profile : browser->profile(), 123 profile ? profile : browser->profile(),
121 Browser::TYPE_NORMAL, true); 124 Browser::TYPE_NORMAL, true);
122 if (normal_browser && normal_browser->window()) 125 if (normal_browser && normal_browser->window())
123 return normal_browser->window()->GetNativeHandle(); 126 return normal_browser->window()->GetNativeHandle();
124 } 127 }
125 128
126 return browser->window()->GetNativeHandle(); 129 return browser->window()->GetNativeHandle();
127 } 130 }
128 #endif // defined(OS_CHROMEOS) 131 #endif // defined(OS_CHROMEOS)
129 132
133 // ContentsContainer is responsible for managing the TabContents views.
134 // ContentsContainer has up to two children: one for the currently active
135 // TabContents and one for the match preview TabContents.
136 class BrowserView::ContentsContainer : public views::View {
137 public:
138 ContentsContainer(BrowserView* browser_view, views::View* active)
139 : browser_view_(browser_view),
140 active_(active),
141 preview_(NULL) {
142 AddChildView(active_);
143 }
144
145 // Makes the preview view the active view and nulls out the old active view.
146 // It's assumed the caller will delete or remove the old active view
147 // separately.
148 void MakePreviewContentsActiveContents() {
149 active_ = preview_;
150 preview_ = NULL;
151 Layout();
152 }
153
154 // Sets the preview view. This does not delete the old.
155 void SetPreview(views::View* preview) {
156 if (preview == preview_)
157 return;
158
159 if (preview_)
160 RemoveChildView(preview_);
161 preview_ = preview;
162 if (preview_)
163 AddChildView(preview_);
164
165 Layout();
166 }
167
168 virtual void Layout() {
169 // The active view always gets the full bounds.
170 active_->SetBounds(0, 0, width(), height());
171
172 if (preview_) {
173 // The preview view gets the full width and is positioned beneath the
174 // bottom of the autocompleted popup.
175 int max_autocomplete_y = browser_view_->toolbar()->location_bar()->
176 location_entry()->model()->popup_model()->view()->GetMaxYCoordinate();
177 gfx::Point screen_origin;
178 views::View::ConvertPointToScreen(this, &screen_origin);
179 DCHECK_GT(max_autocomplete_y, screen_origin.y());
180 int preview_origin = max_autocomplete_y - screen_origin.y();
181 if (preview_origin < height()) {
182 preview_->SetBounds(0, preview_origin, width(),
183 height() - preview_origin);
184 } else {
185 preview_->SetBounds(0, 0, 0, 0);
186 }
187 }
188 }
189
190 private:
191 BrowserView* browser_view_;
192 views::View* active_;
193 views::View* preview_;
194
195 DISALLOW_COPY_AND_ASSIGN(ContentsContainer);
196 };
197
130 /////////////////////////////////////////////////////////////////////////////// 198 ///////////////////////////////////////////////////////////////////////////////
131 // BookmarkExtensionBackground, private: 199 // BookmarkExtensionBackground, private:
132 // This object serves as the views::Background object which is used to layout 200 // This object serves as the views::Background object which is used to layout
133 // and paint the bookmark bar. 201 // and paint the bookmark bar.
134 class BookmarkExtensionBackground : public views::Background { 202 class BookmarkExtensionBackground : public views::Background {
135 public: 203 public:
136 explicit BookmarkExtensionBackground(BrowserView* browser_view, 204 explicit BookmarkExtensionBackground(BrowserView* browser_view,
137 DetachableToolbarView* host_view, 205 DetachableToolbarView* host_view,
138 Browser* browser); 206 Browser* browser);
139 207
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 last_focused_view_storage_id_( 477 last_focused_view_storage_id_(
410 views::ViewStorage::GetSharedInstance()->CreateStorageID()), 478 views::ViewStorage::GetSharedInstance()->CreateStorageID()),
411 frame_(NULL), 479 frame_(NULL),
412 browser_(browser), 480 browser_(browser),
413 active_bookmark_bar_(NULL), 481 active_bookmark_bar_(NULL),
414 tabstrip_(NULL), 482 tabstrip_(NULL),
415 toolbar_(NULL), 483 toolbar_(NULL),
416 infobar_container_(NULL), 484 infobar_container_(NULL),
417 contents_container_(NULL), 485 contents_container_(NULL),
418 devtools_container_(NULL), 486 devtools_container_(NULL),
487 preview_container_(NULL),
488 contents_(NULL),
419 contents_split_(NULL), 489 contents_split_(NULL),
420 initialized_(false), 490 initialized_(false),
421 ignore_layout_(true), 491 ignore_layout_(true),
422 #if defined(OS_WIN) 492 #if defined(OS_WIN)
423 hung_window_detector_(&hung_plugin_action_), 493 hung_window_detector_(&hung_plugin_action_),
424 ticker_(0), 494 ticker_(0),
425 #endif 495 #endif
426 extension_shelf_(NULL) { 496 extension_shelf_(NULL) {
427 browser_->tabstrip_model()->AddObserver(this); 497 browser_->tabstrip_model()->AddObserver(this);
428 } 498 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 TabContents* tab_contents = GetSelectedTabContents(); 581 TabContents* tab_contents = GetSelectedTabContents();
512 if (tab_contents) 582 if (tab_contents)
513 tab_contents->WindowMoveOrResizeStarted(); 583 tab_contents->WindowMoveOrResizeStarted();
514 } 584 }
515 585
516 gfx::Rect BrowserView::GetToolbarBounds() const { 586 gfx::Rect BrowserView::GetToolbarBounds() const {
517 return toolbar_->bounds(); 587 return toolbar_->bounds();
518 } 588 }
519 589
520 gfx::Rect BrowserView::GetClientAreaBounds() const { 590 gfx::Rect BrowserView::GetClientAreaBounds() const {
521 gfx::Rect container_bounds = contents_container_->bounds(); 591 gfx::Rect container_bounds = contents_->bounds();
522 gfx::Point container_origin = container_bounds.origin(); 592 gfx::Point container_origin = container_bounds.origin();
523 ConvertPointToView(this, GetParent(), &container_origin); 593 ConvertPointToView(this, GetParent(), &container_origin);
524 container_bounds.set_origin(container_origin); 594 container_bounds.set_origin(container_origin);
525 return container_bounds; 595 return container_bounds;
526 } 596 }
527 597
528 bool BrowserView::ShouldFindBarBlendWithBookmarksBar() const { 598 bool BrowserView::ShouldFindBarBlendWithBookmarksBar() const {
529 if (bookmark_bar_view_.get()) 599 if (bookmark_bar_view_.get())
530 return bookmark_bar_view_->IsAlwaysShown(); 600 return bookmark_bar_view_->IsAlwaysShown();
531 return false; 601 return false;
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 ToolbarView* BrowserView::GetToolbarView() const { 1383 ToolbarView* BrowserView::GetToolbarView() const {
1314 return toolbar_; 1384 return toolbar_;
1315 } 1385 }
1316 1386
1317 /////////////////////////////////////////////////////////////////////////////// 1387 ///////////////////////////////////////////////////////////////////////////////
1318 // BrowserView, NotificationObserver implementation: 1388 // BrowserView, NotificationObserver implementation:
1319 1389
1320 void BrowserView::Observe(NotificationType type, 1390 void BrowserView::Observe(NotificationType type,
1321 const NotificationSource& source, 1391 const NotificationSource& source,
1322 const NotificationDetails& details) { 1392 const NotificationDetails& details) {
1323 if (type == NotificationType::PREF_CHANGED && 1393 switch (type.value) {
1324 *Details<std::wstring>(details).ptr() == prefs::kShowBookmarkBar) { 1394 case NotificationType::PREF_CHANGED:
1325 if (MaybeShowBookmarkBar(browser_->GetSelectedTabContents())) 1395 if (*Details<std::wstring>(details).ptr() == prefs::kShowBookmarkBar &&
1326 Layout(); 1396 MaybeShowBookmarkBar(browser_->GetSelectedTabContents())) {
1327 } else { 1397 Layout();
1328 NOTREACHED() << "Got a notification we didn't register for!"; 1398 }
1399 break;
1400
1401 case NotificationType::MATCH_PREVIEW_TAB_CONTENTS_CREATED:
1402 if (Source<TabContents>(source).ptr() ==
1403 browser_->GetSelectedTabContents()) {
1404 ShowMatchPreview();
1405 }
1406 break;
1407
1408 case NotificationType::TAB_CONTENTS_DESTROYED: {
1409 if (MatchPreview::IsEnabled()) {
1410 TabContents* selected_contents = browser_->GetSelectedTabContents();
1411 if (selected_contents &&
1412 selected_contents->match_preview()->preview_contents() ==
1413 Source<TabContents>(source).ptr()) {
1414 HideMatchPreview();
1415 }
1416 }
1417 break;
1418 }
1419
1420 default:
1421 NOTREACHED() << "Got a notification we didn't register for!";
1329 } 1422 }
1330 } 1423 }
1331 1424
1332 /////////////////////////////////////////////////////////////////////////////// 1425 ///////////////////////////////////////////////////////////////////////////////
1333 // BrowserView, TabStripModelObserver implementation: 1426 // BrowserView, TabStripModelObserver implementation:
1334 1427
1335 void BrowserView::TabDetachedAt(TabContents* contents, int index) { 1428 void BrowserView::TabDetachedAt(TabContents* contents, int index) {
1336 // We use index here rather than comparing |contents| because by this time 1429 // We use index here rather than comparing |contents| because by this time
1337 // the model has already removed |contents| from its list, so 1430 // the model has already removed |contents| from its list, so
1338 // browser_->GetSelectedTabContents() will return NULL or something else. 1431 // browser_->GetSelectedTabContents() will return NULL or something else.
(...skipping 14 matching lines...) Expand all
1353 if (!contents->is_being_destroyed()) 1446 if (!contents->is_being_destroyed())
1354 contents->view()->StoreFocus(); 1447 contents->view()->StoreFocus();
1355 } 1448 }
1356 1449
1357 void BrowserView::TabSelectedAt(TabContents* old_contents, 1450 void BrowserView::TabSelectedAt(TabContents* old_contents,
1358 TabContents* new_contents, 1451 TabContents* new_contents,
1359 int index, 1452 int index,
1360 bool user_gesture) { 1453 bool user_gesture) {
1361 DCHECK(old_contents != new_contents); 1454 DCHECK(old_contents != new_contents);
1362 1455
1363 // Update various elements that are interested in knowing the current 1456 ProcessTabSelected(new_contents, true);
1364 // TabContents. 1457 }
1365 1458
1366 // When we toggle the NTP floating bookmarks bar and/or the info bar, 1459 void BrowserView::TabReplacedAt(TabContents* old_contents,
1367 // we don't want any TabContents to be attached, so that we 1460 TabContents* new_contents,
1368 // avoid an unnecessary resize and re-layout of a TabContents. 1461 int index,
1369 contents_container_->ChangeTabContents(NULL); 1462 TabStripModelObserver::TabReplaceType type) {
1370 infobar_container_->ChangeTabContents(new_contents); 1463 if (type != TabStripModelObserver::REPLACE_MATCH_PREVIEW ||
1371 UpdateUIForContents(new_contents); 1464 index != browser_->tabstrip_model()->selected_index()) {
1372 contents_container_->ChangeTabContents(new_contents); 1465 return;
1373
1374 UpdateDevToolsForContents(new_contents);
1375 // TODO(beng): This should be called automatically by ChangeTabContents, but I
1376 // am striving for parity now rather than cleanliness. This is
1377 // required to make features like Duplicate Tab, Undo Close Tab,
1378 // etc not result in sad tab.
1379 new_contents->DidBecomeSelected();
1380 if (BrowserList::GetLastActive() == browser_ &&
1381 !browser_->tabstrip_model()->closing_all() && GetWindow()->IsVisible()) {
1382 // We only restore focus if our window is visible, to avoid invoking blur
1383 // handlers when we are eventually shown.
1384 new_contents->view()->RestoreFocus();
1385 } 1466 }
1386 1467
1387 // Update all the UI bits. 1468 // Swap the 'active' and 'preview' and delete what was the active.
1388 UpdateTitleBar(); 1469 contents_->MakePreviewContentsActiveContents();
1389 UpdateToolbar(new_contents, true); 1470 TabContentsContainer* old_container = contents_container_;
1390 UpdateUIForContents(new_contents); 1471 contents_container_ = preview_container_;
1472 old_container->ChangeTabContents(NULL);
1473 delete old_container;
1474 preview_container_ = NULL;
1475
1476 // Update the UI for what was the preview contents and is now active. Pass in
1477 // false to ProcessTabSelected as new_contents is already parented correctly.
1478 ProcessTabSelected(new_contents, false);
1391 } 1479 }
1392 1480
1393 void BrowserView::TabStripEmpty() { 1481 void BrowserView::TabStripEmpty() {
1394 // Make sure all optional UI is removed before we are destroyed, otherwise 1482 // Make sure all optional UI is removed before we are destroyed, otherwise
1395 // there will be consequences (since our view hierarchy will still have 1483 // there will be consequences (since our view hierarchy will still have
1396 // references to freed views). 1484 // references to freed views).
1397 UpdateUIForContents(NULL); 1485 UpdateUIForContents(NULL);
1398 } 1486 }
1399 1487
1400 /////////////////////////////////////////////////////////////////////////////// 1488 ///////////////////////////////////////////////////////////////////////////////
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
1752 1840
1753 toolbar_ = new ToolbarView(browser_.get()); 1841 toolbar_ = new ToolbarView(browser_.get());
1754 AddChildView(toolbar_); 1842 AddChildView(toolbar_);
1755 toolbar_->Init(browser_->profile()); 1843 toolbar_->Init(browser_->profile());
1756 toolbar_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TOOLBAR)); 1844 toolbar_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TOOLBAR));
1757 1845
1758 infobar_container_ = new InfoBarContainer(this); 1846 infobar_container_ = new InfoBarContainer(this);
1759 AddChildView(infobar_container_); 1847 AddChildView(infobar_container_);
1760 1848
1761 contents_container_ = new TabContentsContainer; 1849 contents_container_ = new TabContentsContainer;
1850 contents_ = new ContentsContainer(this, contents_container_);
1762 devtools_container_ = new TabContentsContainer; 1851 devtools_container_ = new TabContentsContainer;
1763 devtools_container_->SetID(VIEW_ID_DEV_TOOLS_DOCKED); 1852 devtools_container_->SetID(VIEW_ID_DEV_TOOLS_DOCKED);
1764 devtools_container_->SetVisible(false); 1853 devtools_container_->SetVisible(false);
1765 contents_split_ = new views::SingleSplitView( 1854 contents_split_ = new views::SingleSplitView(
1766 contents_container_, 1855 contents_,
1767 devtools_container_, 1856 devtools_container_,
1768 views::SingleSplitView::VERTICAL_SPLIT); 1857 views::SingleSplitView::VERTICAL_SPLIT);
1769 contents_split_->SetID(VIEW_ID_CONTENTS_SPLIT); 1858 contents_split_->SetID(VIEW_ID_CONTENTS_SPLIT);
1770 contents_split_-> 1859 contents_split_->
1771 SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_WEB_CONTENTS)); 1860 SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_WEB_CONTENTS));
1772 SkColor bg_color = GetWidget()->GetThemeProvider()-> 1861 SkColor bg_color = GetWidget()->GetThemeProvider()->
1773 GetColor(BrowserThemeProvider::COLOR_TOOLBAR); 1862 GetColor(BrowserThemeProvider::COLOR_TOOLBAR);
1774 contents_split_->set_background( 1863 contents_split_->set_background(
1775 views::Background::CreateSolidBackground(bg_color)); 1864 views::Background::CreateSolidBackground(bg_color));
1776 AddChildView(contents_split_); 1865 AddChildView(contents_split_);
(...skipping 24 matching lines...) Expand all
1801 if (AeroPeekManager::Enabled()) { 1890 if (AeroPeekManager::Enabled()) {
1802 gfx::Rect bounds(frame_->GetBoundsForTabStrip(tabstrip())); 1891 gfx::Rect bounds(frame_->GetBoundsForTabStrip(tabstrip()));
1803 aeropeek_manager_.reset(new AeroPeekManager( 1892 aeropeek_manager_.reset(new AeroPeekManager(
1804 frame_->GetWindow()->GetNativeWindow())); 1893 frame_->GetWindow()->GetNativeWindow()));
1805 browser_->tabstrip_model()->AddObserver(aeropeek_manager_.get()); 1894 browser_->tabstrip_model()->AddObserver(aeropeek_manager_.get());
1806 } 1895 }
1807 #endif 1896 #endif
1808 1897
1809 // We're now initialized and ready to process Layout requests. 1898 // We're now initialized and ready to process Layout requests.
1810 ignore_layout_ = false; 1899 ignore_layout_ = false;
1900
1901 registrar_.Add(this,
1902 NotificationType::MATCH_PREVIEW_TAB_CONTENTS_CREATED,
1903 NotificationService::AllSources());
1904 registrar_.Add(this,
1905 NotificationType::TAB_CONTENTS_DESTROYED,
1906 NotificationService::AllSources());
1811 } 1907 }
1812 1908
1813 #if defined(OS_WIN) 1909 #if defined(OS_WIN)
1814 void BrowserView::InitSystemMenu() { 1910 void BrowserView::InitSystemMenu() {
1815 system_menu_contents_.reset(new views::SystemMenuModel(this)); 1911 system_menu_contents_.reset(new views::SystemMenuModel(this));
1816 // We add the menu items in reverse order so that insertion_index never needs 1912 // We add the menu items in reverse order so that insertion_index never needs
1817 // to change. 1913 // to change.
1818 if (IsBrowserTypeNormal()) 1914 if (IsBrowserTypeNormal())
1819 BuildSystemMenuForBrowserWindow(); 1915 BuildSystemMenuForBrowserWindow();
1820 else 1916 else
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
2227 ticker_.Start(); 2323 ticker_.Start();
2228 2324
2229 pref_service->SetInteger(prefs::kPluginMessageResponseTimeout, 2325 pref_service->SetInteger(prefs::kPluginMessageResponseTimeout,
2230 plugin_message_response_timeout); 2326 plugin_message_response_timeout);
2231 pref_service->SetInteger(prefs::kHungPluginDetectFrequency, 2327 pref_service->SetInteger(prefs::kHungPluginDetectFrequency,
2232 hung_plugin_detect_freq); 2328 hung_plugin_detect_freq);
2233 } 2329 }
2234 #endif 2330 #endif
2235 } 2331 }
2236 2332
2333 void BrowserView::ShowMatchPreview() {
2334 if (!preview_container_)
2335 preview_container_ = new TabContentsContainer();
2336 contents_->SetPreview(preview_container_);
2337 preview_container_->ChangeTabContents(
2338 browser_->GetSelectedTabContents()->match_preview()->preview_contents());
2339 }
2340
2341 void BrowserView::HideMatchPreview() {
2342 if (!preview_container_)
2343 return;
2344
2345 // The contents must be changed before SetPreview is invoked.
2346 preview_container_->ChangeTabContents(NULL);
2347 contents_->SetPreview(NULL);
2348 delete preview_container_;
2349 preview_container_ = NULL;
2350 }
2351
2352 void BrowserView::ProcessTabSelected(TabContents* new_contents,
2353 bool change_tab_contents) {
2354
2355 // Update various elements that are interested in knowing the current
2356 // TabContents.
2357
2358 // When we toggle the NTP floating bookmarks bar and/or the info bar,
2359 // we don't want any TabContents to be attached, so that we
2360 // avoid an unnecessary resize and re-layout of a TabContents.
2361 if (change_tab_contents)
2362 contents_container_->ChangeTabContents(NULL);
2363 infobar_container_->ChangeTabContents(new_contents);
2364 UpdateUIForContents(new_contents);
2365 if (change_tab_contents)
2366 contents_container_->ChangeTabContents(new_contents);
2367
2368 UpdateDevToolsForContents(new_contents);
2369 // TODO(beng): This should be called automatically by ChangeTabContents, but I
2370 // am striving for parity now rather than cleanliness. This is
2371 // required to make features like Duplicate Tab, Undo Close Tab,
2372 // etc not result in sad tab.
2373 new_contents->DidBecomeSelected();
2374 if (BrowserList::GetLastActive() == browser_ &&
2375 !browser_->tabstrip_model()->closing_all() && GetWindow()->IsVisible()) {
2376 // We only restore focus if our window is visible, to avoid invoking blur
2377 // handlers when we are eventually shown.
2378 new_contents->view()->RestoreFocus();
2379 }
2380
2381 // Update all the UI bits.
2382 UpdateTitleBar();
2383 UpdateToolbar(new_contents, true);
2384 UpdateUIForContents(new_contents);
2385 }
2386
2237 #if !defined(OS_CHROMEOS) 2387 #if !defined(OS_CHROMEOS)
2238 // static 2388 // static
2239 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { 2389 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) {
2240 // Create the view and the frame. The frame will attach itself via the view 2390 // Create the view and the frame. The frame will attach itself via the view
2241 // so we don't need to do anything with the pointer. 2391 // so we don't need to do anything with the pointer.
2242 BrowserView* view = new BrowserView(browser); 2392 BrowserView* view = new BrowserView(browser);
2243 BrowserFrame::Create(view, browser->profile()); 2393 BrowserFrame::Create(view, browser->profile());
2244 2394
2245 view->GetWindow()->GetNonClientView()-> 2395 view->GetWindow()->GetNonClientView()->
2246 SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); 2396 SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME));
2247 2397
2248 return view; 2398 return view;
2249 } 2399 }
2250 #endif 2400 #endif
2251 2401
2252 // static 2402 // static
2253 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { 2403 FindBar* BrowserWindow::CreateFindBar(Browser* browser) {
2254 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); 2404 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window()));
2255 } 2405 }
OLDNEW
« no previous file with comments | « chrome/browser/views/frame/browser_view.h ('k') | chrome/browser/views/location_bar/location_bar_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698