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

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

Issue 14205026: views: Cleanup BrowserView function order and variable names (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 8 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 | Annotate | Revision Log
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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 : views::ClientView(NULL, NULL), 432 : views::ClientView(NULL, NULL),
433 last_focused_view_storage_id_( 433 last_focused_view_storage_id_(
434 views::ViewStorage::GetInstance()->CreateStorageID()), 434 views::ViewStorage::GetInstance()->CreateStorageID()),
435 frame_(NULL), 435 frame_(NULL),
436 browser_(browser), 436 browser_(browser),
437 top_container_(NULL), 437 top_container_(NULL),
438 tabstrip_(NULL), 438 tabstrip_(NULL),
439 toolbar_(NULL), 439 toolbar_(NULL),
440 window_switcher_button_(NULL), 440 window_switcher_button_(NULL),
441 infobar_container_(NULL), 441 infobar_container_(NULL),
442 contents_web_view_(NULL),
443 devtools_container_(NULL),
442 contents_container_(NULL), 444 contents_container_(NULL),
443 devtools_container_(NULL),
444 contents_(NULL),
445 contents_split_(NULL), 445 contents_split_(NULL),
446 devtools_dock_side_(DEVTOOLS_DOCK_SIDE_BOTTOM), 446 devtools_dock_side_(DEVTOOLS_DOCK_SIDE_BOTTOM),
447 devtools_window_(NULL), 447 devtools_window_(NULL),
448 initialized_(false), 448 initialized_(false),
449 ignore_layout_(true), 449 ignore_layout_(true),
450 #if defined(OS_WIN) && !defined(USE_AURA) 450 #if defined(OS_WIN) && !defined(USE_AURA)
451 hung_window_detector_(&hung_plugin_action_), 451 hung_window_detector_(&hung_plugin_action_),
452 ticker_(0), 452 ticker_(0),
453 #endif 453 #endif
454 force_location_bar_focus_(false), 454 force_location_bar_focus_(false),
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 gfx::Rect BrowserView::GetToolbarBounds() const { 527 gfx::Rect BrowserView::GetToolbarBounds() const {
528 gfx::Rect toolbar_bounds(toolbar_->bounds()); 528 gfx::Rect toolbar_bounds(toolbar_->bounds());
529 if (toolbar_bounds.IsEmpty()) 529 if (toolbar_bounds.IsEmpty())
530 return toolbar_bounds; 530 return toolbar_bounds;
531 // The apparent toolbar edges are outside the "real" toolbar edges. 531 // The apparent toolbar edges are outside the "real" toolbar edges.
532 toolbar_bounds.Inset(-views::NonClientFrameView::kClientEdgeThickness, 0); 532 toolbar_bounds.Inset(-views::NonClientFrameView::kClientEdgeThickness, 0);
533 return toolbar_bounds; 533 return toolbar_bounds;
534 } 534 }
535 535
536 gfx::Rect BrowserView::GetClientAreaBounds() const { 536 gfx::Rect BrowserView::GetClientAreaBounds() const {
537 gfx::Rect container_bounds = contents_->bounds(); 537 gfx::Rect container_bounds = contents_container_->bounds();
538 gfx::Point container_origin = container_bounds.origin(); 538 gfx::Point container_origin = container_bounds.origin();
539 ConvertPointToTarget(this, parent(), &container_origin); 539 ConvertPointToTarget(this, parent(), &container_origin);
540 container_bounds.set_origin(container_origin); 540 container_bounds.set_origin(container_origin);
541 return container_bounds; 541 return container_bounds;
542 } 542 }
543 543
544 gfx::Rect BrowserView::GetFindBarBoundingBox() const { 544 gfx::Rect BrowserView::GetFindBarBoundingBox() const {
545 return GetBrowserViewLayout()->GetFindBarBoundingBox(); 545 return GetBrowserViewLayout()->GetFindBarBoundingBox();
546 } 546 }
547 547
(...skipping 19 matching lines...) Expand all
567 if (immersive_mode_controller_->ShouldHideTopViews() && 567 if (immersive_mode_controller_->ShouldHideTopViews() &&
568 immersive_mode_controller_->ShouldHideTabIndicators()) 568 immersive_mode_controller_->ShouldHideTabIndicators())
569 return false; 569 return false;
570 return browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP); 570 return browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP);
571 } 571 }
572 572
573 bool BrowserView::IsOffTheRecord() const { 573 bool BrowserView::IsOffTheRecord() const {
574 return browser_->profile()->IsOffTheRecord(); 574 return browser_->profile()->IsOffTheRecord();
575 } 575 }
576 576
577 int BrowserView::GetOTRIconResourceID() const {
578 int otr_resource_id = IDR_OTR_ICON;
579 if (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) {
580 if (IsFullscreen())
581 otr_resource_id = IDR_OTR_ICON_FULLSCREEN;
582 #if defined(OS_WIN)
583 if (win8::IsSingleWindowMetroMode())
584 otr_resource_id = IDR_OTR_ICON_FULLSCREEN;
585 #endif
586 }
587
588 return otr_resource_id;
589 }
590
577 bool BrowserView::IsGuestSession() const { 591 bool BrowserView::IsGuestSession() const {
578 return browser_->profile()->IsGuestSession(); 592 return browser_->profile()->IsGuestSession();
579 } 593 }
580 594
581 bool BrowserView::ShouldShowAvatar() const { 595 bool BrowserView::ShouldShowAvatar() const {
582 if (!IsBrowserTypeNormal()) 596 if (!IsBrowserTypeNormal())
583 return false; 597 return false;
584 if (IsOffTheRecord() && !IsGuestSession()) 598 if (IsOffTheRecord() && !IsGuestSession())
585 return true; 599 return true;
586 if (ManagedMode::IsInManagedMode()) 600 if (ManagedMode::IsInManagedMode())
587 return true; 601 return true;
588 602
589 ProfileInfoCache& cache = 603 ProfileInfoCache& cache =
590 g_browser_process->profile_manager()->GetProfileInfoCache(); 604 g_browser_process->profile_manager()->GetProfileInfoCache();
591 if (cache.GetIndexOfProfileWithPath(browser_->profile()->GetPath()) == 605 if (cache.GetIndexOfProfileWithPath(browser_->profile()->GetPath()) ==
592 std::string::npos) { 606 std::string::npos) {
593 return false; 607 return false;
594 } 608 }
595 609
596 return AvatarMenuModel::ShouldShowAvatarMenu(); 610 return AvatarMenuModel::ShouldShowAvatarMenu();
597 } 611 }
598 612
599 bool BrowserView::AcceleratorPressed(const ui::Accelerator& accelerator) {
600 #if defined(OS_CHROMEOS)
601 // If accessibility is enabled, stop speech and return false so that key
602 // combinations involving Search can be used for extra accessibility
603 // functionality.
604 if (accelerator.key_code() == ui::VKEY_LWIN &&
605 g_browser_process->local_state()->GetBoolean(
606 prefs::kSpokenFeedbackEnabled)) {
607 TtsController::GetInstance()->Stop();
608 return false;
609 }
610 #endif
611
612 std::map<ui::Accelerator, int>::const_iterator iter =
613 accelerator_table_.find(accelerator);
614 DCHECK(iter != accelerator_table_.end());
615 int command_id = iter->second;
616
617 chrome::BrowserCommandController* controller = browser_->command_controller();
618 if (!controller->block_command_execution())
619 UpdateAcceleratorMetrics(accelerator, command_id);
620 return chrome::ExecuteCommand(browser_.get(), command_id);
621 }
622
623 bool BrowserView::GetAccelerator(int cmd_id, ui::Accelerator* accelerator) { 613 bool BrowserView::GetAccelerator(int cmd_id, ui::Accelerator* accelerator) {
624 // We retrieve the accelerator information for standard accelerators 614 // We retrieve the accelerator information for standard accelerators
625 // for cut, copy and paste. 615 // for cut, copy and paste.
626 if (chrome::GetStandardAcceleratorForCommandId(cmd_id, accelerator)) 616 if (chrome::GetStandardAcceleratorForCommandId(cmd_id, accelerator))
627 return true; 617 return true;
628 // Else, we retrieve the accelerator information from the accelerator table. 618 // Else, we retrieve the accelerator information from the accelerator table.
629 for (std::map<ui::Accelerator, int>::const_iterator it = 619 for (std::map<ui::Accelerator, int>::const_iterator it =
630 accelerator_table_.begin(); it != accelerator_table_.end(); ++it) { 620 accelerator_table_.begin(); it != accelerator_table_.end(); ++it) {
631 if (it->second == cmd_id) { 621 if (it->second == cmd_id) {
632 *accelerator = it->first; 622 *accelerator = it->first;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 // If we do find there are cases where we need to restore the focus on show, 680 // If we do find there are cases where we need to restore the focus on show,
691 // that should be added and this should be removed. 681 // that should be added and this should be removed.
692 RestoreFocus(); 682 RestoreFocus();
693 683
694 frame_->Show(); 684 frame_->Show();
695 685
696 force_location_bar_focus_ = false; 686 force_location_bar_focus_ = false;
697 687
698 browser()->OnWindowDidShow(); 688 browser()->OnWindowDidShow();
699 689
700 chrome::MaybeShowInvertBubbleView(browser_.get(), contents_); 690 chrome::MaybeShowInvertBubbleView(browser_.get(), contents_container_);
701 } 691 }
702 692
703 void BrowserView::ShowInactive() { 693 void BrowserView::ShowInactive() {
704 if (frame_->IsVisible()) 694 if (frame_->IsVisible())
705 return; 695 return;
706 CreateLauncherIcon(); 696 CreateLauncherIcon();
707 frame_->ShowInactive(); 697 frame_->ShowInactive();
708 } 698 }
709 699
710 void BrowserView::Hide() { 700 void BrowserView::Hide() {
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 // reentrancy; |call_state| tracks whether we're reentrant. We can't just 927 // reentrancy; |call_state| tracks whether we're reentrant. We can't just
938 // early-return in this case because we need to layout again so the infobar 928 // early-return in this case because we need to layout again so the infobar
939 // container's bounds are set correctly. 929 // container's bounds are set correctly.
940 static CallState call_state = NORMAL; 930 static CallState call_state = NORMAL;
941 931
942 // A reentrant call can (and should) use the fast resize path unless both it 932 // A reentrant call can (and should) use the fast resize path unless both it
943 // and the normal call are both non-animating. 933 // and the normal call are both non-animating.
944 bool use_fast_resize = 934 bool use_fast_resize =
945 is_animating || (call_state == REENTRANT_FORCE_FAST_RESIZE); 935 is_animating || (call_state == REENTRANT_FORCE_FAST_RESIZE);
946 if (use_fast_resize) 936 if (use_fast_resize)
947 contents_container_->SetFastResize(true); 937 contents_web_view_->SetFastResize(true);
948 UpdateUIForContents(GetActiveWebContents()); 938 UpdateUIForContents(GetActiveWebContents());
949 if (use_fast_resize) 939 if (use_fast_resize)
950 contents_container_->SetFastResize(false); 940 contents_web_view_->SetFastResize(false);
951 941
952 // Inform the InfoBarContainer that the distance to the location icon may have 942 // Inform the InfoBarContainer that the distance to the location icon may have
953 // changed. We have to do this after the block above so that the toolbars are 943 // changed. We have to do this after the block above so that the toolbars are
954 // laid out correctly for calculating the maximum arrow height below. 944 // laid out correctly for calculating the maximum arrow height below.
955 { 945 {
956 int top_arrow_height = 0; 946 int top_arrow_height = 0;
957 // Hide the arrows on the Instant Extended NTP. 947 // Hide the arrows on the Instant Extended NTP.
958 if (!chrome::IsInstantExtendedAPIEnabled() || 948 if (!chrome::IsInstantExtendedAPIEnabled() ||
959 !browser()->search_model()->mode().is_ntp()) { 949 !browser()->search_model()->mode().is_ntp()) {
960 const LocationIconView* location_icon_view = 950 const LocationIconView* location_icon_view =
(...skipping 11 matching lines...) Expand all
972 infobar_container_->SetMaxTopArrowHeight(top_arrow_height); 962 infobar_container_->SetMaxTopArrowHeight(top_arrow_height);
973 } 963 }
974 964
975 // When transitioning from animating to not animating we need to make sure the 965 // When transitioning from animating to not animating we need to make sure the
976 // contents_container_ gets layed out. If we don't do this and the bounds 966 // contents_container_ gets layed out. If we don't do this and the bounds
977 // haven't changed contents_container_ won't get a Layout out and we'll end up 967 // haven't changed contents_container_ won't get a Layout out and we'll end up
978 // with a gray rect because the clip wasn't updated. Note that a reentrant 968 // with a gray rect because the clip wasn't updated. Note that a reentrant
979 // call never needs to do this, because after it returns, the normal call 969 // call never needs to do this, because after it returns, the normal call
980 // wrapping it will do it. 970 // wrapping it will do it.
981 if ((call_state == NORMAL) && !is_animating) { 971 if ((call_state == NORMAL) && !is_animating) {
982 contents_container_->InvalidateLayout(); 972 contents_web_view_->InvalidateLayout();
983 contents_split_->Layout(); 973 contents_split_->Layout();
984 } 974 }
985 } 975 }
986 976
987 void BrowserView::MaybeStackImmersiveRevealAtTop() { 977 void BrowserView::MaybeStackImmersiveRevealAtTop() {
988 immersive_mode_controller_->MaybeStackViewAtTop(); 978 immersive_mode_controller_->MaybeStackViewAtTop();
989 } 979 }
990 980
991 LocationBar* BrowserView::GetLocationBar() const { 981 LocationBar* BrowserView::GetLocationBar() const {
992 return GetLocationBarView(); 982 return GetLocationBarView();
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 void BrowserView::UserChangedTheme() { 1279 void BrowserView::UserChangedTheme() {
1290 frame_->FrameTypeChanged(); 1280 frame_->FrameTypeChanged();
1291 } 1281 }
1292 1282
1293 int BrowserView::GetExtraRenderViewHeight() const { 1283 int BrowserView::GetExtraRenderViewHeight() const {
1294 // Currently this is only used on linux. 1284 // Currently this is only used on linux.
1295 return 0; 1285 return 0;
1296 } 1286 }
1297 1287
1298 void BrowserView::WebContentsFocused(WebContents* contents) { 1288 void BrowserView::WebContentsFocused(WebContents* contents) {
1299 if (contents_container_->GetWebContents() == contents) 1289 if (contents_web_view_->GetWebContents() == contents)
1300 contents_container_->OnWebContentsFocused(contents); 1290 contents_web_view_->OnWebContentsFocused(contents);
1301 else if (contents_->overlay_web_contents() == contents) 1291 else if (contents_container_->overlay_web_contents() == contents)
1302 overlay_controller_->overlay()->OnWebContentsFocused(contents); 1292 overlay_controller_->overlay()->OnWebContentsFocused(contents);
1303 else 1293 else
1304 devtools_container_->OnWebContentsFocused(contents); 1294 devtools_container_->OnWebContentsFocused(contents);
1305 } 1295 }
1306 1296
1307 void BrowserView::ShowWebsiteSettings(Profile* profile, 1297 void BrowserView::ShowWebsiteSettings(Profile* profile,
1308 content::WebContents* web_contents, 1298 content::WebContents* web_contents,
1309 const GURL& url, 1299 const GURL& url,
1310 const content::SSLStatus& ssl, 1300 const content::SSLStatus& ssl,
1311 bool show_history) { 1301 bool show_history) {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1435 1425
1436 void BrowserView::Paste() { 1426 void BrowserView::Paste() {
1437 DoCutCopyPaste(&content::RenderWidgetHost::Paste, 1427 DoCutCopyPaste(&content::RenderWidgetHost::Paste,
1438 #if defined(OS_WIN) 1428 #if defined(OS_WIN)
1439 WM_PASTE, 1429 WM_PASTE,
1440 #endif 1430 #endif
1441 IDS_APP_PASTE); 1431 IDS_APP_PASTE);
1442 } 1432 }
1443 1433
1444 gfx::Rect BrowserView::GetInstantBounds() { 1434 gfx::Rect BrowserView::GetInstantBounds() {
1445 return contents_->GetOverlayBounds(); 1435 return contents_container_->GetOverlayBounds();
1446 } 1436 }
1447 1437
1448 WindowOpenDisposition BrowserView::GetDispositionForPopupBounds( 1438 WindowOpenDisposition BrowserView::GetDispositionForPopupBounds(
1449 const gfx::Rect& bounds) { 1439 const gfx::Rect& bounds) {
1450 #if defined(OS_WIN) 1440 #if defined(OS_WIN)
1451 // If we are in Win8's single window Metro mode, we can't allow popup windows. 1441 // If we are in Win8's single window Metro mode, we can't allow popup windows.
1452 return win8::IsSingleWindowMetroMode() ? NEW_BACKGROUND_TAB : NEW_POPUP; 1442 return win8::IsSingleWindowMetroMode() ? NEW_BACKGROUND_TAB : NEW_POPUP;
1453 #else 1443 #else
1454 return NEW_POPUP; 1444 return NEW_POPUP;
1455 #endif 1445 #endif
(...skipping 12 matching lines...) Expand all
1468 1458
1469 BookmarkBarView* BrowserView::GetBookmarkBarView() const { 1459 BookmarkBarView* BrowserView::GetBookmarkBarView() const {
1470 return bookmark_bar_view_.get(); 1460 return bookmark_bar_view_.get();
1471 } 1461 }
1472 1462
1473 LocationBarView* BrowserView::GetLocationBarView() const { 1463 LocationBarView* BrowserView::GetLocationBarView() const {
1474 return toolbar_ ? toolbar_->location_bar() : NULL; 1464 return toolbar_ ? toolbar_->location_bar() : NULL;
1475 } 1465 }
1476 1466
1477 views::View* BrowserView::GetTabContentsContainerView() const { 1467 views::View* BrowserView::GetTabContentsContainerView() const {
1478 return contents_container_; 1468 return contents_web_view_;
1479 } 1469 }
1480 1470
1481 ToolbarView* BrowserView::GetToolbarView() const { 1471 ToolbarView* BrowserView::GetToolbarView() const {
1482 return toolbar_; 1472 return toolbar_;
1483 } 1473 }
1484 1474
1485 /////////////////////////////////////////////////////////////////////////////// 1475 ///////////////////////////////////////////////////////////////////////////////
1486 // BrowserView, TabStripModelObserver implementation: 1476 // BrowserView, TabStripModelObserver implementation:
1487 1477
1488 void BrowserView::TabDetachedAt(WebContents* contents, int index) { 1478 void BrowserView::TabDetachedAt(WebContents* contents, int index) {
1489 // We use index here rather than comparing |contents| because by this time 1479 // We use index here rather than comparing |contents| because by this time
1490 // the model has already removed |contents| from its list, so 1480 // the model has already removed |contents| from its list, so
1491 // browser_->GetActiveWebContents() will return NULL or something else. 1481 // browser_->GetActiveWebContents() will return NULL or something else.
1492 if (index == browser_->tab_strip_model()->active_index()) { 1482 if (index == browser_->tab_strip_model()->active_index()) {
1493 // We need to reset the current tab contents to NULL before it gets 1483 // We need to reset the current tab contents to NULL before it gets
1494 // freed. This is because the focus manager performs some operations 1484 // freed. This is because the focus manager performs some operations
1495 // on the selected WebContents when it is removed. 1485 // on the selected WebContents when it is removed.
1496 contents_container_->SetWebContents(NULL); 1486 contents_web_view_->SetWebContents(NULL);
1497 infobar_container_->ChangeInfoBarService(NULL); 1487 infobar_container_->ChangeInfoBarService(NULL);
1498 UpdateDevToolsForContents(NULL); 1488 UpdateDevToolsForContents(NULL);
1499 } 1489 }
1500 } 1490 }
1501 1491
1502 void BrowserView::TabDeactivated(WebContents* contents) { 1492 void BrowserView::TabDeactivated(WebContents* contents) {
1503 // We do not store the focus when closing the tab to work-around bug 4633. 1493 // We do not store the focus when closing the tab to work-around bug 4633.
1504 // Some reports seem to show that the focus manager and/or focused view can 1494 // Some reports seem to show that the focus manager and/or focused view can
1505 // be garbage at that point, it is not clear why. 1495 // be garbage at that point, it is not clear why.
1506 if (!contents->IsBeingDestroyed()) 1496 if (!contents->IsBeingDestroyed())
1507 contents->GetView()->StoreFocus(); 1497 contents->GetView()->StoreFocus();
1508 } 1498 }
1509 1499
1510 void BrowserView::ActiveTabChanged(content::WebContents* old_contents, 1500 void BrowserView::ActiveTabChanged(content::WebContents* old_contents,
1511 content::WebContents* new_contents, 1501 content::WebContents* new_contents,
1512 int index, 1502 int index,
1513 int reason) { 1503 int reason) {
1514 DCHECK(new_contents); 1504 DCHECK(new_contents);
1515 1505
1516 // See if the Instant overlay is being activated (committed). 1506 // See if the Instant overlay is being activated (committed).
1517 if (contents_->overlay_web_contents() == new_contents) { 1507 if (contents_container_->overlay_web_contents() == new_contents) {
1518 contents_->MakeOverlayContentsActiveContents(); 1508 contents_container_->MakeOverlayContentsActiveContents();
1519 views::WebView* old_container = contents_container_; 1509 views::WebView* old_container = contents_web_view_;
1520 contents_container_ = overlay_controller_->release_overlay(); 1510 contents_web_view_ = overlay_controller_->release_overlay();
1521 old_container->SetWebContents(NULL); 1511 old_container->SetWebContents(NULL);
1522 delete old_container; 1512 delete old_container;
1523 } 1513 }
1524 1514
1525 // If |contents_container_| already has the correct WebContents, we can save 1515 // If |contents_container_| already has the correct WebContents, we can save
1526 // some work. This also prevents extra events from being reported by the 1516 // some work. This also prevents extra events from being reported by the
1527 // Visibility API under Windows, as ChangeWebContents will briefly hide 1517 // Visibility API under Windows, as ChangeWebContents will briefly hide
1528 // the WebContents window. 1518 // the WebContents window.
1529 bool change_tab_contents = 1519 bool change_tab_contents =
1530 contents_container_->web_contents() != new_contents; 1520 contents_web_view_->web_contents() != new_contents;
1531 1521
1532 // Update various elements that are interested in knowing the current 1522 // Update various elements that are interested in knowing the current
1533 // WebContents. 1523 // WebContents.
1534 1524
1535 // When we toggle the NTP floating bookmarks bar and/or the info bar, 1525 // When we toggle the NTP floating bookmarks bar and/or the info bar,
1536 // we don't want any WebContents to be attached, so that we 1526 // we don't want any WebContents to be attached, so that we
1537 // avoid an unnecessary resize and re-layout of a WebContents. 1527 // avoid an unnecessary resize and re-layout of a WebContents.
1538 if (change_tab_contents) 1528 if (change_tab_contents)
1539 contents_container_->SetWebContents(NULL); 1529 contents_web_view_->SetWebContents(NULL);
1540 infobar_container_->ChangeInfoBarService( 1530 infobar_container_->ChangeInfoBarService(
1541 InfoBarService::FromWebContents(new_contents)); 1531 InfoBarService::FromWebContents(new_contents));
1542 if (bookmark_bar_view_.get()) { 1532 if (bookmark_bar_view_.get()) {
1543 bookmark_bar_view_->SetBookmarkBarState( 1533 bookmark_bar_view_->SetBookmarkBarState(
1544 browser_->bookmark_bar_state(), 1534 browser_->bookmark_bar_state(),
1545 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); 1535 BookmarkBar::DONT_ANIMATE_STATE_CHANGE);
1546 } 1536 }
1547 UpdateUIForContents(new_contents); 1537 UpdateUIForContents(new_contents);
1548 1538
1549 // Layout for DevTools _before_ setting the main WebContents to avoid 1539 // Layout for DevTools _before_ setting the main WebContents to avoid
1550 // toggling the size of the main WebContents. 1540 // toggling the size of the main WebContents.
1551 UpdateDevToolsForContents(new_contents); 1541 UpdateDevToolsForContents(new_contents);
1552 1542
1553 if (change_tab_contents) { 1543 if (change_tab_contents) {
1554 contents_container_->SetWebContents(new_contents); 1544 contents_web_view_->SetWebContents(new_contents);
1555 contents_->MaybeStackOverlayAtTop(); 1545 contents_container_->MaybeStackOverlayAtTop();
1556 } 1546 }
1557 1547
1558 if (!browser_->tab_strip_model()->closing_all() && GetWidget()->IsActive() && 1548 if (!browser_->tab_strip_model()->closing_all() && GetWidget()->IsActive() &&
1559 GetWidget()->IsVisible()) { 1549 GetWidget()->IsVisible()) {
1560 // We only restore focus if our window is visible, to avoid invoking blur 1550 // We only restore focus if our window is visible, to avoid invoking blur
1561 // handlers when we are eventually shown. 1551 // handlers when we are eventually shown.
1562 new_contents->GetView()->RestoreFocus(); 1552 new_contents->GetView()->RestoreFocus();
1563 } 1553 }
1564 1554
1565 // Update all the UI bits. 1555 // Update all the UI bits.
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1773 } 1763 }
1774 1764
1775 // We return true because we can _always_ locate reasonable bounds using the 1765 // We return true because we can _always_ locate reasonable bounds using the
1776 // WindowSizer, and we don't want to trigger the Window's built-in "size to 1766 // WindowSizer, and we don't want to trigger the Window's built-in "size to
1777 // default" handling because the browser window has no default preferred 1767 // default" handling because the browser window has no default preferred
1778 // size. 1768 // size.
1779 return true; 1769 return true;
1780 } 1770 }
1781 1771
1782 views::View* BrowserView::GetContentsView() { 1772 views::View* BrowserView::GetContentsView() {
1783 return contents_container_; 1773 return contents_web_view_;
1784 } 1774 }
1785 1775
1786 views::ClientView* BrowserView::CreateClientView(views::Widget* widget) { 1776 views::ClientView* BrowserView::CreateClientView(views::Widget* widget) {
1787 return this; 1777 return this;
1788 } 1778 }
1789 1779
1790 void BrowserView::OnWidgetActivationChanged(views::Widget* widget, 1780 void BrowserView::OnWidgetActivationChanged(views::Widget* widget,
1791 bool active) { 1781 bool active) {
1792 #if defined(USE_ASH) 1782 #if defined(USE_ASH)
1793 if (launcher_item_controller_.get()) 1783 if (launcher_item_controller_.get())
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1940 1930
1941 void BrowserView::ChildPreferredSizeChanged(View* child) { 1931 void BrowserView::ChildPreferredSizeChanged(View* child) {
1942 Layout(); 1932 Layout();
1943 } 1933 }
1944 1934
1945 void BrowserView::GetAccessibleState(ui::AccessibleViewState* state) { 1935 void BrowserView::GetAccessibleState(ui::AccessibleViewState* state) {
1946 state->role = ui::AccessibilityTypes::ROLE_CLIENT; 1936 state->role = ui::AccessibilityTypes::ROLE_CLIENT;
1947 } 1937 }
1948 1938
1949 /////////////////////////////////////////////////////////////////////////////// 1939 ///////////////////////////////////////////////////////////////////////////////
1950 // BrowserView, protected 1940 // BrowserView, ui::AcceleratorTarget overrides:
1941
1942 bool BrowserView::AcceleratorPressed(const ui::Accelerator& accelerator) {
1943 #if defined(OS_CHROMEOS)
1944 // If accessibility is enabled, stop speech and return false so that key
1945 // combinations involving Search can be used for extra accessibility
1946 // functionality.
1947 if (accelerator.key_code() == ui::VKEY_LWIN &&
1948 g_browser_process->local_state()->GetBoolean(
1949 prefs::kSpokenFeedbackEnabled)) {
1950 TtsController::GetInstance()->Stop();
1951 return false;
1952 }
1953 #endif
1954
1955 std::map<ui::Accelerator, int>::const_iterator iter =
1956 accelerator_table_.find(accelerator);
1957 DCHECK(iter != accelerator_table_.end());
1958 int command_id = iter->second;
1959
1960 chrome::BrowserCommandController* controller = browser_->command_controller();
1961 if (!controller->block_command_execution())
1962 UpdateAcceleratorMetrics(accelerator, command_id);
1963 return chrome::ExecuteCommand(browser_.get(), command_id);
1964 }
1965
1966 ///////////////////////////////////////////////////////////////////////////////
1967 // BrowserView, private
1951 1968
1952 void BrowserView::GetAccessiblePanes( 1969 void BrowserView::GetAccessiblePanes(
1953 std::vector<views::AccessiblePaneView*>* panes) { 1970 std::vector<views::AccessiblePaneView*>* panes) {
1954 // This should be in the order of pane traversal of the panes using F6. 1971 // This should be in the order of pane traversal of the panes using F6.
1955 // If one of these is invisible or has no focusable children, it will be 1972 // If one of these is invisible or has no focusable children, it will be
1956 // automatically skipped. 1973 // automatically skipped.
1957 panes->push_back(toolbar_); 1974 panes->push_back(toolbar_);
1958 if (bookmark_bar_view_.get()) 1975 if (bookmark_bar_view_.get())
1959 panes->push_back(bookmark_bar_view_.get()); 1976 panes->push_back(bookmark_bar_view_.get());
1960 if (infobar_container_) 1977 if (infobar_container_)
(...skipping 27 matching lines...) Expand all
1988 2005
1989 bool BrowserView::SplitHandleMoved(views::SingleSplitView* sender) { 2006 bool BrowserView::SplitHandleMoved(views::SingleSplitView* sender) {
1990 for (int i = 0; i < sender->child_count(); ++i) 2007 for (int i = 0; i < sender->child_count(); ++i)
1991 sender->child_at(i)->InvalidateLayout(); 2008 sender->child_at(i)->InvalidateLayout();
1992 SchedulePaint(); 2009 SchedulePaint();
1993 Layout(); 2010 Layout();
1994 return false; 2011 return false;
1995 } 2012 }
1996 2013
1997 void BrowserView::OnSysColorChange() { 2014 void BrowserView::OnSysColorChange() {
1998 chrome::MaybeShowInvertBubbleView(browser_.get(), contents_); 2015 chrome::MaybeShowInvertBubbleView(browser_.get(), contents_container_);
1999 }
2000
2001 int BrowserView::GetOTRIconResourceID() const {
2002 int otr_resource_id = IDR_OTR_ICON;
2003 if (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) {
2004 if (IsFullscreen())
2005 otr_resource_id = IDR_OTR_ICON_FULLSCREEN;
2006 #if defined(OS_WIN)
2007 if (win8::IsSingleWindowMetroMode())
2008 otr_resource_id = IDR_OTR_ICON_FULLSCREEN;
2009 #endif
2010 }
2011
2012 return otr_resource_id;
2013 } 2016 }
2014 2017
2015 void BrowserView::Init() { 2018 void BrowserView::Init() {
2016 GetWidget()->AddObserver(this); 2019 GetWidget()->AddObserver(this);
2017 2020
2018 SetLayoutManager(new BrowserViewLayout); 2021 SetLayoutManager(new BrowserViewLayout);
2019 // Stow a pointer to this object onto the window handle so that we can get at 2022 // Stow a pointer to this object onto the window handle so that we can get at
2020 // it later when all we have is a native view. 2023 // it later when all we have is a native view.
2021 GetWidget()->SetNativeWindowProperty(kBrowserViewKey, this); 2024 GetWidget()->SetNativeWindowProperty(kBrowserViewKey, this);
2022 2025
(...skipping 11 matching lines...) Expand all
2034 switches::kDisableHangMonitor)) { 2037 switches::kDisableHangMonitor)) {
2035 InitHangMonitor(); 2038 InitHangMonitor();
2036 } 2039 }
2037 2040
2038 LoadAccelerators(); 2041 LoadAccelerators();
2039 2042
2040 infobar_container_ = new InfoBarContainerView(this, 2043 infobar_container_ = new InfoBarContainerView(this,
2041 browser()->search_model()); 2044 browser()->search_model());
2042 AddChildView(infobar_container_); 2045 AddChildView(infobar_container_);
2043 2046
2044 contents_container_ = new views::WebView(browser_->profile()); 2047 contents_web_view_ = new views::WebView(browser_->profile());
2045 contents_container_->set_id(VIEW_ID_TAB_CONTAINER); 2048 contents_web_view_->set_id(VIEW_ID_TAB_CONTAINER);
2046 contents_ = new ContentsContainer(contents_container_, this); 2049 contents_container_ = new ContentsContainer(contents_web_view_, this);
2047 2050
2048 overlay_controller_.reset( 2051 overlay_controller_.reset(
2049 new InstantOverlayControllerViews(browser(), contents_)); 2052 new InstantOverlayControllerViews(browser(), contents_container_));
2050 2053
2051 SkColor bg_color = GetWidget()->GetThemeProvider()-> 2054 SkColor bg_color = GetWidget()->GetThemeProvider()->
2052 GetColor(ThemeProperties::COLOR_TOOLBAR); 2055 GetColor(ThemeProperties::COLOR_TOOLBAR);
2053 2056
2054 devtools_container_ = new views::WebView(browser_->profile()); 2057 devtools_container_ = new views::WebView(browser_->profile());
2055 devtools_container_->set_id(VIEW_ID_DEV_TOOLS_DOCKED); 2058 devtools_container_->set_id(VIEW_ID_DEV_TOOLS_DOCKED);
2056 devtools_container_->SetVisible(false); 2059 devtools_container_->SetVisible(false);
2057 2060
2058 views::View* contents_view = contents_; 2061 views::View* contents_container_view = contents_container_;
2059 2062
2060 contents_split_ = new views::SingleSplitView( 2063 contents_split_ = new views::SingleSplitView(
2061 contents_view, 2064 contents_container_view,
2062 devtools_container_, 2065 devtools_container_,
2063 views::SingleSplitView::VERTICAL_SPLIT, 2066 views::SingleSplitView::VERTICAL_SPLIT,
2064 this); 2067 this);
2065 contents_split_->set_id(VIEW_ID_CONTENTS_SPLIT); 2068 contents_split_->set_id(VIEW_ID_CONTENTS_SPLIT);
2066 contents_split_->SetAccessibleName( 2069 contents_split_->SetAccessibleName(
2067 l10n_util::GetStringUTF16(IDS_ACCNAME_WEB_CONTENTS)); 2070 l10n_util::GetStringUTF16(IDS_ACCNAME_WEB_CONTENTS));
2068 contents_split_->set_background( 2071 contents_split_->set_background(
2069 views::Background::CreateSolidBackground(bg_color)); 2072 views::Background::CreateSolidBackground(bg_color));
2070 AddChildView(contents_split_); 2073 AddChildView(contents_split_);
2071 set_contents_view(contents_split_); 2074 set_contents_view(contents_split_);
2072 2075
2073 status_bubble_.reset(new StatusBubbleViews(contents_)); 2076 status_bubble_.reset(new StatusBubbleViews(contents_container_));
2074 2077
2075 // Top container holds tab strip and toolbar and lives at the front of the 2078 // Top container holds tab strip and toolbar and lives at the front of the
2076 // view hierarchy. 2079 // view hierarchy.
2077 top_container_ = new TopContainerView(this); 2080 top_container_ = new TopContainerView(this);
2078 AddChildView(top_container_); 2081 AddChildView(top_container_);
2079 2082
2080 // TabStrip takes ownership of the controller. 2083 // TabStrip takes ownership of the controller.
2081 BrowserTabStripController* tabstrip_controller = 2084 BrowserTabStripController* tabstrip_controller =
2082 new BrowserTabStripController(browser_.get(), 2085 new BrowserTabStripController(browser_.get(),
2083 browser_->tab_strip_model()); 2086 browser_->tab_strip_model());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2128 } 2131 }
2129 2132
2130 void BrowserView::OnLoadCompleted() { 2133 void BrowserView::OnLoadCompleted() {
2131 #if defined(OS_WIN) && !defined(USE_AURA) 2134 #if defined(OS_WIN) && !defined(USE_AURA)
2132 DCHECK(!jumplist_); 2135 DCHECK(!jumplist_);
2133 jumplist_ = new JumpList(); 2136 jumplist_ = new JumpList();
2134 jumplist_->AddObserver(browser_->profile()); 2137 jumplist_->AddObserver(browser_->profile());
2135 #endif 2138 #endif
2136 } 2139 }
2137 2140
2138 // BrowserView, private --------------------------------------------------------
2139
2140 BrowserViewLayout* BrowserView::GetBrowserViewLayout() const { 2141 BrowserViewLayout* BrowserView::GetBrowserViewLayout() const {
2141 return static_cast<BrowserViewLayout*>(GetLayoutManager()); 2142 return static_cast<BrowserViewLayout*>(GetLayoutManager());
2142 } 2143 }
2143 2144
2144 void BrowserView::LayoutStatusBubble() { 2145 void BrowserView::LayoutStatusBubble() {
2145 // In restored mode, the client area has a client edge between it and the 2146 // In restored mode, the client area has a client edge between it and the
2146 // frame. 2147 // frame.
2147 int overlap = StatusBubbleViews::kShadowThickness; 2148 int overlap = StatusBubbleViews::kShadowThickness;
2148 // The extra pixels defined by kClientEdgeThickness is only drawn in frame 2149 // The extra pixels defined by kClientEdgeThickness is only drawn in frame
2149 // content border on windows for non-aura build. 2150 // content border on windows for non-aura build.
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
2727 2728
2728 Browser* modal_browser = 2729 Browser* modal_browser =
2729 chrome::FindBrowserWithWebContents(active_dialog->web_contents()); 2730 chrome::FindBrowserWithWebContents(active_dialog->web_contents());
2730 if (modal_browser && (browser_ != modal_browser)) { 2731 if (modal_browser && (browser_ != modal_browser)) {
2731 modal_browser->window()->FlashFrame(true); 2732 modal_browser->window()->FlashFrame(true);
2732 modal_browser->window()->Activate(); 2733 modal_browser->window()->Activate();
2733 } 2734 }
2734 2735
2735 AppModalDialogQueue::GetInstance()->ActivateModalDialog(); 2736 AppModalDialogQueue::GetInstance()->ActivateModalDialog();
2736 } 2737 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.h ('k') | chrome/browser/ui/views/frame/browser_view_layout.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698