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" | |
18 #include "chrome/browser/ui/views/avatar_menu_button.h" | 17 #include "chrome/browser/ui/views/avatar_menu_button.h" |
19 #include "chrome/browser/ui/views/frame/browser_view.h" | 18 #include "chrome/browser/ui/views/frame/browser_view.h" |
20 #include "chrome/browser/ui/views/tabs/side_tab_strip.h" | 19 #include "chrome/browser/ui/views/tabs/side_tab_strip.h" |
21 #include "chrome/browser/ui/views/tabs/tab.h" | 20 #include "chrome/browser/ui/views/tabs/tab.h" |
22 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 21 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
23 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
24 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
25 #include "content/common/notification_service.h" | 24 #include "content/common/notification_service.h" |
26 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
27 #include "grit/theme_resources.h" | 26 #include "grit/theme_resources.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 BrowserView* browser_view) | 78 BrowserView* browser_view) |
80 : BrowserNonClientFrameView(), | 79 : BrowserNonClientFrameView(), |
81 frame_(frame), | 80 frame_(frame), |
82 browser_view_(browser_view), | 81 browser_view_(browser_view), |
83 throbber_running_(false), | 82 throbber_running_(false), |
84 throbber_frame_(0) { | 83 throbber_frame_(0) { |
85 if (browser_view_->ShouldShowWindowIcon()) | 84 if (browser_view_->ShouldShowWindowIcon()) |
86 InitThrobberIcons(); | 85 InitThrobberIcons(); |
87 | 86 |
88 if (browser_view_->ShouldShowAvatar()) { | 87 if (browser_view_->ShouldShowAvatar()) { |
89 ui::MenuModel* menu_model = browser_view_->IsOffTheRecord() ? | 88 avatar_button_.reset(new AvatarMenuButton( |
90 NULL : new ProfileMenuModel(browser_view_->browser()); | 89 browser_view_->browser(), !browser_view_->IsOffTheRecord())); |
91 // AvatarMenuButton takes ownership of |menu_model|. | |
92 avatar_button_.reset(new AvatarMenuButton(std::wstring(), menu_model)); | |
93 AddChildView(avatar_button_.get()); | 90 AddChildView(avatar_button_.get()); |
94 UpdateAvatarInfo(); | 91 UpdateAvatarInfo(); |
95 if (!browser_view_->IsOffTheRecord()) { | 92 if (!browser_view_->IsOffTheRecord()) { |
96 registrar_.Add(this, NotificationType::PROFILE_CACHED_INFO_CHANGED, | 93 registrar_.Add(this, NotificationType::PROFILE_CACHED_INFO_CHANGED, |
97 NotificationService::AllSources()); | 94 NotificationService::AllSources()); |
98 } | 95 } |
99 } | 96 } |
100 } | 97 } |
101 | 98 |
102 GlassBrowserFrameView::~GlassBrowserFrameView() { | 99 GlassBrowserFrameView::~GlassBrowserFrameView() { |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 ProfileInfoCache& cache = | 547 ProfileInfoCache& cache = |
551 g_browser_process->profile_manager()->GetProfileInfoCache(); | 548 g_browser_process->profile_manager()->GetProfileInfoCache(); |
552 Profile* profile = browser_view_->browser()->profile(); | 549 Profile* profile = browser_view_->browser()->profile(); |
553 size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath()); | 550 size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath()); |
554 if (index != std::string::npos) { | 551 if (index != std::string::npos) { |
555 avatar_button_->SetIcon(cache.GetAvatarIconOfProfileAtIndex(index)); | 552 avatar_button_->SetIcon(cache.GetAvatarIconOfProfileAtIndex(index)); |
556 avatar_button_->SetText(cache.GetNameOfProfileAtIndex(index)); | 553 avatar_button_->SetText(cache.GetNameOfProfileAtIndex(index)); |
557 } | 554 } |
558 } | 555 } |
559 } | 556 } |
OLD | NEW |