diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-28 01:29:20 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-28 01:29:20 +0000 |
commit | e5d549d8889c0533703211652564bc0a55ec9938 (patch) | |
tree | 1657b37fe9aab6dc719d2f4cc2298c42a8d92e62 /content/public | |
parent | 1f2f300c1767a21a17e1b9ce3acb4b75ae854600 (diff) | |
download | chromium_src-e5d549d8889c0533703211652564bc0a55ec9938.zip chromium_src-e5d549d8889c0533703211652564bc0a55ec9938.tar.gz chromium_src-e5d549d8889c0533703211652564bc0a55ec9938.tar.bz2 |
Move the PageNavigator interface and GlobalRequestID struct to content\public and put them in the content namespace. Make PageNavigator use WebContents instead of TabContents. While I'm touching all the callers, I've removed the deprecated PageNavigator function and converted users to the new one.
BUG=98716
TBR=joi
Review URL: http://codereview.chromium.org/8991012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115858 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/public')
-rw-r--r-- | content/public/browser/global_request_id.h | 44 | ||||
-rw-r--r-- | content/public/browser/page_navigator.cc | 31 | ||||
-rw-r--r-- | content/public/browser/page_navigator.h | 71 | ||||
-rw-r--r-- | content/public/browser/web_contents.h | 2 | ||||
-rw-r--r-- | content/public/browser/web_contents_delegate.cc | 2 | ||||
-rw-r--r-- | content/public/browser/web_contents_delegate.h | 9 |
6 files changed, 153 insertions, 6 deletions
diff --git a/content/public/browser/global_request_id.h b/content/public/browser/global_request_id.h new file mode 100644 index 0000000..e3a541c --- /dev/null +++ b/content/public/browser/global_request_id.h @@ -0,0 +1,44 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_PUBLIC_BROWSER_GLOBAL_REQUEST_ID_H_ +#define CONTENT_PUBLIC_BROWSER_GLOBAL_REQUEST_ID_H_ +#pragma once + +namespace content { + +// Uniquely identifies a net::URLRequest. +struct GlobalRequestID { + GlobalRequestID() : child_id(-1), request_id(-1) { + } + + GlobalRequestID(int child_id, int request_id) + : child_id(child_id), + request_id(request_id) { + } + + // The unique ID of the child process (different from OS's PID). + int child_id; + + // The request ID (unique for the child). + int request_id; + + bool operator<(const GlobalRequestID& other) const { + if (child_id == other.child_id) + return request_id < other.request_id; + return child_id < other.child_id; + } + bool operator==(const GlobalRequestID& other) const { + return child_id == other.child_id && + request_id == other.request_id; + } + bool operator!=(const GlobalRequestID& other) const { + return child_id != other.child_id || + request_id != other.request_id; + } +}; + +} // namespace content + +#endif // CONTENT_PUBLIC_BROWSER_GLOBAL_REQUEST_ID_H_ diff --git a/content/public/browser/page_navigator.cc b/content/public/browser/page_navigator.cc new file mode 100644 index 0000000..b37ea4b --- /dev/null +++ b/content/public/browser/page_navigator.cc @@ -0,0 +1,31 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/public/browser/page_navigator.h" + +namespace content { + +OpenURLParams::OpenURLParams( + const GURL& url, + const Referrer& referrer, + WindowOpenDisposition disposition, + PageTransition transition, + bool is_renderer_initiated) + : url(url), + referrer(referrer), + disposition(disposition), + transition(transition), + is_renderer_initiated(is_renderer_initiated) { +} + +OpenURLParams::OpenURLParams() + : disposition(UNKNOWN), + transition(PageTransitionFromInt(0)), + is_renderer_initiated(false) { +} + +OpenURLParams::~OpenURLParams() { +} + +} // namespace content diff --git a/content/public/browser/page_navigator.h b/content/public/browser/page_navigator.h new file mode 100644 index 0000000..0fded4e --- /dev/null +++ b/content/public/browser/page_navigator.h @@ -0,0 +1,71 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// PageNavigator defines an interface that can be used to express the user's +// intention to navigate to a particular URL. The implementing class should +// perform the navigation. + +#ifndef CONTENT_PUBLIC_BROWSER_PAGE_NAVIGATOR_H_ +#define CONTENT_PUBLIC_BROWSER_PAGE_NAVIGATOR_H_ +#pragma once + +#include <string> + +#include "content/common/content_export.h" +#include "content/public/browser/global_request_id.h" +#include "content/public/common/page_transition_types.h" +#include "content/public/common/referrer.h" +#include "googleurl/src/gurl.h" +#include "webkit/glue/window_open_disposition.h" + +namespace content { + +class WebContents; + +struct CONTENT_EXPORT OpenURLParams { + OpenURLParams(const GURL& url, + const Referrer& referrer, + WindowOpenDisposition disposition, + PageTransition transition, + bool is_renderer_initiated); + ~OpenURLParams(); + + // The URL/referrer to be opened. + GURL url; + Referrer referrer; + + // The disposition requested by the navigation source. + WindowOpenDisposition disposition; + + // The transition type of navigation. + PageTransition transition; + + // Whether this navigation is initiated by the renderer process. + bool is_renderer_initiated; + + // The override encoding of the URL contents to be opened. + std::string override_encoding; + + // Reference to the old request id in case this is a navigation that is being + // transferred to a new renderer. + GlobalRequestID transferred_global_request_id; + + private: + OpenURLParams(); +}; + +class PageNavigator { + public: + virtual ~PageNavigator() {} + + // Opens a URL with the given disposition. The transition specifies how this + // navigation should be recorded in the history system (for example, typed). + // Returns the TabContents the URL is opened in, or NULL if the URL wasn't + // opened immediately. + virtual WebContents* OpenURL(const OpenURLParams& params) = 0; +}; + +} + +#endif // CONTENT_PUBLIC_BROWSER_PAGE_NAVIGATOR_H_ diff --git a/content/public/browser/web_contents.h b/content/public/browser/web_contents.h index 518853f..0c6df16 100644 --- a/content/public/browser/web_contents.h +++ b/content/public/browser/web_contents.h @@ -10,9 +10,9 @@ #include "base/process_util.h" #include "base/string16.h" #include "content/browser/download/save_package.h" -#include "content/browser/tab_contents/page_navigator.h" #include "content/browser/webui/web_ui.h" #include "content/common/content_export.h" +#include "content/public/browser/page_navigator.h" #include "content/public/common/view_type.h" #include "ui/gfx/native_widget_types.h" #include "webkit/glue/window_open_disposition.h" diff --git a/content/public/browser/web_contents_delegate.cc b/content/public/browser/web_contents_delegate.cc index 1ca147c..766af90 100644 --- a/content/public/browser/web_contents_delegate.cc +++ b/content/public/browser/web_contents_delegate.cc @@ -21,7 +21,7 @@ namespace content { WebContentsDelegate::WebContentsDelegate() { } -TabContents* WebContentsDelegate::OpenURLFromTab(TabContents* source, +WebContents* WebContentsDelegate::OpenURLFromTab(WebContents* source, const OpenURLParams& params) { return NULL; } diff --git a/content/public/browser/web_contents_delegate.h b/content/public/browser/web_contents_delegate.h index 57bf077..e2fef31 100644 --- a/content/public/browser/web_contents_delegate.h +++ b/content/public/browser/web_contents_delegate.h @@ -22,7 +22,6 @@ class GURL; class TabContents; struct ContextMenuParams; struct NativeWebKeyboardEvent; -struct OpenURLParams; namespace base { class ListValue; @@ -54,22 +53,24 @@ struct WebIntentData; namespace content { +struct OpenURLParams; + // Objects implement this interface to get notified about changes in the // TabContents and to provide necessary functionality. class CONTENT_EXPORT WebContentsDelegate { public: WebContentsDelegate(); - // Opens a new URL inside the passed in TabContents (if source is 0 open + // Opens a new URL inside the passed in WebContents (if source is 0 open // in the current front-most tab), unless |disposition| indicates the url // should be opened in a new tab or window. // // A NULL source indicates the current tab (callers should probably use // OpenURL() for these cases which does it for you). - // Returns the TabContents the URL is opened in, or NULL if the URL wasn't + // Returns the WebContents the URL is opened in, or NULL if the URL wasn't // opened immediately. - virtual TabContents* OpenURLFromTab(TabContents* source, + virtual WebContents* OpenURLFromTab(WebContents* source, const OpenURLParams& params); // Called to inform the delegate that the tab content's navigation state |