| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/arc/notification/arc_notification_manager.h" | 5 #include "ui/arc/notification/arc_notification_manager.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "ash/common/system/toast/toast_manager.h" | 10 #include "ash/common/system/toast/toast_manager.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 notifications_instance->Init(binding_.CreateInterfacePtrAndBind()); | 55 notifications_instance->Init(binding_.CreateInterfacePtrAndBind()); |
| 56 ready_ = true; | 56 ready_ = true; |
| 57 } | 57 } |
| 58 | 58 |
| 59 void ArcNotificationManager::OnInstanceClosed() { | 59 void ArcNotificationManager::OnInstanceClosed() { |
| 60 DCHECK(ready_); | 60 DCHECK(ready_); |
| 61 while (!items_.empty()) { | 61 while (!items_.empty()) { |
| 62 auto it = items_.begin(); | 62 auto it = items_.begin(); |
| 63 std::unique_ptr<ArcNotificationItem> item = std::move(it->second); | 63 std::unique_ptr<ArcNotificationItem> item = std::move(it->second); |
| 64 items_.erase(it); | 64 items_.erase(it); |
| 65 item->OnClosedFromAndroid(false /* by_user */); | 65 item->OnClosedFromAndroid(); |
| 66 } | 66 } |
| 67 ready_ = false; | 67 ready_ = false; |
| 68 } | 68 } |
| 69 | 69 |
| 70 void ArcNotificationManager::OnNotificationPosted( | 70 void ArcNotificationManager::OnNotificationPosted( |
| 71 mojom::ArcNotificationDataPtr data) { | 71 mojom::ArcNotificationDataPtr data) { |
| 72 const std::string& key = data->key; | 72 const std::string& key = data->key; |
| 73 auto it = items_.find(key); | 73 auto it = items_.find(key); |
| 74 if (it == items_.end()) { | 74 if (it == items_.end()) { |
| 75 // Old client with version < 5 would have use_custom_notification default, | 75 // Old client with version < 5 would have use_custom_notification default, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 94 void ArcNotificationManager::OnNotificationRemoved(const mojo::String& key) { | 94 void ArcNotificationManager::OnNotificationRemoved(const mojo::String& key) { |
| 95 auto it = items_.find(key.get()); | 95 auto it = items_.find(key.get()); |
| 96 if (it == items_.end()) { | 96 if (it == items_.end()) { |
| 97 VLOG(3) << "Android requests to remove a notification (key: " << key | 97 VLOG(3) << "Android requests to remove a notification (key: " << key |
| 98 << "), but it is already gone."; | 98 << "), but it is already gone."; |
| 99 return; | 99 return; |
| 100 } | 100 } |
| 101 | 101 |
| 102 std::unique_ptr<ArcNotificationItem> item = std::move(it->second); | 102 std::unique_ptr<ArcNotificationItem> item = std::move(it->second); |
| 103 items_.erase(it); | 103 items_.erase(it); |
| 104 item->OnClosedFromAndroid(true /* by_user */); | 104 item->OnClosedFromAndroid(); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void ArcNotificationManager::SendNotificationRemovedFromChrome( | 107 void ArcNotificationManager::SendNotificationRemovedFromChrome( |
| 108 const std::string& key) { | 108 const std::string& key) { |
| 109 auto it = items_.find(key); | 109 auto it = items_.find(key); |
| 110 if (it == items_.end()) { | 110 if (it == items_.end()) { |
| 111 VLOG(3) << "Chrome requests to remove a notification (key: " << key | 111 VLOG(3) << "Chrome requests to remove a notification (key: " << key |
| 112 << "), but it is already gone."; | 112 << "), but it is already gone."; |
| 113 return; | 113 return; |
| 114 } | 114 } |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 ash::WmShell::Get()->toast_manager()->Show( | 238 ash::WmShell::Get()->toast_manager()->Show( |
| 239 ash::ToastData(data->id, data->text.To<base::string16>(), data->duration, | 239 ash::ToastData(data->id, data->text.To<base::string16>(), data->duration, |
| 240 data->dismiss_text.To<base::string16>())); | 240 data->dismiss_text.To<base::string16>())); |
| 241 } | 241 } |
| 242 | 242 |
| 243 void ArcNotificationManager::OnToastCancelled(mojom::ArcToastDataPtr data) { | 243 void ArcNotificationManager::OnToastCancelled(mojom::ArcToastDataPtr data) { |
| 244 ash::WmShell::Get()->toast_manager()->Cancel(data->id); | 244 ash::WmShell::Get()->toast_manager()->Cancel(data->id); |
| 245 } | 245 } |
| 246 | 246 |
| 247 } // namespace arc | 247 } // namespace arc |
| OLD | NEW |