Chromium Code Reviews| 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 "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/app/chrome_dll_resource.h" | 10 #include "chrome/app/chrome_dll_resource.h" |
| 11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/signin/signin_header_helper.h" | 13 #include "chrome/browser/signin/signin_header_helper.h" |
| 14 #include "chrome/browser/themes/theme_properties.h" | 14 #include "chrome/browser/themes/theme_properties.h" |
| 15 #include "chrome/browser/ui/views/frame/browser_view.h" | 15 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 16 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" | 16 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" |
| 17 #include "chrome/browser/ui/views/profiles/new_avatar_button.h" | 17 #include "chrome/browser/ui/views/profiles/new_avatar_button.h" |
| 18 #include "chrome/browser/ui/views/tabs/tab.h" | 18 #include "chrome/browser/ui/views/tabs/tab.h" |
| 19 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 19 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| 20 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | 20 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
| 21 #include "components/signin/core/common/profile_management_switches.h" | 21 #include "components/signin/core/common/profile_management_switches.h" |
| 22 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
| 23 #include "grit/theme_resources.h" | 23 #include "grit/theme_resources.h" |
| 24 #include "skia/ext/image_operations.h" | |
| 24 #include "ui/base/resource/resource_bundle_win.h" | 25 #include "ui/base/resource/resource_bundle_win.h" |
| 25 #include "ui/base/theme_provider.h" | 26 #include "ui/base/theme_provider.h" |
| 26 #include "ui/gfx/canvas.h" | 27 #include "ui/gfx/canvas.h" |
| 27 #include "ui/gfx/icon_util.h" | 28 #include "ui/gfx/icon_util.h" |
| 28 #include "ui/gfx/image/image.h" | 29 #include "ui/gfx/image/image.h" |
| 29 #include "ui/gfx/win/dpi.h" | 30 #include "ui/gfx/win/dpi.h" |
| 30 #include "ui/resources/grit/ui_resources.h" | 31 #include "ui/resources/grit/ui_resources.h" |
| 31 #include "ui/views/controls/label.h" | 32 #include "ui/views/controls/label.h" |
| 32 #include "ui/views/layout/layout_constants.h" | 33 #include "ui/views/layout/layout_constants.h" |
| 33 #include "ui/views/win/hwnd_util.h" | 34 #include "ui/views/win/hwnd_util.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 // so we stop it when the gap between the two is down to 5 px. | 66 // so we stop it when the gap between the two is down to 5 px. |
| 66 const int kNewTabCaptionRestoredSpacing = 5; | 67 const int kNewTabCaptionRestoredSpacing = 5; |
| 67 // In maximized mode, where the New Tab button and the caption buttons are at | 68 // In maximized mode, where the New Tab button and the caption buttons are at |
| 68 // similar vertical coordinates, we need to reserve a larger, 16 px gap to avoid | 69 // similar vertical coordinates, we need to reserve a larger, 16 px gap to avoid |
| 69 // looking too cluttered. | 70 // looking too cluttered. |
| 70 const int kNewTabCaptionMaximizedSpacing = 16; | 71 const int kNewTabCaptionMaximizedSpacing = 16; |
| 71 // How far to indent the tabstrip from the left side of the screen when there | 72 // How far to indent the tabstrip from the left side of the screen when there |
| 72 // is no avatar icon. | 73 // is no avatar icon. |
| 73 const int kTabStripIndent = -6; | 74 const int kTabStripIndent = -6; |
| 74 | 75 |
| 76 HICON CreateHICONFromSkBitmap(const gfx::ImageSkia& image, int width, | |
|
sky
2014/12/11 15:51:23
Make sure to run git cl format.
sky
2014/12/11 15:51:23
Add description of this. Also, it should be rename
Tomasz Moniuszko
2014/12/12 11:47:07
Done.
Tomasz Moniuszko
2014/12/12 11:47:07
Done.
| |
| 77 int height) { | |
| 78 if (width == image.width() && height == image.height()) { | |
|
sky
2014/12/11 15:51:23
nit: no {}
Tomasz Moniuszko
2014/12/12 11:47:07
Done.
| |
| 79 return IconUtil::CreateHICONFromSkBitmap(*image.bitmap()); | |
| 80 } | |
| 81 return IconUtil::CreateHICONFromSkBitmap(skia::ImageOperations::Resize( | |
| 82 *image.bitmap(), skia::ImageOperations::RESIZE_BEST, width, height)); | |
| 83 } | |
| 84 | |
| 75 } // namespace | 85 } // namespace |
| 76 | 86 |
| 77 /////////////////////////////////////////////////////////////////////////////// | 87 /////////////////////////////////////////////////////////////////////////////// |
| 78 // GlassBrowserFrameView, public: | 88 // GlassBrowserFrameView, public: |
| 79 | 89 |
| 80 GlassBrowserFrameView::GlassBrowserFrameView(BrowserFrame* frame, | 90 GlassBrowserFrameView::GlassBrowserFrameView(BrowserFrame* frame, |
| 81 BrowserView* browser_view) | 91 BrowserView* browser_view) |
| 82 : BrowserNonClientFrameView(frame, browser_view), | 92 : BrowserNonClientFrameView(frame, browser_view), |
| 83 throbber_running_(false), | 93 throbber_running_(false), |
| 84 throbber_frame_(0) { | 94 throbber_frame_(0) { |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 532 SendMessage(views::HWNDForWidget(frame()), WM_SETICON, | 542 SendMessage(views::HWNDForWidget(frame()), WM_SETICON, |
| 533 static_cast<WPARAM>(ICON_SMALL), | 543 static_cast<WPARAM>(ICON_SMALL), |
| 534 reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_])); | 544 reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_])); |
| 535 } | 545 } |
| 536 } | 546 } |
| 537 | 547 |
| 538 void GlassBrowserFrameView::StopThrobber() { | 548 void GlassBrowserFrameView::StopThrobber() { |
| 539 if (throbber_running_) { | 549 if (throbber_running_) { |
| 540 throbber_running_ = false; | 550 throbber_running_ = false; |
| 541 | 551 |
| 542 HICON frame_icon = nullptr; | 552 HICON small_icon = nullptr; |
| 553 HICON big_icon = nullptr; | |
| 543 | 554 |
| 544 // Check if hosted BrowserView has a window icon to use. | 555 // Check if hosted BrowserView has a window icon to use. |
| 545 if (browser_view()->ShouldShowWindowIcon()) { | 556 if (browser_view()->ShouldShowWindowIcon()) { |
| 546 gfx::ImageSkia icon = browser_view()->GetWindowIcon(); | 557 gfx::ImageSkia icon = browser_view()->GetWindowIcon(); |
| 547 if (!icon.isNull()) | 558 if (!icon.isNull()) { |
| 548 frame_icon = IconUtil::CreateHICONFromSkBitmap(*icon.bitmap()); | 559 small_icon = CreateHICONFromSkBitmap( |
| 560 icon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON)); | |
| 561 big_icon = CreateHICONFromSkBitmap( | |
| 562 icon, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON)); | |
| 563 } | |
| 549 } | 564 } |
| 550 | 565 |
| 551 // Fallback to class icon. | 566 // Fallback to class icon. |
| 552 if (!frame_icon) { | 567 if (!small_icon) { |
| 553 frame_icon = reinterpret_cast<HICON>(GetClassLongPtr( | 568 small_icon = reinterpret_cast<HICON>(GetClassLongPtr( |
| 554 views::HWNDForWidget(frame()), GCLP_HICONSM)); | 569 views::HWNDForWidget(frame()), GCLP_HICONSM)); |
| 555 } | 570 } |
| 571 if (!big_icon) { | |
| 572 big_icon = reinterpret_cast<HICON>(GetClassLongPtr( | |
| 573 views::HWNDForWidget(frame()), GCLP_HICON)); | |
| 574 } | |
| 556 | 575 |
| 557 // This will reset the small icon which we set in the throbber code. | 576 // This will reset the icon which we set in the throbber code. |
| 558 // WM_SETICON with null icon restores the icon for title bar but not | 577 // WM_SETICON with null icon restores the icon for title bar but not |
| 559 // for taskbar. See http://crbug.com/29996 | 578 // for taskbar. See http://crbug.com/29996 |
| 560 SendMessage(views::HWNDForWidget(frame()), WM_SETICON, | 579 SendMessage(views::HWNDForWidget(frame()), WM_SETICON, |
| 561 static_cast<WPARAM>(ICON_SMALL), | 580 static_cast<WPARAM>(ICON_SMALL), |
| 562 reinterpret_cast<LPARAM>(frame_icon)); | 581 reinterpret_cast<LPARAM>(small_icon)); |
| 582 SendMessage(views::HWNDForWidget(frame()), WM_SETICON, | |
| 583 static_cast<WPARAM>(ICON_BIG), | |
| 584 reinterpret_cast<LPARAM>(big_icon)); | |
| 563 } | 585 } |
| 564 } | 586 } |
| 565 | 587 |
| 566 void GlassBrowserFrameView::DisplayNextThrobberFrame() { | 588 void GlassBrowserFrameView::DisplayNextThrobberFrame() { |
| 567 throbber_frame_ = (throbber_frame_ + 1) % kThrobberIconCount; | 589 throbber_frame_ = (throbber_frame_ + 1) % kThrobberIconCount; |
| 568 SendMessage(views::HWNDForWidget(frame()), WM_SETICON, | 590 SendMessage(views::HWNDForWidget(frame()), WM_SETICON, |
| 569 static_cast<WPARAM>(ICON_SMALL), | 591 static_cast<WPARAM>(ICON_SMALL), |
| 570 reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_])); | 592 reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_])); |
| 571 } | 593 } |
| 572 | 594 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 594 static bool initialized = false; | 616 static bool initialized = false; |
| 595 if (!initialized) { | 617 if (!initialized) { |
| 596 for (int i = 0; i < kThrobberIconCount; ++i) { | 618 for (int i = 0; i < kThrobberIconCount; ++i) { |
| 597 throbber_icons_[i] = | 619 throbber_icons_[i] = |
| 598 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); | 620 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); |
| 599 DCHECK(throbber_icons_[i]); | 621 DCHECK(throbber_icons_[i]); |
| 600 } | 622 } |
| 601 initialized = true; | 623 initialized = true; |
| 602 } | 624 } |
| 603 } | 625 } |
| OLD | NEW |