OLD | NEW |
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 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 /////////////////////////////////////////////////////////////////////////////// | 657 /////////////////////////////////////////////////////////////////////////////// |
658 // BrowserView, BrowserWindow implementation: | 658 // BrowserView, BrowserWindow implementation: |
659 | 659 |
660 void BrowserView::Show() { | 660 void BrowserView::Show() { |
661 #if !defined(OS_WIN) | 661 #if !defined(OS_WIN) |
662 // The Browser associated with this browser window must become the active | 662 // The Browser associated with this browser window must become the active |
663 // browser at the time |Show()| is called. This is the natural behavior under | 663 // browser at the time |Show()| is called. This is the natural behavior under |
664 // Windows and Ash, but other platforms will not trigger | 664 // Windows and Ash, but other platforms will not trigger |
665 // OnWidgetActivationChanged() until we return to the runloop. Therefore any | 665 // OnWidgetActivationChanged() until we return to the runloop. Therefore any |
666 // calls to Browser::GetLastActive() will return the wrong result if we do not | 666 // calls to Browser::GetLastActive() will return the wrong result if we do not |
667 // explicitly set it here. | 667 // explicitly set it here and in ShowForUserGesture(). |
668 // A similar block also appears in BrowserWindowCocoa::Show(). | 668 // A similar block also appears in BrowserWindowCocoa::Show(). |
669 if (browser()->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH) | 669 if (browser()->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH) |
670 BrowserList::SetLastActive(browser()); | 670 BrowserList::SetLastActive(browser()); |
671 #endif | 671 #endif |
672 | 672 |
673 // If the window is already visible, just activate it. | 673 // If the window is already visible, just activate it. |
674 if (frame_->IsVisible()) { | 674 if (frame_->IsVisible()) { |
675 frame_->Activate(); | 675 frame_->Activate(); |
676 return; | 676 return; |
677 } | 677 } |
(...skipping 18 matching lines...) Expand all Loading... |
696 | 696 |
697 frame_->Show(); | 697 frame_->Show(); |
698 | 698 |
699 force_location_bar_focus_ = false; | 699 force_location_bar_focus_ = false; |
700 | 700 |
701 browser()->OnWindowDidShow(); | 701 browser()->OnWindowDidShow(); |
702 | 702 |
703 chrome::MaybeShowInvertBubbleView(this); | 703 chrome::MaybeShowInvertBubbleView(this); |
704 } | 704 } |
705 | 705 |
| 706 void BrowserView::ShowForUserGesture() { |
| 707 if (!frame_->IsVisible()) { |
| 708 Show(); |
| 709 return; |
| 710 } |
| 711 |
| 712 #if !defined(OS_WIN) |
| 713 // See comment in Show(). |
| 714 if (browser()->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH) |
| 715 BrowserList::SetLastActive(browser()); |
| 716 #endif |
| 717 |
| 718 // Since the window is already visible, just activate it. |
| 719 frame_->ActivateForUserGesture(); |
| 720 } |
| 721 |
706 void BrowserView::ShowInactive() { | 722 void BrowserView::ShowInactive() { |
707 if (!frame_->IsVisible()) | 723 if (!frame_->IsVisible()) |
708 frame_->ShowInactive(); | 724 frame_->ShowInactive(); |
709 } | 725 } |
710 | 726 |
711 void BrowserView::Hide() { | 727 void BrowserView::Hide() { |
712 // Not implemented. | 728 // Not implemented. |
713 } | 729 } |
714 | 730 |
715 void BrowserView::SetBounds(const gfx::Rect& bounds) { | 731 void BrowserView::SetBounds(const gfx::Rect& bounds) { |
716 ExitFullscreen(); | 732 ExitFullscreen(); |
717 GetWidget()->SetBounds(bounds); | 733 GetWidget()->SetBounds(bounds); |
718 } | 734 } |
719 | 735 |
720 void BrowserView::Close() { | 736 void BrowserView::Close() { |
721 frame_->Close(); | 737 frame_->Close(); |
722 } | 738 } |
723 | 739 |
724 void BrowserView::Activate() { | 740 void BrowserView::Activate() { |
725 frame_->Activate(); | 741 frame_->Activate(); |
726 } | 742 } |
727 | 743 |
| 744 void BrowserView::ActivateForUserGesture() { |
| 745 frame_->ActivateForUserGesture(); |
| 746 } |
| 747 |
728 void BrowserView::Deactivate() { | 748 void BrowserView::Deactivate() { |
729 frame_->Deactivate(); | 749 frame_->Deactivate(); |
730 } | 750 } |
731 | 751 |
732 bool BrowserView::IsActive() const { | 752 bool BrowserView::IsActive() const { |
733 return frame_->IsActive(); | 753 return frame_->IsActive(); |
734 } | 754 } |
735 | 755 |
736 void BrowserView::FlashFrame(bool flash) { | 756 void BrowserView::FlashFrame(bool flash) { |
737 frame_->FlashFrame(flash); | 757 frame_->FlashFrame(flash); |
(...skipping 1870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2608 return immersive_mode_controller()->IsEnabled(); | 2628 return immersive_mode_controller()->IsEnabled(); |
2609 } | 2629 } |
2610 | 2630 |
2611 views::Widget* BrowserView::GetBubbleAssociatedWidget() { | 2631 views::Widget* BrowserView::GetBubbleAssociatedWidget() { |
2612 return GetWidget(); | 2632 return GetWidget(); |
2613 } | 2633 } |
2614 | 2634 |
2615 gfx::Rect BrowserView::GetTopContainerBoundsInScreen() { | 2635 gfx::Rect BrowserView::GetTopContainerBoundsInScreen() { |
2616 return top_container_->GetBoundsInScreen(); | 2636 return top_container_->GetBoundsInScreen(); |
2617 } | 2637 } |
OLD | NEW |