Chromium Code Reviews| Index: ios/public/provider/web/web_state.h |
| diff --git a/ios/public/provider/web/web_state.h b/ios/public/provider/web/web_state.h |
| index 0e47bbe1ea2ba9173eca7c1fe5904a8024e755a6..84df21ab3d7dcace56a381562028d9701b1e3dd5 100644 |
| --- a/ios/public/provider/web/web_state.h |
| +++ b/ios/public/provider/web/web_state.h |
| @@ -5,16 +5,129 @@ |
| #ifndef IOS_PUBLIC_PROVIDER_WEB_WEB_STATE_H_ |
| #define IOS_PUBLIC_PROVIDER_WEB_WEB_STATE_H_ |
| -#include "ios/public/consumer/base/supports_user_data.h" |
| +#include <string> |
| + |
| +#include "base/callback_forward.h" |
| +#include "base/supports_user_data.h" |
| +#include "ios/web/public/referrer.h" |
| +#include "ui/base/page_transition_types.h" |
| +#include "ui/base/window_open_disposition.h" |
| +#include "url/gurl.h" |
| + |
| +class GURL; |
| + |
| +#if defined(__OBJC__) |
| +// TODO(droger): Convert all the public web API to C++. |
| +@class CRWJSInjectionReceiver; |
| +#else |
| +class CRWJSInjectionReceiver; |
| +#endif // defined(__OBJC__) |
| + |
| +namespace base { |
| +class DictionaryValue; |
| +} |
| + |
| +namespace web { |
| +class BrowserState; |
| +class WebStateObserver; |
| +} |
| namespace ios { |
| +class NavigationManager; |
| + |
| // Core interface for interaction with the web. |
| -class WebState : public ios::SupportsUserData { |
| +class WebState : public base::SupportsUserData { |
| public: |
| + struct OpenURLParams { |
| + OpenURLParams(const GURL& url, |
| + const web::Referrer& referrer, |
| + WindowOpenDisposition disposition, |
| + ui::PageTransition transition, |
| + bool is_renderer_initiated); |
| + ~OpenURLParams(); |
| + |
| + // The URL/referrer to be opened. |
| + GURL url; |
| + web::Referrer referrer; |
| + |
| + // The disposition requested by the navigation source. |
| + WindowOpenDisposition disposition; |
| + |
| + // The transition type of navigation. |
| + ui::PageTransition transition; |
| + |
| + // Whether this navigation is initiated by the renderer process. |
| + bool is_renderer_initiated; |
| + }; |
| + |
| virtual ~WebState() {} |
| + // Gets the web::BrowserState associated with this WebState. Can never return |
| + // NULL. |
| + virtual web::BrowserState* GetBrowserState() const = 0; |
| + |
| + // Opens a URL with the given disposition. The transition specifies how this |
| + // navigation should be recorded in the history system (for example, typed). |
| + virtual void OpenURL(const OpenURLParams& params) = 0; |
| + |
| + // Gets the NavigationManager associated with this WebState. Can never return |
| + // NULL. |
| + virtual NavigationManager* GetNavigationManager() = 0; |
| + |
| + // Gets the CRWJSInjectionReceiver associated with this WebState. |
| + virtual CRWJSInjectionReceiver* GetJSInjectionReceiver() const = 0; |
| + |
| + // Gets the contents MIME type. |
| + virtual const std::string& GetContentsMimeType() const = 0; |
| + |
| + // Gets the value of the "Content-Language" HTTP header. |
| + virtual const std::string& GetContentLanguageHeader() const = 0; |
| + |
| + // Returns true if the current view is a web view with HTML. |
| + virtual bool ContentIsHTML() const = 0; |
| + |
| + // Gets the URL currently being displayed in the URL bar, if there is one. |
| + // This URL might be a pending navigation that hasn't committed yet, so it is |
| + // not guaranteed to match the current page in this WebState. A typical |
| + // example of this is interstitials, which show the URL of the new/loading |
| + // page (active) but the security context is of the old page (last committed). |
| + virtual const GURL& GetVisibleURL() const = 0; |
| + |
| + // Gets the last committed URL. It represents the current page that is |
| + // displayed in this WebState. It represents the current security context. |
| + virtual const GURL& GetLastCommittedURL() const = 0; |
| + |
| + // Callback used to handle script commands. |
| + // The callback must return true if the command was handled, and false |
| + // otherwise. |
| + // In particular the callback must return false if the command is unexpected |
| + // or ill-formatted. |
| + // The first parameter is the content of the command, the second parameter is |
| + // the URL of the page, and the third parameter is a bool indicating if the |
| + // user is currently interacting with the page. |
| + typedef base::Callback<bool(const base::DictionaryValue&, const GURL&, bool)> |
| + ScriptCommandCallback; |
| + |
| + // Registers a callback that will be called when a command matching |
| + // |command_prefix| is received. |
| + virtual void AddScriptCommandCallback(const ScriptCommandCallback& callback, |
| + const std::string& command_prefix) = 0; |
| + |
| + // Removes the callback associated with |command_prefix|. |
| + virtual void RemoveScriptCommandCallback( |
| + const std::string& command_prefix) = 0; |
| + |
| protected: |
| + friend class web::WebStateObserver; |
|
stuartmorgan
2014/12/04 23:11:43
Can we upstream this header yet? It's odd to have
stuartmorgan
2014/12/04 23:14:11
Nm, I see it's in the next CL.
|
| + |
| + // Adds and removes observers for page navigation notifications. The order in |
| + // which notifications are sent to observers is undefined. Clients must be |
| + // sure to remove the observer before they go away. |
| + // TODO(droger): Move these methods to WebStateImpl once it is in ios/. |
| + virtual void AddObserver(web::WebStateObserver* observer) = 0; |
| + virtual void RemoveObserver(web::WebStateObserver* observer) = 0; |
| + |
| WebState() {} |
| }; |