| 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 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(NotificationType type, |
| 520 const NotificationSource& source, | 521 const NotificationSource& source, |
| 521 const NotificationDetails& details) { | 522 const NotificationDetails& details) { |
| 522 switch (type.value) { | 523 switch (type.value) { |
| 523 case NotificationType::PROFILE_CACHED_INFO_CHANGED: | 524 case chrome::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 } |
| 532 >>>>>>> .r91766 |
| 531 } | 533 } |
| 532 | 534 |
| 533 // static | 535 // static |
| 534 void GlassBrowserFrameView::InitThrobberIcons() { | 536 void GlassBrowserFrameView::InitThrobberIcons() { |
| 535 static bool initialized = false; | 537 static bool initialized = false; |
| 536 if (!initialized) { | 538 if (!initialized) { |
| 537 ResourceBundle &rb = ResourceBundle::GetSharedInstance(); | 539 ResourceBundle &rb = ResourceBundle::GetSharedInstance(); |
| 538 for (int i = 0; i < kThrobberIconCount; ++i) { | 540 for (int i = 0; i < kThrobberIconCount; ++i) { |
| 539 throbber_icons_[i] = rb.LoadThemeIcon(IDI_THROBBER_01 + i); | 541 throbber_icons_[i] = rb.LoadThemeIcon(IDI_THROBBER_01 + i); |
| 540 DCHECK(throbber_icons_[i]); | 542 DCHECK(throbber_icons_[i]); |
| 541 } | 543 } |
| 542 initialized = true; | 544 initialized = true; |
| 543 } | 545 } |
| 544 } | 546 } |
| 545 | 547 |
| 546 void GlassBrowserFrameView::UpdateAvatarInfo() { | 548 void GlassBrowserFrameView::UpdateAvatarInfo() { |
| 547 if (browser_view_->IsOffTheRecord()) { | 549 if (browser_view_->IsOffTheRecord()) { |
| 548 avatar_button_->SetIcon(browser_view_->GetOTRAvatarIcon()); | 550 avatar_button_->SetIcon(browser_view_->GetOTRAvatarIcon()); |
| 549 } else { | 551 } else { |
| 550 ProfileInfoCache& cache = | 552 ProfileInfoCache& cache = |
| 551 g_browser_process->profile_manager()->GetProfileInfoCache(); | 553 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 552 Profile* profile = browser_view_->browser()->profile(); | 554 Profile* profile = browser_view_->browser()->profile(); |
| 553 size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath()); | 555 size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath()); |
| 554 if (index != std::string::npos) { | 556 if (index != std::string::npos) { |
| 555 avatar_button_->SetIcon(cache.GetAvatarIconOfProfileAtIndex(index)); | 557 avatar_button_->SetIcon(cache.GetAvatarIconOfProfileAtIndex(index)); |
| 556 avatar_button_->SetText(cache.GetNameOfProfileAtIndex(index)); | 558 avatar_button_->SetText(cache.GetNameOfProfileAtIndex(index)); |
| 557 } | 559 } |
| 558 } | 560 } |
| 559 } | 561 } |
| OLD | NEW |