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

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

Issue 895803003: [Profiles] Remove the NotificationService from the ProfileInfoCache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: copy paste the right function Created 5 years, 10 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/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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 if (browser_view->IsRegularOrGuestSession() && switches::IsNewAvatarMenu())
151 UpdateNewStyleAvatarInfo(this, NewAvatarButton::THEMED_BUTTON); 150 UpdateNewStyleAvatarInfo(this, NewAvatarButton::THEMED_BUTTON);
152 else 151 else
153 UpdateAvatarInfo(); 152 UpdateAvatarInfo();
154 153
155 if (!browser_view->IsOffTheRecord()) {
156 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
157 content::NotificationService::AllSources());
158 }
159
160 platform_observer_.reset(OpaqueBrowserFrameViewPlatformSpecific::Create( 154 platform_observer_.reset(OpaqueBrowserFrameViewPlatformSpecific::Create(
161 this, layout_, browser_view->browser()->profile())); 155 this, layout_, browser_view->browser()->profile()));
162 } 156 }
163 157
164 OpaqueBrowserFrameView::~OpaqueBrowserFrameView() { 158 OpaqueBrowserFrameView::~OpaqueBrowserFrameView() {
165 } 159 }
166 160
167 /////////////////////////////////////////////////////////////////////////////// 161 ///////////////////////////////////////////////////////////////////////////////
168 // OpaqueBrowserFrameView, BrowserNonClientFrameView implementation: 162 // OpaqueBrowserFrameView, BrowserNonClientFrameView implementation:
169 163
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 if (!delegate) { 356 if (!delegate) {
363 LOG(WARNING) << "delegate is null, returning safe default."; 357 LOG(WARNING) << "delegate is null, returning safe default.";
364 return gfx::ImageSkia(); 358 return gfx::ImageSkia();
365 } 359 }
366 return delegate->GetWindowIcon(); 360 return delegate->GetWindowIcon();
367 } 361 }
368 362
369 /////////////////////////////////////////////////////////////////////////////// 363 ///////////////////////////////////////////////////////////////////////////////
370 // OpaqueBrowserFrameView, protected: 364 // OpaqueBrowserFrameView, protected:
371 365
372 void OpaqueBrowserFrameView::Observe( 366 void OpaqueBrowserFrameView::OnProfileAdded(
373 int type, 367 const base::FilePath& profile_path) {
374 const content::NotificationSource& source, 368 if (browser_view()->IsRegularOrGuestSession() && switches::IsNewAvatarMenu())
375 const content::NotificationDetails& details) { 369 UpdateNewStyleAvatarInfo(this, NewAvatarButton::NATIVE_BUTTON);
376 switch (type) { 370 else
377 case chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED: 371 UpdateAvatarInfo();
378 if (browser_view() ->IsRegularOrGuestSession() && 372 }
379 switches::IsNewAvatarMenu()) { 373
380 UpdateNewStyleAvatarInfo(this, NewAvatarButton::THEMED_BUTTON); 374 void OpaqueBrowserFrameView::OnProfileWasRemoved(
381 } else { 375 const base::FilePath& profile_path,
382 UpdateAvatarInfo(); 376 const base::string16& profile_name) {
383 } 377 if (browser_view()->IsRegularOrGuestSession() && switches::IsNewAvatarMenu())
384 break; 378 UpdateNewStyleAvatarInfo(this, NewAvatarButton::NATIVE_BUTTON);
385 default: 379 else
386 NOTREACHED() << "Got a notification we didn't register for!"; 380 UpdateAvatarInfo();
387 break; 381 }
388 } 382
383 void OpaqueBrowserFrameView::OnProfileNameChanged(
384 const base::FilePath& profile_path,
385 const base::string16& old_profile_name) {
386 // Profile names are only displayed in the new UI.
387 if (browser_view()->IsRegularOrGuestSession() && switches::IsNewAvatarMenu())
388 UpdateNewStyleAvatarInfo(this, NewAvatarButton::NATIVE_BUTTON);
389 }
390
391 void OpaqueBrowserFrameView::OnProfileAvatarChanged(
392 const base::FilePath& profile_path) {
393 // Profile avatars are only displayed in the old UI or incognito.
394 if (browser_view()->IsOffTheRecord() || !switches::IsNewAvatarMenu())
395 UpdateAvatarInfo();
389 } 396 }
390 397
391 /////////////////////////////////////////////////////////////////////////////// 398 ///////////////////////////////////////////////////////////////////////////////
392 // OpaqueBrowserFrameView, OpaqueBrowserFrameViewLayoutDelegate implementation: 399 // OpaqueBrowserFrameView, OpaqueBrowserFrameViewLayoutDelegate implementation:
393 400
394 bool OpaqueBrowserFrameView::ShouldShowWindowIcon() const { 401 bool OpaqueBrowserFrameView::ShouldShowWindowIcon() const {
395 views::WidgetDelegate* delegate = frame()->widget_delegate(); 402 views::WidgetDelegate* delegate = frame()->widget_delegate();
396 return ShouldShowWindowTitleBar() && delegate && 403 return ShouldShowWindowTitleBar() && delegate &&
397 delegate->ShouldShowWindowIcon(); 404 delegate->ShouldShowWindowIcon();
398 } 405 }
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 929
923 int OpaqueBrowserFrameView::GetTopAreaHeight() const { 930 int OpaqueBrowserFrameView::GetTopAreaHeight() const {
924 gfx::ImageSkia* frame_image = GetFrameImage(); 931 gfx::ImageSkia* frame_image = GetFrameImage();
925 int top_area_height = frame_image->height(); 932 int top_area_height = frame_image->height();
926 if (browser_view()->IsTabStripVisible()) { 933 if (browser_view()->IsTabStripVisible()) {
927 top_area_height = std::max(top_area_height, 934 top_area_height = std::max(top_area_height,
928 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); 935 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom());
929 } 936 }
930 return top_area_height; 937 return top_area_height;
931 } 938 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698