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/opaque_browser_frame_view.h" | 5 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "chrome/browser/chrome_notification_types.h" | |
14 #include "chrome/browser/profiles/profiles_state.h" | 13 #include "chrome/browser/profiles/profiles_state.h" |
15 #include "chrome/browser/signin/signin_header_helper.h" | 14 #include "chrome/browser/signin/signin_header_helper.h" |
16 #include "chrome/browser/themes/theme_properties.h" | 15 #include "chrome/browser/themes/theme_properties.h" |
17 #include "chrome/browser/ui/views/frame/browser_frame.h" | 16 #include "chrome/browser/ui/views/frame/browser_frame.h" |
18 #include "chrome/browser/ui/views/frame/browser_view.h" | 17 #include "chrome/browser/ui/views/frame/browser_view.h" |
19 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h" | 18 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h" |
20 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_platform_speci fic.h" | 19 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_platform_speci fic.h" |
21 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" | 20 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" |
22 #include "chrome/browser/ui/views/profiles/new_avatar_button.h" | 21 #include "chrome/browser/ui/views/profiles/new_avatar_button.h" |
23 #include "chrome/browser/ui/views/tab_icon_view.h" | 22 #include "chrome/browser/ui/views/tab_icon_view.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
140 window_title_ = new views::Label( | 139 window_title_ = new views::Label( |
141 browser_view->GetWindowTitle(), | 140 browser_view->GetWindowTitle(), |
142 gfx::FontList(BrowserFrame::GetTitleFontList())); | 141 gfx::FontList(BrowserFrame::GetTitleFontList())); |
143 window_title_->SetVisible(browser_view->ShouldShowWindowTitle()); | 142 window_title_->SetVisible(browser_view->ShouldShowWindowTitle()); |
144 window_title_->SetEnabledColor(SK_ColorWHITE); | 143 window_title_->SetEnabledColor(SK_ColorWHITE); |
145 window_title_->SetSubpixelRenderingEnabled(false); | 144 window_title_->SetSubpixelRenderingEnabled(false); |
146 window_title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 145 window_title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
147 window_title_->set_id(VIEW_ID_WINDOW_TITLE); | 146 window_title_->set_id(VIEW_ID_WINDOW_TITLE); |
148 AddChildView(window_title_); | 147 AddChildView(window_title_); |
149 | 148 |
150 if (browser_view->IsRegularOrGuestSession() && switches::IsNewAvatarMenu()) | 149 UpdateAvatar(); |
151 UpdateNewStyleAvatarInfo(this, NewAvatarButton::THEMED_BUTTON); | |
152 else | |
153 UpdateAvatarInfo(); | |
154 | |
155 if (!browser_view->IsOffTheRecord()) { | |
156 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, | |
157 content::NotificationService::AllSources()); | |
158 } | |
159 | 150 |
160 platform_observer_.reset(OpaqueBrowserFrameViewPlatformSpecific::Create( | 151 platform_observer_.reset(OpaqueBrowserFrameViewPlatformSpecific::Create( |
161 this, layout_, browser_view->browser()->profile())); | 152 this, layout_, browser_view->browser()->profile())); |
162 } | 153 } |
163 | 154 |
164 OpaqueBrowserFrameView::~OpaqueBrowserFrameView() { | 155 OpaqueBrowserFrameView::~OpaqueBrowserFrameView() { |
165 } | 156 } |
166 | 157 |
167 /////////////////////////////////////////////////////////////////////////////// | 158 /////////////////////////////////////////////////////////////////////////////// |
168 // OpaqueBrowserFrameView, BrowserNonClientFrameView implementation: | 159 // OpaqueBrowserFrameView, BrowserNonClientFrameView implementation: |
(...skipping 18 matching lines...) Expand all Loading... | |
187 | 178 |
188 void OpaqueBrowserFrameView::UpdateThrobber(bool running) { | 179 void OpaqueBrowserFrameView::UpdateThrobber(bool running) { |
189 if (window_icon_) | 180 if (window_icon_) |
190 window_icon_->Update(); | 181 window_icon_->Update(); |
191 } | 182 } |
192 | 183 |
193 gfx::Size OpaqueBrowserFrameView::GetMinimumSize() const { | 184 gfx::Size OpaqueBrowserFrameView::GetMinimumSize() const { |
194 return layout_->GetMinimumSize(width()); | 185 return layout_->GetMinimumSize(width()); |
195 } | 186 } |
196 | 187 |
188 void OpaqueBrowserFrameView::UpdateNewStyleAvatar() { | |
189 UpdateNewStyleAvatarInfo(this, NewAvatarButton::THEMED_BUTTON); | |
sky
2015/02/20 21:43:19
How about a GetNewAvatarButtonStyle() protected vi
noms (inactive)
2015/02/20 21:46:30
Hmm, but the `this` is also bad because BrowserNon
sky
2015/02/20 21:51:01
Good point. And it looks like they all have differ
noms
2015/02/23 15:46:52
Done.
| |
190 } | |
191 | |
197 /////////////////////////////////////////////////////////////////////////////// | 192 /////////////////////////////////////////////////////////////////////////////// |
198 // OpaqueBrowserFrameView, views::NonClientFrameView implementation: | 193 // OpaqueBrowserFrameView, views::NonClientFrameView implementation: |
199 | 194 |
200 gfx::Rect OpaqueBrowserFrameView::GetBoundsForClientView() const { | 195 gfx::Rect OpaqueBrowserFrameView::GetBoundsForClientView() const { |
201 return layout_->client_view_bounds(); | 196 return layout_->client_view_bounds(); |
202 } | 197 } |
203 | 198 |
204 gfx::Rect OpaqueBrowserFrameView::GetWindowBoundsForClientBounds( | 199 gfx::Rect OpaqueBrowserFrameView::GetWindowBoundsForClientBounds( |
205 const gfx::Rect& client_bounds) const { | 200 const gfx::Rect& client_bounds) const { |
206 return layout_->GetWindowBoundsForClientBounds(client_bounds); | 201 return layout_->GetWindowBoundsForClientBounds(client_bounds); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 gfx::ImageSkia OpaqueBrowserFrameView::GetFaviconForTabIconView() { | 363 gfx::ImageSkia OpaqueBrowserFrameView::GetFaviconForTabIconView() { |
369 views::WidgetDelegate* delegate = frame()->widget_delegate(); | 364 views::WidgetDelegate* delegate = frame()->widget_delegate(); |
370 if (!delegate) { | 365 if (!delegate) { |
371 LOG(WARNING) << "delegate is null, returning safe default."; | 366 LOG(WARNING) << "delegate is null, returning safe default."; |
372 return gfx::ImageSkia(); | 367 return gfx::ImageSkia(); |
373 } | 368 } |
374 return delegate->GetWindowIcon(); | 369 return delegate->GetWindowIcon(); |
375 } | 370 } |
376 | 371 |
377 /////////////////////////////////////////////////////////////////////////////// | 372 /////////////////////////////////////////////////////////////////////////////// |
378 // OpaqueBrowserFrameView, protected: | |
379 | |
380 void OpaqueBrowserFrameView::Observe( | |
381 int type, | |
382 const content::NotificationSource& source, | |
383 const content::NotificationDetails& details) { | |
384 switch (type) { | |
385 case chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED: | |
386 if (browser_view() ->IsRegularOrGuestSession() && | |
387 switches::IsNewAvatarMenu()) { | |
388 UpdateNewStyleAvatarInfo(this, NewAvatarButton::THEMED_BUTTON); | |
389 } else { | |
390 UpdateAvatarInfo(); | |
391 } | |
392 break; | |
393 default: | |
394 NOTREACHED() << "Got a notification we didn't register for!"; | |
395 break; | |
396 } | |
397 } | |
398 | |
399 /////////////////////////////////////////////////////////////////////////////// | |
400 // OpaqueBrowserFrameView, OpaqueBrowserFrameViewLayoutDelegate implementation: | 373 // OpaqueBrowserFrameView, OpaqueBrowserFrameViewLayoutDelegate implementation: |
401 | 374 |
402 bool OpaqueBrowserFrameView::ShouldShowWindowIcon() const { | 375 bool OpaqueBrowserFrameView::ShouldShowWindowIcon() const { |
403 views::WidgetDelegate* delegate = frame()->widget_delegate(); | 376 views::WidgetDelegate* delegate = frame()->widget_delegate(); |
404 return ShouldShowWindowTitleBar() && delegate && | 377 return ShouldShowWindowTitleBar() && delegate && |
405 delegate->ShouldShowWindowIcon(); | 378 delegate->ShouldShowWindowIcon(); |
406 } | 379 } |
407 | 380 |
408 bool OpaqueBrowserFrameView::ShouldShowWindowTitle() const { | 381 bool OpaqueBrowserFrameView::ShouldShowWindowTitle() const { |
409 // |delegate| may be null if called from callback of InputMethodChanged while | 382 // |delegate| may be null if called from callback of InputMethodChanged while |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
930 | 903 |
931 int OpaqueBrowserFrameView::GetTopAreaHeight() const { | 904 int OpaqueBrowserFrameView::GetTopAreaHeight() const { |
932 gfx::ImageSkia* frame_image = GetFrameImage(); | 905 gfx::ImageSkia* frame_image = GetFrameImage(); |
933 int top_area_height = frame_image->height(); | 906 int top_area_height = frame_image->height(); |
934 if (browser_view()->IsTabStripVisible()) { | 907 if (browser_view()->IsTabStripVisible()) { |
935 top_area_height = std::max(top_area_height, | 908 top_area_height = std::max(top_area_height, |
936 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); | 909 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); |
937 } | 910 } |
938 return top_area_height; | 911 return top_area_height; |
939 } | 912 } |
OLD | NEW |