Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: chrome/browser/ui/views/frame/opaque_browser_frame_view.cc

Issue 24647003: Redesign of the avatar menu button. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix RTL button Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/command_line.h" 10 #include "base/command_line.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/prefs/pref_service.h" 12 #include "base/prefs/pref_service.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/browser/chrome_notification_types.h" 14 #include "chrome/browser/chrome_notification_types.h"
15 #include "chrome/browser/profiles/profiles_state.h"
15 #include "chrome/browser/themes/theme_properties.h" 16 #include "chrome/browser/themes/theme_properties.h"
16 #include "chrome/browser/ui/views/avatar_label.h" 17 #include "chrome/browser/ui/views/avatar_label.h"
17 #include "chrome/browser/ui/views/avatar_menu_button.h" 18 #include "chrome/browser/ui/views/avatar_menu_button.h"
18 #include "chrome/browser/ui/views/frame/browser_frame.h" 19 #include "chrome/browser/ui/views/frame/browser_frame.h"
19 #include "chrome/browser/ui/views/frame/browser_view.h" 20 #include "chrome/browser/ui/views/frame/browser_view.h"
20 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h" 21 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h"
21 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_platform_speci fic.h" 22 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_platform_speci fic.h"
23 #include "chrome/browser/ui/views/new_avatar_button.h"
22 #include "chrome/browser/ui/views/tab_icon_view.h" 24 #include "chrome/browser/ui/views/tab_icon_view.h"
23 #include "chrome/browser/ui/views/tabs/tab_strip.h" 25 #include "chrome/browser/ui/views/tabs/tab_strip.h"
24 #include "chrome/browser/ui/views/toolbar_view.h" 26 #include "chrome/browser/ui/views/toolbar_view.h"
25 #include "chrome/common/chrome_switches.h" 27 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/pref_names.h" 28 #include "chrome/common/pref_names.h"
27 #include "content/public/browser/notification_service.h" 29 #include "content/public/browser/notification_service.h"
28 #include "content/public/browser/web_contents.h" 30 #include "content/public/browser/web_contents.h"
29 #include "grit/chromium_strings.h" 31 #include "grit/chromium_strings.h"
30 #include "grit/generated_resources.h" 32 #include "grit/generated_resources.h"
31 #include "grit/theme_resources.h" 33 #include "grit/theme_resources.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 BrowserFrame::GetTitleFont()); 145 BrowserFrame::GetTitleFont());
144 window_title_->SetVisible(browser_view->ShouldShowWindowTitle()); 146 window_title_->SetVisible(browser_view->ShouldShowWindowTitle());
145 window_title_->SetEnabledColor(SK_ColorWHITE); 147 window_title_->SetEnabledColor(SK_ColorWHITE);
146 // TODO(msw): Use a transparent background color as a workaround to use the 148 // TODO(msw): Use a transparent background color as a workaround to use the
147 // gfx::Canvas::NO_SUBPIXEL_RENDERING flag and avoid some visual artifacts. 149 // gfx::Canvas::NO_SUBPIXEL_RENDERING flag and avoid some visual artifacts.
148 window_title_->SetBackgroundColor(0x00000000); 150 window_title_->SetBackgroundColor(0x00000000);
149 window_title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 151 window_title_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
150 window_title_->set_id(VIEW_ID_WINDOW_TITLE); 152 window_title_->set_id(VIEW_ID_WINDOW_TITLE);
151 AddChildView(window_title_); 153 AddChildView(window_title_);
152 154
153 UpdateAvatarInfo(); 155 bool is_incognito = browser_view->IsOffTheRecord() &&
sky 2013/09/26 20:21:39 You seem to have this check in a couple of places,
noms (inactive) 2013/10/01 17:42:21 Done.
156 !browser_view->IsGuestSession();
157 if (!is_incognito && profiles::IsNewProfileManagementEnabled())
158 UpdateNewStyleAvatarInfo();
159 else
160 UpdateAvatarInfo();
161
154 if (!browser_view->IsOffTheRecord()) { 162 if (!browser_view->IsOffTheRecord()) {
155 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, 163 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
156 content::NotificationService::AllSources()); 164 content::NotificationService::AllSources());
157 } 165 }
158 166
159 platform_observer_.reset( 167 platform_observer_.reset(
160 OpaqueBrowserFrameViewPlatformSpecific::Create(this, layout_)); 168 OpaqueBrowserFrameViewPlatformSpecific::Create(this, layout_));
161 } 169 }
162 170
163 OpaqueBrowserFrameView::~OpaqueBrowserFrameView() { 171 OpaqueBrowserFrameView::~OpaqueBrowserFrameView() {
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 return delegate->GetWindowIcon(); 424 return delegate->GetWindowIcon();
417 } 425 }
418 426
419 /////////////////////////////////////////////////////////////////////////////// 427 ///////////////////////////////////////////////////////////////////////////////
420 // OpaqueBrowserFrameView, protected: 428 // OpaqueBrowserFrameView, protected:
421 429
422 void OpaqueBrowserFrameView::Observe( 430 void OpaqueBrowserFrameView::Observe(
423 int type, 431 int type,
424 const content::NotificationSource& source, 432 const content::NotificationSource& source,
425 const content::NotificationDetails& details) { 433 const content::NotificationDetails& details) {
434 bool is_incognito = browser_view()->IsOffTheRecord() &&
435 !browser_view()->IsGuestSession();
426 switch (type) { 436 switch (type) {
427 case chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED: 437 case chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED:
428 UpdateAvatarInfo(); 438 if (!is_incognito && profiles::IsNewProfileManagementEnabled())
439 UpdateNewStyleAvatarInfo();
440 else
441 UpdateAvatarInfo();
429 break; 442 break;
430 default: 443 default:
431 NOTREACHED() << "Got a notification we didn't register for!"; 444 NOTREACHED() << "Got a notification we didn't register for!";
432 break; 445 break;
433 } 446 }
434 } 447 }
435 448
436 /////////////////////////////////////////////////////////////////////////////// 449 ///////////////////////////////////////////////////////////////////////////////
437 // OpaqueBrowserFrameView, OpaqueBrowserFrameViewLayoutDelegate implementation: 450 // OpaqueBrowserFrameView, OpaqueBrowserFrameViewLayoutDelegate implementation:
438 451
(...skipping 29 matching lines...) Expand all
468 } 481 }
469 482
470 gfx::Size OpaqueBrowserFrameView::GetBrowserViewMinimumSize() const { 483 gfx::Size OpaqueBrowserFrameView::GetBrowserViewMinimumSize() const {
471 return browser_view()->GetMinimumSize(); 484 return browser_view()->GetMinimumSize();
472 } 485 }
473 486
474 bool OpaqueBrowserFrameView::ShouldShowAvatar() const { 487 bool OpaqueBrowserFrameView::ShouldShowAvatar() const {
475 return browser_view()->ShouldShowAvatar(); 488 return browser_view()->ShouldShowAvatar();
476 } 489 }
477 490
491 bool OpaqueBrowserFrameView::IsOffTheRecord() const {
492 return browser_view()->IsOffTheRecord();
493 }
494
495 bool OpaqueBrowserFrameView::IsGuestSession() const {
496 return browser_view()->IsGuestSession();
497 }
498
478 gfx::ImageSkia OpaqueBrowserFrameView::GetOTRAvatarIcon() const { 499 gfx::ImageSkia OpaqueBrowserFrameView::GetOTRAvatarIcon() const {
479 return browser_view()->GetOTRAvatarIcon(); 500 return browser_view()->GetOTRAvatarIcon();
480 } 501 }
481 502
482 bool OpaqueBrowserFrameView::IsMaximized() const { 503 bool OpaqueBrowserFrameView::IsMaximized() const {
483 return frame()->IsMaximized(); 504 return frame()->IsMaximized();
484 } 505 }
485 506
486 bool OpaqueBrowserFrameView::IsMinimized() const { 507 bool OpaqueBrowserFrameView::IsMinimized() const {
487 return frame()->IsMinimized(); 508 return frame()->IsMinimized();
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 885
865 int OpaqueBrowserFrameView::GetTopAreaHeight() const { 886 int OpaqueBrowserFrameView::GetTopAreaHeight() const {
866 gfx::ImageSkia* frame_image = GetFrameImage(); 887 gfx::ImageSkia* frame_image = GetFrameImage();
867 int top_area_height = frame_image->height(); 888 int top_area_height = frame_image->height();
868 if (browser_view()->IsTabStripVisible()) { 889 if (browser_view()->IsTabStripVisible()) {
869 top_area_height = std::max(top_area_height, 890 top_area_height = std::max(top_area_height,
870 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); 891 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom());
871 } 892 }
872 return top_area_height; 893 return top_area_height;
873 } 894 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698