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

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 ps10 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) 150 #if defined(OS_CHROMEOS)
151 #include "chrome/browser/ui/ash/ash_util.h"
152 #else // defined(OS_CHROMEOS)
151 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h" 153 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h"
152 #endif 154 #endif // !defined(OS_CHROMEOS)
sky 2017/02/01 21:36:12 Conditional ifdefs are harder to read. Please star
Qiang(Joe) Xu 2017/02/01 21:54:23 Done.
153
154 #if defined(USE_ASH)
155 #include "chrome/browser/ui/ash/ash_util.h"
156 #endif
157 155
158 #if defined(USE_AURA) 156 #if defined(USE_AURA)
159 #include "ui/aura/client/window_parenting_client.h" 157 #include "ui/aura/client/window_parenting_client.h"
160 #include "ui/aura/window.h" 158 #include "ui/aura/window.h"
161 #include "ui/aura/window_tree_host.h" 159 #include "ui/aura/window_tree_host.h"
162 #endif 160 #endif
163 161
164 #if defined(OS_WIN) 162 #if defined(OS_WIN)
165 #include "base/win/windows_version.h" 163 #include "base/win/windows_version.h"
166 #include "chrome/browser/win/jumplist.h" 164 #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 517 // 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 518 // 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. 519 // be). We expect our parent's origin to be the window origin.
522 gfx::Point window_point(point + GetMirroredPosition().OffsetFromOrigin()); 520 gfx::Point window_point(point + GetMirroredPosition().OffsetFromOrigin());
523 window_point.Offset(frame_->GetThemeBackgroundXInset(), 521 window_point.Offset(frame_->GetThemeBackgroundXInset(),
524 -frame_->GetTopInset(false)); 522 -frame_->GetTopInset(false));
525 return window_point; 523 return window_point;
526 } 524 }
527 525
528 bool BrowserView::IsTabStripVisible() const { 526 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. 527 // Return false if this window does not normally display a tabstrip.
535 if (!browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP)) 528 if (!browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP))
536 return false; 529 return false;
537 530
538 // Return false if the tabstrip has not yet been created (by InitViews()), 531 // 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 532 // 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 533 // this alone, as the tabstrip is created unconditionally even for windows
541 // that won't display it. 534 // that won't display it.
542 return tabstrip_ != nullptr; 535 return tabstrip_ != nullptr;
543 } 536 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 } 579 }
587 580
588 WebContents* BrowserView::GetActiveWebContents() const { 581 WebContents* BrowserView::GetActiveWebContents() const {
589 return browser_->tab_strip_model()->GetActiveWebContents(); 582 return browser_->tab_strip_model()->GetActiveWebContents();
590 } 583 }
591 584
592 /////////////////////////////////////////////////////////////////////////////// 585 ///////////////////////////////////////////////////////////////////////////////
593 // BrowserView, BrowserWindow implementation: 586 // BrowserView, BrowserWindow implementation:
594 587
595 void BrowserView::Show() { 588 void BrowserView::Show() {
596 #if !defined(OS_WIN) && !defined(USE_ASH) 589 #if !defined(OS_WIN) && !defined(OS_CHROMEOS)
597 // The Browser associated with this browser window must become the active 590 // 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 591 // browser at the time |Show()| is called. This is the natural behavior under
599 // Windows and Ash, but other platforms will not trigger 592 // Windows and Ash, but other platforms will not trigger
600 // OnWidgetActivationChanged() until we return to the runloop. Therefore any 593 // OnWidgetActivationChanged() until we return to the runloop. Therefore any
601 // calls to Browser::GetLastActive() will return the wrong result if we do not 594 // calls to Browser::GetLastActive() will return the wrong result if we do not
602 // explicitly set it here. 595 // explicitly set it here.
603 // A similar block also appears in BrowserWindowCocoa::Show(). 596 // A similar block also appears in BrowserWindowCocoa::Show().
604 BrowserList::SetLastActive(browser()); 597 BrowserList::SetLastActive(browser());
605 #endif 598 #endif
606 599
(...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after
1651 return window_title; 1644 return window_title;
1652 } 1645 }
1653 return base::string16(); 1646 return base::string16();
1654 } 1647 }
1655 1648
1656 views::View* BrowserView::GetInitiallyFocusedView() { 1649 views::View* BrowserView::GetInitiallyFocusedView() {
1657 return nullptr; 1650 return nullptr;
1658 } 1651 }
1659 1652
1660 bool BrowserView::ShouldShowWindowTitle() const { 1653 bool BrowserView::ShouldShowWindowTitle() const {
1661 #if defined(USE_ASH) 1654 #if defined(OS_CHROMEOS)
1662 // For Ash only, trusted windows (apps and settings) do not show a title, 1655 // For Ash only, trusted windows (apps and settings) do not show a title,
sky 2017/02/01 21:36:12 Ash -> Chrome OS (I think I'm not sure what the ri
Qiang(Joe) Xu 2017/02/01 21:54:23 Done.
1663 // crbug.com/119411. Child windows (i.e. popups) do show a title. 1656 // crbug.com/119411. Child windows (i.e. popups) do show a title.
1664 if (browser_->is_trusted_source()) 1657 if (browser_->is_trusted_source())
1665 return false; 1658 return false;
1666 #endif // USE_ASH 1659 #endif // OS_CHROMEOS
1667 1660
1668 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR); 1661 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR);
1669 } 1662 }
1670 1663
1671 gfx::ImageSkia BrowserView::GetWindowAppIcon() { 1664 gfx::ImageSkia BrowserView::GetWindowAppIcon() {
1672 if (browser_->is_app()) { 1665 if (browser_->is_app()) {
1673 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents(); 1666 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents();
1674 extensions::TabHelper* extensions_tab_helper = 1667 extensions::TabHelper* extensions_tab_helper =
1675 contents ? extensions::TabHelper::FromWebContents(contents) : nullptr; 1668 contents ? extensions::TabHelper::FromWebContents(contents) : nullptr;
1676 if (extensions_tab_helper && extensions_tab_helper->GetExtensionAppIcon()) 1669 if (extensions_tab_helper && extensions_tab_helper->GetExtensionAppIcon())
1677 return gfx::ImageSkia::CreateFrom1xBitmap( 1670 return gfx::ImageSkia::CreateFrom1xBitmap(
1678 *extensions_tab_helper->GetExtensionAppIcon()); 1671 *extensions_tab_helper->GetExtensionAppIcon());
1679 } 1672 }
1680 1673
1681 return GetWindowIcon(); 1674 return GetWindowIcon();
1682 } 1675 }
1683 1676
1684 gfx::ImageSkia BrowserView::GetWindowIcon() { 1677 gfx::ImageSkia BrowserView::GetWindowIcon() {
1685 // Use the default icon for devtools. 1678 // Use the default icon for devtools.
1686 if (browser_->is_devtools()) 1679 if (browser_->is_devtools())
1687 return gfx::ImageSkia(); 1680 return gfx::ImageSkia();
1688 1681
1689 if (browser_->is_app() || browser_->is_type_popup()) 1682 if (browser_->is_app() || browser_->is_type_popup())
1690 return browser_->GetCurrentPageIcon().AsImageSkia(); 1683 return browser_->GetCurrentPageIcon().AsImageSkia();
1691 return gfx::ImageSkia(); 1684 return gfx::ImageSkia();
1692 } 1685 }
1693 1686
1694 bool BrowserView::ShouldShowWindowIcon() const { 1687 bool BrowserView::ShouldShowWindowIcon() const {
1695 #if defined(USE_ASH) 1688 #if defined(OS_CHROMEOS)
1696 // For Ash only, trusted windows (apps and settings) do not show an icon, 1689 // For Ash only, trusted windows (apps and settings) do not show an icon,
1697 // crbug.com/119411. Child windows (i.e. popups) do show an icon. 1690 // crbug.com/119411. Child windows (i.e. popups) do show an icon.
1698 if (browser_->is_trusted_source()) 1691 if (browser_->is_trusted_source())
1699 return false; 1692 return false;
1700 #endif // USE_ASH 1693 #endif // OS_CHROMEOS
1701 1694
1702 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR); 1695 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR);
1703 } 1696 }
1704 1697
1705 bool BrowserView::ExecuteWindowsCommand(int command_id) { 1698 bool BrowserView::ExecuteWindowsCommand(int command_id) {
1706 // This function handles WM_SYSCOMMAND, WM_APPCOMMAND, and WM_COMMAND. 1699 // This function handles WM_SYSCOMMAND, WM_APPCOMMAND, and WM_COMMAND.
1707 #if defined(OS_WIN) 1700 #if defined(OS_WIN)
1708 if (command_id == IDC_DEBUG_FRAME_TOGGLE) 1701 if (command_id == IDC_DEBUG_FRAME_TOGGLE)
1709 GetWidget()->DebugToggleFrameType(); 1702 GetWidget()->DebugToggleFrameType();
1710 #endif 1703 #endif
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
2345 // order to let the layout occur. 2338 // order to let the layout occur.
2346 in_process_fullscreen_ = false; 2339 in_process_fullscreen_ = false;
2347 ToolbarSizeChanged(false); 2340 ToolbarSizeChanged(false);
2348 2341
2349 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents(); 2342 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents();
2350 if (contents && PermissionRequestManager::FromWebContents(contents)) 2343 if (contents && PermissionRequestManager::FromWebContents(contents))
2351 PermissionRequestManager::FromWebContents(contents)->UpdateAnchorPosition(); 2344 PermissionRequestManager::FromWebContents(contents)->UpdateAnchorPosition();
2352 } 2345 }
2353 2346
2354 bool BrowserView::ShouldUseImmersiveFullscreenForUrl(const GURL& url) const { 2347 bool BrowserView::ShouldUseImmersiveFullscreenForUrl(const GURL& url) const {
2355 #if defined(USE_ASH) 2348 #if defined(OS_CHROMEOS)
2356 // Kiosk mode needs the whole screen. 2349 // Kiosk mode needs the whole screen.
2357 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode)) 2350 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode))
2358 return false; 2351 return false;
2359 2352
2360 return url.is_empty(); 2353 return url.is_empty();
2361 #else 2354 #else
2362 // No immersive except in Ash. 2355 // No immersive except in Ash.
2363 return false; 2356 return false;
2364 #endif // !USE_ASH 2357 #endif
2365 } 2358 }
2366 2359
2367 void BrowserView::LoadAccelerators() { 2360 void BrowserView::LoadAccelerators() {
2368 views::FocusManager* focus_manager = GetFocusManager(); 2361 views::FocusManager* focus_manager = GetFocusManager();
2369 DCHECK(focus_manager); 2362 DCHECK(focus_manager);
2370 2363
2371 // Let's fill our own accelerator table. 2364 // Let's fill our own accelerator table.
2372 const bool is_app_mode = chrome::IsRunningInForcedAppMode(); 2365 const bool is_app_mode = chrome::IsRunningInForcedAppMode();
2373 const std::vector<AcceleratorMapping> accelerator_list(GetAcceleratorList()); 2366 const std::vector<AcceleratorMapping> accelerator_list(GetAcceleratorList());
2374 for (const auto& entry : accelerator_list) { 2367 for (const auto& entry : accelerator_list) {
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
2643 } 2636 }
2644 2637
2645 extensions::ActiveTabPermissionGranter* 2638 extensions::ActiveTabPermissionGranter*
2646 BrowserView::GetActiveTabPermissionGranter() { 2639 BrowserView::GetActiveTabPermissionGranter() {
2647 content::WebContents* web_contents = GetActiveWebContents(); 2640 content::WebContents* web_contents = GetActiveWebContents();
2648 if (!web_contents) 2641 if (!web_contents)
2649 return nullptr; 2642 return nullptr;
2650 return extensions::TabHelper::FromWebContents(web_contents) 2643 return extensions::TabHelper::FromWebContents(web_contents)
2651 ->active_tab_permission_granter(); 2644 ->active_tab_permission_granter();
2652 } 2645 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698