OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chrome/browser/task_manager/tab_contents_resource_provider.h" | 5 #include "chrome/browser/task_manager/tab_contents_resource_provider.h" |
6 | 6 |
7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/devtools/devtools_window.h" | 9 #include "chrome/browser/devtools/devtools_window.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 for (printing::BackgroundPrintingManager::WebContentsSet::iterator i = | 251 for (printing::BackgroundPrintingManager::WebContentsSet::iterator i = |
252 printing_manager->begin(); | 252 printing_manager->begin(); |
253 i != printing_manager->end(); ++i) { | 253 i != printing_manager->end(); ++i) { |
254 Add(*i); | 254 Add(*i); |
255 } | 255 } |
256 #endif | 256 #endif |
257 | 257 |
258 // Then we register for notifications to get new web contents. | 258 // Then we register for notifications to get new web contents. |
259 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_CONNECTED, | 259 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_CONNECTED, |
260 content::NotificationService::AllBrowserContextsAndSources()); | 260 content::NotificationService::AllBrowserContextsAndSources()); |
261 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_SWAPPED, | 261 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
262 content::NotificationService::AllBrowserContextsAndSources()); | 262 content::NotificationService::AllBrowserContextsAndSources()); |
263 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED, | 263 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED, |
264 content::NotificationService::AllBrowserContextsAndSources()); | 264 content::NotificationService::AllBrowserContextsAndSources()); |
265 } | 265 } |
266 | 266 |
267 void TabContentsResourceProvider::StopUpdating() { | 267 void TabContentsResourceProvider::StopUpdating() { |
268 DCHECK(updating_); | 268 DCHECK(updating_); |
269 updating_ = false; | 269 updating_ = false; |
270 | 270 |
271 // Then we unregister for notifications to get new web contents. | 271 // Then we unregister for notifications to get new web contents. |
272 registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_CONNECTED, | 272 registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_CONNECTED, |
273 content::NotificationService::AllBrowserContextsAndSources()); | 273 content::NotificationService::AllBrowserContextsAndSources()); |
274 registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_SWAPPED, | 274 registrar_.Remove(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
275 content::NotificationService::AllBrowserContextsAndSources()); | 275 content::NotificationService::AllBrowserContextsAndSources()); |
276 registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED, | 276 registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED, |
277 content::NotificationService::AllBrowserContextsAndSources()); | 277 content::NotificationService::AllBrowserContextsAndSources()); |
278 | 278 |
279 // Delete all the resources. | 279 // Delete all the resources. |
280 STLDeleteContainerPairSecondPointers(resources_.begin(), resources_.end()); | 280 STLDeleteContainerPairSecondPointers(resources_.begin(), resources_.end()); |
281 | 281 |
282 resources_.clear(); | 282 resources_.clear(); |
283 } | 283 } |
284 | 284 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 void TabContentsResourceProvider::Observe( | 344 void TabContentsResourceProvider::Observe( |
345 int type, | 345 int type, |
346 const content::NotificationSource& source, | 346 const content::NotificationSource& source, |
347 const content::NotificationDetails& details) { | 347 const content::NotificationDetails& details) { |
348 WebContents* web_contents = content::Source<WebContents>(source).ptr(); | 348 WebContents* web_contents = content::Source<WebContents>(source).ptr(); |
349 | 349 |
350 switch (type) { | 350 switch (type) { |
351 case content::NOTIFICATION_WEB_CONTENTS_CONNECTED: | 351 case content::NOTIFICATION_WEB_CONTENTS_CONNECTED: |
352 Add(web_contents); | 352 Add(web_contents); |
353 break; | 353 break; |
354 case content::NOTIFICATION_WEB_CONTENTS_SWAPPED: | 354 case content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED: |
355 Remove(web_contents); | 355 Remove(web_contents); |
356 Add(web_contents); | 356 Add(web_contents); |
357 break; | 357 break; |
358 case content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED: | 358 case content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED: |
359 Remove(web_contents); | 359 Remove(web_contents); |
360 break; | 360 break; |
361 default: | 361 default: |
362 NOTREACHED() << "Unexpected notification."; | 362 NOTREACHED() << "Unexpected notification."; |
363 return; | 363 return; |
364 } | 364 } |
365 } | 365 } |
366 | 366 |
367 } // namespace task_manager | 367 } // namespace task_manager |
OLD | NEW |