| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/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/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/prefs/pref_service.h" | 12 #include "chrome/browser/prefs/pref_service.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/profiles/profile_info_cache.h" | 14 #include "chrome/browser/profiles/profile_info_cache.h" |
| 15 #include "chrome/browser/profiles/profile_manager.h" | 15 #include "chrome/browser/profiles/profile_manager.h" |
| 16 #include "chrome/browser/themes/theme_service.h" | 16 #include "chrome/browser/themes/theme_service.h" |
| 17 #include "chrome/browser/ui/profile_menu_model.h" | 17 #include "chrome/browser/ui/profile_menu_model.h" |
| 18 #include "chrome/browser/ui/views/avatar_menu_button.h" | 18 #include "chrome/browser/ui/views/avatar_menu_button.h" |
| 19 #include "chrome/browser/ui/views/frame/browser_view.h" | 19 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 20 #include "chrome/browser/ui/views/tabs/side_tab_strip.h" | 20 #include "chrome/browser/ui/views/tabs/side_tab_strip.h" |
| 21 #include "chrome/browser/ui/views/tabs/tab.h" | 21 #include "chrome/browser/ui/views/tabs/tab.h" |
| 22 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 22 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| 23 #include "chrome/common/chrome_notification_types.h" |
| 23 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
| 24 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
| 25 #include "content/common/notification_service.h" | 26 #include "content/common/notification_service.h" |
| 26 #include "grit/generated_resources.h" | 27 #include "grit/generated_resources.h" |
| 27 #include "grit/theme_resources.h" | 28 #include "grit/theme_resources.h" |
| 28 #include "grit/theme_resources_standard.h" | 29 #include "grit/theme_resources_standard.h" |
| 29 #include "grit/ui_resources.h" | 30 #include "grit/ui_resources.h" |
| 30 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
| 31 #include "ui/base/resource/resource_bundle.h" | 32 #include "ui/base/resource/resource_bundle.h" |
| 32 #include "ui/base/theme_provider.h" | 33 #include "ui/base/theme_provider.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 InitThrobberIcons(); | 87 InitThrobberIcons(); |
| 87 | 88 |
| 88 if (browser_view_->ShouldShowAvatar()) { | 89 if (browser_view_->ShouldShowAvatar()) { |
| 89 ui::MenuModel* menu_model = browser_view_->IsOffTheRecord() ? | 90 ui::MenuModel* menu_model = browser_view_->IsOffTheRecord() ? |
| 90 NULL : new ProfileMenuModel(browser_view_->browser()); | 91 NULL : new ProfileMenuModel(browser_view_->browser()); |
| 91 // AvatarMenuButton takes ownership of |menu_model|. | 92 // AvatarMenuButton takes ownership of |menu_model|. |
| 92 avatar_button_.reset(new AvatarMenuButton(std::wstring(), menu_model)); | 93 avatar_button_.reset(new AvatarMenuButton(std::wstring(), menu_model)); |
| 93 AddChildView(avatar_button_.get()); | 94 AddChildView(avatar_button_.get()); |
| 94 UpdateAvatarInfo(); | 95 UpdateAvatarInfo(); |
| 95 if (!browser_view_->IsOffTheRecord()) { | 96 if (!browser_view_->IsOffTheRecord()) { |
| 96 registrar_.Add(this, NotificationType::PROFILE_CACHED_INFO_CHANGED, | 97 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, |
| 97 NotificationService::AllSources()); | 98 NotificationService::AllSources()); |
| 98 } | 99 } |
| 99 } | 100 } |
| 100 } | 101 } |
| 101 | 102 |
| 102 GlassBrowserFrameView::~GlassBrowserFrameView() { | 103 GlassBrowserFrameView::~GlassBrowserFrameView() { |
| 103 } | 104 } |
| 104 | 105 |
| 105 /////////////////////////////////////////////////////////////////////////////// | 106 /////////////////////////////////////////////////////////////////////////////// |
| 106 // GlassBrowserFrameView, BrowserNonClientFrameView implementation: | 107 // GlassBrowserFrameView, BrowserNonClientFrameView implementation: |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 } | 510 } |
| 510 } | 511 } |
| 511 | 512 |
| 512 void GlassBrowserFrameView::DisplayNextThrobberFrame() { | 513 void GlassBrowserFrameView::DisplayNextThrobberFrame() { |
| 513 throbber_frame_ = (throbber_frame_ + 1) % kThrobberIconCount; | 514 throbber_frame_ = (throbber_frame_ + 1) % kThrobberIconCount; |
| 514 SendMessage(frame_->GetNativeWindow(), WM_SETICON, | 515 SendMessage(frame_->GetNativeWindow(), WM_SETICON, |
| 515 static_cast<WPARAM>(ICON_SMALL), | 516 static_cast<WPARAM>(ICON_SMALL), |
| 516 reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_])); | 517 reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_])); |
| 517 } | 518 } |
| 518 | 519 |
| 519 void GlassBrowserFrameView::Observe(NotificationType type, | 520 void GlassBrowserFrameView::Observe(int type, |
| 520 const NotificationSource& source, | 521 const NotificationSource& source, |
| 521 const NotificationDetails& details) { | 522 const NotificationDetails& details) { |
| 522 switch (type.value) { | 523 switch (type) { |
| 523 case NotificationType::PROFILE_CACHED_INFO_CHANGED: | 524 case chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED: |
| 524 UpdateAvatarInfo(); | 525 UpdateAvatarInfo(); |
| 525 LayoutAvatar(); | 526 LayoutAvatar(); |
| 526 break; | 527 break; |
| 527 default: | 528 default: |
| 528 NOTREACHED() << "Got a notification we didn't register for!"; | 529 NOTREACHED() << "Got a notification we didn't register for!"; |
| 529 break; | 530 break; |
| 530 } | 531 } |
| 531 } | 532 } |
| 532 | 533 |
| 533 // static | 534 // static |
| (...skipping 16 matching lines...) Expand all Loading... |
| 550 ProfileInfoCache& cache = | 551 ProfileInfoCache& cache = |
| 551 g_browser_process->profile_manager()->GetProfileInfoCache(); | 552 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 552 Profile* profile = browser_view_->browser()->profile(); | 553 Profile* profile = browser_view_->browser()->profile(); |
| 553 size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath()); | 554 size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath()); |
| 554 if (index != std::string::npos) { | 555 if (index != std::string::npos) { |
| 555 avatar_button_->SetIcon(cache.GetAvatarIconOfProfileAtIndex(index)); | 556 avatar_button_->SetIcon(cache.GetAvatarIconOfProfileAtIndex(index)); |
| 556 avatar_button_->SetText(cache.GetNameOfProfileAtIndex(index)); | 557 avatar_button_->SetText(cache.GetNameOfProfileAtIndex(index)); |
| 557 } | 558 } |
| 558 } | 559 } |
| 559 } | 560 } |
| OLD | NEW |