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

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

Issue 2668413004: [Merge to M57] ChromeOS MD: Fix cannot drag tab onto immersive fullscreen window (Closed)
Patch Set: Created 3 years, 10 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 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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 #include "ui/views/controls/textfield/textfield.h" 144 #include "ui/views/controls/textfield/textfield.h"
145 #include "ui/views/controls/webview/webview.h" 145 #include "ui/views/controls/webview/webview.h"
146 #include "ui/views/focus/external_focus_tracker.h" 146 #include "ui/views/focus/external_focus_tracker.h"
147 #include "ui/views/focus/view_storage.h" 147 #include "ui/views/focus/view_storage.h"
148 #include "ui/views/layout/grid_layout.h" 148 #include "ui/views/layout/grid_layout.h"
149 #include "ui/views/widget/native_widget.h" 149 #include "ui/views/widget/native_widget.h"
150 #include "ui/views/widget/root_view.h" 150 #include "ui/views/widget/root_view.h"
151 #include "ui/views/widget/widget.h" 151 #include "ui/views/widget/widget.h"
152 #include "ui/views/window/dialog_delegate.h" 152 #include "ui/views/window/dialog_delegate.h"
153 153
154 #if defined(OS_CHROMEOS)
155 #include "chrome/browser/ui/ash/ash_util.h"
156 #endif // defined(OS_CHROMEOS)
157
154 #if !defined(OS_CHROMEOS) 158 #if !defined(OS_CHROMEOS)
155 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h" 159 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h"
156 #endif 160 #endif // !defined(OS_CHROMEOS)
157
158 #if defined(USE_ASH)
159 #include "chrome/browser/ui/ash/ash_util.h"
160 #endif
161 161
162 #if defined(USE_AURA) 162 #if defined(USE_AURA)
163 #include "ui/aura/client/window_parenting_client.h" 163 #include "ui/aura/client/window_parenting_client.h"
164 #include "ui/aura/window.h" 164 #include "ui/aura/window.h"
165 #include "ui/aura/window_tree_host.h" 165 #include "ui/aura/window_tree_host.h"
166 #endif 166 #endif
167 167
168 #if defined(OS_WIN) 168 #if defined(OS_WIN)
169 #include "base/win/windows_version.h" 169 #include "base/win/windows_version.h"
170 #include "chrome/browser/win/jumplist.h" 170 #include "chrome/browser/win/jumplist.h"
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 // The background image starts tiling horizontally at the window left edge and 519 // The background image starts tiling horizontally at the window left edge and
520 // vertically at the top edge of the horizontal tab strip (or where it would 520 // vertically at the top edge of the horizontal tab strip (or where it would
521 // be). We expect our parent's origin to be the window origin. 521 // be). We expect our parent's origin to be the window origin.
522 gfx::Point window_point(point + GetMirroredPosition().OffsetFromOrigin()); 522 gfx::Point window_point(point + GetMirroredPosition().OffsetFromOrigin());
523 window_point.Offset(frame_->GetThemeBackgroundXInset(), 523 window_point.Offset(frame_->GetThemeBackgroundXInset(),
524 -frame_->GetTopInset(false)); 524 -frame_->GetTopInset(false));
525 return window_point; 525 return window_point;
526 } 526 }
527 527
528 bool BrowserView::IsTabStripVisible() const { 528 bool BrowserView::IsTabStripVisible() const {
529 if (immersive_mode_controller_->ShouldHideTopViews() &&
530 immersive_mode_controller_->ShouldHideTabIndicators()) {
531 return false;
532 }
533
534 // Return false if this window does not normally display a tabstrip. 529 // Return false if this window does not normally display a tabstrip.
535 if (!browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP)) 530 if (!browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP))
536 return false; 531 return false;
537 532
538 // Return false if the tabstrip has not yet been created (by InitViews()), 533 // Return false if the tabstrip has not yet been created (by InitViews()),
539 // since callers may otherwise try to access it. Note that we can't just check 534 // since callers may otherwise try to access it. Note that we can't just check
540 // this alone, as the tabstrip is created unconditionally even for windows 535 // this alone, as the tabstrip is created unconditionally even for windows
541 // that won't display it. 536 // that won't display it.
542 return tabstrip_ != nullptr; 537 return tabstrip_ != nullptr;
543 } 538 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 } 581 }
587 582
588 WebContents* BrowserView::GetActiveWebContents() const { 583 WebContents* BrowserView::GetActiveWebContents() const {
589 return browser_->tab_strip_model()->GetActiveWebContents(); 584 return browser_->tab_strip_model()->GetActiveWebContents();
590 } 585 }
591 586
592 /////////////////////////////////////////////////////////////////////////////// 587 ///////////////////////////////////////////////////////////////////////////////
593 // BrowserView, BrowserWindow implementation: 588 // BrowserView, BrowserWindow implementation:
594 589
595 void BrowserView::Show() { 590 void BrowserView::Show() {
596 #if !defined(OS_WIN) && !defined(USE_ASH) 591 #if !defined(OS_WIN) && !defined(OS_CHROMEOS)
597 // The Browser associated with this browser window must become the active 592 // The Browser associated with this browser window must become the active
598 // browser at the time |Show()| is called. This is the natural behavior under 593 // browser at the time |Show()| is called. This is the natural behavior under
599 // Windows and Ash, but other platforms will not trigger 594 // Windows and Chrome OS, but other platforms will not trigger
600 // OnWidgetActivationChanged() until we return to the runloop. Therefore any 595 // OnWidgetActivationChanged() until we return to the runloop. Therefore any
601 // calls to Browser::GetLastActive() will return the wrong result if we do not 596 // calls to Browser::GetLastActive() will return the wrong result if we do not
602 // explicitly set it here. 597 // explicitly set it here.
603 // A similar block also appears in BrowserWindowCocoa::Show(). 598 // A similar block also appears in BrowserWindowCocoa::Show().
604 BrowserList::SetLastActive(browser()); 599 BrowserList::SetLastActive(browser());
605 #endif 600 #endif
606 601
607 // If the window is already visible, just activate it. 602 // If the window is already visible, just activate it.
608 if (frame_->IsVisible()) { 603 if (frame_->IsVisible()) {
609 frame_->Activate(); 604 frame_->Activate();
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 void BrowserView::FullscreenStateChanged() { 980 void BrowserView::FullscreenStateChanged() {
986 CHECK(!IsFullscreen()); 981 CHECK(!IsFullscreen());
987 ProcessFullscreen(false, GURL(), EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE); 982 ProcessFullscreen(false, GURL(), EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE);
988 } 983 }
989 984
990 LocationBar* BrowserView::GetLocationBar() const { 985 LocationBar* BrowserView::GetLocationBar() const {
991 return GetLocationBarView(); 986 return GetLocationBarView();
992 } 987 }
993 988
994 void BrowserView::SetFocusToLocationBar(bool select_all) { 989 void BrowserView::SetFocusToLocationBar(bool select_all) {
995 // On Windows, changing focus to the location bar causes the browser 990 // On Windows, changing focus to the location bar causes the browser window to
996 // window to become active. This can steal focus if the user has 991 // become active. This can steal focus if the user has another window open
997 // another window open already. On ChromeOS, changing focus makes a 992 // already. On Chrome OS, changing focus makes a view believe it has a focus
998 // view believe it has a focus even if the widget doens't have a 993 // even if the widget doens't have a focus. Either cases, we need to ignore
999 // focus. Either cases, we need to ignore this when the browser 994 // this when the browser window isn't active.
1000 // window isn't active.
1001 #if defined(OS_WIN) || defined(OS_CHROMEOS) 995 #if defined(OS_WIN) || defined(OS_CHROMEOS)
1002 if (!force_location_bar_focus_ && !IsActive()) 996 if (!force_location_bar_focus_ && !IsActive())
1003 return; 997 return;
1004 #endif 998 #endif
1005 999
1006 // Temporarily reveal the top-of-window views (if not already revealed) so 1000 // Temporarily reveal the top-of-window views (if not already revealed) so
1007 // that the location bar view is visible and is considered focusable. If the 1001 // that the location bar view is visible and is considered focusable. If the
1008 // location bar view gains focus, |immersive_mode_controller_| will keep the 1002 // location bar view gains focus, |immersive_mode_controller_| will keep the
1009 // top-of-window views revealed. 1003 // top-of-window views revealed.
1010 std::unique_ptr<ImmersiveRevealedLock> focus_reveal_lock( 1004 std::unique_ptr<ImmersiveRevealedLock> focus_reveal_lock(
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 return window_title; 1646 return window_title;
1653 } 1647 }
1654 return base::string16(); 1648 return base::string16();
1655 } 1649 }
1656 1650
1657 views::View* BrowserView::GetInitiallyFocusedView() { 1651 views::View* BrowserView::GetInitiallyFocusedView() {
1658 return nullptr; 1652 return nullptr;
1659 } 1653 }
1660 1654
1661 bool BrowserView::ShouldShowWindowTitle() const { 1655 bool BrowserView::ShouldShowWindowTitle() const {
1662 #if defined(USE_ASH) 1656 #if defined(OS_CHROMEOS)
1663 // For Ash only, trusted windows (apps and settings) do not show a title, 1657 // For Chrome OS only, trusted windows (apps and settings) do not show a
1664 // crbug.com/119411. Child windows (i.e. popups) do show a title. 1658 // title, crbug.com/119411. Child windows (i.e. popups) do show a title.
1665 if (browser_->is_trusted_source()) 1659 if (browser_->is_trusted_source())
1666 return false; 1660 return false;
1667 #endif // USE_ASH 1661 #endif // OS_CHROMEOS
1668 1662
1669 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR); 1663 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR);
1670 } 1664 }
1671 1665
1672 gfx::ImageSkia BrowserView::GetWindowAppIcon() { 1666 gfx::ImageSkia BrowserView::GetWindowAppIcon() {
1673 if (browser_->is_app()) { 1667 if (browser_->is_app()) {
1674 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents(); 1668 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents();
1675 extensions::TabHelper* extensions_tab_helper = 1669 extensions::TabHelper* extensions_tab_helper =
1676 contents ? extensions::TabHelper::FromWebContents(contents) : nullptr; 1670 contents ? extensions::TabHelper::FromWebContents(contents) : nullptr;
1677 if (extensions_tab_helper && extensions_tab_helper->GetExtensionAppIcon()) 1671 if (extensions_tab_helper && extensions_tab_helper->GetExtensionAppIcon())
1678 return gfx::ImageSkia::CreateFrom1xBitmap( 1672 return gfx::ImageSkia::CreateFrom1xBitmap(
1679 *extensions_tab_helper->GetExtensionAppIcon()); 1673 *extensions_tab_helper->GetExtensionAppIcon());
1680 } 1674 }
1681 1675
1682 return GetWindowIcon(); 1676 return GetWindowIcon();
1683 } 1677 }
1684 1678
1685 gfx::ImageSkia BrowserView::GetWindowIcon() { 1679 gfx::ImageSkia BrowserView::GetWindowIcon() {
1686 // Use the default icon for devtools. 1680 // Use the default icon for devtools.
1687 if (browser_->is_devtools()) 1681 if (browser_->is_devtools())
1688 return gfx::ImageSkia(); 1682 return gfx::ImageSkia();
1689 1683
1690 if (browser_->is_app() || browser_->is_type_popup()) 1684 if (browser_->is_app() || browser_->is_type_popup())
1691 return browser_->GetCurrentPageIcon().AsImageSkia(); 1685 return browser_->GetCurrentPageIcon().AsImageSkia();
1692 return gfx::ImageSkia(); 1686 return gfx::ImageSkia();
1693 } 1687 }
1694 1688
1695 bool BrowserView::ShouldShowWindowIcon() const { 1689 bool BrowserView::ShouldShowWindowIcon() const {
1696 #if defined(USE_ASH) 1690 #if defined(OS_CHROMEOS)
1697 // For Ash only, trusted windows (apps and settings) do not show an icon, 1691 // For Chrome OS only, trusted windows (apps and settings) do not show an
1698 // crbug.com/119411. Child windows (i.e. popups) do show an icon. 1692 // icon, crbug.com/119411. Child windows (i.e. popups) do show an icon.
1699 if (browser_->is_trusted_source()) 1693 if (browser_->is_trusted_source())
1700 return false; 1694 return false;
1701 #endif // USE_ASH 1695 #endif // OS_CHROMEOS
1702 1696
1703 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR); 1697 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR);
1704 } 1698 }
1705 1699
1706 bool BrowserView::ExecuteWindowsCommand(int command_id) { 1700 bool BrowserView::ExecuteWindowsCommand(int command_id) {
1707 // This function handles WM_SYSCOMMAND, WM_APPCOMMAND, and WM_COMMAND. 1701 // This function handles WM_SYSCOMMAND, WM_APPCOMMAND, and WM_COMMAND.
1708 #if defined(OS_WIN) 1702 #if defined(OS_WIN)
1709 if (command_id == IDC_DEBUG_FRAME_TOGGLE) 1703 if (command_id == IDC_DEBUG_FRAME_TOGGLE)
1710 GetWidget()->DebugToggleFrameType(); 1704 GetWidget()->DebugToggleFrameType();
1711 #endif 1705 #endif
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
2346 // order to let the layout occur. 2340 // order to let the layout occur.
2347 in_process_fullscreen_ = false; 2341 in_process_fullscreen_ = false;
2348 ToolbarSizeChanged(false); 2342 ToolbarSizeChanged(false);
2349 2343
2350 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents(); 2344 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents();
2351 if (contents && PermissionRequestManager::FromWebContents(contents)) 2345 if (contents && PermissionRequestManager::FromWebContents(contents))
2352 PermissionRequestManager::FromWebContents(contents)->UpdateAnchorPosition(); 2346 PermissionRequestManager::FromWebContents(contents)->UpdateAnchorPosition();
2353 } 2347 }
2354 2348
2355 bool BrowserView::ShouldUseImmersiveFullscreenForUrl(const GURL& url) const { 2349 bool BrowserView::ShouldUseImmersiveFullscreenForUrl(const GURL& url) const {
2356 #if defined(USE_ASH) 2350 #if defined(OS_CHROMEOS)
2357 // Kiosk mode needs the whole screen. 2351 // Kiosk mode needs the whole screen.
2358 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode)) 2352 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode))
2359 return false; 2353 return false;
2360 2354
2361 return url.is_empty(); 2355 return url.is_empty();
2362 #else 2356 #else
2363 // No immersive except in Ash. 2357 // No immersive except in Chrome OS.
2364 return false; 2358 return false;
2365 #endif // !USE_ASH 2359 #endif
2366 } 2360 }
2367 2361
2368 void BrowserView::LoadAccelerators() { 2362 void BrowserView::LoadAccelerators() {
2369 views::FocusManager* focus_manager = GetFocusManager(); 2363 views::FocusManager* focus_manager = GetFocusManager();
2370 DCHECK(focus_manager); 2364 DCHECK(focus_manager);
2371 2365
2372 // Let's fill our own accelerator table. 2366 // Let's fill our own accelerator table.
2373 const bool is_app_mode = chrome::IsRunningInForcedAppMode(); 2367 const bool is_app_mode = chrome::IsRunningInForcedAppMode();
2374 const std::vector<AcceleratorMapping> accelerator_list(GetAcceleratorList()); 2368 const std::vector<AcceleratorMapping> accelerator_list(GetAcceleratorList());
2375 for (const auto& entry : accelerator_list) { 2369 for (const auto& entry : accelerator_list) {
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
2644 } 2638 }
2645 2639
2646 extensions::ActiveTabPermissionGranter* 2640 extensions::ActiveTabPermissionGranter*
2647 BrowserView::GetActiveTabPermissionGranter() { 2641 BrowserView::GetActiveTabPermissionGranter() {
2648 content::WebContents* web_contents = GetActiveWebContents(); 2642 content::WebContents* web_contents = GetActiveWebContents();
2649 if (!web_contents) 2643 if (!web_contents)
2650 return nullptr; 2644 return nullptr;
2651 return extensions::TabHelper::FromWebContents(web_contents) 2645 return extensions::TabHelper::FromWebContents(web_contents)
2652 ->active_tab_permission_granter(); 2646 ->active_tab_permission_granter();
2653 } 2647 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698