Get rid of the remaining implementation in TabContentsView and make all the methods be pure. This removes the dependency on RenderViewHostDelegateHelper, which is Chrome specific.

BUG=87702
Review URL: http://codereview.chromium.org/7285050

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92217 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/content/browser/tab_contents/interstitial_page.cc b/content/browser/tab_contents/interstitial_page.cc
index 383b26e..97357bb 100644
--- a/content/browser/tab_contents/interstitial_page.cc
+++ b/content/browser/tab_contents/interstitial_page.cc
@@ -663,13 +663,3 @@
     int request_id, int number_of_matches, const gfx::Rect& selection_rect,
     int active_match_ordinal, bool final_update) {
 }
-
-void InterstitialPage::UpdateInspectorSetting(const std::string& key,
-                                              const std::string& value) {
-  RenderViewHostDelegateHelper::UpdateInspectorSetting(
-      tab_->profile(), key, value);
-}
-
-void InterstitialPage::ClearInspectorSettings() {
-  RenderViewHostDelegateHelper::ClearInspectorSettings(tab_->profile());
-}
diff --git a/content/browser/tab_contents/interstitial_page.h b/content/browser/tab_contents/interstitial_page.h
index 2719274..5087762 100644
--- a/content/browser/tab_contents/interstitial_page.h
+++ b/content/browser/tab_contents/interstitial_page.h
@@ -109,10 +109,6 @@
   }
   bool reload_on_dont_proceed() const { return reload_on_dont_proceed_; }
 
-  virtual void UpdateInspectorSetting(const std::string& key,
-                                      const std::string& value);
-  virtual void ClearInspectorSettings();
-
  protected:
   // NotificationObserver method:
   virtual void Observe(int type,
diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc
index 98f03f93..25057f4ed 100644
--- a/content/browser/tab_contents/tab_contents.cc
+++ b/content/browser/tab_contents/tab_contents.cc
@@ -1448,15 +1448,6 @@
     delegate()->UpdateTargetURL(this, url);
 }
 
-void TabContents::UpdateInspectorSetting(const std::string& key,
-                                         const std::string& value) {
-  RenderViewHostDelegateHelper::UpdateInspectorSetting(profile(), key, value);
-}
-
-void TabContents::ClearInspectorSettings() {
-  RenderViewHostDelegateHelper::ClearInspectorSettings(profile());
-}
-
 void TabContents::Close(RenderViewHost* rvh) {
   // The UI may be in an event-tracking loop, such as between the
   // mouse-down and mouse-up in text selection or a button click.
@@ -1637,10 +1628,9 @@
 }
 
 WebPreferences TabContents::GetWebkitPrefs() {
-  Profile* profile = render_view_host()->process()->profile();
-  bool is_web_ui = false;
   WebPreferences web_prefs =
-      RenderViewHostDelegateHelper::GetWebkitPrefs(profile, is_web_ui);
+      content::GetContentClient()->browser()->GetWebkitPrefs(
+          render_view_host()->process()->profile(), false);
 
   // Force accelerated compositing and 2d canvas off for chrome:, about: and
   // chrome-devtools: pages.
diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h
index 018fc7a..7a92b22 100644
--- a/content/browser/tab_contents/tab_contents.h
+++ b/content/browser/tab_contents/tab_contents.h
@@ -623,9 +623,6 @@
   virtual void UpdateEncoding(RenderViewHost* render_view_host,
                               const std::string& encoding);
   virtual void UpdateTargetURL(int32 page_id, const GURL& url);
-  virtual void UpdateInspectorSetting(const std::string& key,
-                                      const std::string& value);
-  virtual void ClearInspectorSettings();
   virtual void Close(RenderViewHost* render_view_host);
   virtual void RequestMove(const gfx::Rect& new_bounds);
   virtual void DidStartLoading();
diff --git a/content/browser/tab_contents/tab_contents_view.cc b/content/browser/tab_contents/tab_contents_view.cc
index 7458f54..e4fda32 100644
--- a/content/browser/tab_contents/tab_contents_view.cc
+++ b/content/browser/tab_contents/tab_contents_view.cc
@@ -4,120 +4,6 @@
 
 #include "content/browser/tab_contents/tab_contents_view.h"
 
-#include "content/browser/renderer_host/render_process_host.h"
-#include "content/browser/renderer_host/render_view_host.h"
-#include "content/browser/renderer_host/render_view_host_delegate.h"
-#include "content/browser/renderer_host/render_widget_host.h"
-#include "content/browser/renderer_host/render_widget_host_view.h"
-#include "content/browser/tab_contents/tab_contents.h"
-#include "content/browser/tab_contents/tab_contents_delegate.h"
-#include "content/common/notification_service.h"
-#include "content/common/view_messages.h"
-
-TabContentsView::TabContentsView(TabContents* tab_contents)
-    : tab_contents_(tab_contents) {
-}
+TabContentsView::TabContentsView() {}
 
 TabContentsView::~TabContentsView() {}
-
-void TabContentsView::CreateNewWindow(
-    int route_id,
-    const ViewHostMsg_CreateWindow_Params& params) {
-  TabContents* new_contents = delegate_view_helper_.CreateNewWindow(
-      route_id,
-      tab_contents_->profile(),
-      tab_contents_->GetSiteInstance(),
-      tab_contents_->GetWebUITypeForCurrentState(),
-      tab_contents_,
-      params.window_container_type,
-      params.frame_name);
-
-  if (new_contents) {
-    NotificationService::current()->Notify(
-        content::NOTIFICATION_CREATING_NEW_WINDOW,
-        Source<TabContents>(tab_contents_),
-        Details<const ViewHostMsg_CreateWindow_Params>(&params));
-
-    if (tab_contents_->delegate())
-      tab_contents_->delegate()->TabContentsCreated(new_contents);
-  } else {
-    NotificationService::current()->Notify(
-        content::NOTIFICATION_CREATING_NEW_WINDOW_CANCELLED,
-        Source<TabContents>(tab_contents_),
-        Details<const ViewHostMsg_CreateWindow_Params>(&params));
-  }
-}
-
-void TabContentsView::CreateNewWidget(int route_id,
-                                      WebKit::WebPopupType popup_type) {
-  CreateNewWidgetInternal(route_id, popup_type);
-}
-
-void TabContentsView::CreateNewFullscreenWidget(int route_id) {
-  CreateNewFullscreenWidgetInternal(route_id);
-}
-
-void TabContentsView::ShowCreatedWindow(int route_id,
-                                        WindowOpenDisposition disposition,
-                                        const gfx::Rect& initial_pos,
-                                        bool user_gesture) {
-  TabContents* contents = delegate_view_helper_.GetCreatedWindow(route_id);
-  if (contents) {
-    tab_contents()->AddNewContents(
-        contents, disposition, initial_pos, user_gesture);
-  }
-}
-
-void TabContentsView::ShowCreatedWidget(int route_id,
-                                        const gfx::Rect& initial_pos) {
-  RenderWidgetHostView* widget_host_view =
-      delegate_view_helper_.GetCreatedWidget(route_id);
-  ShowCreatedWidgetInternal(widget_host_view, initial_pos);
-}
-
-void TabContentsView::ShowCreatedFullscreenWidget(int route_id) {
-  RenderWidgetHostView* widget_host_view =
-      delegate_view_helper_.GetCreatedWidget(route_id);
-  ShowCreatedFullscreenWidgetInternal(widget_host_view);
-}
-
-bool TabContentsView::IsDoingDrag() const {
-  return false;
-}
-
-bool TabContentsView::IsEventTracking() const {
-  return false;
-}
-
-TabContentsView::TabContentsView() : tab_contents_(NULL) {}
-
-RenderWidgetHostView* TabContentsView::CreateNewWidgetInternal(
-    int route_id, WebKit::WebPopupType popup_type) {
-  return delegate_view_helper_.CreateNewWidget(route_id, popup_type,
-      tab_contents()->render_view_host()->process());
-}
-
-void TabContentsView::ShowCreatedWidgetInternal(
-    RenderWidgetHostView* widget_host_view, const gfx::Rect& initial_pos) {
-  if (tab_contents_->delegate())
-    tab_contents_->delegate()->RenderWidgetShowing();
-
-  widget_host_view->InitAsPopup(tab_contents_->GetRenderWidgetHostView(),
-                                initial_pos);
-  widget_host_view->GetRenderWidgetHost()->Init();
-}
-
-RenderWidgetHostView* TabContentsView::CreateNewFullscreenWidgetInternal(
-    int route_id) {
-  return delegate_view_helper_.CreateNewFullscreenWidget(
-      route_id, tab_contents()->render_view_host()->process());
-}
-
-void TabContentsView::ShowCreatedFullscreenWidgetInternal(
-    RenderWidgetHostView* widget_host_view) {
-  if (tab_contents_->delegate())
-    tab_contents_->delegate()->RenderWidgetShowing();
-
-  widget_host_view->InitAsFullscreen();
-  widget_host_view->GetRenderWidgetHost()->Init();
-}
diff --git a/content/browser/tab_contents/tab_contents_view.h b/content/browser/tab_contents/tab_contents_view.h
index 16ae3ab..bbc6d3b9 100644
--- a/content/browser/tab_contents/tab_contents_view.h
+++ b/content/browser/tab_contents/tab_contents_view.h
@@ -6,11 +6,9 @@
 #define CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_H_
 #pragma once
 
-#include <map>
 #include <string>
 
 #include "base/basictypes.h"
-#include "chrome/browser/tab_contents/render_view_host_delegate_helper.h"
 #include "content/browser/renderer_host/render_view_host_delegate.h"
 #include "ui/gfx/native_widget_types.h"
 #include "ui/gfx/rect.h"
@@ -25,12 +23,8 @@
 // dependent web contents views. The TabContents uses this interface to talk to
 // them. View-related messages will also get forwarded directly to this class
 // from RenderViewHost via RenderViewHostDelegate::View.
-//
-// It contains a small amount of logic with respect to creating new sub-view
-// that should be the same for all platforms.
 class TabContentsView : public RenderViewHostDelegate::View {
  public:
-  explicit TabContentsView(TabContents* tab_contents);
   virtual ~TabContentsView();
 
   // Creates the appropriate type of TabContentsView for the current system.
@@ -38,8 +32,6 @@
   // the caller.
   static TabContentsView* Create(TabContents* tab_contents);
 
-  TabContents* tab_contents() const { return tab_contents_; }
-
   virtual void CreateView(const gfx::Size& initial_size) = 0;
 
   // Sets up the View that holds the rendered web page, receives messages for
@@ -95,7 +87,7 @@
 
   // Invoked when the TabContents is notified that the RenderView has been
   // fully created.
-  virtual void RenderViewCreated(RenderViewHost* host) {}
+  virtual void RenderViewCreated(RenderViewHost* host) = 0;
 
   // Sets focus to the native widget for this tab.
   virtual void Focus() = 0;
@@ -112,21 +104,21 @@
   virtual void RestoreFocus() = 0;
 
   // Notification that the preferred size of the contents has changed.
-  virtual void UpdatePreferredSize(const gfx::Size& pref_size) {}
+  virtual void UpdatePreferredSize(const gfx::Size& pref_size) = 0;
 
   // If we try to close the tab while a drag is in progress, we crash.  These
   // methods allow the tab contents to determine if a drag is in progress and
   // postpone the tab closing.
-  virtual bool IsDoingDrag() const;
-  virtual void CancelDragAndCloseTab() {}
+  virtual bool IsDoingDrag() const = 0;
+  virtual void CancelDragAndCloseTab() = 0;
 
   // If we close the tab while a UI control is in an event-tracking
   // loop, the control may message freed objects and crash.
   // TabContents::Close() calls IsEventTracking(), and if it returns
   // true CloseTabAfterEventTracking() is called and the close is not
   // completed.
-  virtual bool IsEventTracking() const;
-  virtual void CloseTabAfterEventTracking() {}
+  virtual bool IsEventTracking() const = 0;
+  virtual void CloseTabAfterEventTracking() = 0;
 
   // Get the bounds of the View, relative to the parent.
   // TODO(beng): Return a rect rather than using an out param.
@@ -135,56 +127,7 @@
  protected:
   TabContentsView();  // Abstract interface.
 
-  // Internal functions used to support the CreateNewWidget() method. If a
-  // platform requires plugging into widget creation at a lower level then a
-  // subclass might want to override these functions, but otherwise they should
-  // be fine just implementing RenderWidgetHostView::InitAsPopup().
-  //
-  // The Create function returns the newly created widget so it can be
-  // associated with the given route. When the widget needs to be shown later,
-  // we'll look it up again and pass the object to the Show functions rather
-  // than the route ID.
-  virtual RenderWidgetHostView* CreateNewWidgetInternal(
-      int route_id,
-      WebKit::WebPopupType popup_type);
-  virtual void ShowCreatedWidgetInternal(RenderWidgetHostView* widget_host_view,
-                                         const gfx::Rect& initial_pos);
-  virtual RenderWidgetHostView* CreateNewFullscreenWidgetInternal(int route_id);
-  virtual void ShowCreatedFullscreenWidgetInternal(
-      RenderWidgetHostView* widget_host_view);
-
-  // Common implementations of some RenderViewHostDelegate::View methods.
-  RenderViewHostDelegateViewHelper delegate_view_helper_;
-
  private:
-  // We implement these functions on RenderViewHostDelegate::View directly and
-  // do some book-keeping associated with the request. The request is then
-  // forwarded to *Internal which does platform-specific work.
-  virtual void CreateNewWindow(
-      int route_id,
-      const ViewHostMsg_CreateWindow_Params& params);
-  virtual void CreateNewWidget(int route_id, WebKit::WebPopupType popup_type);
-  virtual void CreateNewFullscreenWidget(int route_id);
-  virtual void ShowCreatedWindow(int route_id,
-                                 WindowOpenDisposition disposition,
-                                 const gfx::Rect& initial_pos,
-                                 bool user_gesture);
-  virtual void ShowCreatedWidget(int route_id, const gfx::Rect& initial_pos);
-  virtual void ShowCreatedFullscreenWidget(int route_id);
-
-  // The TabContents whose contents we display.
-  TabContents* tab_contents_;
-
-  // Tracks created TabContents objects that have not been shown yet. They are
-  // identified by the route ID passed to CreateNewWindow.
-  typedef std::map<int, TabContents*> PendingContents;
-  PendingContents pending_contents_;
-
-  // These maps hold on to the widgets that we created on behalf of the
-  // renderer that haven't shown yet.
-  typedef std::map<int, RenderWidgetHostView*> PendingWidgetViews;
-  PendingWidgetViews pending_widget_views_;
-
   DISALLOW_COPY_AND_ASSIGN(TabContentsView);
 };