summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-25 21:37:09 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-25 21:37:09 +0000
commitea049a01f82647dc12e4001c8be03e4124faaff3 (patch)
tree0bb59450d13be2f37e404cfd2374ea27fba7461f /content
parent5ca3ddf71cb1db27e206c4d048770ad21e5688c9 (diff)
downloadchromium_src-ea049a01f82647dc12e4001c8be03e4124faaff3.zip
chromium_src-ea049a01f82647dc12e4001c8be03e4124faaff3.tar.gz
chromium_src-ea049a01f82647dc12e4001c8be03e4124faaff3.tar.bz2
Convert a bunch of WebContentsObservers to use web_contents() instead of tab_contents(), as well as all the dependent code.
BUG=98716 TBR=joi Review URL: http://codereview.chromium.org/8982008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115777 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/debugger/render_view_devtools_agent_host.cc4
-rw-r--r--content/browser/download/save_package.cc5
-rw-r--r--content/browser/download/save_package.h4
-rw-r--r--content/browser/tab_contents/interstitial_page.cc7
-rw-r--r--content/browser/tab_contents/tab_contents.cc13
-rw-r--r--content/browser/tab_contents/tab_contents.h4
-rw-r--r--content/public/browser/DEPS1
-rw-r--r--content/public/browser/devtools_agent_host_registry.h4
-rw-r--r--content/public/browser/notification_types.h16
-rw-r--r--content/public/browser/web_contents.h8
-rw-r--r--content/public/browser/web_contents_observer.cc4
-rw-r--r--content/public/browser/web_contents_observer.h2
12 files changed, 46 insertions, 26 deletions
diff --git a/content/browser/debugger/render_view_devtools_agent_host.cc b/content/browser/debugger/render_view_devtools_agent_host.cc
index fd3574e..72ffe8f 100644
--- a/content/browser/debugger/render_view_devtools_agent_host.cc
+++ b/content/browser/debugger/render_view_devtools_agent_host.cc
@@ -46,13 +46,13 @@ bool DevToolsAgentHostRegistry::HasDevToolsAgentHost(RenderViewHost* rvh) {
return it != g_instances.Get().end();
}
-bool DevToolsAgentHostRegistry::IsDebuggerAttached(TabContents* tab_contents) {
+bool DevToolsAgentHostRegistry::IsDebuggerAttached(WebContents* web_contents) {
if (g_instances == NULL)
return false;
DevToolsManager* devtools_manager = DevToolsManager::GetInstance();
if (!devtools_manager)
return false;
- RenderViewHostDelegate* delegate = tab_contents;
+ RenderViewHostDelegate* delegate = static_cast<TabContents*>(web_contents);
for (Instances::iterator it = g_instances.Get().begin();
it != g_instances.Get().end(); ++it) {
if (it->first->delegate() != delegate)
diff --git a/content/browser/download/save_package.cc b/content/browser/download/save_package.cc
index ffc2cd7..b09be32 100644
--- a/content/browser/download/save_package.cc
+++ b/content/browser/download/save_package.cc
@@ -1150,6 +1150,11 @@ const FilePath::CharType* SavePackage::ExtensionForMimeType(
return FILE_PATH_LITERAL("");
}
+TabContents* SavePackage::tab_contents() const {
+ return
+ static_cast<TabContents*>(content::WebContentsObserver::web_contents());
+}
+
void SavePackage::GetSaveInfo() {
// Can't use tab_contents_ in the file thread, so get the data that we need
// before calling to it.
diff --git a/content/browser/download/save_package.h b/content/browser/download/save_package.h
index 5e36b70..e18a160 100644
--- a/content/browser/download/save_package.h
+++ b/content/browser/download/save_package.h
@@ -122,9 +122,7 @@ class CONTENT_EXPORT SavePackage
SavePackageType save_type() const { return save_type_; }
int tab_id() const { return tab_id_; }
int id() const { return unique_id_; }
- TabContents* tab_contents() const {
- return content::WebContentsObserver::tab_contents();
- }
+ TabContents* tab_contents() const;
void GetSaveInfo();
diff --git a/content/browser/tab_contents/interstitial_page.cc b/content/browser/tab_contents/interstitial_page.cc
index 0b34ede..125d12e3 100644
--- a/content/browser/tab_contents/interstitial_page.cc
+++ b/content/browser/tab_contents/interstitial_page.cc
@@ -34,6 +34,7 @@
#include "net/url_request/url_request_context_getter.h"
using content::BrowserThread;
+using content::WebContents;
using WebKit::WebDragOperation;
using WebKit::WebDragOperationsMask;
@@ -205,8 +206,8 @@ void InterstitialPage::Show() {
render_view_host_->NavigateToURL(GURL(data_url));
notification_registrar_.Add(this,
- content::NOTIFICATION_TAB_CONTENTS_DESTROYED,
- content::Source<TabContents>(tab_));
+ content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
+ content::Source<WebContents>(tab_));
notification_registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
content::Source<NavigationController>(&tab_->GetController()));
notification_registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING,
@@ -279,7 +280,7 @@ void InterstitialPage::Observe(int type,
TakeActionOnResourceDispatcher(CANCEL);
}
break;
- case content::NOTIFICATION_TAB_CONTENTS_DESTROYED:
+ case content::NOTIFICATION_WEB_CONTENTS_DESTROYED:
case content::NOTIFICATION_NAV_ENTRY_COMMITTED:
if (action_taken_ == NO_ACTION) {
// We are navigating away from the interstitial or closing a tab with an
diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc
index 3ada454..327f407 100644
--- a/content/browser/tab_contents/tab_contents.cc
+++ b/content/browser/tab_contents/tab_contents.cc
@@ -112,6 +112,7 @@ using content::DevToolsManagerImpl;
using content::DownloadItem;
using content::DownloadManager;
using content::UserMetricsAction;
+using content::WebContents;
using content::WebContentsObserver;
namespace {
@@ -244,8 +245,8 @@ TabContents::~TabContents() {
// Notify any observer that have a reference on this tab contents.
content::NotificationService::current()->Notify(
- content::NOTIFICATION_TAB_CONTENTS_DESTROYED,
- content::Source<TabContents>(this),
+ content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
+ content::Source<WebContents>(this),
content::NotificationService::NoDetails());
// TODO(brettw) this should be moved to the view.
@@ -347,6 +348,10 @@ void TabContents::SetViewType(content::ViewType type) {
view_type_ = type;
}
+content::ViewType TabContents::GetViewType() const {
+ return view_type_;
+}
+
const GURL& TabContents::GetURL() const {
// We may not have a navigation entry yet
NavigationEntry* entry = controller_.GetActiveEntry();
@@ -572,8 +577,8 @@ void TabContents::WasHidden() {
}
content::NotificationService::current()->Notify(
- content::NOTIFICATION_TAB_CONTENTS_HIDDEN,
- content::Source<TabContents>(this),
+ content::NOTIFICATION_WEB_CONTENTS_HIDDEN,
+ content::Source<WebContents>(this),
content::NotificationService::NoDetails());
}
diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h
index 26de662..04bc8fc 100644
--- a/content/browser/tab_contents/tab_contents.h
+++ b/content/browser/tab_contents/tab_contents.h
@@ -19,8 +19,6 @@
#include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager.h"
#include "content/browser/renderer_host/render_view_host_delegate.h"
#include "content/browser/tab_contents/navigation_controller.h"
-#include "content/browser/tab_contents/navigation_entry.h"
-#include "content/browser/tab_contents/page_navigator.h"
#include "content/browser/tab_contents/render_view_host_manager.h"
#include "content/common/content_export.h"
#include "content/public/browser/web_contents.h"
@@ -51,7 +49,6 @@ struct WebIntentData;
class CONTENT_EXPORT TabContents
: public NON_EXPORTED_BASE(content::WebContents),
- public PageNavigator,
public RenderViewHostDelegate,
public RenderViewHostManager::Delegate,
public content::JavaScriptDialogDelegate {
@@ -136,6 +133,7 @@ class CONTENT_EXPORT TabContents
virtual const NavigationController& GetController() const OVERRIDE;
virtual content::BrowserContext* GetBrowserContext() const OVERRIDE;
virtual void SetViewType(content::ViewType type) OVERRIDE;
+ virtual content::ViewType GetViewType() const OVERRIDE;
virtual content::RenderProcessHost* GetRenderProcessHost() const OVERRIDE;
virtual RenderViewHost* GetRenderViewHost() const OVERRIDE;
virtual RenderWidgetHostView* GetRenderWidgetHostView() const OVERRIDE;
diff --git a/content/public/browser/DEPS b/content/public/browser/DEPS
index 9e39647..ae8cc61 100644
--- a/content/public/browser/DEPS
+++ b/content/public/browser/DEPS
@@ -9,6 +9,7 @@ include_rules = [
"+content/browser/javascript_dialogs.h",
"+content/browser/tab_contents/navigation_controller.h",
"+content/browser/tab_contents/navigation_entry.h",
+ "+content/browser/tab_contents/page_navigator.h",
"+content/browser/tab_contents/tab_contents.h",
"+content/browser/webui/web_ui.h",
]
diff --git a/content/public/browser/devtools_agent_host_registry.h b/content/public/browser/devtools_agent_host_registry.h
index 567d32e..1d1e2c2 100644
--- a/content/public/browser/devtools_agent_host_registry.h
+++ b/content/public/browser/devtools_agent_host_registry.h
@@ -9,11 +9,11 @@
#include "content/common/content_export.h"
class RenderViewHost;
-class TabContents;
namespace content {
class DevToolsAgentHost;
+class WebContents;
class CONTENT_EXPORT DevToolsAgentHostRegistry {
public:
@@ -31,7 +31,7 @@ class CONTENT_EXPORT DevToolsAgentHostRegistry {
int worker_process_id,
int worker_route_id);
- static bool IsDebuggerAttached(TabContents* tab_contents);
+ static bool IsDebuggerAttached(WebContents* web_contents);
};
} // namespace content
diff --git a/content/public/browser/notification_types.h b/content/public/browser/notification_types.h
index 0fdaadf..912f2603 100644
--- a/content/public/browser/notification_types.h
+++ b/content/public/browser/notification_types.h
@@ -205,7 +205,7 @@ enum NotificationType {
// Tabs --------------------------------------------------------------------
// Sent when a tab is added to a WebContentsDelegate. The source is the
- // WebContentsDelegate and the details is the added TabContents.
+ // WebContentsDelegate and the details is the added content::WebContents.
NOTIFICATION_TAB_ADDED,
// This notification is sent after a tab has been appended to the tab_strip.
@@ -248,15 +248,15 @@ enum NotificationType {
// is a Details<TitleUpdatedDetails> that contains more information.
NOTIFICATION_TAB_CONTENTS_TITLE_UPDATED,
- // This notification is sent when a TabContents is being hidden, e.g. due
- // to switching away from this tab. The source is a Source<TabContents>.
- NOTIFICATION_TAB_CONTENTS_HIDDEN,
+ // This notification is sent when a WebContents is being hidden, e.g. due
+ // to switching away from this tab. The source is a Source<WebContents>.
+ NOTIFICATION_WEB_CONTENTS_HIDDEN,
- // This notification is sent when a TabContents is being destroyed. Any
- // object holding a reference to a TabContents can listen to that
+ // This notification is sent when a WebContents is being destroyed. Any
+ // object holding a reference to a WebContents can listen to that
// notification to properly reset the reference. The source is a
- // Source<TabContents>.
- NOTIFICATION_TAB_CONTENTS_DESTROYED,
+ // Source<WebContents>.
+ NOTIFICATION_WEB_CONTENTS_DESTROYED,
// This notification is sent when a WebContentsDelegate is being
// destroyed. The source is a Source<WebContentsDelegate>.
diff --git a/content/public/browser/web_contents.h b/content/public/browser/web_contents.h
index 113e6a4..0aa3196 100644
--- a/content/public/browser/web_contents.h
+++ b/content/public/browser/web_contents.h
@@ -11,7 +11,9 @@
#include "base/string16.h"
#include "content/browser/download/save_package.h"
#include "content/browser/tab_contents/navigation_entry.h"
+#include "content/browser/tab_contents/page_navigator.h"
#include "content/browser/webui/web_ui.h"
+#include "content/public/common/view_type.h"
#include "content/common/content_export.h"
#include "ui/gfx/native_widget_types.h"
#include "webkit/glue/window_open_disposition.h"
@@ -47,7 +49,7 @@ class WebContentsDelegate;
struct RendererPreferences;
// Describes what goes in the main content area of a tab.
-class WebContents {
+class WebContents : public PageNavigator {
public:
virtual ~WebContents() {}
@@ -73,6 +75,10 @@ class WebContents {
// Allows overriding the type of this tab.
virtual void SetViewType(content::ViewType type) = 0;
+ virtual content::ViewType GetViewType() const = 0;
+
+ // Gets the URL that is currently being displayed, if there is one.
+ virtual const GURL& GetURL() const = 0;
// Return the currently active RenderProcessHost and RenderViewHost. Each of
// these may change over time.
diff --git a/content/public/browser/web_contents_observer.cc b/content/public/browser/web_contents_observer.cc
index fb76750..ecbb3bf 100644
--- a/content/public/browser/web_contents_observer.cc
+++ b/content/public/browser/web_contents_observer.cc
@@ -24,6 +24,10 @@ WebContentsObserver::~WebContentsObserver() {
tab_contents_->RemoveObserver(this);
}
+WebContents* WebContentsObserver::web_contents() const {
+ return tab_contents_;
+}
+
void WebContentsObserver::Observe(WebContents* web_contents) {
if (tab_contents_)
tab_contents_->RemoveObserver(this);
diff --git a/content/public/browser/web_contents_observer.h b/content/public/browser/web_contents_observer.h
index 253f6a6..cc44ca0 100644
--- a/content/public/browser/web_contents_observer.h
+++ b/content/public/browser/web_contents_observer.h
@@ -119,6 +119,8 @@ class CONTENT_EXPORT WebContentsObserver : public IPC::Channel::Listener,
// Start observing a different WebContents; used with the default constructor.
void Observe(WebContents* web_contents);
+ WebContents* web_contents() const;
+ // TODO(jam): remove me
TabContents* tab_contents() const { return tab_contents_; }
private: