Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(270)

Side by Side Diff: ios/web/public/web_state/web_state.h

Issue 1022463002: [iOS] Upstream files in //ios/chrome/browser/autofill (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ios/web/public/web_state/crw_web_view_proxy.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_H_ 5 #ifndef IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_H_
6 #define IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_H_ 6 #define IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector>
9 10
10 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
11 #include "base/supports_user_data.h" 12 #include "base/supports_user_data.h"
12 #include "ios/web/public/referrer.h" 13 #include "ios/web/public/referrer.h"
14 #include "ios/web/public/web_state/url_verification_constants.h"
15 #include "ios/web/public/web_view_type.h"
13 #include "ui/base/page_transition_types.h" 16 #include "ui/base/page_transition_types.h"
14 #include "ui/base/window_open_disposition.h" 17 #include "ui/base/window_open_disposition.h"
18 #include "ui/gfx/geometry/size.h"
15 #include "url/gurl.h" 19 #include "url/gurl.h"
16 20
17 class GURL; 21 class GURL;
22 class SkBitmap;
18 23
19 #if defined(__OBJC__) 24 #if defined(__OBJC__)
20 // TODO(droger): Convert all the public web API to C++.
21 @class CRWJSInjectionReceiver; 25 @class CRWJSInjectionReceiver;
26 @protocol CRWWebViewProxy;
27 typedef id<CRWWebViewProxy> CRWWebViewProxyType;
28 @class UIView;
22 #else 29 #else
23 class CRWJSInjectionReceiver; 30 class CRWJSInjectionReceiver;
31 typedef void* CRWWebViewProxyType;
32 class UIView;
24 #endif // defined(__OBJC__) 33 #endif // defined(__OBJC__)
25 34
26 namespace base { 35 namespace base {
27 class DictionaryValue; 36 class DictionaryValue;
28 } 37 }
29 38
30 namespace web { 39 namespace web {
31 40
32 class BrowserState; 41 class BrowserState;
33 class NavigationManager; 42 class NavigationManager;
43 class WebInterstitial;
34 class WebStateObserver; 44 class WebStateObserver;
35 45
36 // Core interface for interaction with the web. 46 // Core interface for interaction with the web.
37 class WebState : public base::SupportsUserData { 47 class WebState : public base::SupportsUserData {
38 public: 48 public:
39 // Parameters for the OpenURL() method. 49 // Parameters for the OpenURL() method.
40 struct OpenURLParams { 50 struct OpenURLParams {
41 OpenURLParams(const GURL& url, 51 OpenURLParams(const GURL& url,
42 const Referrer& referrer, 52 const Referrer& referrer,
43 WindowOpenDisposition disposition, 53 WindowOpenDisposition disposition,
44 ui::PageTransition transition, 54 ui::PageTransition transition,
45 bool is_renderer_initiated); 55 bool is_renderer_initiated);
46 ~OpenURLParams(); 56 ~OpenURLParams();
47 57
48 // The URL/referrer to be opened. 58 // The URL/referrer to be opened.
49 GURL url; 59 GURL url;
50 Referrer referrer; 60 Referrer referrer;
51 61
52 // The disposition requested by the navigation source. 62 // The disposition requested by the navigation source.
53 WindowOpenDisposition disposition; 63 WindowOpenDisposition disposition;
54 64
55 // The transition type of navigation. 65 // The transition type of navigation.
56 ui::PageTransition transition; 66 ui::PageTransition transition;
57 67
58 // Whether this navigation is initiated by the renderer process. 68 // Whether this navigation is initiated by the renderer process.
59 bool is_renderer_initiated; 69 bool is_renderer_initiated;
60 }; 70 };
61 71
72 // Callback for |DownloadImage()|.
73 typedef base::Callback<void(
74 int, /* id */
75 int, /* HTTP status code */
76 const GURL&, /* image_url */
77 const std::vector<SkBitmap>&, /* bitmaps */
78 /* The sizes in pixel of the bitmaps before they were resized due to the
79 max bitmap size passed to DownloadImage(). Each entry in the bitmaps
80 vector corresponds to an entry in the sizes vector. If a bitmap was
81 resized, there should be a single returned bitmap. */
82 const std::vector<gfx::Size>&)>
83 ImageDownloadCallback;
84
62 ~WebState() override {} 85 ~WebState() override {}
63 86
87 // The view containing the contents of the current web page. If the view has
88 // been purged due to low memory, this will recreate it. It is up to the
89 // caller to size the view.
90 virtual UIView* GetView() = 0;
91
92 // Returns the type of the web view associated with this WebState.
93 virtual WebViewType GetWebViewType() const = 0;
94
64 // Gets the BrowserState associated with this WebState. Can never return null. 95 // Gets the BrowserState associated with this WebState. Can never return null.
65 virtual BrowserState* GetBrowserState() const = 0; 96 virtual BrowserState* GetBrowserState() const = 0;
66 97
67 // Opens a URL with the given disposition. The transition specifies how this 98 // Opens a URL with the given disposition. The transition specifies how this
68 // navigation should be recorded in the history system (for example, typed). 99 // navigation should be recorded in the history system (for example, typed).
69 virtual void OpenURL(const OpenURLParams& params) = 0; 100 virtual void OpenURL(const OpenURLParams& params) = 0;
70 101
71 // Gets the NavigationManager associated with this WebState. Can never return 102 // Gets the NavigationManager associated with this WebState. Can never return
72 // null. 103 // null.
73 virtual NavigationManager* GetNavigationManager() = 0; 104 virtual NavigationManager* GetNavigationManager() = 0;
(...skipping 14 matching lines...) Expand all
88 // This URL might be a pending navigation that hasn't committed yet, so it is 119 // This URL might be a pending navigation that hasn't committed yet, so it is
89 // not guaranteed to match the current page in this WebState. A typical 120 // not guaranteed to match the current page in this WebState. A typical
90 // example of this is interstitials, which show the URL of the new/loading 121 // example of this is interstitials, which show the URL of the new/loading
91 // page (active) but the security context is of the old page (last committed). 122 // page (active) but the security context is of the old page (last committed).
92 virtual const GURL& GetVisibleURL() const = 0; 123 virtual const GURL& GetVisibleURL() const = 0;
93 124
94 // Gets the last committed URL. It represents the current page that is 125 // Gets the last committed URL. It represents the current page that is
95 // displayed in this WebState. It represents the current security context. 126 // displayed in this WebState. It represents the current security context.
96 virtual const GURL& GetLastCommittedURL() const = 0; 127 virtual const GURL& GetLastCommittedURL() const = 0;
97 128
129 // Returns the WebState view of the current URL. Moreover, this method
130 // will set the trustLevel enum to the appropriate level from a security point
131 // of view. The caller has to handle the case where |trust_level| is not
132 // appropriate.
133 // TODO(stuartmorgan): Figure out a clean API for this.
134 // See http://crbug.com/457679
135 virtual GURL GetCurrentURL(URLVerificationTrustLevel* trust_level) const = 0;
136
137 // Returns true if a WebInterstitial is currently displayed.
138 virtual bool IsShowingWebInterstitial() const = 0;
139
140 // Returns the currently visible WebInterstitial if one is shown.
141 virtual WebInterstitial* GetWebInterstitial() const = 0;
142
98 // Callback used to handle script commands. 143 // Callback used to handle script commands.
99 // The callback must return true if the command was handled, and false 144 // The callback must return true if the command was handled, and false
100 // otherwise. 145 // otherwise.
101 // In particular the callback must return false if the command is unexpected 146 // In particular the callback must return false if the command is unexpected
102 // or ill-formatted. 147 // or ill-formatted.
103 // The first parameter is the content of the command, the second parameter is 148 // The first parameter is the content of the command, the second parameter is
104 // the URL of the page, and the third parameter is a bool indicating if the 149 // the URL of the page, and the third parameter is a bool indicating if the
105 // user is currently interacting with the page. 150 // user is currently interacting with the page.
106 typedef base::Callback<bool(const base::DictionaryValue&, const GURL&, bool)> 151 typedef base::Callback<bool(const base::DictionaryValue&, const GURL&, bool)>
107 ScriptCommandCallback; 152 ScriptCommandCallback;
108 153
109 // Registers a callback that will be called when a command matching 154 // Registers a callback that will be called when a command matching
110 // |command_prefix| is received. 155 // |command_prefix| is received.
111 virtual void AddScriptCommandCallback(const ScriptCommandCallback& callback, 156 virtual void AddScriptCommandCallback(const ScriptCommandCallback& callback,
112 const std::string& command_prefix) = 0; 157 const std::string& command_prefix) = 0;
113 158
114 // Removes the callback associated with |command_prefix|. 159 // Removes the callback associated with |command_prefix|.
115 virtual void RemoveScriptCommandCallback( 160 virtual void RemoveScriptCommandCallback(
116 const std::string& command_prefix) = 0; 161 const std::string& command_prefix) = 0;
117 162
163 // Returns the current CRWWebViewProxy object.
164 virtual CRWWebViewProxyType GetWebViewProxy() const = 0;
165
118 protected: 166 protected:
119 friend class WebStateObserver; 167 friend class WebStateObserver;
120 168
121 // Adds and removes observers for page navigation notifications. The order in 169 // Adds and removes observers for page navigation notifications. The order in
122 // which notifications are sent to observers is undefined. Clients must be 170 // which notifications are sent to observers is undefined. Clients must be
123 // sure to remove the observer before they go away. 171 // sure to remove the observer before they go away.
124 // TODO(droger): Move these methods to WebStateImpl once it is in ios/. 172 // TODO(droger): Move these methods to WebStateImpl once it is in ios/.
125 virtual void AddObserver(WebStateObserver* observer) = 0; 173 virtual void AddObserver(WebStateObserver* observer) = 0;
126 virtual void RemoveObserver(WebStateObserver* observer) = 0; 174 virtual void RemoveObserver(WebStateObserver* observer) = 0;
127 175
128 WebState() {} 176 WebState() {}
129 }; 177 };
130 178
131 } // namespace web 179 } // namespace web
132 180
133 #endif // IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_H_ 181 #endif // IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_H_
OLDNEW
« no previous file with comments | « ios/web/public/web_state/crw_web_view_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698