| 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" | |
| 12 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/signin/signin_header_helper.h" | 12 #include "chrome/browser/signin/signin_header_helper.h" |
| 14 #include "chrome/browser/themes/theme_properties.h" | 13 #include "chrome/browser/themes/theme_properties.h" |
| 15 #include "chrome/browser/ui/views/frame/browser_view.h" | 14 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 16 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" | 15 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" |
| 17 #include "chrome/browser/ui/views/profiles/new_avatar_button.h" | 16 #include "chrome/browser/ui/views/profiles/new_avatar_button.h" |
| 18 #include "chrome/browser/ui/views/tabs/tab.h" | 17 #include "chrome/browser/ui/views/tabs/tab.h" |
| 19 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 18 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| 20 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | 19 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
| 21 #include "components/signin/core/common/profile_management_switches.h" | 20 #include "components/signin/core/common/profile_management_switches.h" |
| 22 #include "content/public/browser/notification_service.h" | |
| 23 #include "grit/theme_resources.h" | 21 #include "grit/theme_resources.h" |
| 24 #include "skia/ext/image_operations.h" | 22 #include "skia/ext/image_operations.h" |
| 25 #include "ui/base/resource/resource_bundle_win.h" | 23 #include "ui/base/resource/resource_bundle_win.h" |
| 26 #include "ui/base/theme_provider.h" | 24 #include "ui/base/theme_provider.h" |
| 27 #include "ui/gfx/canvas.h" | 25 #include "ui/gfx/canvas.h" |
| 28 #include "ui/gfx/icon_util.h" | 26 #include "ui/gfx/icon_util.h" |
| 29 #include "ui/gfx/image/image.h" | 27 #include "ui/gfx/image/image.h" |
| 30 #include "ui/gfx/win/dpi.h" | 28 #include "ui/gfx/win/dpi.h" |
| 31 #include "ui/resources/grit/ui_resources.h" | 29 #include "ui/resources/grit/ui_resources.h" |
| 32 #include "ui/views/controls/label.h" | 30 #include "ui/views/controls/label.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 // GlassBrowserFrameView, public: | 88 // GlassBrowserFrameView, public: |
| 91 | 89 |
| 92 GlassBrowserFrameView::GlassBrowserFrameView(BrowserFrame* frame, | 90 GlassBrowserFrameView::GlassBrowserFrameView(BrowserFrame* frame, |
| 93 BrowserView* browser_view) | 91 BrowserView* browser_view) |
| 94 : BrowserNonClientFrameView(frame, browser_view), | 92 : BrowserNonClientFrameView(frame, browser_view), |
| 95 throbber_running_(false), | 93 throbber_running_(false), |
| 96 throbber_frame_(0) { | 94 throbber_frame_(0) { |
| 97 if (browser_view->ShouldShowWindowIcon()) | 95 if (browser_view->ShouldShowWindowIcon()) |
| 98 InitThrobberIcons(); | 96 InitThrobberIcons(); |
| 99 | 97 |
| 100 if (browser_view->IsRegularOrGuestSession() && switches::IsNewAvatarMenu()) | 98 UpdateAvatar(); |
| 101 UpdateNewStyleAvatarInfo(this, NewAvatarButton::NATIVE_BUTTON); | |
| 102 else | |
| 103 UpdateAvatarInfo(); | |
| 104 | |
| 105 if (!browser_view->IsOffTheRecord()) { | |
| 106 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, | |
| 107 content::NotificationService::AllSources()); | |
| 108 } | |
| 109 } | 99 } |
| 110 | 100 |
| 111 GlassBrowserFrameView::~GlassBrowserFrameView() { | 101 GlassBrowserFrameView::~GlassBrowserFrameView() { |
| 112 } | 102 } |
| 113 | 103 |
| 114 /////////////////////////////////////////////////////////////////////////////// | 104 /////////////////////////////////////////////////////////////////////////////// |
| 115 // GlassBrowserFrameView, BrowserNonClientFrameView implementation: | 105 // GlassBrowserFrameView, BrowserNonClientFrameView implementation: |
| 116 | 106 |
| 117 gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip( | 107 gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip( |
| 118 views::View* tabstrip) const { | 108 views::View* tabstrip) const { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 TabStrip* tabstrip = browser_view()->tabstrip(); | 185 TabStrip* tabstrip = browser_view()->tabstrip(); |
| 196 int min_tabstrip_width = tabstrip->GetMinimumSize().width(); | 186 int min_tabstrip_width = tabstrip->GetMinimumSize().width(); |
| 197 int min_tabstrip_area_width = | 187 int min_tabstrip_area_width = |
| 198 width() - GetBoundsForTabStrip(tabstrip).width() + min_tabstrip_width; | 188 width() - GetBoundsForTabStrip(tabstrip).width() + min_tabstrip_width; |
| 199 min_size.set_width(std::max(min_tabstrip_area_width, min_size.width())); | 189 min_size.set_width(std::max(min_tabstrip_area_width, min_size.width())); |
| 200 } | 190 } |
| 201 | 191 |
| 202 return min_size; | 192 return min_size; |
| 203 } | 193 } |
| 204 | 194 |
| 195 void GlassBrowserFrameView::UpdateNewStyleAvatar() { |
| 196 UpdateNewStyleAvatarInfo(this, NewAvatarButton::NATIVE_BUTTON); |
| 197 } |
| 198 |
| 205 /////////////////////////////////////////////////////////////////////////////// | 199 /////////////////////////////////////////////////////////////////////////////// |
| 206 // GlassBrowserFrameView, views::NonClientFrameView implementation: | 200 // GlassBrowserFrameView, views::NonClientFrameView implementation: |
| 207 | 201 |
| 208 gfx::Rect GlassBrowserFrameView::GetBoundsForClientView() const { | 202 gfx::Rect GlassBrowserFrameView::GetBoundsForClientView() const { |
| 209 return client_view_bounds_; | 203 return client_view_bounds_; |
| 210 } | 204 } |
| 211 | 205 |
| 212 gfx::Rect GlassBrowserFrameView::GetWindowBoundsForClientBounds( | 206 gfx::Rect GlassBrowserFrameView::GetWindowBoundsForClientBounds( |
| 213 const gfx::Rect& client_bounds) const { | 207 const gfx::Rect& client_bounds) const { |
| 214 HWND hwnd = views::HWNDForWidget(frame()); | 208 HWND hwnd = views::HWNDForWidget(frame()); |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 } | 581 } |
| 588 } | 582 } |
| 589 | 583 |
| 590 void GlassBrowserFrameView::DisplayNextThrobberFrame() { | 584 void GlassBrowserFrameView::DisplayNextThrobberFrame() { |
| 591 throbber_frame_ = (throbber_frame_ + 1) % kThrobberIconCount; | 585 throbber_frame_ = (throbber_frame_ + 1) % kThrobberIconCount; |
| 592 SendMessage(views::HWNDForWidget(frame()), WM_SETICON, | 586 SendMessage(views::HWNDForWidget(frame()), WM_SETICON, |
| 593 static_cast<WPARAM>(ICON_SMALL), | 587 static_cast<WPARAM>(ICON_SMALL), |
| 594 reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_])); | 588 reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_])); |
| 595 } | 589 } |
| 596 | 590 |
| 597 void GlassBrowserFrameView::Observe( | |
| 598 int type, | |
| 599 const content::NotificationSource& source, | |
| 600 const content::NotificationDetails& details) { | |
| 601 switch (type) { | |
| 602 case chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED: | |
| 603 if (browser_view()->IsRegularOrGuestSession() && | |
| 604 switches::IsNewAvatarMenu()) { | |
| 605 UpdateNewStyleAvatarInfo(this, NewAvatarButton::NATIVE_BUTTON); | |
| 606 } else { | |
| 607 UpdateAvatarInfo(); | |
| 608 } | |
| 609 break; | |
| 610 default: | |
| 611 NOTREACHED() << "Got a notification we didn't register for!"; | |
| 612 break; | |
| 613 } | |
| 614 } | |
| 615 | |
| 616 // static | 591 // static |
| 617 void GlassBrowserFrameView::InitThrobberIcons() { | 592 void GlassBrowserFrameView::InitThrobberIcons() { |
| 618 static bool initialized = false; | 593 static bool initialized = false; |
| 619 if (!initialized) { | 594 if (!initialized) { |
| 620 for (int i = 0; i < kThrobberIconCount; ++i) { | 595 for (int i = 0; i < kThrobberIconCount; ++i) { |
| 621 throbber_icons_[i] = | 596 throbber_icons_[i] = |
| 622 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); | 597 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); |
| 623 DCHECK(throbber_icons_[i]); | 598 DCHECK(throbber_icons_[i]); |
| 624 } | 599 } |
| 625 initialized = true; | 600 initialized = true; |
| 626 } | 601 } |
| 627 } | 602 } |
| OLD | NEW |