Switch NOTIFICATION_TAB_PARENTED to use WebContents.

BUG=107201
TEST=no visible change


Review URL: https://chromiumcodereview.appspot.com/10917198

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157134 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc
index 4ce7d7d4..8dc8dcf 100644
--- a/chrome/browser/metrics/metrics_service.cc
+++ b/chrome/browser/metrics/metrics_service.cc
@@ -197,6 +197,7 @@
 #include "content/public/browser/plugin_service.h"
 #include "content/public/browser/render_process_host.h"
 #include "content/public/browser/user_metrics.h"
+#include "content/public/browser/web_contents.h"
 #include "net/base/load_flags.h"
 #include "net/url_request/url_fetcher.h"
 #include "webkit/plugins/webplugininfo.h"
@@ -679,14 +680,26 @@
       break;
 
     case chrome::NOTIFICATION_BROWSER_OPENED:
-    case chrome::NOTIFICATION_BROWSER_CLOSED:
-      LogWindowChange(type, source, details);
+    case chrome::NOTIFICATION_BROWSER_CLOSED: {
+      Browser* browser = content::Source<Browser>(source).ptr();
+      LogWindowOrTabChange(type, reinterpret_cast<uintptr_t>(browser));
       break;
+    }
 
-    case chrome::NOTIFICATION_TAB_PARENTED:
-    case chrome::NOTIFICATION_TAB_CLOSING:
-      LogWindowChange(type, source, details);
+    case chrome::NOTIFICATION_TAB_PARENTED: {
+      content::WebContents* web_contents =
+          content::Source<content::WebContents>(source).ptr();
+      LogWindowOrTabChange(type, reinterpret_cast<uintptr_t>(web_contents));
       break;
+    }
+
+    case chrome::NOTIFICATION_TAB_CLOSING: {
+      content::NavigationController* controller =
+          content::Source<content::NavigationController>(source).ptr();
+      content::WebContents* web_contents = controller->GetWebContents();
+      LogWindowOrTabChange(type, reinterpret_cast<uintptr_t>(web_contents));
+      break;
+    }
 
     case content::NOTIFICATION_LOAD_STOP:
       LogLoadComplete(type, source, details);
@@ -1518,12 +1531,8 @@
   }
 }
 
-void MetricsService::LogWindowChange(
-    int type,
-    const content::NotificationSource& source,
-    const content::NotificationDetails& details) {
+void MetricsService::LogWindowOrTabChange(int type, uintptr_t window_or_tab) {
   int controller_id = -1;
-  uintptr_t window_or_tab = source.map_key();
   MetricsLog::WindowEventType window_type;
 
   // Note: since we stop all logging when a single OTR session is active, it is