OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ui/message_center/views/group_view.h" | 5 #include "ui/message_center/views/group_view.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "grit/ui_resources.h" | 10 #include "grit/ui_resources.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 group_icon_(group_icon), | 71 group_icon_(group_icon), |
72 group_size_(group_size), | 72 group_size_(group_size), |
73 last_notification_id_(last_notification.id()), | 73 last_notification_id_(last_notification.id()), |
74 top_view_(NULL), | 74 top_view_(NULL), |
75 bottom_view_(NULL), | 75 bottom_view_(NULL), |
76 title_view_(NULL), | 76 title_view_(NULL), |
77 message_view_(NULL), | 77 message_view_(NULL), |
78 context_message_view_(NULL), | 78 context_message_view_(NULL), |
79 icon_view_(NULL) | 79 icon_view_(NULL) |
80 { | 80 { |
81 std::vector<string16> accessible_lines; | 81 std::vector<base::string16> accessible_lines; |
82 // Create the top_view_, which collects into a vertical box all content | 82 // Create the top_view_, which collects into a vertical box all content |
83 // at the top of the notification (to the right of the icon) except for the | 83 // at the top of the notification (to the right of the icon) except for the |
84 // close button. | 84 // close button. |
85 top_view_ = new views::View(); | 85 top_view_ = new views::View(); |
86 top_view_->SetLayoutManager( | 86 top_view_->SetLayoutManager( |
87 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | 87 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
88 top_view_->set_border(views::Border::CreateEmptyBorder( | 88 top_view_->set_border(views::Border::CreateEmptyBorder( |
89 kTextTopPadding - 8, 0, kTextBottomPadding - 5, 0)); | 89 kTextTopPadding - 8, 0, kTextBottomPadding - 5, 0)); |
90 | 90 |
91 const gfx::FontList default_label_font_list = views::Label().font_list(); | 91 const gfx::FontList default_label_font_list = views::Label().font_list(); |
92 | 92 |
93 // Create the title view if appropriate. | 93 // Create the title view if appropriate. |
94 const gfx::FontList& font_list = | 94 const gfx::FontList& font_list = |
95 default_label_font_list.DeriveFontListWithSizeDelta(2); | 95 default_label_font_list.DeriveFontListWithSizeDelta(2); |
96 int padding = kTitleLineHeight - font_list.GetHeight(); | 96 int padding = kTitleLineHeight - font_list.GetHeight(); |
97 | 97 |
98 title_view_ = new BoundedLabel( | 98 title_view_ = new BoundedLabel( |
99 gfx::TruncateString(string16(last_notification.title()), | 99 gfx::TruncateString(base::string16(last_notification.title()), |
100 kTitleCharacterLimit), | 100 kTitleCharacterLimit), |
101 font_list); | 101 font_list); |
102 accessible_lines.push_back(last_notification.title()); | 102 accessible_lines.push_back(last_notification.title()); |
103 title_view_->SetLineHeight(kTitleLineHeight); | 103 title_view_->SetLineHeight(kTitleLineHeight); |
104 title_view_->SetLineLimit(message_center::kTitleLineLimit); | 104 title_view_->SetLineLimit(message_center::kTitleLineLimit); |
105 title_view_->SetColors(message_center::kRegularTextColor, | 105 title_view_->SetColors(message_center::kRegularTextColor, |
106 kRegularTextBackgroundColor); | 106 kRegularTextBackgroundColor); |
107 title_view_->set_border(MakeTextBorder(padding, 3, 0)); | 107 title_view_->set_border(MakeTextBorder(padding, 3, 0)); |
108 top_view_->AddChildView(title_view_); | 108 top_view_->AddChildView(title_view_); |
109 | 109 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 bottom_view_ = new views::View(); | 148 bottom_view_ = new views::View(); |
149 bottom_view_->SetLayoutManager( | 149 bottom_view_->SetLayoutManager( |
150 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | 150 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
151 | 151 |
152 // Create "N more.." action button | 152 // Create "N more.." action button |
153 views::View* separator = new views::ImageView(); | 153 views::View* separator = new views::ImageView(); |
154 separator->set_border(views::Border::CreateSolidSidedBorder( | 154 separator->set_border(views::Border::CreateSolidSidedBorder( |
155 1, 0, 0, 0, kButtonSeparatorColor)); | 155 1, 0, 0, 0, kButtonSeparatorColor)); |
156 bottom_view_->AddChildView(separator); | 156 bottom_view_->AddChildView(separator); |
157 more_button_ = new NotificationButton(this); | 157 more_button_ = new NotificationButton(this); |
158 string16 button_title = | 158 base::string16 button_title = |
159 l10n_util::GetStringFUTF16(IDS_MESSAGE_CENTER_MORE_FROM, | 159 l10n_util::GetStringFUTF16(IDS_MESSAGE_CENTER_MORE_FROM, |
160 base::IntToString16(group_size_), | 160 base::IntToString16(group_size_), |
161 display_source_); | 161 display_source_); |
162 more_button_->SetTitle(button_title); | 162 more_button_->SetTitle(button_title); |
163 more_button_->SetIcon(group_icon_); | 163 more_button_->SetIcon(group_icon_); |
164 bottom_view_->AddChildView(more_button_); | 164 bottom_view_->AddChildView(more_button_); |
165 | 165 |
166 // Put together the different content and control views. Layering those allows | 166 // Put together the different content and control views. Layering those allows |
167 // for proper layout logic and it also allows the close button to | 167 // for proper layout logic and it also allows the close button to |
168 // overlap the content as needed to provide large enough click and touch area. | 168 // overlap the content as needed to provide large enough click and touch area. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 void GroupView::ClickOnNotification(const std::string& notification_id) { | 244 void GroupView::ClickOnNotification(const std::string& notification_id) { |
245 controller_->GroupBodyClicked(notification_id); | 245 controller_->GroupBodyClicked(notification_id); |
246 } | 246 } |
247 | 247 |
248 void GroupView::RemoveNotification(const std::string& notification_id, | 248 void GroupView::RemoveNotification(const std::string& notification_id, |
249 bool by_user) { | 249 bool by_user) { |
250 controller_->RemoveGroup(notifier_id_); | 250 controller_->RemoveGroup(notifier_id_); |
251 } | 251 } |
252 | 252 |
253 } // namespace message_center | 253 } // namespace message_center |
OLD | NEW |