OLD | NEW |
---|---|
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/i18n/rtl.h" | |
7 #include "base/macros.h" | 8 #include "base/macros.h" |
8 #include "base/metrics/user_metrics.h" | 9 #include "base/metrics/user_metrics.h" |
9 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
11 #include "chrome/browser/lifetime/application_lifetime.h" | 12 #include "chrome/browser/lifetime/application_lifetime.h" |
12 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 13 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
13 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 14 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
14 #include "chrome/browser/profiles/profile_manager.h" | 15 #include "chrome/browser/profiles/profile_manager.h" |
15 #include "chrome/browser/profiles/profile_metrics.h" | 16 #include "chrome/browser/profiles/profile_metrics.h" |
16 #include "chrome/browser/profiles/profile_window.h" | 17 #include "chrome/browser/profiles/profile_window.h" |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
366 SetBorder(views::Border::NullBorder()); | 367 SetBorder(views::Border::NullBorder()); |
367 if (switches::IsMaterialDesignUserMenu()) { | 368 if (switches::IsMaterialDesignUserMenu()) { |
368 SetMinSize(gfx::Size(GetPreferredSize().width() + badge_spacing(), | 369 SetMinSize(gfx::Size(GetPreferredSize().width() + badge_spacing(), |
369 GetPreferredSize().height() + badge_spacing() + | 370 GetPreferredSize().height() + badge_spacing() + |
370 views::kRelatedControlSmallVerticalSpacing)); | 371 views::kRelatedControlSmallVerticalSpacing)); |
371 } else { | 372 } else { |
372 SetSize(GetPreferredSize()); | 373 SetSize(GetPreferredSize()); |
373 } | 374 } |
374 | 375 |
375 // Calculate the circular mask that will be used to display the photo. | 376 // Calculate the circular mask that will be used to display the photo. |
377 // For RTL layouts, right-align the circular mask because profile badge can | |
378 // appear on the LHS. | |
376 circular_mask_.addCircle( | 379 circular_mask_.addCircle( |
377 SkIntToScalar(icon_image_side() / 2), | 380 SkIntToScalar(icon_image_side() / 2) + |
381 (base::i18n::IsRTL() ? badge_spacing() : 0), | |
sky
2016/08/26 19:18:27
In general we use the various GetMirrored* functio
| |
378 SkIntToScalar(icon_image_side() / 2) + badge_spacing(), | 382 SkIntToScalar(icon_image_side() / 2) + badge_spacing(), |
379 SkIntToScalar(icon_image_side() / 2)); | 383 SkIntToScalar(icon_image_side() / 2)); |
380 | 384 |
381 if (switches::IsMaterialDesignUserMenu() || !is_editing_allowed) { | 385 if (switches::IsMaterialDesignUserMenu() || !is_editing_allowed) { |
382 SetEnabled(false); | 386 SetEnabled(false); |
383 return; | 387 return; |
384 } | 388 } |
385 | 389 |
386 set_notify_enter_exit_on_child(true); | 390 set_notify_enter_exit_on_child(true); |
387 | 391 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
421 gfx::Canvas* canvas = paint_recorder.canvas(); | 425 gfx::Canvas* canvas = paint_recorder.canvas(); |
422 if (profile_->IsSupervised()) { | 426 if (profile_->IsSupervised()) { |
423 gfx::Rect bounds(0, 0, GetProfileBadgeSize(), GetProfileBadgeSize()); | 427 gfx::Rect bounds(0, 0, GetProfileBadgeSize(), GetProfileBadgeSize()); |
424 int badge_offset = | 428 int badge_offset = |
425 icon_image_side() + badge_spacing() - GetProfileBadgeSize(); | 429 icon_image_side() + badge_spacing() - GetProfileBadgeSize(); |
426 gfx::Vector2d badge_offset_vector = gfx::Vector2d( | 430 gfx::Vector2d badge_offset_vector = gfx::Vector2d( |
427 badge_offset, | 431 badge_offset, |
428 badge_offset + (switches::IsMaterialDesignUserMenu() | 432 badge_offset + (switches::IsMaterialDesignUserMenu() |
429 ? views::kRelatedControlSmallVerticalSpacing | 433 ? views::kRelatedControlSmallVerticalSpacing |
430 : 0)); | 434 : 0)); |
435 // For RTL layouts, left-align the profile badge. | |
sky
2016/08/26 19:18:27
Similar comment here. Generally you calculate the
| |
436 if (base::i18n::IsRTL()) | |
437 badge_offset_vector.set_x(0); | |
431 gfx::Point center_point = bounds.CenterPoint() + badge_offset_vector; | 438 gfx::Point center_point = bounds.CenterPoint() + badge_offset_vector; |
432 | 439 |
433 // Paint the circular background. | 440 // Paint the circular background. |
434 SkPaint paint; | 441 SkPaint paint; |
435 paint.setAntiAlias(true); | 442 paint.setAntiAlias(true); |
436 paint.setColor(GetNativeTheme()->GetSystemColor( | 443 paint.setColor(GetNativeTheme()->GetSystemColor( |
437 ui::NativeTheme::kColorId_BubbleBackground)); | 444 ui::NativeTheme::kColorId_BubbleBackground)); |
438 canvas->DrawCircle(center_point, GetProfileBadgeSize() / 2, paint); | 445 canvas->DrawCircle(center_point, GetProfileBadgeSize() / 2, paint); |
439 | 446 |
440 gfx::VectorIconId icon_id; | 447 gfx::VectorIconId icon_id; |
(...skipping 1863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2304 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 2311 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
2305 IncognitoModePrefs::DISABLED; | 2312 IncognitoModePrefs::DISABLED; |
2306 return incognito_available && !browser_->profile()->IsGuestSession(); | 2313 return incognito_available && !browser_->profile()->IsGuestSession(); |
2307 } | 2314 } |
2308 | 2315 |
2309 void ProfileChooserView::PostActionPerformed( | 2316 void ProfileChooserView::PostActionPerformed( |
2310 ProfileMetrics::ProfileDesktopMenu action_performed) { | 2317 ProfileMetrics::ProfileDesktopMenu action_performed) { |
2311 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 2318 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
2312 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 2319 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
2313 } | 2320 } |
OLD | NEW |