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/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/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 public: | 233 public: |
234 explicit SizedContainer(const gfx::Size& preferred_size) | 234 explicit SizedContainer(const gfx::Size& preferred_size) |
235 : preferred_size_(preferred_size) {} | 235 : preferred_size_(preferred_size) {} |
236 | 236 |
237 gfx::Size GetPreferredSize() const override { return preferred_size_; } | 237 gfx::Size GetPreferredSize() const override { return preferred_size_; } |
238 | 238 |
239 private: | 239 private: |
240 gfx::Size preferred_size_; | 240 gfx::Size preferred_size_; |
241 }; | 241 }; |
242 | 242 |
243 // NonInteractiveContainer ------------------------------------------------- | |
244 | |
245 // A simple container view that does not process events within subtree. | |
246 class NonInteractiveContainer : public views::View { | |
247 public: | |
248 NonInteractiveContainer() {} | |
249 | |
250 // views::CanProcessEventsWithinSubtree: | |
251 bool CanProcessEventsWithinSubtree() const override { return false; } | |
252 | |
253 private: | |
254 DISALLOW_COPY_AND_ASSIGN(NonInteractiveContainer); | |
255 }; | |
256 | |
257 // A view to host the GAIA webview overlapped with a back button. This class | 243 // A view to host the GAIA webview overlapped with a back button. This class |
258 // is needed to reparent the back button inside a native view so that on | 244 // is needed to reparent the back button inside a native view so that on |
259 // windows, user input can be be properly routed to the button. | 245 // windows, user input can be be properly routed to the button. |
260 class HostView : public views::View { | 246 class HostView : public views::View { |
261 public: | 247 public: |
262 HostView() {} | 248 HostView() {} |
263 | 249 |
264 private: | 250 private: |
265 // views::View: | 251 // views::View: |
266 void ViewHierarchyChanged( | 252 void ViewHierarchyChanged( |
(...skipping 1411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1678 EditableProfilePhoto* current_profile_photo = new EditableProfilePhoto( | 1664 EditableProfilePhoto* current_profile_photo = new EditableProfilePhoto( |
1679 this, avatar_item.icon, !is_guest, browser_->profile()); | 1665 this, avatar_item.icon, !is_guest, browser_->profile()); |
1680 | 1666 |
1681 // Profile name, left-aligned to the right of profile icon. | 1667 // Profile name, left-aligned to the right of profile icon. |
1682 views::Label* current_profile_name = new views::Label( | 1668 views::Label* current_profile_name = new views::Label( |
1683 profiles::GetAvatarNameForProfile(browser_->profile()->GetPath())); | 1669 profiles::GetAvatarNameForProfile(browser_->profile()->GetPath())); |
1684 current_profile_name->SetFontList( | 1670 current_profile_name->SetFontList( |
1685 ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta( | 1671 ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta( |
1686 1, gfx::Font::FontStyle::NORMAL, gfx::Font::Weight::MEDIUM)); | 1672 1, gfx::Font::FontStyle::NORMAL, gfx::Font::Weight::MEDIUM)); |
1687 current_profile_name->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 1673 current_profile_name->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
1688 NonInteractiveContainer* profile_name_container = | 1674 views::View* profile_name_container = new views::View(); |
1689 new NonInteractiveContainer(); | |
1690 int name_container_v_spacing = | 1675 int name_container_v_spacing = |
1691 (current_profile_photo->GetPreferredSize().height() - | 1676 (current_profile_photo->GetPreferredSize().height() - |
1692 current_profile_name->GetPreferredSize().height()) / 2; | 1677 current_profile_name->GetPreferredSize().height()) / 2; |
1693 views::BoxLayout* profile_name_layout = new views::BoxLayout( | 1678 views::BoxLayout* profile_name_layout = new views::BoxLayout( |
1694 views::BoxLayout::kVertical, 0, name_container_v_spacing, 0); | 1679 views::BoxLayout::kVertical, 0, name_container_v_spacing, 0); |
1695 profile_name_container->SetLayoutManager(profile_name_layout); | 1680 profile_name_container->SetLayoutManager(profile_name_layout); |
1696 profile_name_container->AddChildView(current_profile_name); | 1681 profile_name_container->AddChildView(current_profile_name); |
1697 | 1682 |
1698 const int between_child_spacing = | 1683 const int between_child_spacing = |
1699 kMaterialMenuEdgeMargin - EditableProfilePhoto::badge_spacing(); | 1684 kMaterialMenuEdgeMargin - EditableProfilePhoto::badge_spacing(); |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2304 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 2289 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
2305 IncognitoModePrefs::DISABLED; | 2290 IncognitoModePrefs::DISABLED; |
2306 return incognito_available && !browser_->profile()->IsGuestSession(); | 2291 return incognito_available && !browser_->profile()->IsGuestSession(); |
2307 } | 2292 } |
2308 | 2293 |
2309 void ProfileChooserView::PostActionPerformed( | 2294 void ProfileChooserView::PostActionPerformed( |
2310 ProfileMetrics::ProfileDesktopMenu action_performed) { | 2295 ProfileMetrics::ProfileDesktopMenu action_performed) { |
2311 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 2296 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
2312 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 2297 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
2313 } | 2298 } |
OLD | NEW |