| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chromeos/network/tray_sms.h" | 5 #include "ash/system/chromeos/network/tray_sms.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/system/tray/fixed_sized_scroll_view.h" | 8 #include "ash/system/tray/fixed_sized_scroll_view.h" |
| 9 #include "ash/system/tray/system_tray.h" | 9 #include "ash/system/tray/system_tray.h" |
| 10 #include "ash/system/tray/system_tray_bubble.h" | 10 #include "ash/system/tray/system_tray_bubble.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 | 56 |
| 57 class TraySms::SmsDefaultView : public TrayItemMore { | 57 class TraySms::SmsDefaultView : public TrayItemMore { |
| 58 public: | 58 public: |
| 59 explicit SmsDefaultView(TraySms* owner) | 59 explicit SmsDefaultView(TraySms* owner) |
| 60 : TrayItemMore(owner, true) { | 60 : TrayItemMore(owner, true) { |
| 61 SetImage(ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 61 SetImage(ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 62 IDR_AURA_UBER_TRAY_SMS)); | 62 IDR_AURA_UBER_TRAY_SMS)); |
| 63 Update(); | 63 Update(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 virtual ~SmsDefaultView() {} | 66 ~SmsDefaultView() override {} |
| 67 | 67 |
| 68 void Update() { | 68 void Update() { |
| 69 int message_count = static_cast<TraySms*>(owner())->messages().GetSize(); | 69 int message_count = static_cast<TraySms*>(owner())->messages().GetSize(); |
| 70 base::string16 label = l10n_util::GetStringFUTF16( | 70 base::string16 label = l10n_util::GetStringFUTF16( |
| 71 IDS_ASH_STATUS_TRAY_SMS_MESSAGES, base::IntToString16(message_count)); | 71 IDS_ASH_STATUS_TRAY_SMS_MESSAGES, base::IntToString16(message_count)); |
| 72 SetLabel(label); | 72 SetLabel(label); |
| 73 SetAccessibleName(label); | 73 SetAccessibleName(label); |
| 74 } | 74 } |
| 75 | 75 |
| 76 private: | 76 private: |
| (...skipping 26 matching lines...) Expand all Loading... |
| 103 message_label_ = new views::Label(base::UTF8ToUTF16(message)); | 103 message_label_ = new views::Label(base::UTF8ToUTF16(message)); |
| 104 message_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 104 message_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 105 message_label_->SetMultiLine(true); | 105 message_label_->SetMultiLine(true); |
| 106 | 106 |
| 107 if (view_type == VIEW_DETAILED) | 107 if (view_type == VIEW_DETAILED) |
| 108 LayoutDetailedView(); | 108 LayoutDetailedView(); |
| 109 else | 109 else |
| 110 LayoutNotificationView(); | 110 LayoutNotificationView(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 virtual ~SmsMessageView() { | 113 ~SmsMessageView() override {} |
| 114 } | |
| 115 | 114 |
| 116 // Overridden from ButtonListener. | 115 // Overridden from ButtonListener. |
| 117 virtual void ButtonPressed(views::Button* sender, | 116 void ButtonPressed(views::Button* sender, const ui::Event& event) override { |
| 118 const ui::Event& event) override { | |
| 119 owner_->RemoveMessage(index_); | 117 owner_->RemoveMessage(index_); |
| 120 owner_->Update(false); | 118 owner_->Update(false); |
| 121 } | 119 } |
| 122 | 120 |
| 123 private: | 121 private: |
| 124 void LayoutDetailedView() { | 122 void LayoutDetailedView() { |
| 125 views::ImageButton* close_button = new views::ImageButton(this); | 123 views::ImageButton* close_button = new views::ImageButton(this); |
| 126 close_button->SetImage( | 124 close_button->SetImage( |
| 127 views::CustomButton::STATE_NORMAL, | 125 views::CustomButton::STATE_NORMAL, |
| 128 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 126 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 | 176 |
| 179 class TraySms::SmsDetailedView : public TrayDetailsView, | 177 class TraySms::SmsDetailedView : public TrayDetailsView, |
| 180 public ViewClickListener { | 178 public ViewClickListener { |
| 181 public: | 179 public: |
| 182 explicit SmsDetailedView(TraySms* owner) | 180 explicit SmsDetailedView(TraySms* owner) |
| 183 : TrayDetailsView(owner) { | 181 : TrayDetailsView(owner) { |
| 184 Init(); | 182 Init(); |
| 185 Update(); | 183 Update(); |
| 186 } | 184 } |
| 187 | 185 |
| 188 virtual ~SmsDetailedView() { | 186 ~SmsDetailedView() override {} |
| 189 } | |
| 190 | 187 |
| 191 void Init() { | 188 void Init() { |
| 192 CreateScrollableList(); | 189 CreateScrollableList(); |
| 193 CreateSpecialRow(IDS_ASH_STATUS_TRAY_SMS, this); | 190 CreateSpecialRow(IDS_ASH_STATUS_TRAY_SMS, this); |
| 194 } | 191 } |
| 195 | 192 |
| 196 void Update() { | 193 void Update() { |
| 197 UpdateMessageList(); | 194 UpdateMessageList(); |
| 198 Layout(); | 195 Layout(); |
| 199 SchedulePaint(); | 196 SchedulePaint(); |
| 200 } | 197 } |
| 201 | 198 |
| 202 // Overridden from views::View. | 199 // Overridden from views::View. |
| 203 virtual gfx::Size GetPreferredSize() const override { | 200 gfx::Size GetPreferredSize() const override { |
| 204 gfx::Size preferred_size = TrayDetailsView::GetPreferredSize(); | 201 gfx::Size preferred_size = TrayDetailsView::GetPreferredSize(); |
| 205 if (preferred_size.height() < kMessageListMinHeight) | 202 if (preferred_size.height() < kMessageListMinHeight) |
| 206 preferred_size.set_height(kMessageListMinHeight); | 203 preferred_size.set_height(kMessageListMinHeight); |
| 207 return preferred_size; | 204 return preferred_size; |
| 208 } | 205 } |
| 209 | 206 |
| 210 private: | 207 private: |
| 211 void UpdateMessageList() { | 208 void UpdateMessageList() { |
| 212 const base::ListValue& messages = | 209 const base::ListValue& messages = |
| 213 static_cast<TraySms*>(owner())->messages(); | 210 static_cast<TraySms*>(owner())->messages(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 225 } | 222 } |
| 226 SmsMessageView* msgview = new SmsMessageView( | 223 SmsMessageView* msgview = new SmsMessageView( |
| 227 static_cast<TraySms*>(owner()), SmsMessageView::VIEW_DETAILED, index, | 224 static_cast<TraySms*>(owner()), SmsMessageView::VIEW_DETAILED, index, |
| 228 number, text); | 225 number, text); |
| 229 scroll_content()->AddChildView(msgview); | 226 scroll_content()->AddChildView(msgview); |
| 230 } | 227 } |
| 231 scroller()->Layout(); | 228 scroller()->Layout(); |
| 232 } | 229 } |
| 233 | 230 |
| 234 // Overridden from ViewClickListener. | 231 // Overridden from ViewClickListener. |
| 235 virtual void OnViewClicked(views::View* sender) override { | 232 void OnViewClicked(views::View* sender) override { |
| 236 if (sender == footer()->content()) | 233 if (sender == footer()->content()) |
| 237 TransitionToDefaultView(); | 234 TransitionToDefaultView(); |
| 238 } | 235 } |
| 239 | 236 |
| 240 DISALLOW_COPY_AND_ASSIGN(SmsDetailedView); | 237 DISALLOW_COPY_AND_ASSIGN(SmsDetailedView); |
| 241 }; | 238 }; |
| 242 | 239 |
| 243 class TraySms::SmsNotificationView : public TrayNotificationView { | 240 class TraySms::SmsNotificationView : public TrayNotificationView { |
| 244 public: | 241 public: |
| 245 SmsNotificationView(TraySms* owner, | 242 SmsNotificationView(TraySms* owner, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 256 void Update(size_t message_index, | 253 void Update(size_t message_index, |
| 257 const std::string& number, | 254 const std::string& number, |
| 258 const std::string& text) { | 255 const std::string& text) { |
| 259 SmsMessageView* message_view = new SmsMessageView( | 256 SmsMessageView* message_view = new SmsMessageView( |
| 260 tray_sms(), SmsMessageView::VIEW_NOTIFICATION, | 257 tray_sms(), SmsMessageView::VIEW_NOTIFICATION, |
| 261 message_index_, number, text); | 258 message_index_, number, text); |
| 262 UpdateView(message_view); | 259 UpdateView(message_view); |
| 263 } | 260 } |
| 264 | 261 |
| 265 // Overridden from TrayNotificationView: | 262 // Overridden from TrayNotificationView: |
| 266 virtual void OnClose() override { | 263 void OnClose() override { tray_sms()->RemoveMessage(message_index_); } |
| 267 tray_sms()->RemoveMessage(message_index_); | |
| 268 } | |
| 269 | 264 |
| 270 virtual void OnClickAction() override { | 265 void OnClickAction() override { owner()->PopupDetailedView(0, true); } |
| 271 owner()->PopupDetailedView(0, true); | |
| 272 } | |
| 273 | 266 |
| 274 private: | 267 private: |
| 275 TraySms* tray_sms() { | 268 TraySms* tray_sms() { |
| 276 return static_cast<TraySms*>(owner()); | 269 return static_cast<TraySms*>(owner()); |
| 277 } | 270 } |
| 278 | 271 |
| 279 size_t message_index_; | 272 size_t message_index_; |
| 280 | 273 |
| 281 DISALLOW_COPY_AND_ASSIGN(SmsNotificationView); | 274 DISALLOW_COPY_AND_ASSIGN(SmsNotificationView); |
| 282 }; | 275 }; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 std::string number, text; | 403 std::string number, text; |
| 411 if (GetLatestMessage(&index, &number, &text)) | 404 if (GetLatestMessage(&index, &number, &text)) |
| 412 notification_->Update(index, number, text); | 405 notification_->Update(index, number, text); |
| 413 } else if (notify) { | 406 } else if (notify) { |
| 414 ShowNotificationView(); | 407 ShowNotificationView(); |
| 415 } | 408 } |
| 416 } | 409 } |
| 417 } | 410 } |
| 418 | 411 |
| 419 } // namespace ash | 412 } // namespace ash |
| OLD | NEW |