Switch ExternalProtocolObserver to use WebContentsUserData.

BUG=107201
TEST=no visible change


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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@158878 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/external_protocol/external_protocol_observer.cc b/chrome/browser/external_protocol/external_protocol_observer.cc
index 72990ae..e13e121 100644
--- a/chrome/browser/external_protocol/external_protocol_observer.cc
+++ b/chrome/browser/external_protocol/external_protocol_observer.cc
@@ -8,6 +8,8 @@
 
 using content::WebContents;
 
+int ExternalProtocolObserver::kUserDataKey;
+
 ExternalProtocolObserver::ExternalProtocolObserver(WebContents* web_contents)
     : content::WebContentsObserver(web_contents) {
 }
diff --git a/chrome/browser/external_protocol/external_protocol_observer.h b/chrome/browser/external_protocol/external_protocol_observer.h
index 4f6c1ff..e031804 100644
--- a/chrome/browser/external_protocol/external_protocol_observer.h
+++ b/chrome/browser/external_protocol/external_protocol_observer.h
@@ -5,19 +5,25 @@
 #ifndef CHROME_BROWSER_EXTERNAL_PROTOCOL_EXTERNAL_PROTOCOL_OBSERVER_H_
 #define CHROME_BROWSER_EXTERNAL_PROTOCOL_EXTERNAL_PROTOCOL_OBSERVER_H_
 
+#include "chrome/browser/tab_contents/web_contents_user_data.h"
 #include "content/public/browser/web_contents_observer.h"
 
 // ExternalProtocolObserver is responsible for handling messages from
 // WebContents relating to external protocols.
-class ExternalProtocolObserver : public content::WebContentsObserver {
+class ExternalProtocolObserver
+    : public content::WebContentsObserver,
+      public WebContentsUserData<ExternalProtocolObserver> {
  public:
-  explicit ExternalProtocolObserver(content::WebContents* web_contents);
   virtual ~ExternalProtocolObserver();
 
   // content::WebContentsObserver overrides.
   virtual void DidGetUserGesture() OVERRIDE;
 
  private:
+  explicit ExternalProtocolObserver(content::WebContents* web_contents);
+  static int kUserDataKey;
+  friend class WebContentsUserData<ExternalProtocolObserver>;
+
   DISALLOW_COPY_AND_ASSIGN(ExternalProtocolObserver);
 };
 
diff --git a/chrome/browser/ui/tab_contents/tab_contents.cc b/chrome/browser/ui/tab_contents/tab_contents.cc
index 55570cf..d15a154 100644
--- a/chrome/browser/ui/tab_contents/tab_contents.cc
+++ b/chrome/browser/ui/tab_contents/tab_contents.cc
@@ -133,6 +133,7 @@
   CoreTabHelper::CreateForWebContents(contents);
   extensions::TabHelper::CreateForWebContents(contents);
   extensions::WebNavigationTabObserver::CreateForWebContents(contents);
+  ExternalProtocolObserver::CreateForWebContents(contents);
   favicon_tab_helper_.reset(new FaviconTabHelper(contents));
   find_tab_helper_.reset(new FindTabHelper(contents));
   history_tab_helper_.reset(new HistoryTabHelper(contents));
@@ -169,7 +170,6 @@
   WebIntentPickerController::CreateForWebContents(contents);
 #endif
 
-  external_protocol_observer_.reset(new ExternalProtocolObserver(contents));
   navigation_metrics_recorder_.reset(new NavigationMetricsRecorder(contents));
   pepper_broker_observer_.reset(new PepperBrokerObserver(contents));
   safe_browsing_tab_observer_.reset(
diff --git a/chrome/browser/ui/tab_contents/tab_contents.h b/chrome/browser/ui/tab_contents/tab_contents.h
index d7afc28..9366762 100644
--- a/chrome/browser/ui/tab_contents/tab_contents.h
+++ b/chrome/browser/ui/tab_contents/tab_contents.h
@@ -25,7 +25,6 @@
 class ConstrainedWebDialogDelegateBase;
 class ConstrainedWindowTabHelper;
 class ExtensionTabUtil;
-class ExternalProtocolObserver;
 class ExternalTabContainerWin;
 class FaviconTabHelper;
 class FindBackendTestContentsCreator;
@@ -259,7 +258,6 @@
   // (These provide no API for callers; objects that need to exist 1:1 with tabs
   // and silently do their thing live here.)
 
-  scoped_ptr<ExternalProtocolObserver> external_protocol_observer_;
   scoped_ptr<NavigationMetricsRecorder> navigation_metrics_recorder_;
   scoped_ptr<PepperBrokerObserver> pepper_broker_observer_;
   scoped_ptr<safe_browsing::SafeBrowsingTabObserver>