| 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 #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 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 } | 565 } |
| 566 | 566 |
| 567 bool BrowserView::IsPositionInWindowCaption(const gfx::Point& point) { | 567 bool BrowserView::IsPositionInWindowCaption(const gfx::Point& point) { |
| 568 return GetBrowserViewLayout()->IsPositionInWindowCaption(point); | 568 return GetBrowserViewLayout()->IsPositionInWindowCaption(point); |
| 569 } | 569 } |
| 570 | 570 |
| 571 /////////////////////////////////////////////////////////////////////////////// | 571 /////////////////////////////////////////////////////////////////////////////// |
| 572 // BrowserView, BrowserWindow implementation: | 572 // BrowserView, BrowserWindow implementation: |
| 573 | 573 |
| 574 void BrowserView::Show() { | 574 void BrowserView::Show() { |
| 575 // The same fix as in BrowserWindowGtk::Show. | |
| 576 // | |
| 577 // The Browser must become the active browser when Show() is called. | |
| 578 // But, on Gtk, the browser won't be shown until we return to the runloop. | |
| 579 // Therefore we need to set the active window here explicitly. otherwise | |
| 580 // any calls to BrowserList::GetLastActive() (for example, in bookmark_util), | |
| 581 // will return the previous browser. | |
| 582 BrowserList::SetLastActive(browser()); | |
| 583 | |
| 584 // If the window is already visible, just activate it. | 575 // If the window is already visible, just activate it. |
| 585 if (frame_->IsVisible()) { | 576 if (frame_->IsVisible()) { |
| 586 frame_->Activate(); | 577 frame_->Activate(); |
| 587 return; | 578 return; |
| 588 } | 579 } |
| 589 | 580 |
| 590 CreateLauncherIcon(); | 581 CreateLauncherIcon(); |
| 591 | 582 |
| 592 // Showing the window doesn't make the browser window active right away. | 583 // Showing the window doesn't make the browser window active right away. |
| 593 // This can cause SetFocusToLocationBar() to skip setting focus to the | 584 // This can cause SetFocusToLocationBar() to skip setting focus to the |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 | 792 |
| 802 void BrowserView::Restore() { | 793 void BrowserView::Restore() { |
| 803 frame_->Restore(); | 794 frame_->Restore(); |
| 804 } | 795 } |
| 805 | 796 |
| 806 void BrowserView::EnterFullscreen( | 797 void BrowserView::EnterFullscreen( |
| 807 const GURL& url, FullscreenExitBubbleType bubble_type) { | 798 const GURL& url, FullscreenExitBubbleType bubble_type) { |
| 808 if (IsFullscreen()) | 799 if (IsFullscreen()) |
| 809 return; // Nothing to do. | 800 return; // Nothing to do. |
| 810 | 801 |
| 811 #if defined(OS_WIN) || defined(USE_AURA) | |
| 812 ProcessFullscreen(true, url, bubble_type); | 802 ProcessFullscreen(true, url, bubble_type); |
| 813 #else | |
| 814 // On Linux/gtk changing fullscreen is async. Ask the window to change it's | |
| 815 // fullscreen state, and when done invoke ProcessFullscreen. | |
| 816 fullscreen_request_.pending = true; | |
| 817 fullscreen_request_.url = url; | |
| 818 fullscreen_request_.bubble_type = bubble_type; | |
| 819 frame_->SetFullscreen(true); | |
| 820 #endif | |
| 821 } | 803 } |
| 822 | 804 |
| 823 void BrowserView::ExitFullscreen() { | 805 void BrowserView::ExitFullscreen() { |
| 824 if (!IsFullscreen()) | 806 if (!IsFullscreen()) |
| 825 return; // Nothing to do. | 807 return; // Nothing to do. |
| 826 | 808 |
| 827 #if defined(OS_WIN) || defined(USE_AURA) | |
| 828 ProcessFullscreen(false, GURL(), FEB_TYPE_NONE); | 809 ProcessFullscreen(false, GURL(), FEB_TYPE_NONE); |
| 829 #else | |
| 830 fullscreen_request_.pending = false; | |
| 831 // On Linux changing fullscreen is async. Ask the window to change it's | |
| 832 // fullscreen state, and when done invoke ProcessFullscreen. | |
| 833 frame_->SetFullscreen(false); | |
| 834 #endif | |
| 835 } | 810 } |
| 836 | 811 |
| 837 void BrowserView::UpdateFullscreenExitBubbleContent( | 812 void BrowserView::UpdateFullscreenExitBubbleContent( |
| 838 const GURL& url, | 813 const GURL& url, |
| 839 FullscreenExitBubbleType bubble_type) { | 814 FullscreenExitBubbleType bubble_type) { |
| 840 if (fullscreen_bubble_.get()) | 815 if (fullscreen_bubble_.get()) |
| 841 fullscreen_bubble_->UpdateContent(url, bubble_type); | 816 fullscreen_bubble_->UpdateContent(url, bubble_type); |
| 842 } | 817 } |
| 843 | 818 |
| 844 bool BrowserView::IsFullscreen() const { | 819 bool BrowserView::IsFullscreen() const { |
| (...skipping 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2172 omnibox_view->set_force_hidden(true); | 2147 omnibox_view->set_force_hidden(true); |
| 2173 ShowWindow(omnibox_view->m_hWnd, SW_HIDE); | 2148 ShowWindow(omnibox_view->m_hWnd, SW_HIDE); |
| 2174 #endif | 2149 #endif |
| 2175 } | 2150 } |
| 2176 #if defined(OS_WIN) && !defined(USE_AURA) | 2151 #if defined(OS_WIN) && !defined(USE_AURA) |
| 2177 static_cast<views::NativeWidgetWin*>(frame_->native_widget())-> | 2152 static_cast<views::NativeWidgetWin*>(frame_->native_widget())-> |
| 2178 PushForceHidden(); | 2153 PushForceHidden(); |
| 2179 #endif | 2154 #endif |
| 2180 | 2155 |
| 2181 // Toggle fullscreen mode. | 2156 // Toggle fullscreen mode. |
| 2182 #if defined(OS_WIN) || defined(USE_AURA) | |
| 2183 frame_->SetFullscreen(fullscreen); | 2157 frame_->SetFullscreen(fullscreen); |
| 2184 #endif // No need to invoke SetFullscreen for linux/gtk as this code | |
| 2185 // is executed once we're already fullscreen on linux. | |
| 2186 | 2158 |
| 2187 browser_->WindowFullscreenStateChanged(); | 2159 browser_->WindowFullscreenStateChanged(); |
| 2188 | 2160 |
| 2189 if (fullscreen) { | 2161 if (fullscreen) { |
| 2190 bool is_kiosk = | 2162 bool is_kiosk = |
| 2191 CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); | 2163 CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); |
| 2192 if (!is_kiosk) { | 2164 if (!is_kiosk) { |
| 2193 fullscreen_bubble_.reset(new FullscreenExitBubbleViews( | 2165 fullscreen_bubble_.reset(new FullscreenExitBubbleViews( |
| 2194 GetWidget(), browser_.get(), url, bubble_type)); | 2166 GetWidget(), browser_.get(), url, bubble_type)); |
| 2195 } | 2167 } |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2499 return; | 2471 return; |
| 2500 | 2472 |
| 2501 PasswordGenerationBubbleView* bubble = | 2473 PasswordGenerationBubbleView* bubble = |
| 2502 new PasswordGenerationBubbleView(bounds, | 2474 new PasswordGenerationBubbleView(bounds, |
| 2503 this, | 2475 this, |
| 2504 web_contents->GetRenderViewHost()); | 2476 web_contents->GetRenderViewHost()); |
| 2505 browser::CreateViewsBubble(bubble); | 2477 browser::CreateViewsBubble(bubble); |
| 2506 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); | 2478 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); |
| 2507 bubble->Show(); | 2479 bubble->Show(); |
| 2508 } | 2480 } |
| OLD | NEW |