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

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

Issue 243703003: Removes win8_util (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: moar Created 6 years, 8 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 | Annotate | Revision Log
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 <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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 #include "ui/aura/client/window_tree_client.h" 148 #include "ui/aura/client/window_tree_client.h"
149 #include "ui/aura/window.h" 149 #include "ui/aura/window.h"
150 #include "ui/aura/window_tree_host.h" 150 #include "ui/aura/window_tree_host.h"
151 #include "ui/gfx/screen.h" 151 #include "ui/gfx/screen.h"
152 #endif 152 #endif
153 153
154 #if defined(OS_WIN) 154 #if defined(OS_WIN)
155 #include "base/win/windows_version.h" 155 #include "base/win/windows_version.h"
156 #include "chrome/browser/jumplist_win.h" 156 #include "chrome/browser/jumplist_win.h"
157 #include "ui/views/win/scoped_fullscreen_visibility.h" 157 #include "ui/views/win/scoped_fullscreen_visibility.h"
158 #include "win8/util/win8_util.h"
159 #endif 158 #endif
160 159
161 #if defined(ENABLE_ONE_CLICK_SIGNIN) 160 #if defined(ENABLE_ONE_CLICK_SIGNIN)
162 #include "chrome/browser/ui/sync/one_click_signin_bubble_delegate.h" 161 #include "chrome/browser/ui/sync/one_click_signin_bubble_delegate.h"
163 #include "chrome/browser/ui/sync/one_click_signin_bubble_links_delegate.h" 162 #include "chrome/browser/ui/sync/one_click_signin_bubble_links_delegate.h"
164 #include "chrome/browser/ui/views/sync/one_click_signin_bubble_view.h" 163 #include "chrome/browser/ui/views/sync/one_click_signin_bubble_view.h"
165 #endif 164 #endif
166 165
167 #if defined(OS_CHROMEOS) 166 #if defined(OS_CHROMEOS)
168 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" 167 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 ThemeProperties::GetDefaultColor( 237 ThemeProperties::GetDefaultColor(
239 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); 238 ThemeProperties::COLOR_TOOLBAR_SEPARATOR));
240 } 239 }
241 } 240 }
242 241
243 } // namespace 242 } // namespace
244 243
245 // static 244 // static
246 const char BrowserView::kViewClassName[] = "BrowserView"; 245 const char BrowserView::kViewClassName[] = "BrowserView";
247 246
248 namespace {
249
250 bool ShouldSaveOrRestoreWindowPos() {
251 #if defined(OS_WIN)
252 // In Windows 8's single window Metro mode the window is always maximized
253 // (without the WS_MAXIMIZE style).
254 if (win8::IsSingleWindowMetroMode())
255 return false;
256 #endif
257 return true;
258 }
259
260 } // namespace
261
262 /////////////////////////////////////////////////////////////////////////////// 247 ///////////////////////////////////////////////////////////////////////////////
263 248
264 // Delegate implementation for BrowserViewLayout. Usually just forwards calls 249 // Delegate implementation for BrowserViewLayout. Usually just forwards calls
265 // into BrowserView. 250 // into BrowserView.
266 class BrowserViewLayoutDelegateImpl : public BrowserViewLayoutDelegate { 251 class BrowserViewLayoutDelegateImpl : public BrowserViewLayoutDelegate {
267 public: 252 public:
268 explicit BrowserViewLayoutDelegateImpl(BrowserView* browser_view) 253 explicit BrowserViewLayoutDelegateImpl(BrowserView* browser_view)
269 : browser_view_(browser_view) {} 254 : browser_view_(browser_view) {}
270 virtual ~BrowserViewLayoutDelegateImpl() {} 255 virtual ~BrowserViewLayoutDelegateImpl() {}
271 256
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 549
565 bool BrowserView::IsGuestSession() const { 550 bool BrowserView::IsGuestSession() const {
566 return browser_->profile()->IsGuestSession(); 551 return browser_->profile()->IsGuestSession();
567 } 552 }
568 553
569 bool BrowserView::IsRegularOrGuestSession() const { 554 bool BrowserView::IsRegularOrGuestSession() const {
570 return profiles::IsRegularOrGuestSession(browser_.get()); 555 return profiles::IsRegularOrGuestSession(browser_.get());
571 } 556 }
572 557
573 int BrowserView::GetOTRIconResourceID() const { 558 int BrowserView::GetOTRIconResourceID() const {
574 int otr_resource_id = IDR_OTR_ICON; 559 if (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH && IsFullscreen())
575 if (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) { 560 return IDR_OTR_ICON_FULLSCREEN;
576 if (IsFullscreen()) 561 return IDR_OTR_ICON;
577 otr_resource_id = IDR_OTR_ICON_FULLSCREEN;
578 #if defined(OS_WIN)
579 if (win8::IsSingleWindowMetroMode())
580 otr_resource_id = IDR_OTR_ICON_FULLSCREEN;
581 #endif
582 }
583
584 return otr_resource_id;
585 } 562 }
586 563
587 int BrowserView::GetGuestIconResourceID() const { 564 int BrowserView::GetGuestIconResourceID() const {
588 return IDR_LOGIN_GUEST; 565 return IDR_LOGIN_GUEST;
589 } 566 }
590 567
591 bool BrowserView::ShouldShowAvatar() const { 568 bool BrowserView::ShouldShowAvatar() const {
592 #if defined(OS_CHROMEOS) 569 #if defined(OS_CHROMEOS)
593 if (!browser_->is_type_tabbed() && !browser_->is_app()) 570 if (!browser_->is_type_tabbed() && !browser_->is_app())
594 return false; 571 return false;
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
1421 void BrowserView::Copy() { 1398 void BrowserView::Copy() {
1422 DoCutCopyPaste(&content::WebContents::Copy, IDS_APP_COPY); 1399 DoCutCopyPaste(&content::WebContents::Copy, IDS_APP_COPY);
1423 } 1400 }
1424 1401
1425 void BrowserView::Paste() { 1402 void BrowserView::Paste() {
1426 DoCutCopyPaste(&content::WebContents::Paste, IDS_APP_PASTE); 1403 DoCutCopyPaste(&content::WebContents::Paste, IDS_APP_PASTE);
1427 } 1404 }
1428 1405
1429 WindowOpenDisposition BrowserView::GetDispositionForPopupBounds( 1406 WindowOpenDisposition BrowserView::GetDispositionForPopupBounds(
1430 const gfx::Rect& bounds) { 1407 const gfx::Rect& bounds) {
1431 #if defined(OS_WIN)
1432 // If we are in Win8's single window Metro mode, we can't allow popup windows.
1433 return win8::IsSingleWindowMetroMode() ? NEW_BACKGROUND_TAB : NEW_POPUP;
1434 #else
1435 return NEW_POPUP; 1408 return NEW_POPUP;
1436 #endif
1437 } 1409 }
1438 1410
1439 FindBar* BrowserView::CreateFindBar() { 1411 FindBar* BrowserView::CreateFindBar() {
1440 return chrome::CreateFindBar(this); 1412 return chrome::CreateFindBar(this);
1441 } 1413 }
1442 1414
1443 WebContentsModalDialogHost* BrowserView::GetWebContentsModalDialogHost() { 1415 WebContentsModalDialogHost* BrowserView::GetWebContentsModalDialogHost() {
1444 return GetBrowserViewLayout()->GetWebContentsModalDialogHost(); 1416 return GetBrowserViewLayout()->GetWebContentsModalDialogHost();
1445 } 1417 }
1446 1418
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1625 return false; 1597 return false;
1626 1598
1627 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR); 1599 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR);
1628 } 1600 }
1629 1601
1630 bool BrowserView::ExecuteWindowsCommand(int command_id) { 1602 bool BrowserView::ExecuteWindowsCommand(int command_id) {
1631 // This function handles WM_SYSCOMMAND, WM_APPCOMMAND, and WM_COMMAND. 1603 // This function handles WM_SYSCOMMAND, WM_APPCOMMAND, and WM_COMMAND.
1632 #if defined(OS_WIN) 1604 #if defined(OS_WIN)
1633 if (command_id == IDC_DEBUG_FRAME_TOGGLE) 1605 if (command_id == IDC_DEBUG_FRAME_TOGGLE)
1634 GetWidget()->DebugToggleFrameType(); 1606 GetWidget()->DebugToggleFrameType();
1635
1636 // In Windows 8 metro mode prevent sizing and moving.
1637 if (win8::IsSingleWindowMetroMode()) {
1638 // Windows uses the 4 lower order bits of |notification_code| for type-
1639 // specific information so we must exclude this when comparing.
1640 static const int sc_mask = 0xFFF0;
1641 if (((command_id & sc_mask) == SC_MOVE) ||
1642 ((command_id & sc_mask) == SC_SIZE) ||
1643 ((command_id & sc_mask) == SC_MAXIMIZE))
1644 return true;
1645 }
1646 #endif 1607 #endif
1647 // Translate WM_APPCOMMAND command ids into a command id that the browser 1608 // Translate WM_APPCOMMAND command ids into a command id that the browser
1648 // knows how to handle. 1609 // knows how to handle.
1649 int command_id_from_app_command = GetCommandIDForAppCommandID(command_id); 1610 int command_id_from_app_command = GetCommandIDForAppCommandID(command_id);
1650 if (command_id_from_app_command != -1) 1611 if (command_id_from_app_command != -1)
1651 command_id = command_id_from_app_command; 1612 command_id = command_id_from_app_command;
1652 1613
1653 return chrome::ExecuteCommand(browser_.get(), command_id); 1614 return chrome::ExecuteCommand(browser_.get(), command_id);
1654 } 1615 }
1655 1616
1656 std::string BrowserView::GetWindowName() const { 1617 std::string BrowserView::GetWindowName() const {
1657 return chrome::GetWindowPlacementKey(browser_.get()); 1618 return chrome::GetWindowPlacementKey(browser_.get());
1658 } 1619 }
1659 1620
1660 void BrowserView::SaveWindowPlacement(const gfx::Rect& bounds, 1621 void BrowserView::SaveWindowPlacement(const gfx::Rect& bounds,
1661 ui::WindowShowState show_state) { 1622 ui::WindowShowState show_state) {
1662 // If IsFullscreen() is true, we've just changed into fullscreen mode, and 1623 // If IsFullscreen() is true, we've just changed into fullscreen mode, and
1663 // we're catching the going-into-fullscreen sizing and positioning calls, 1624 // we're catching the going-into-fullscreen sizing and positioning calls,
1664 // which we want to ignore. 1625 // which we want to ignore.
1665 if (!ShouldSaveOrRestoreWindowPos())
1666 return;
1667
1668 if (!IsFullscreen() && chrome::ShouldSaveWindowPlacement(browser_.get())) { 1626 if (!IsFullscreen() && chrome::ShouldSaveWindowPlacement(browser_.get())) {
1669 WidgetDelegate::SaveWindowPlacement(bounds, show_state); 1627 WidgetDelegate::SaveWindowPlacement(bounds, show_state);
1670 chrome::SaveWindowPlacement(browser_.get(), bounds, show_state); 1628 chrome::SaveWindowPlacement(browser_.get(), bounds, show_state);
1671 } 1629 }
1672 } 1630 }
1673 1631
1674 bool BrowserView::GetSavedWindowPlacement( 1632 bool BrowserView::GetSavedWindowPlacement(
1675 const views::Widget* widget, 1633 const views::Widget* widget,
1676 gfx::Rect* bounds, 1634 gfx::Rect* bounds,
1677 ui::WindowShowState* show_state) const { 1635 ui::WindowShowState* show_state) const {
1678 if (!ShouldSaveOrRestoreWindowPos())
1679 return false;
1680 chrome::GetSavedWindowBoundsAndShowState(browser_.get(), bounds, show_state); 1636 chrome::GetSavedWindowBoundsAndShowState(browser_.get(), bounds, show_state);
1681 1637
1682 if (browser_->is_type_popup() && 1638 if (browser_->is_type_popup() &&
1683 !browser_->is_app() && 1639 !browser_->is_app() &&
1684 !browser_->is_trusted_source()) { 1640 !browser_->is_trusted_source()) {
1685 // This is normal non-app popup window. The value passed in |bounds| 1641 // This is normal non-app popup window. The value passed in |bounds|
1686 // represents two pieces of information: 1642 // represents two pieces of information:
1687 // - the position of the window, in screen coordinates (outer position). 1643 // - the position of the window, in screen coordinates (outer position).
1688 // - the size of the content area (inner size). 1644 // - the size of the content area (inner size).
1689 // We need to use these values to determine the appropriate size and 1645 // We need to use these values to determine the appropriate size and
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
2600 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) { 2556 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) {
2601 gfx::Point icon_bottom( 2557 gfx::Point icon_bottom(
2602 toolbar_->location_bar()->GetLocationBarAnchorPoint()); 2558 toolbar_->location_bar()->GetLocationBarAnchorPoint());
2603 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); 2559 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom);
2604 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); 2560 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL));
2605 ConvertPointToTarget(infobar_container_, this, &infobar_top); 2561 ConvertPointToTarget(infobar_container_, this, &infobar_top);
2606 top_arrow_height = infobar_top.y() - icon_bottom.y(); 2562 top_arrow_height = infobar_top.y() - icon_bottom.y();
2607 } 2563 }
2608 return top_arrow_height; 2564 return top_arrow_height;
2609 } 2565 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698