| 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_desktop_window_tree_host_win.h" | 5 #include "chrome/browser/ui/views/frame/browser_desktop_window_tree_host_win.h" |
| 6 | 6 |
| 7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/process/process_handle.h" | 10 #include "base/process/process_handle.h" |
| 11 #include "base/win/windows_version.h" | 11 #include "base/win/windows_version.h" |
| 12 #include "chrome/browser/lifetime/application_lifetime.h" | 12 #include "chrome/browser/lifetime/application_lifetime.h" |
| 13 #include "chrome/browser/themes/theme_service.h" | 13 #include "chrome/browser/themes/theme_service.h" |
| 14 #include "chrome/browser/themes/theme_service_factory.h" | 14 #include "chrome/browser/themes/theme_service_factory.h" |
| 15 #include "chrome/browser/ui/views/frame/browser_frame.h" | 15 #include "chrome/browser/ui/views/frame/browser_frame.h" |
| 16 #include "chrome/browser/ui/views/frame/browser_frame_common_win.h" | 16 #include "chrome/browser/ui/views/frame/browser_frame_common_win.h" |
| 17 #include "chrome/browser/ui/views/frame/browser_view.h" | 17 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 18 #include "chrome/browser/ui/views/frame/browser_window_property_manager_win.h" | 18 #include "chrome/browser/ui/views/frame/browser_window_property_manager_win.h" |
| 19 #include "chrome/browser/ui/views/frame/system_menu_insertion_delegate_win.h" | 19 #include "chrome/browser/ui/views/frame/system_menu_insertion_delegate_win.h" |
| 20 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 20 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| 21 #include "chrome/browser/ui/views/theme_image_mapper.h" | 21 #include "chrome/browser/ui/views/theme_image_mapper.h" |
| 22 #include "chrome/common/chrome_constants.h" | 22 #include "chrome/common/chrome_constants.h" |
| 23 #include "ui/base/theme_provider.h" | 23 #include "ui/base/theme_provider.h" |
| 24 #include "ui/gfx/win/dpi.h" | 24 #include "ui/gfx/screen_win.h" |
| 25 #include "ui/views/controls/menu/native_menu_win.h" | 25 #include "ui/views/controls/menu/native_menu_win.h" |
| 26 | 26 |
| 27 #pragma comment(lib, "dwmapi.lib") | 27 #pragma comment(lib, "dwmapi.lib") |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 const int kClientEdgeThickness = 3; | 31 const int kClientEdgeThickness = 3; |
| 32 | 32 |
| 33 // DesktopThemeProvider maps resource ids using MapThemeImage(). This is | 33 // DesktopThemeProvider maps resource ids using MapThemeImage(). This is |
| 34 // necessary for BrowserDesktopWindowTreeHostWin so that it uses the windows | 34 // necessary for BrowserDesktopWindowTreeHostWin so that it uses the windows |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 margins.cxLeftWidth = kClientEdgeThickness + 1; | 311 margins.cxLeftWidth = kClientEdgeThickness + 1; |
| 312 margins.cxRightWidth = kClientEdgeThickness + 1; | 312 margins.cxRightWidth = kClientEdgeThickness + 1; |
| 313 margins.cyBottomHeight = kClientEdgeThickness + 1; | 313 margins.cyBottomHeight = kClientEdgeThickness + 1; |
| 314 } | 314 } |
| 315 } | 315 } |
| 316 // In maximized mode, we only have a titlebar strip of glass, no side/bottom | 316 // In maximized mode, we only have a titlebar strip of glass, no side/bottom |
| 317 // borders. | 317 // borders. |
| 318 if (!browser_view_->IsFullscreen()) { | 318 if (!browser_view_->IsFullscreen()) { |
| 319 gfx::Rect tabstrip_bounds( | 319 gfx::Rect tabstrip_bounds( |
| 320 browser_frame_->GetBoundsForTabStrip(browser_view_->tabstrip())); | 320 browser_frame_->GetBoundsForTabStrip(browser_view_->tabstrip())); |
| 321 tabstrip_bounds = gfx::win::DIPToScreenRect(tabstrip_bounds); | 321 tabstrip_bounds = gfx::ScreenWin::DIPToClientRect(GetHWND(), |
| 322 tabstrip_bounds); |
| 322 margins.cyTopHeight = tabstrip_bounds.bottom(); | 323 margins.cyTopHeight = tabstrip_bounds.bottom(); |
| 323 | 324 |
| 324 // On pre-Win 10, we need to offset the DWM frame into the toolbar so that | 325 // On pre-Win 10, we need to offset the DWM frame into the toolbar so that |
| 325 // the blackness doesn't show up on our rounded toolbar corners. In Win | 326 // the blackness doesn't show up on our rounded toolbar corners. In Win |
| 326 // 10 and above there are no rounded corners, so this is unnecessary. | 327 // 10 and above there are no rounded corners, so this is unnecessary. |
| 327 const int kDWMFrameTopOffset = 3; | 328 const int kDWMFrameTopOffset = 3; |
| 328 if (base::win::GetVersion() < base::win::VERSION_WIN10) | 329 if (base::win::GetVersion() < base::win::VERSION_WIN10) |
| 329 margins.cyTopHeight += kDWMFrameTopOffset; | 330 margins.cyTopHeight += kDWMFrameTopOffset; |
| 330 } | 331 } |
| 331 } | 332 } |
| 332 return margins; | 333 return margins; |
| 333 } | 334 } |
| 334 | 335 |
| 335 //////////////////////////////////////////////////////////////////////////////// | 336 //////////////////////////////////////////////////////////////////////////////// |
| 336 // BrowserDesktopWindowTreeHost, public: | 337 // BrowserDesktopWindowTreeHost, public: |
| 337 | 338 |
| 338 // static | 339 // static |
| 339 BrowserDesktopWindowTreeHost* | 340 BrowserDesktopWindowTreeHost* |
| 340 BrowserDesktopWindowTreeHost::CreateBrowserDesktopWindowTreeHost( | 341 BrowserDesktopWindowTreeHost::CreateBrowserDesktopWindowTreeHost( |
| 341 views::internal::NativeWidgetDelegate* native_widget_delegate, | 342 views::internal::NativeWidgetDelegate* native_widget_delegate, |
| 342 views::DesktopNativeWidgetAura* desktop_native_widget_aura, | 343 views::DesktopNativeWidgetAura* desktop_native_widget_aura, |
| 343 BrowserView* browser_view, | 344 BrowserView* browser_view, |
| 344 BrowserFrame* browser_frame) { | 345 BrowserFrame* browser_frame) { |
| 345 return new BrowserDesktopWindowTreeHostWin(native_widget_delegate, | 346 return new BrowserDesktopWindowTreeHostWin(native_widget_delegate, |
| 346 desktop_native_widget_aura, | 347 desktop_native_widget_aura, |
| 347 browser_view, | 348 browser_view, |
| 348 browser_frame); | 349 browser_frame); |
| 349 } | 350 } |
| OLD | NEW |