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/network/tray_sms.h" | 5 #include "ash/system/network/tray_sms.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/system/tray/system_tray.h" | 9 #include "ash/system/tray/system_tray.h" |
10 #include "ash/system/tray/tray_constants.h" | 10 #include "ash/system/tray/tray_constants.h" |
11 #include "ash/system/tray/tray_details_view.h" | 11 #include "ash/system/tray/tray_details_view.h" |
12 #include "ash/system/tray/tray_item_more.h" | 12 #include "ash/system/tray/tray_item_more.h" |
13 #include "ash/system/tray/tray_item_view.h" | 13 #include "ash/system/tray/tray_item_view.h" |
| 14 #include "ash/system/tray/tray_notification_view.h" |
14 #include "ash/system/tray/tray_views.h" | 15 #include "ash/system/tray/tray_views.h" |
15 #include "base/command_line.h" | 16 #include "base/command_line.h" |
16 #include "base/string_number_conversions.h" | 17 #include "base/string_number_conversions.h" |
17 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
18 #include "grit/ash_strings.h" | 19 #include "grit/ash_strings.h" |
19 #include "grit/ui_resources_standard.h" | 20 #include "grit/ui_resources_standard.h" |
20 #include "grit/ui_resources_standard.h" | 21 #include "grit/ui_resources_standard.h" |
21 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
22 #include "ui/base/resource/resource_bundle.h" | 23 #include "ui/base/resource/resource_bundle.h" |
23 #include "ui/views/controls/image_view.h" | 24 #include "ui/views/controls/image_view.h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 | 237 |
237 DISALLOW_COPY_AND_ASSIGN(SmsDetailedView); | 238 DISALLOW_COPY_AND_ASSIGN(SmsDetailedView); |
238 }; | 239 }; |
239 | 240 |
240 class TraySms::SmsNotificationView : public TrayNotificationView { | 241 class TraySms::SmsNotificationView : public TrayNotificationView { |
241 public: | 242 public: |
242 SmsNotificationView(TraySms* tray, | 243 SmsNotificationView(TraySms* tray, |
243 size_t message_index, | 244 size_t message_index, |
244 const std::string& number, | 245 const std::string& number, |
245 const std::string& text) | 246 const std::string& text) |
246 : TrayNotificationView(IDR_AURA_UBER_TRAY_SMS), | 247 : TrayNotificationView(tray, IDR_AURA_UBER_TRAY_SMS), |
247 tray_(tray), | |
248 message_index_(message_index) { | 248 message_index_(message_index) { |
249 SmsMessageView* message_view = new SmsMessageView( | 249 SmsMessageView* message_view = new SmsMessageView( |
250 tray_, SmsMessageView::VIEW_NOTIFICATION, message_index_, number, text); | 250 tray, SmsMessageView::VIEW_NOTIFICATION, message_index_, number, text); |
251 InitView(message_view); | 251 InitView(message_view); |
252 } | 252 } |
253 | 253 |
254 void Update(size_t message_index, | 254 void Update(size_t message_index, |
255 const std::string& number, | 255 const std::string& number, |
256 const std::string& text) { | 256 const std::string& text) { |
257 SmsMessageView* message_view = new SmsMessageView( | 257 SmsMessageView* message_view = new SmsMessageView( |
258 tray_, SmsMessageView::VIEW_NOTIFICATION, message_index_, number, text); | 258 tray_sms(), SmsMessageView::VIEW_NOTIFICATION, |
| 259 message_index_, number, text); |
259 UpdateView(message_view); | 260 UpdateView(message_view); |
260 } | 261 } |
261 | 262 |
262 // Overridden from views::View. | |
263 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE { | |
264 tray_->PopupDetailedView(0, true); | |
265 return true; | |
266 } | |
267 | |
268 // Overridden from TrayNotificationView: | 263 // Overridden from TrayNotificationView: |
269 virtual void OnClose() OVERRIDE { | 264 virtual void OnClose() OVERRIDE { |
270 tray_->RemoveMessage(message_index_); | 265 tray_sms()->RemoveMessage(message_index_); |
271 tray_->HideNotificationView(); | 266 } |
| 267 |
| 268 virtual void OnClickAction() OVERRIDE { |
| 269 tray()->PopupDetailedView(0, true); |
272 } | 270 } |
273 | 271 |
274 private: | 272 private: |
275 TraySms* tray_; | 273 TraySms* tray_sms() { |
| 274 return static_cast<TraySms*>(tray()); |
| 275 } |
| 276 |
276 size_t message_index_; | 277 size_t message_index_; |
277 | 278 |
278 DISALLOW_COPY_AND_ASSIGN(SmsNotificationView); | 279 DISALLOW_COPY_AND_ASSIGN(SmsNotificationView); |
279 }; | 280 }; |
280 | 281 |
281 TraySms::TraySms() | 282 TraySms::TraySms() |
282 : default_(NULL), | 283 : default_(NULL), |
283 detailed_(NULL), | 284 detailed_(NULL), |
284 notification_(NULL) { | 285 notification_(NULL) { |
285 } | 286 } |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 if (GetLatestMessage(&index, &number, &text)) | 370 if (GetLatestMessage(&index, &number, &text)) |
370 notification_->Update(index, number, text); | 371 notification_->Update(index, number, text); |
371 } else if (notify) { | 372 } else if (notify) { |
372 ShowNotificationView(); | 373 ShowNotificationView(); |
373 } | 374 } |
374 } | 375 } |
375 } | 376 } |
376 | 377 |
377 } // namespace internal | 378 } // namespace internal |
378 } // namespace ash | 379 } // namespace ash |
OLD | NEW |