| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/task_manager/web_contents_information.h" | |
| 6 #include "content/public/browser/notification_service.h" | |
| 7 #include "content/public/browser/notification_types.h" | |
| 8 | |
| 9 namespace task_manager { | |
| 10 | |
| 11 WebContentsInformation::WebContentsInformation() {} | |
| 12 | |
| 13 WebContentsInformation::~WebContentsInformation() {} | |
| 14 | |
| 15 NotificationObservingWebContentsInformation:: | |
| 16 NotificationObservingWebContentsInformation() {} | |
| 17 | |
| 18 NotificationObservingWebContentsInformation:: | |
| 19 ~NotificationObservingWebContentsInformation() {} | |
| 20 | |
| 21 void NotificationObservingWebContentsInformation::StartObservingCreation( | |
| 22 const NewWebContentsCallback& callback) { | |
| 23 observer_callback_ = callback; | |
| 24 registrar_.Add(this, | |
| 25 content::NOTIFICATION_WEB_CONTENTS_CONNECTED, | |
| 26 content::NotificationService::AllBrowserContextsAndSources()); | |
| 27 } | |
| 28 | |
| 29 void NotificationObservingWebContentsInformation::StopObservingCreation() { | |
| 30 registrar_.Remove( | |
| 31 this, | |
| 32 content::NOTIFICATION_WEB_CONTENTS_CONNECTED, | |
| 33 content::NotificationService::AllBrowserContextsAndSources()); | |
| 34 observer_callback_.Reset(); | |
| 35 } | |
| 36 | |
| 37 void NotificationObservingWebContentsInformation::Observe( | |
| 38 int type, | |
| 39 const content::NotificationSource& source, | |
| 40 const content::NotificationDetails& details) { | |
| 41 DCHECK_EQ(content::NOTIFICATION_WEB_CONTENTS_CONNECTED, type); | |
| 42 | |
| 43 content::WebContents* web_contents = | |
| 44 content::Source<content::WebContents>(source).ptr(); | |
| 45 if (CheckOwnership(web_contents)) | |
| 46 observer_callback_.Run(web_contents); | |
| 47 } | |
| 48 | |
| 49 } // namespace task_manager | |
| OLD | NEW |