Switch PepperBrokerObserver to use WebContentsUserData.

BUG=107201
TEST=no visible change


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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@158887 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/pepper_broker_observer.cc b/chrome/browser/pepper_broker_observer.cc
index 3d73e57..0f84010 100644
--- a/chrome/browser/pepper_broker_observer.cc
+++ b/chrome/browser/pepper_broker_observer.cc
@@ -30,6 +30,8 @@
 using content::Referrer;
 using content::WebContents;
 
+int PepperBrokerObserver::kUserDataKey;
+
 namespace {
 
 // The URL for the "learn more" article about the PPAPI broker.
diff --git a/chrome/browser/pepper_broker_observer.h b/chrome/browser/pepper_broker_observer.h
index e49d962..01f84bf 100644
--- a/chrome/browser/pepper_broker_observer.h
+++ b/chrome/browser/pepper_broker_observer.h
@@ -5,20 +5,25 @@
 #ifndef CHROME_BROWSER_PEPPER_BROKER_OBSERVER_H_
 #define CHROME_BROWSER_PEPPER_BROKER_OBSERVER_H_
 
+#include "chrome/browser/tab_contents/web_contents_user_data.h"
 #include "content/public/browser/web_contents_observer.h"
 
-class PepperBrokerObserver : public content::WebContentsObserver {
+class PepperBrokerObserver : public content::WebContentsObserver,
+                             public WebContentsUserData<PepperBrokerObserver> {
  public:
-  explicit PepperBrokerObserver(content::WebContents* web_contents);
   virtual ~PepperBrokerObserver();
 
+ private:
+  explicit PepperBrokerObserver(content::WebContents* web_contents);
+  static int kUserDataKey;
+  friend class WebContentsUserData<PepperBrokerObserver>;
+
   virtual bool RequestPpapiBrokerPermission(
       content::WebContents* web_contents,
       const GURL& url,
       const FilePath& plugin_path,
       const base::Callback<void(bool)>& callback) OVERRIDE;
 
- private:
   DISALLOW_COPY_AND_ASSIGN(PepperBrokerObserver);
 };
 
diff --git a/chrome/browser/ui/tab_contents/tab_contents.cc b/chrome/browser/ui/tab_contents/tab_contents.cc
index d15a154..4264e60 100644
--- a/chrome/browser/ui/tab_contents/tab_contents.cc
+++ b/chrome/browser/ui/tab_contents/tab_contents.cc
@@ -143,6 +143,7 @@
   password_manager_delegate_.reset(new PasswordManagerDelegateImpl(this));
   password_manager_.reset(
       new PasswordManager(contents, password_manager_delegate_.get()));
+  PepperBrokerObserver::CreateForWebContents(contents);
   PluginObserver::CreateForWebContents(contents);
   prefs_tab_helper_.reset(new PrefsTabHelper(contents));
   prerender_tab_helper_.reset(new prerender::PrerenderTabHelper(this));
@@ -171,7 +172,6 @@
 #endif
 
   navigation_metrics_recorder_.reset(new NavigationMetricsRecorder(contents));
-  pepper_broker_observer_.reset(new PepperBrokerObserver(contents));
   safe_browsing_tab_observer_.reset(
       new safe_browsing::SafeBrowsingTabObserver(this));
 
diff --git a/chrome/browser/ui/tab_contents/tab_contents.h b/chrome/browser/ui/tab_contents/tab_contents.h
index 9366762..26aa370 100644
--- a/chrome/browser/ui/tab_contents/tab_contents.h
+++ b/chrome/browser/ui/tab_contents/tab_contents.h
@@ -39,7 +39,6 @@
 class PanelHost;
 class PasswordManager;
 class PasswordManagerDelegate;
-class PepperBrokerObserver;
 class PrefsTabHelper;
 class Profile;
 class ShellWindow;
@@ -259,7 +258,6 @@
   // and silently do their thing live here.)
 
   scoped_ptr<NavigationMetricsRecorder> navigation_metrics_recorder_;
-  scoped_ptr<PepperBrokerObserver> pepper_broker_observer_;
   scoped_ptr<safe_browsing::SafeBrowsingTabObserver>
       safe_browsing_tab_observer_;