OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/chromeos/file_system_provider/notification_manager.h" | 5 #include "chrome/browser/chromeos/file_system_provider/notification_manager.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/extensions/app_icon_loader_impl.h" | 9 #include "chrome/browser/extensions/app_icon_loader_impl.h" |
10 #include "chrome/grit/generated_resources.h" | 10 #include "chrome/grit/generated_resources.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 // Passing a raw pointer is safe here, since the life of each notification is | 29 // Passing a raw pointer is safe here, since the life of each notification is |
30 // shorter than life of the |notification_manager|. | 30 // shorter than life of the |notification_manager|. |
31 explicit ProviderNotificationDelegate( | 31 explicit ProviderNotificationDelegate( |
32 NotificationManager* notification_manager) | 32 NotificationManager* notification_manager) |
33 : notification_manager_(notification_manager) {} | 33 : notification_manager_(notification_manager) {} |
34 | 34 |
35 virtual void ButtonClick(int button_index) override { | 35 virtual void ButtonClick(int button_index) override { |
36 notification_manager_->OnButtonClick(button_index); | 36 notification_manager_->OnButtonClick(button_index); |
37 } | 37 } |
38 | 38 |
39 virtual void Error() override { notification_manager_->OnError(); } | |
40 | |
41 virtual void Close(bool by_user) override { | 39 virtual void Close(bool by_user) override { |
42 notification_manager_->OnClose(); | 40 notification_manager_->OnClose(); |
43 } | 41 } |
44 | 42 |
45 private: | 43 private: |
46 virtual ~ProviderNotificationDelegate() {} | 44 virtual ~ProviderNotificationDelegate() {} |
47 NotificationManager* notification_manager_; // Not owned. | 45 NotificationManager* notification_manager_; // Not owned. |
48 | 46 |
49 DISALLOW_COPY_AND_ASSIGN(ProviderNotificationDelegate); | 47 DISALLOW_COPY_AND_ASSIGN(ProviderNotificationDelegate); |
50 }; | 48 }; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 } | 88 } |
91 | 89 |
92 g_browser_process->message_center()->RemoveNotification( | 90 g_browser_process->message_center()->RemoveNotification( |
93 file_system_info_.mount_path().value(), false /* by_user */); | 91 file_system_info_.mount_path().value(), false /* by_user */); |
94 } | 92 } |
95 | 93 |
96 void NotificationManager::OnButtonClick(int button_index) { | 94 void NotificationManager::OnButtonClick(int button_index) { |
97 OnNotificationResult(ABORT); | 95 OnNotificationResult(ABORT); |
98 } | 96 } |
99 | 97 |
100 void NotificationManager::OnError() { | |
101 OnNotificationResult(CONTINUE); | |
102 } | |
103 | |
104 void NotificationManager::OnClose() { | 98 void NotificationManager::OnClose() { |
105 OnNotificationResult(CONTINUE); | 99 OnNotificationResult(CONTINUE); |
106 } | 100 } |
107 | 101 |
108 void NotificationManager::SetAppImage(const std::string& id, | 102 void NotificationManager::SetAppImage(const std::string& id, |
109 const gfx::ImageSkia& image) { | 103 const gfx::ImageSkia& image) { |
110 extension_icon_.reset(new gfx::Image(image)); | 104 extension_icon_.reset(new gfx::Image(image)); |
111 g_browser_process->message_center()->UpdateNotification( | 105 g_browser_process->message_center()->UpdateNotification( |
112 file_system_info_.mount_path().value(), CreateNotification()); | 106 file_system_info_.mount_path().value(), CreateNotification()); |
113 } | 107 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 while (it != callbacks_.end()) { | 142 while (it != callbacks_.end()) { |
149 CallbackMap::iterator current_it = it++; | 143 CallbackMap::iterator current_it = it++; |
150 NotificationCallback callback = current_it->second; | 144 NotificationCallback callback = current_it->second; |
151 callbacks_.erase(current_it); | 145 callbacks_.erase(current_it); |
152 callback.Run(result); | 146 callback.Run(result); |
153 } | 147 } |
154 } | 148 } |
155 | 149 |
156 } // namespace file_system_provider | 150 } // namespace file_system_provider |
157 } // namespace chromeos | 151 } // namespace chromeos |
OLD | NEW |