| 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 "ash/system/user/user_card_view.h" | 5 #include "ash/system/user/user_card_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 gfx::Size GetPreferredSize() const override; | 90 gfx::Size GetPreferredSize() const override; |
| 91 void OnPaint(gfx::Canvas* canvas) override; | 91 void OnPaint(gfx::Canvas* canvas) override; |
| 92 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; | 92 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; |
| 93 | 93 |
| 94 // Overridden from views::LinkListener. | 94 // Overridden from views::LinkListener. |
| 95 void LinkClicked(views::Link* source, int event_flags) override; | 95 void LinkClicked(views::Link* source, int event_flags) override; |
| 96 | 96 |
| 97 // Calculate a preferred size that ensures the label text and the following | 97 // Calculate a preferred size that ensures the label text and the following |
| 98 // link do not wrap over more than three lines in total for aesthetic reasons | 98 // link do not wrap over more than three lines in total for aesthetic reasons |
| 99 // if possible. | 99 // if possible. |
| 100 void CalculatePreferredSize(); | 100 void DeterminePreferredSize(); |
| 101 | 101 |
| 102 base::string16 text_; | 102 base::string16 text_; |
| 103 views::Link* learn_more_; | 103 views::Link* learn_more_; |
| 104 gfx::Size preferred_size_; | 104 gfx::Size preferred_size_; |
| 105 std::vector<std::unique_ptr<gfx::RenderText>> lines_; | 105 std::vector<std::unique_ptr<gfx::RenderText>> lines_; |
| 106 | 106 |
| 107 DISALLOW_COPY_AND_ASSIGN(PublicAccountUserDetails); | 107 DISALLOW_COPY_AND_ASSIGN(PublicAccountUserDetails); |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 PublicAccountUserDetails::PublicAccountUserDetails() : learn_more_(nullptr) { | 110 PublicAccountUserDetails::PublicAccountUserDetails() : learn_more_(nullptr) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 129 base::i18n::WrapStringWithLTRFormatting(&domain); | 129 base::i18n::WrapStringWithLTRFormatting(&domain); |
| 130 // Retrieve the label text, inserting the display name and domain. | 130 // Retrieve the label text, inserting the display name and domain. |
| 131 text_ = l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_PUBLIC_LABEL, | 131 text_ = l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_PUBLIC_LABEL, |
| 132 display_name, domain); | 132 display_name, domain); |
| 133 | 133 |
| 134 learn_more_ = new views::Link(l10n_util::GetStringUTF16(IDS_ASH_LEARN_MORE)); | 134 learn_more_ = new views::Link(l10n_util::GetStringUTF16(IDS_ASH_LEARN_MORE)); |
| 135 learn_more_->SetUnderline(false); | 135 learn_more_->SetUnderline(false); |
| 136 learn_more_->set_listener(this); | 136 learn_more_->set_listener(this); |
| 137 AddChildView(learn_more_); | 137 AddChildView(learn_more_); |
| 138 | 138 |
| 139 CalculatePreferredSize(); | 139 DeterminePreferredSize(); |
| 140 } | 140 } |
| 141 | 141 |
| 142 PublicAccountUserDetails::~PublicAccountUserDetails() {} | 142 PublicAccountUserDetails::~PublicAccountUserDetails() {} |
| 143 | 143 |
| 144 void PublicAccountUserDetails::Layout() { | 144 void PublicAccountUserDetails::Layout() { |
| 145 lines_.clear(); | 145 lines_.clear(); |
| 146 const gfx::Rect contents_area = GetContentsBounds(); | 146 const gfx::Rect contents_area = GetContentsBounds(); |
| 147 if (contents_area.IsEmpty()) | 147 if (contents_area.IsEmpty()) |
| 148 return; | 148 return; |
| 149 | 149 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 node_data->role = ui::AX_ROLE_STATIC_TEXT; | 224 node_data->role = ui::AX_ROLE_STATIC_TEXT; |
| 225 node_data->SetName(text_); | 225 node_data->SetName(text_); |
| 226 } | 226 } |
| 227 | 227 |
| 228 void PublicAccountUserDetails::LinkClicked(views::Link* source, | 228 void PublicAccountUserDetails::LinkClicked(views::Link* source, |
| 229 int event_flags) { | 229 int event_flags) { |
| 230 DCHECK_EQ(source, learn_more_); | 230 DCHECK_EQ(source, learn_more_); |
| 231 Shell::Get()->system_tray_controller()->ShowPublicAccountInfo(); | 231 Shell::Get()->system_tray_controller()->ShowPublicAccountInfo(); |
| 232 } | 232 } |
| 233 | 233 |
| 234 void PublicAccountUserDetails::CalculatePreferredSize() { | 234 void PublicAccountUserDetails::DeterminePreferredSize() { |
| 235 const gfx::FontList font_list; | 235 const gfx::FontList font_list; |
| 236 const gfx::Size link_size = learn_more_->GetPreferredSize(); | 236 const gfx::Size link_size = learn_more_->GetPreferredSize(); |
| 237 const int space_width = | 237 const int space_width = |
| 238 gfx::GetStringWidth(base::ASCIIToUTF16(" "), font_list); | 238 gfx::GetStringWidth(base::ASCIIToUTF16(" "), font_list); |
| 239 const gfx::Insets insets = GetInsets(); | 239 const gfx::Insets insets = GetInsets(); |
| 240 int min_width = link_size.width(); | 240 int min_width = link_size.width(); |
| 241 int max_width = | 241 int max_width = |
| 242 gfx::GetStringWidth(text_, font_list) + space_width + link_size.width(); | 242 gfx::GetStringWidth(text_, font_list) + space_width + link_size.width(); |
| 243 | 243 |
| 244 // Do a binary search for the minimum width that ensures no more than three | 244 // Do a binary search for the minimum width that ensures no more than three |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 media_capture_container_ = new views::View(); | 441 media_capture_container_ = new views::View(); |
| 442 media_capture_container_->SetLayoutManager(new views::FillLayout()); | 442 media_capture_container_->SetLayoutManager(new views::FillLayout()); |
| 443 media_capture_container_->AddChildView(media_capture_icon_); | 443 media_capture_container_->AddChildView(media_capture_icon_); |
| 444 AddChildView(media_capture_container_); | 444 AddChildView(media_capture_container_); |
| 445 | 445 |
| 446 Shell::Get()->media_controller()->RequestCaptureState(); | 446 Shell::Get()->media_controller()->RequestCaptureState(); |
| 447 } | 447 } |
| 448 | 448 |
| 449 } // namespace tray | 449 } // namespace tray |
| 450 } // namespace ash | 450 } // namespace ash |
| OLD | NEW |