OLD | NEW |
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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/supports_user_data.h" | 15 #include "base/supports_user_data.h" |
16 #include "ios/web/public/referrer.h" | 16 #include "ios/web/public/referrer.h" |
17 #include "ios/web/public/web_state/url_verification_constants.h" | 17 #include "ios/web/public/web_state/url_verification_constants.h" |
18 #include "ui/base/page_transition_types.h" | 18 #include "ui/base/page_transition_types.h" |
19 #include "ui/base/window_open_disposition.h" | 19 #include "ui/base/window_open_disposition.h" |
20 #include "ui/gfx/geometry/size.h" | 20 #include "ui/gfx/geometry/size.h" |
21 #include "url/gurl.h" | 21 #include "url/gurl.h" |
22 | 22 |
23 class GURL; | 23 class GURL; |
| 24 class SkBitmap; |
24 | 25 |
25 @class CRWJSInjectionReceiver; | 26 @class CRWJSInjectionReceiver; |
26 @class CRWSessionStorage; | 27 @class CRWSessionStorage; |
27 @protocol CRWScrollableContent; | 28 @protocol CRWScrollableContent; |
28 @protocol CRWWebViewProxy; | 29 @protocol CRWWebViewProxy; |
29 typedef id<CRWWebViewProxy> CRWWebViewProxyType; | 30 typedef id<CRWWebViewProxy> CRWWebViewProxyType; |
30 @class UIView; | 31 @class UIView; |
31 typedef UIView<CRWScrollableContent> CRWContentView; | 32 typedef UIView<CRWScrollableContent> CRWContentView; |
32 | 33 |
33 namespace base { | 34 namespace base { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 // The disposition requested by the navigation source. | 77 // The disposition requested by the navigation source. |
77 WindowOpenDisposition disposition; | 78 WindowOpenDisposition disposition; |
78 | 79 |
79 // The transition type of navigation. | 80 // The transition type of navigation. |
80 ui::PageTransition transition; | 81 ui::PageTransition transition; |
81 | 82 |
82 // Whether this navigation is initiated by the renderer process. | 83 // Whether this navigation is initiated by the renderer process. |
83 bool is_renderer_initiated; | 84 bool is_renderer_initiated; |
84 }; | 85 }; |
85 | 86 |
| 87 // Callback for |DownloadImage()|. |
| 88 typedef base::Callback<void( |
| 89 int, /* id */ |
| 90 int, /* HTTP status code */ |
| 91 const GURL&, /* image_url */ |
| 92 const std::vector<SkBitmap>&, /* bitmaps */ |
| 93 /* The sizes in pixel of the bitmaps before they were resized due to the |
| 94 max bitmap size passed to DownloadImage(). Each entry in the bitmaps |
| 95 vector corresponds to an entry in the sizes vector. If a bitmap was |
| 96 resized, there should be a single returned bitmap. */ |
| 97 const std::vector<gfx::Size>&)> |
| 98 ImageDownloadCallback; |
| 99 |
86 // Creates a new WebState. | 100 // Creates a new WebState. |
87 static std::unique_ptr<WebState> Create(const CreateParams& params); | 101 static std::unique_ptr<WebState> Create(const CreateParams& params); |
88 // Creates a new WebState from a serialized NavigationManager. | 102 // Creates a new WebState from a serialized NavigationManager. |
89 static std::unique_ptr<WebState> Create(const CreateParams& params, | 103 static std::unique_ptr<WebState> Create(const CreateParams& params, |
90 CRWSessionStorage* session_storage); | 104 CRWSessionStorage* session_storage); |
91 | 105 |
92 ~WebState() override {} | 106 ~WebState() override {} |
93 | 107 |
94 // Gets/Sets the delegate. | 108 // Gets/Sets the delegate. |
95 virtual WebStateDelegate* GetDelegate() = 0; | 109 virtual WebStateDelegate* GetDelegate() = 0; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 virtual void AddScriptCommandCallback(const ScriptCommandCallback& callback, | 234 virtual void AddScriptCommandCallback(const ScriptCommandCallback& callback, |
221 const std::string& command_prefix) = 0; | 235 const std::string& command_prefix) = 0; |
222 | 236 |
223 // Removes the callback associated with |command_prefix|. | 237 // Removes the callback associated with |command_prefix|. |
224 virtual void RemoveScriptCommandCallback( | 238 virtual void RemoveScriptCommandCallback( |
225 const std::string& command_prefix) = 0; | 239 const std::string& command_prefix) = 0; |
226 | 240 |
227 // Returns the current CRWWebViewProxy object. | 241 // Returns the current CRWWebViewProxy object. |
228 virtual CRWWebViewProxyType GetWebViewProxy() const = 0; | 242 virtual CRWWebViewProxyType GetWebViewProxy() const = 0; |
229 | 243 |
| 244 // Sends a request to download the given image |url| and returns the unique |
| 245 // id of the download request. When the download is finished, |callback| will |
| 246 // be called with the bitmaps received from the renderer. |
| 247 // If |is_favicon| is true, the cookies are not sent and not accepted during |
| 248 // download. |
| 249 // Bitmaps with pixel sizes larger than |max_bitmap_size| are filtered out |
| 250 // from the bitmap results. If there are no bitmap results <= |
| 251 // |max_bitmap_size|, the smallest bitmap is resized to |max_bitmap_size| and |
| 252 // is the only result. A |max_bitmap_size| of 0 means unlimited. |
| 253 // If |bypass_cache| is true, |url| is requested from the server even if it |
| 254 // is present in the browser cache. |
| 255 virtual int DownloadImage(const GURL& url, |
| 256 bool is_favicon, |
| 257 uint32_t max_bitmap_size, |
| 258 bool bypass_cache, |
| 259 const ImageDownloadCallback& callback) = 0; |
| 260 |
230 // Returns Mojo interface registry for this WebState. | 261 // Returns Mojo interface registry for this WebState. |
231 virtual service_manager::InterfaceRegistry* GetMojoInterfaceRegistry() = 0; | 262 virtual service_manager::InterfaceRegistry* GetMojoInterfaceRegistry() = 0; |
232 | 263 |
233 protected: | 264 protected: |
234 friend class WebStateObserver; | 265 friend class WebStateObserver; |
235 friend class WebStatePolicyDecider; | 266 friend class WebStatePolicyDecider; |
236 | 267 |
237 // Adds and removes observers for page navigation notifications. The order in | 268 // Adds and removes observers for page navigation notifications. The order in |
238 // which notifications are sent to observers is undefined. Clients must be | 269 // which notifications are sent to observers is undefined. Clients must be |
239 // sure to remove the observer before they go away. | 270 // sure to remove the observer before they go away. |
(...skipping 15 matching lines...) Expand all Loading... |
255 | 286 |
256 // Returns a WeakPtr<WebState> to the current WebState. Must remain private | 287 // Returns a WeakPtr<WebState> to the current WebState. Must remain private |
257 // and only call must be in WebStateWeakPtrFactory. Please consult that class | 288 // and only call must be in WebStateWeakPtrFactory. Please consult that class |
258 // for more details. Remove as part of http://crbug.com/556736. | 289 // for more details. Remove as part of http://crbug.com/556736. |
259 virtual base::WeakPtr<WebState> AsWeakPtr() = 0; | 290 virtual base::WeakPtr<WebState> AsWeakPtr() = 0; |
260 }; | 291 }; |
261 | 292 |
262 } // namespace web | 293 } // namespace web |
263 | 294 |
264 #endif // IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_H_ | 295 #endif // IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_H_ |
OLD | NEW |