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.
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"
9 namespace task_manager
{
11 WebContentsInformation::WebContentsInformation() {}
13 WebContentsInformation::~WebContentsInformation() {}
15 NotificationObservingWebContentsInformation::
16 NotificationObservingWebContentsInformation() {}
18 NotificationObservingWebContentsInformation::
19 ~NotificationObservingWebContentsInformation() {}
21 void NotificationObservingWebContentsInformation::StartObservingCreation(
22 const NewWebContentsCallback
& callback
) {
23 observer_callback_
= callback
;
25 content::NOTIFICATION_WEB_CONTENTS_CONNECTED
,
26 content::NotificationService::AllBrowserContextsAndSources());
29 void NotificationObservingWebContentsInformation::StopObservingCreation() {
32 content::NOTIFICATION_WEB_CONTENTS_CONNECTED
,
33 content::NotificationService::AllBrowserContextsAndSources());
34 observer_callback_
.Reset();
37 void NotificationObservingWebContentsInformation::Observe(
39 const content::NotificationSource
& source
,
40 const content::NotificationDetails
& details
) {
41 content::WebContents
* web_contents
=
42 content::Source
<content::WebContents
>(source
).ptr();
45 case content::NOTIFICATION_WEB_CONTENTS_CONNECTED
:
46 if (CheckOwnership(web_contents
))
47 observer_callback_
.Run(web_contents
);
52 } // namespace task_manager