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" | |
| 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(this, NewAvatarButton::NATIVE_BUTTON); |
| 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 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 587 } | 577 } |
| 588 } | 578 } |
| 589 | 579 |
| 590 void GlassBrowserFrameView::DisplayNextThrobberFrame() { | 580 void GlassBrowserFrameView::DisplayNextThrobberFrame() { |
| 591 throbber_frame_ = (throbber_frame_ + 1) % kThrobberIconCount; | 581 throbber_frame_ = (throbber_frame_ + 1) % kThrobberIconCount; |
| 592 SendMessage(views::HWNDForWidget(frame()), WM_SETICON, | 582 SendMessage(views::HWNDForWidget(frame()), WM_SETICON, |
| 593 static_cast<WPARAM>(ICON_SMALL), | 583 static_cast<WPARAM>(ICON_SMALL), |
| 594 reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_])); | 584 reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_])); |
| 595 } | 585 } |
| 596 | 586 |
| 597 void GlassBrowserFrameView::Observe( | 587 void GlassBrowserFrameView::OnProfileAdded(const base::FilePath& profile_path) { |
| 598 int type, | 588 UpdateAvatar(this, NewAvatarButton::NATIVE_BUTTON); |
|
sky
2015/02/19 15:59:36
The new code for all this looks quite a bit differ
noms (inactive)
2015/02/19 16:07:19
Oof, that's some misplaced confidence :)
Jokes as
| |
| 599 const content::NotificationSource& source, | 589 } |
| 600 const content::NotificationDetails& details) { | 590 |
| 601 switch (type) { | 591 void GlassBrowserFrameView::OnProfileWasRemoved( |
| 602 case chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED: | 592 const base::FilePath& profile_path, |
| 603 if (browser_view()->IsRegularOrGuestSession() && | 593 const base::string16& profile_name) { |
| 604 switches::IsNewAvatarMenu()) { | 594 UpdateAvatar(this, NewAvatarButton::NATIVE_BUTTON); |
| 605 UpdateNewStyleAvatarInfo(this, NewAvatarButton::NATIVE_BUTTON); | 595 } |
| 606 } else { | 596 |
| 607 UpdateAvatarInfo(); | 597 void GlassBrowserFrameView::OnProfileNameChanged( |
| 608 } | 598 const base::FilePath& profile_path, |
| 609 break; | 599 const base::string16& old_profile_name) { |
| 610 default: | 600 UpdateAvatar(this, NewAvatarButton::NATIVE_BUTTON); |
| 611 NOTREACHED() << "Got a notification we didn't register for!"; | 601 } |
| 612 break; | 602 |
| 613 } | 603 void GlassBrowserFrameView::OnProfileAvatarChanged( |
| 604 const base::FilePath& profile_path) { | |
| 605 // Profile avatars are only displayed in the old UI or incognito. | |
| 606 if (browser_view()->IsOffTheRecord() || !switches::IsNewAvatarMenu()) | |
|
sky
2015/02/19 15:59:36
Seems silly to duplicate code like this between gl
noms (inactive)
2015/02/19 16:07:19
Do you think BrowserNonClientFrameView would be a
sky
2015/02/19 16:09:18
I was assuming you didn't want this for ash, in wh
noms (inactive)
2015/02/19 16:11:49
Oh Ash has this button too (Metro mode, not Chrome
noms
2015/02/20 21:24:34
Ok, done. I still had to override a method, as the
| |
| 607 UpdateAvatarInfo(); | |
| 614 } | 608 } |
| 615 | 609 |
| 616 // static | 610 // static |
| 617 void GlassBrowserFrameView::InitThrobberIcons() { | 611 void GlassBrowserFrameView::InitThrobberIcons() { |
| 618 static bool initialized = false; | 612 static bool initialized = false; |
| 619 if (!initialized) { | 613 if (!initialized) { |
| 620 for (int i = 0; i < kThrobberIconCount; ++i) { | 614 for (int i = 0; i < kThrobberIconCount; ++i) { |
| 621 throbber_icons_[i] = | 615 throbber_icons_[i] = |
| 622 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); | 616 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); |
| 623 DCHECK(throbber_icons_[i]); | 617 DCHECK(throbber_icons_[i]); |
| 624 } | 618 } |
| 625 initialized = true; | 619 initialized = true; |
| 626 } | 620 } |
| 627 } | 621 } |
| OLD | NEW |