Chromium Code Reviews| 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/common/system/chromeos/network/tray_sms.h" | 5 #include "ash/common/system/chromeos/network/tray_sms.h" |
| 6 | 6 |
| 7 #include <memory> | |
| 8 #include <utility> | |
| 9 | |
| 7 #include "ash/common/material_design/material_design_controller.h" | 10 #include "ash/common/material_design/material_design_controller.h" |
| 8 #include "ash/common/metrics/user_metrics_action.h" | 11 #include "ash/common/metrics/user_metrics_action.h" |
| 9 #include "ash/common/system/tray/fixed_sized_scroll_view.h" | 12 #include "ash/common/system/tray/fixed_sized_scroll_view.h" |
| 10 #include "ash/common/system/tray/system_tray.h" | 13 #include "ash/common/system/tray/system_tray.h" |
| 11 #include "ash/common/system/tray/system_tray_bubble.h" | 14 #include "ash/common/system/tray/system_tray_bubble.h" |
| 12 #include "ash/common/system/tray/tray_constants.h" | 15 #include "ash/common/system/tray/tray_constants.h" |
| 13 #include "ash/common/system/tray/tray_details_view.h" | 16 #include "ash/common/system/tray/tray_details_view.h" |
| 14 #include "ash/common/system/tray/tray_item_more.h" | 17 #include "ash/common/system/tray/tray_item_more.h" |
| 15 #include "ash/common/system/tray/tray_item_view.h" | 18 #include "ash/common/system/tray/tray_item_view.h" |
| 16 #include "ash/common/system/tray/tray_notification_view.h" | 19 #include "ash/common/system/tray/tray_notification_view.h" |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 361 if (!message.GetStringWithoutPathExpansion( | 364 if (!message.GetStringWithoutPathExpansion( |
| 362 chromeos::NetworkSmsHandler::kNumberKey, &message_number)) { | 365 chromeos::NetworkSmsHandler::kNumberKey, &message_number)) { |
| 363 NET_LOG_DEBUG("SMS contains no number. Ignoring.", ""); | 366 NET_LOG_DEBUG("SMS contains no number. Ignoring.", ""); |
| 364 return; | 367 return; |
| 365 } | 368 } |
| 366 | 369 |
| 367 NET_LOG_DEBUG( | 370 NET_LOG_DEBUG( |
| 368 "Received SMS from: " + message_number + " with text: " + message_text, | 371 "Received SMS from: " + message_number + " with text: " + message_text, |
| 369 ""); | 372 ""); |
| 370 | 373 |
| 371 base::DictionaryValue* dict = new base::DictionaryValue(); | 374 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
|
sky
2016/10/03 21:48:18
MakeUnique?
| |
| 372 dict->SetString(kSmsNumberKey, message_number); | 375 dict->SetString(kSmsNumberKey, message_number); |
| 373 dict->SetString(kSmsTextKey, message_text); | 376 dict->SetString(kSmsTextKey, message_text); |
| 374 messages_.Append(dict); | 377 messages_.Append(std::move(dict)); |
| 375 Update(true); | 378 Update(true); |
| 376 } | 379 } |
| 377 | 380 |
| 378 bool TraySms::GetLatestMessage(size_t* index, | 381 bool TraySms::GetLatestMessage(size_t* index, |
| 379 std::string* number, | 382 std::string* number, |
| 380 std::string* text) { | 383 std::string* text) { |
| 381 if (messages_.empty()) | 384 if (messages_.empty()) |
| 382 return false; | 385 return false; |
| 383 base::DictionaryValue* message; | 386 base::DictionaryValue* message; |
| 384 size_t message_index = messages_.GetSize() - 1; | 387 size_t message_index = messages_.GetSize() - 1; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 416 std::string number, text; | 419 std::string number, text; |
| 417 if (GetLatestMessage(&index, &number, &text)) | 420 if (GetLatestMessage(&index, &number, &text)) |
| 418 notification_->Update(index, number, text); | 421 notification_->Update(index, number, text); |
| 419 } else if (notify) { | 422 } else if (notify) { |
| 420 ShowNotificationView(); | 423 ShowNotificationView(); |
| 421 } | 424 } |
| 422 } | 425 } |
| 423 } | 426 } |
| 424 | 427 |
| 425 } // namespace ash | 428 } // namespace ash |
| OLD | NEW |