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

Side by Side Diff: chrome/browser/ui/views/profiles/profile_chooser_view.cc

Issue 2877483003: Implements core logic for Pixel Canvas (Closed)
Patch Set: Unittest update Created 3 years, 4 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/profiles/profile_chooser_view.h" 5 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/metrics/user_metrics.h" 8 #include "base/metrics/user_metrics.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/app/vector_icons/vector_icons.h" 10 #include "chrome/app/vector_icons/vector_icons.h"
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 SetImage(views::LabelButton::STATE_NORMAL, *image.ToImageSkia()); 338 SetImage(views::LabelButton::STATE_NORMAL, *image.ToImageSkia());
339 SetBorder(views::NullBorder()); 339 SetBorder(views::NullBorder());
340 SetMinSize(gfx::Size(GetPreferredSize().width() + kBadgeSpacing, 340 SetMinSize(gfx::Size(GetPreferredSize().width() + kBadgeSpacing,
341 GetPreferredSize().height() + kBadgeSpacing + 341 GetPreferredSize().height() + kBadgeSpacing +
342 ChromeLayoutProvider::Get()->GetDistanceMetric( 342 ChromeLayoutProvider::Get()->GetDistanceMetric(
343 DISTANCE_RELATED_CONTROL_VERTICAL_SMALL))); 343 DISTANCE_RELATED_CONTROL_VERTICAL_SMALL)));
344 344
345 SetEnabled(false); 345 SetEnabled(false);
346 } 346 }
347 347
348 void PaintChildren(const ui::PaintContext& context) override { 348 void PaintChildren(const views::PaintInfo& paint_info) override {
349 { 349 {
350 // Display any children (the "change photo" overlay) as a circle. 350 // Display any children (the "change photo" overlay) as a circle.
351 ui::ClipRecorder clip_recorder(context); 351 ui::ClipRecorder clip_recorder(paint_info.context());
352 gfx::Rect clip_bounds = image()->GetMirroredBounds(); 352 gfx::Rect clip_bounds = image()->GetMirroredBounds();
353 gfx::Path clip_mask; 353 gfx::Path clip_mask;
354 clip_mask.addCircle( 354 clip_mask.addCircle(
355 clip_bounds.x() + clip_bounds.width() / 2, 355 clip_bounds.x() + clip_bounds.width() / 2,
356 clip_bounds.y() + clip_bounds.height() / 2, 356 clip_bounds.y() + clip_bounds.height() / 2,
357 clip_bounds.width() / 2); 357 clip_bounds.width() / 2);
358 clip_recorder.ClipPathWithAntiAliasing(clip_mask); 358 clip_recorder.ClipPathWithAntiAliasing(clip_mask);
359 View::PaintChildren(context); 359 View::PaintChildren(paint_info);
360 } 360 }
361 361
362 ui::PaintRecorder paint_recorder( 362 ui::PaintRecorder paint_recorder(
363 context, gfx::Size(kProfileBadgeSize, kProfileBadgeSize)); 363 paint_info.context(), gfx::Size(kProfileBadgeSize, kProfileBadgeSize));
364 gfx::Canvas* canvas = paint_recorder.canvas(); 364 gfx::Canvas* canvas = paint_recorder.canvas();
365 if (profile_->IsSupervised()) { 365 if (profile_->IsSupervised()) {
366 gfx::Rect bounds(0, 0, kProfileBadgeSize, kProfileBadgeSize); 366 gfx::Rect bounds(0, 0, kProfileBadgeSize, kProfileBadgeSize);
367 int badge_offset = kImageSide + kBadgeSpacing - kProfileBadgeSize; 367 int badge_offset = kImageSide + kBadgeSpacing - kProfileBadgeSize;
368 gfx::Vector2d badge_offset_vector = gfx::Vector2d( 368 gfx::Vector2d badge_offset_vector = gfx::Vector2d(
369 GetMirroredXWithWidthInView(badge_offset, kProfileBadgeSize), 369 GetMirroredXWithWidthInView(badge_offset, kProfileBadgeSize),
370 badge_offset + ChromeLayoutProvider::Get()->GetDistanceMetric( 370 badge_offset + ChromeLayoutProvider::Get()->GetDistanceMetric(
371 DISTANCE_RELATED_CONTROL_VERTICAL_SMALL)); 371 DISTANCE_RELATED_CONTROL_VERTICAL_SMALL));
372 372
373 gfx::Point center_point = bounds.CenterPoint() + badge_offset_vector; 373 gfx::Point center_point = bounds.CenterPoint() + badge_offset_vector;
(...skipping 1263 matching lines...) Expand 10 before | Expand all | Expand 10 after
1637 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 1637 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
1638 IncognitoModePrefs::DISABLED; 1638 IncognitoModePrefs::DISABLED;
1639 return incognito_available && !browser_->profile()->IsGuestSession(); 1639 return incognito_available && !browser_->profile()->IsGuestSession();
1640 } 1640 }
1641 1641
1642 void ProfileChooserView::PostActionPerformed( 1642 void ProfileChooserView::PostActionPerformed(
1643 ProfileMetrics::ProfileDesktopMenu action_performed) { 1643 ProfileMetrics::ProfileDesktopMenu action_performed) {
1644 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); 1644 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_);
1645 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; 1645 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE;
1646 } 1646 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698