OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/task_manager/task_manager_resource_providers.h" | 5 #include "chrome/browser/task_manager/task_manager_resource_providers.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/stl_util-inl.h" | 8 #include "base/stl_util-inl.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/notifications/balloon_collection.h" | 10 #include "chrome/browser/notifications/balloon_collection.h" |
11 #include "chrome/browser/notifications/balloon_host.h" | 11 #include "chrome/browser/notifications/balloon_host.h" |
12 #include "chrome/browser/notifications/notification_ui_manager.h" | 12 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 13 #include "chrome/common/chrome_notification_types.h" |
13 #include "content/browser/renderer_host/render_process_host.h" | 14 #include "content/browser/renderer_host/render_process_host.h" |
14 #include "content/browser/renderer_host/render_view_host.h" | 15 #include "content/browser/renderer_host/render_view_host.h" |
15 #include "content/common/notification_service.h" | 16 #include "content/common/notification_service.h" |
16 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
17 #include "grit/theme_resources.h" | 18 #include "grit/theme_resources.h" |
18 #include "third_party/skia/include/core/SkBitmap.h" | 19 #include "third_party/skia/include/core/SkBitmap.h" |
19 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
20 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
21 | 22 |
22 //////////////////////////////////////////////////////////////////////////////// | 23 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 // Add all the existing BalloonHosts. | 97 // Add all the existing BalloonHosts. |
97 BalloonCollection* collection = | 98 BalloonCollection* collection = |
98 g_browser_process->notification_ui_manager()->balloon_collection(); | 99 g_browser_process->notification_ui_manager()->balloon_collection(); |
99 const BalloonCollection::Balloons& balloons = collection->GetActiveBalloons(); | 100 const BalloonCollection::Balloons& balloons = collection->GetActiveBalloons(); |
100 for (BalloonCollection::Balloons::const_iterator it = balloons.begin(); | 101 for (BalloonCollection::Balloons::const_iterator it = balloons.begin(); |
101 it != balloons.end(); ++it) { | 102 it != balloons.end(); ++it) { |
102 AddToTaskManager((*it)->view()->GetHost()); | 103 AddToTaskManager((*it)->view()->GetHost()); |
103 } | 104 } |
104 | 105 |
105 // Register for notifications about extension process changes. | 106 // Register for notifications about extension process changes. |
106 registrar_.Add(this, NotificationType::NOTIFY_BALLOON_CONNECTED, | 107 registrar_.Add(this, chrome::NOTIFICATION_NOTIFY_BALLOON_CONNECTED, |
107 NotificationService::AllSources()); | 108 NotificationService::AllSources()); |
108 registrar_.Add(this, NotificationType::NOTIFY_BALLOON_DISCONNECTED, | 109 registrar_.Add(this, chrome::NOTIFICATION_NOTIFY_BALLOON_DISCONNECTED, |
109 NotificationService::AllSources()); | 110 NotificationService::AllSources()); |
110 } | 111 } |
111 | 112 |
112 void TaskManagerNotificationResourceProvider::StopUpdating() { | 113 void TaskManagerNotificationResourceProvider::StopUpdating() { |
113 DCHECK(updating_); | 114 DCHECK(updating_); |
114 updating_ = false; | 115 updating_ = false; |
115 | 116 |
116 // Unregister for notifications about extension process changes. | 117 // Unregister for notifications about extension process changes. |
117 registrar_.Remove(this, NotificationType::NOTIFY_BALLOON_CONNECTED, | 118 registrar_.Remove(this, chrome::NOTIFICATION_NOTIFY_BALLOON_CONNECTED, |
118 NotificationService::AllSources()); | 119 NotificationService::AllSources()); |
119 registrar_.Remove(this, NotificationType::NOTIFY_BALLOON_DISCONNECTED, | 120 registrar_.Remove(this, chrome::NOTIFICATION_NOTIFY_BALLOON_DISCONNECTED, |
120 NotificationService::AllSources()); | 121 NotificationService::AllSources()); |
121 | 122 |
122 // Delete all the resources. | 123 // Delete all the resources. |
123 STLDeleteContainerPairSecondPointers(resources_.begin(), resources_.end()); | 124 STLDeleteContainerPairSecondPointers(resources_.begin(), resources_.end()); |
124 resources_.clear(); | 125 resources_.clear(); |
125 } | 126 } |
126 | 127 |
127 void TaskManagerNotificationResourceProvider::Observe( | 128 void TaskManagerNotificationResourceProvider::Observe( |
128 NotificationType type, | 129 int type, |
129 const NotificationSource& source, | 130 const NotificationSource& source, |
130 const NotificationDetails& details) { | 131 const NotificationDetails& details) { |
131 switch (type.value) { | 132 switch (type) { |
132 case NotificationType::NOTIFY_BALLOON_CONNECTED: | 133 case chrome::NOTIFICATION_NOTIFY_BALLOON_CONNECTED: |
133 AddToTaskManager(Source<BalloonHost>(source).ptr()); | 134 AddToTaskManager(Source<BalloonHost>(source).ptr()); |
134 break; | 135 break; |
135 case NotificationType::NOTIFY_BALLOON_DISCONNECTED: | 136 case chrome::NOTIFICATION_NOTIFY_BALLOON_DISCONNECTED: |
136 RemoveFromTaskManager(Source<BalloonHost>(source).ptr()); | 137 RemoveFromTaskManager(Source<BalloonHost>(source).ptr()); |
137 break; | 138 break; |
138 default: | 139 default: |
139 NOTREACHED() << "Unexpected notification."; | 140 NOTREACHED() << "Unexpected notification."; |
140 return; | 141 return; |
141 } | 142 } |
142 } | 143 } |
143 | 144 |
144 void TaskManagerNotificationResourceProvider::AddToTaskManager( | 145 void TaskManagerNotificationResourceProvider::AddToTaskManager( |
145 BalloonHost* balloon_host) { | 146 BalloonHost* balloon_host) { |
(...skipping 16 matching lines...) Expand all Loading... |
162 // Remove the resource from the Task Manager. | 163 // Remove the resource from the Task Manager. |
163 TaskManagerNotificationResource* resource = iter->second; | 164 TaskManagerNotificationResource* resource = iter->second; |
164 task_manager_->RemoveResource(resource); | 165 task_manager_->RemoveResource(resource); |
165 | 166 |
166 // Remove it from the map. | 167 // Remove it from the map. |
167 resources_.erase(iter); | 168 resources_.erase(iter); |
168 | 169 |
169 // Finally, delete the resource. | 170 // Finally, delete the resource. |
170 delete resource; | 171 delete resource; |
171 } | 172 } |
OLD | NEW |