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/glass_browser_frame_view.h" | 5 #include "chrome/browser/ui/views/frame/glass_browser_frame_view.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "base/win/windows_version.h" | 9 #include "base/win/windows_version.h" |
10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 // frame has a 0 frame border around most edges and a CYSIZEFRAME-thick border | 296 // frame has a 0 frame border around most edges and a CYSIZEFRAME-thick border |
297 // at the top (see AeroGlassFrame::OnGetMinMaxInfo()). | 297 // at the top (see AeroGlassFrame::OnGetMinMaxInfo()). |
298 return (frame()->IsFullscreen() && !restored) ? | 298 return (frame()->IsFullscreen() && !restored) ? |
299 0 : gfx::win::GetSystemMetricsInDIP(SM_CYSIZEFRAME); | 299 0 : gfx::win::GetSystemMetricsInDIP(SM_CYSIZEFRAME); |
300 } | 300 } |
301 | 301 |
302 int GlassBrowserFrameView::NonClientBorderThickness(bool restored) const { | 302 int GlassBrowserFrameView::NonClientBorderThickness(bool restored) const { |
303 if ((frame()->IsMaximized() || frame()->IsFullscreen()) && !restored) | 303 if ((frame()->IsMaximized() || frame()->IsFullscreen()) && !restored) |
304 return 0; | 304 return 0; |
305 | 305 |
306 return (base::win::GetVersion() <= base::win::VERSION_WIN8_1) | 306 return (base::win::GetVersion() < base::win::VERSION_WIN10) |
307 ? kNonClientBorderThicknessPreWin10 | 307 ? kNonClientBorderThicknessPreWin10 |
308 : kNonClientBorderThicknessWin10; | 308 : kNonClientBorderThicknessWin10; |
309 } | 309 } |
310 | 310 |
311 int GlassBrowserFrameView::NonClientTopBorderHeight(bool restored) const { | 311 int GlassBrowserFrameView::NonClientTopBorderHeight(bool restored) const { |
312 if (frame()->IsFullscreen() && !restored) | 312 if (frame()->IsFullscreen() && !restored) |
313 return 0; | 313 return 0; |
314 | 314 |
315 const int top = FrameTopBorderHeight(restored); | 315 const int top = FrameTopBorderHeight(restored); |
316 // The tab top inset is equal to the height of any shadow region above the | 316 // The tab top inset is equal to the height of any shadow region above the |
317 // tabs, plus a 1 px top stroke. In maximized mode, we want to push the | 317 // tabs, plus a 1 px top stroke. In maximized mode, we want to push the |
318 // shadow region off the top of the screen but leave the top stroke. | 318 // shadow region off the top of the screen but leave the top stroke. |
319 // Annoyingly, the pre-MD layout uses different heights for the hit-test | 319 // Annoyingly, the pre-MD layout uses different heights for the hit-test |
320 // exclusion region (which we want here, since we're trying to size the border | 320 // exclusion region (which we want here, since we're trying to size the border |
321 // so that the region above the tab's hit-test zone matches) versus the shadow | 321 // so that the region above the tab's hit-test zone matches) versus the shadow |
322 // thickness. | 322 // thickness. |
323 const int exclusion = GetLayoutConstant(TAB_TOP_EXCLUSION_HEIGHT); | 323 const int exclusion = GetLayoutConstant(TAB_TOP_EXCLUSION_HEIGHT); |
324 return (frame()->IsMaximized() && !restored) ? | 324 return (frame()->IsMaximized() && !restored) ? |
325 (top - GetLayoutInsets(TAB).top() + 1) : | 325 (top - GetLayoutInsets(TAB).top() + 1) : |
326 (top + kNonClientRestoredExtraThickness - exclusion); | 326 (top + kNonClientRestoredExtraThickness - exclusion); |
327 } | 327 } |
328 | 328 |
329 bool GlassBrowserFrameView::IsToolbarVisible() const { | 329 bool GlassBrowserFrameView::IsToolbarVisible() const { |
330 return browser_view()->IsToolbarVisible() && | 330 return browser_view()->IsToolbarVisible() && |
331 !browser_view()->toolbar()->GetPreferredSize().IsEmpty(); | 331 !browser_view()->toolbar()->GetPreferredSize().IsEmpty(); |
332 } | 332 } |
333 | 333 |
334 void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { | 334 void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) const { |
335 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); | 335 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); |
336 if (toolbar_bounds.IsEmpty()) | 336 if (toolbar_bounds.IsEmpty()) |
337 return; | 337 return; |
338 gfx::Point toolbar_origin(toolbar_bounds.origin()); | 338 gfx::Point toolbar_origin(toolbar_bounds.origin()); |
339 ConvertPointToTarget(browser_view(), this, &toolbar_origin); | 339 ConvertPointToTarget(browser_view(), this, &toolbar_origin); |
340 toolbar_bounds.set_origin(toolbar_origin); | 340 toolbar_bounds.set_origin(toolbar_origin); |
341 const int h = toolbar_bounds.height(); | 341 const int h = toolbar_bounds.height(); |
342 const bool md = ui::MaterialDesignController::IsModeMaterial(); | 342 const bool md = ui::MaterialDesignController::IsModeMaterial(); |
343 const ui::ThemeProvider* tp = GetThemeProvider(); | 343 const ui::ThemeProvider* tp = GetThemeProvider(); |
344 const SkColor separator_color = | 344 const SkColor separator_color = |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 toolbar_bounds.Inset(kClientEdgeThickness, h - kClientEdgeThickness, | 429 toolbar_bounds.Inset(kClientEdgeThickness, h - kClientEdgeThickness, |
430 kClientEdgeThickness, 0); | 430 kClientEdgeThickness, 0); |
431 if (md) { | 431 if (md) { |
432 BrowserView::Paint1pxHorizontalLine(canvas, separator_color, | 432 BrowserView::Paint1pxHorizontalLine(canvas, separator_color, |
433 toolbar_bounds, true); | 433 toolbar_bounds, true); |
434 } else { | 434 } else { |
435 canvas->FillRect(toolbar_bounds, separator_color); | 435 canvas->FillRect(toolbar_bounds, separator_color); |
436 } | 436 } |
437 } | 437 } |
438 | 438 |
439 void GlassBrowserFrameView::PaintClientEdge(gfx::Canvas* canvas) { | 439 void GlassBrowserFrameView::PaintClientEdge(gfx::Canvas* canvas) const { |
440 gfx::Rect client_bounds = CalculateClientAreaBounds(); | 440 gfx::Rect client_bounds = CalculateClientAreaBounds(); |
441 int y = client_bounds.y(); | 441 int y = client_bounds.y(); |
442 const bool normal_mode = browser_view()->IsTabStripVisible(); | 442 const bool normal_mode = browser_view()->IsTabStripVisible(); |
443 const ui::ThemeProvider* tp = GetThemeProvider(); | 443 const ui::ThemeProvider* tp = GetThemeProvider(); |
444 const SkColor toolbar_color = | 444 const SkColor toolbar_color = |
445 normal_mode | 445 normal_mode |
446 ? tp->GetColor(ThemeProperties::COLOR_TOOLBAR) | 446 ? tp->GetColor(ThemeProperties::COLOR_TOOLBAR) |
447 : ThemeProperties::GetDefaultColor(ThemeProperties::COLOR_TOOLBAR, | 447 : ThemeProperties::GetDefaultColor(ThemeProperties::COLOR_TOOLBAR, |
448 browser_view()->IsOffTheRecord()); | 448 browser_view()->IsOffTheRecord()); |
449 | 449 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 static bool initialized = false; | 674 static bool initialized = false; |
675 if (!initialized) { | 675 if (!initialized) { |
676 for (int i = 0; i < kThrobberIconCount; ++i) { | 676 for (int i = 0; i < kThrobberIconCount; ++i) { |
677 throbber_icons_[i] = | 677 throbber_icons_[i] = |
678 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); | 678 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); |
679 DCHECK(throbber_icons_[i]); | 679 DCHECK(throbber_icons_[i]); |
680 } | 680 } |
681 initialized = true; | 681 initialized = true; |
682 } | 682 } |
683 } | 683 } |
OLD | NEW |