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

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

Issue 2640433004: ChromeOS MD: Fix cannot drag tab onto immersive fullscreen window (Closed)
Patch Set: comments from ps11 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 #include "ui/views/controls/textfield/textfield.h" 140 #include "ui/views/controls/textfield/textfield.h"
141 #include "ui/views/controls/webview/webview.h" 141 #include "ui/views/controls/webview/webview.h"
142 #include "ui/views/focus/external_focus_tracker.h" 142 #include "ui/views/focus/external_focus_tracker.h"
143 #include "ui/views/focus/view_storage.h" 143 #include "ui/views/focus/view_storage.h"
144 #include "ui/views/layout/grid_layout.h" 144 #include "ui/views/layout/grid_layout.h"
145 #include "ui/views/widget/native_widget.h" 145 #include "ui/views/widget/native_widget.h"
146 #include "ui/views/widget/root_view.h" 146 #include "ui/views/widget/root_view.h"
147 #include "ui/views/widget/widget.h" 147 #include "ui/views/widget/widget.h"
148 #include "ui/views/window/dialog_delegate.h" 148 #include "ui/views/window/dialog_delegate.h"
149 149
150 #if defined(OS_CHROMEOS)
151 #include "chrome/browser/ui/ash/ash_util.h"
152 #endif // defined(OS_CHROMEOS)
153
150 #if !defined(OS_CHROMEOS) 154 #if !defined(OS_CHROMEOS)
151 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h" 155 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h"
152 #endif 156 #endif // !defined(OS_CHROMEOS)
153
154 #if defined(USE_ASH)
155 #include "chrome/browser/ui/ash/ash_util.h"
156 #endif
157 157
158 #if defined(USE_AURA) 158 #if defined(USE_AURA)
159 #include "ui/aura/client/window_parenting_client.h" 159 #include "ui/aura/client/window_parenting_client.h"
160 #include "ui/aura/window.h" 160 #include "ui/aura/window.h"
161 #include "ui/aura/window_tree_host.h" 161 #include "ui/aura/window_tree_host.h"
162 #endif 162 #endif
163 163
164 #if defined(OS_WIN) 164 #if defined(OS_WIN)
165 #include "base/win/windows_version.h" 165 #include "base/win/windows_version.h"
166 #include "chrome/browser/win/jumplist.h" 166 #include "chrome/browser/win/jumplist.h"
(...skipping 352 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 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
1651 return window_title; 1645 return window_title;
1652 } 1646 }
1653 return base::string16(); 1647 return base::string16();
1654 } 1648 }
1655 1649
1656 views::View* BrowserView::GetInitiallyFocusedView() { 1650 views::View* BrowserView::GetInitiallyFocusedView() {
1657 return nullptr; 1651 return nullptr;
1658 } 1652 }
1659 1653
1660 bool BrowserView::ShouldShowWindowTitle() const { 1654 bool BrowserView::ShouldShowWindowTitle() const {
1661 #if defined(USE_ASH) 1655 #if defined(OS_CHROMEOS)
1662 // For Ash only, trusted windows (apps and settings) do not show a title, 1656 // For Chrome OS only, trusted windows (apps and settings) do not show a
1663 // crbug.com/119411. Child windows (i.e. popups) do show a title. 1657 // title, crbug.com/119411. Child windows (i.e. popups) do show a title.
1664 if (browser_->is_trusted_source()) 1658 if (browser_->is_trusted_source())
1665 return false; 1659 return false;
1666 #endif // USE_ASH 1660 #endif // OS_CHROMEOS
1667 1661
1668 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR); 1662 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR);
1669 } 1663 }
1670 1664
1671 gfx::ImageSkia BrowserView::GetWindowAppIcon() { 1665 gfx::ImageSkia BrowserView::GetWindowAppIcon() {
1672 if (browser_->is_app()) { 1666 if (browser_->is_app()) {
1673 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents(); 1667 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents();
1674 extensions::TabHelper* extensions_tab_helper = 1668 extensions::TabHelper* extensions_tab_helper =
1675 contents ? extensions::TabHelper::FromWebContents(contents) : nullptr; 1669 contents ? extensions::TabHelper::FromWebContents(contents) : nullptr;
1676 if (extensions_tab_helper && extensions_tab_helper->GetExtensionAppIcon()) 1670 if (extensions_tab_helper && extensions_tab_helper->GetExtensionAppIcon())
1677 return gfx::ImageSkia::CreateFrom1xBitmap( 1671 return gfx::ImageSkia::CreateFrom1xBitmap(
1678 *extensions_tab_helper->GetExtensionAppIcon()); 1672 *extensions_tab_helper->GetExtensionAppIcon());
1679 } 1673 }
1680 1674
1681 return GetWindowIcon(); 1675 return GetWindowIcon();
1682 } 1676 }
1683 1677
1684 gfx::ImageSkia BrowserView::GetWindowIcon() { 1678 gfx::ImageSkia BrowserView::GetWindowIcon() {
1685 // Use the default icon for devtools. 1679 // Use the default icon for devtools.
1686 if (browser_->is_devtools()) 1680 if (browser_->is_devtools())
1687 return gfx::ImageSkia(); 1681 return gfx::ImageSkia();
1688 1682
1689 if (browser_->is_app() || browser_->is_type_popup()) 1683 if (browser_->is_app() || browser_->is_type_popup())
1690 return browser_->GetCurrentPageIcon().AsImageSkia(); 1684 return browser_->GetCurrentPageIcon().AsImageSkia();
1691 return gfx::ImageSkia(); 1685 return gfx::ImageSkia();
1692 } 1686 }
1693 1687
1694 bool BrowserView::ShouldShowWindowIcon() const { 1688 bool BrowserView::ShouldShowWindowIcon() const {
1695 #if defined(USE_ASH) 1689 #if defined(OS_CHROMEOS)
1696 // For Ash only, trusted windows (apps and settings) do not show an icon, 1690 // For Chrome OS only, trusted windows (apps and settings) do not show an
1697 // crbug.com/119411. Child windows (i.e. popups) do show an icon. 1691 // icon, crbug.com/119411. Child windows (i.e. popups) do show an icon.
1698 if (browser_->is_trusted_source()) 1692 if (browser_->is_trusted_source())
1699 return false; 1693 return false;
1700 #endif // USE_ASH 1694 #endif // OS_CHROMEOS
1701 1695
1702 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR); 1696 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR);
1703 } 1697 }
1704 1698
1705 bool BrowserView::ExecuteWindowsCommand(int command_id) { 1699 bool BrowserView::ExecuteWindowsCommand(int command_id) {
1706 // This function handles WM_SYSCOMMAND, WM_APPCOMMAND, and WM_COMMAND. 1700 // This function handles WM_SYSCOMMAND, WM_APPCOMMAND, and WM_COMMAND.
1707 #if defined(OS_WIN) 1701 #if defined(OS_WIN)
1708 if (command_id == IDC_DEBUG_FRAME_TOGGLE) 1702 if (command_id == IDC_DEBUG_FRAME_TOGGLE)
1709 GetWidget()->DebugToggleFrameType(); 1703 GetWidget()->DebugToggleFrameType();
1710 #endif 1704 #endif
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
2345 // order to let the layout occur. 2339 // order to let the layout occur.
2346 in_process_fullscreen_ = false; 2340 in_process_fullscreen_ = false;
2347 ToolbarSizeChanged(false); 2341 ToolbarSizeChanged(false);
2348 2342
2349 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents(); 2343 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents();
2350 if (contents && PermissionRequestManager::FromWebContents(contents)) 2344 if (contents && PermissionRequestManager::FromWebContents(contents))
2351 PermissionRequestManager::FromWebContents(contents)->UpdateAnchorPosition(); 2345 PermissionRequestManager::FromWebContents(contents)->UpdateAnchorPosition();
2352 } 2346 }
2353 2347
2354 bool BrowserView::ShouldUseImmersiveFullscreenForUrl(const GURL& url) const { 2348 bool BrowserView::ShouldUseImmersiveFullscreenForUrl(const GURL& url) const {
2355 #if defined(USE_ASH) 2349 #if defined(OS_CHROMEOS)
2356 // Kiosk mode needs the whole screen. 2350 // Kiosk mode needs the whole screen.
2357 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode)) 2351 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode))
2358 return false; 2352 return false;
2359 2353
2360 return url.is_empty(); 2354 return url.is_empty();
2361 #else 2355 #else
2362 // No immersive except in Ash. 2356 // No immersive except in Chrome OS.
2363 return false; 2357 return false;
2364 #endif // !USE_ASH 2358 #endif
2365 } 2359 }
2366 2360
2367 void BrowserView::LoadAccelerators() { 2361 void BrowserView::LoadAccelerators() {
2368 views::FocusManager* focus_manager = GetFocusManager(); 2362 views::FocusManager* focus_manager = GetFocusManager();
2369 DCHECK(focus_manager); 2363 DCHECK(focus_manager);
2370 2364
2371 // Let's fill our own accelerator table. 2365 // Let's fill our own accelerator table.
2372 const bool is_app_mode = chrome::IsRunningInForcedAppMode(); 2366 const bool is_app_mode = chrome::IsRunningInForcedAppMode();
2373 const std::vector<AcceleratorMapping> accelerator_list(GetAcceleratorList()); 2367 const std::vector<AcceleratorMapping> accelerator_list(GetAcceleratorList());
2374 for (const auto& entry : accelerator_list) { 2368 for (const auto& entry : accelerator_list) {
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
2643 } 2637 }
2644 2638
2645 extensions::ActiveTabPermissionGranter* 2639 extensions::ActiveTabPermissionGranter*
2646 BrowserView::GetActiveTabPermissionGranter() { 2640 BrowserView::GetActiveTabPermissionGranter() {
2647 content::WebContents* web_contents = GetActiveWebContents(); 2641 content::WebContents* web_contents = GetActiveWebContents();
2648 if (!web_contents) 2642 if (!web_contents)
2649 return nullptr; 2643 return nullptr;
2650 return extensions::TabHelper::FromWebContents(web_contents) 2644 return extensions::TabHelper::FromWebContents(web_contents)
2651 ->active_tab_permission_granter(); 2645 ->active_tab_permission_granter();
2652 } 2646 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698