| 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; | |
| 25 | 24 |
| 26 @class CRWJSInjectionReceiver; | 25 @class CRWJSInjectionReceiver; |
| 27 @class CRWSessionStorage; | 26 @class CRWSessionStorage; |
| 28 @protocol CRWScrollableContent; | 27 @protocol CRWScrollableContent; |
| 29 @protocol CRWWebViewProxy; | 28 @protocol CRWWebViewProxy; |
| 30 typedef id<CRWWebViewProxy> CRWWebViewProxyType; | 29 typedef id<CRWWebViewProxy> CRWWebViewProxyType; |
| 31 @class UIView; | 30 @class UIView; |
| 32 typedef UIView<CRWScrollableContent> CRWContentView; | 31 typedef UIView<CRWScrollableContent> CRWContentView; |
| 33 | 32 |
| 34 namespace base { | 33 namespace base { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 // The disposition requested by the navigation source. | 76 // The disposition requested by the navigation source. |
| 78 WindowOpenDisposition disposition; | 77 WindowOpenDisposition disposition; |
| 79 | 78 |
| 80 // The transition type of navigation. | 79 // The transition type of navigation. |
| 81 ui::PageTransition transition; | 80 ui::PageTransition transition; |
| 82 | 81 |
| 83 // Whether this navigation is initiated by the renderer process. | 82 // Whether this navigation is initiated by the renderer process. |
| 84 bool is_renderer_initiated; | 83 bool is_renderer_initiated; |
| 85 }; | 84 }; |
| 86 | 85 |
| 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 | |
| 100 // Creates a new WebState. | 86 // Creates a new WebState. |
| 101 static std::unique_ptr<WebState> Create(const CreateParams& params); | 87 static std::unique_ptr<WebState> Create(const CreateParams& params); |
| 102 // Creates a new WebState from a serialized NavigationManager. | 88 // Creates a new WebState from a serialized NavigationManager. |
| 103 static std::unique_ptr<WebState> Create(const CreateParams& params, | 89 static std::unique_ptr<WebState> Create(const CreateParams& params, |
| 104 CRWSessionStorage* session_storage); | 90 CRWSessionStorage* session_storage); |
| 105 | 91 |
| 106 ~WebState() override {} | 92 ~WebState() override {} |
| 107 | 93 |
| 108 // Gets/Sets the delegate. | 94 // Gets/Sets the delegate. |
| 109 virtual WebStateDelegate* GetDelegate() = 0; | 95 virtual WebStateDelegate* GetDelegate() = 0; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 virtual void AddScriptCommandCallback(const ScriptCommandCallback& callback, | 220 virtual void AddScriptCommandCallback(const ScriptCommandCallback& callback, |
| 235 const std::string& command_prefix) = 0; | 221 const std::string& command_prefix) = 0; |
| 236 | 222 |
| 237 // Removes the callback associated with |command_prefix|. | 223 // Removes the callback associated with |command_prefix|. |
| 238 virtual void RemoveScriptCommandCallback( | 224 virtual void RemoveScriptCommandCallback( |
| 239 const std::string& command_prefix) = 0; | 225 const std::string& command_prefix) = 0; |
| 240 | 226 |
| 241 // Returns the current CRWWebViewProxy object. | 227 // Returns the current CRWWebViewProxy object. |
| 242 virtual CRWWebViewProxyType GetWebViewProxy() const = 0; | 228 virtual CRWWebViewProxyType GetWebViewProxy() const = 0; |
| 243 | 229 |
| 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 | |
| 261 // Returns Mojo interface registry for this WebState. | 230 // Returns Mojo interface registry for this WebState. |
| 262 virtual service_manager::InterfaceRegistry* GetMojoInterfaceRegistry() = 0; | 231 virtual service_manager::InterfaceRegistry* GetMojoInterfaceRegistry() = 0; |
| 263 | 232 |
| 264 protected: | 233 protected: |
| 265 friend class WebStateObserver; | 234 friend class WebStateObserver; |
| 266 friend class WebStatePolicyDecider; | 235 friend class WebStatePolicyDecider; |
| 267 | 236 |
| 268 // Adds and removes observers for page navigation notifications. The order in | 237 // Adds and removes observers for page navigation notifications. The order in |
| 269 // which notifications are sent to observers is undefined. Clients must be | 238 // which notifications are sent to observers is undefined. Clients must be |
| 270 // sure to remove the observer before they go away. | 239 // sure to remove the observer before they go away. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 286 | 255 |
| 287 // Returns a WeakPtr<WebState> to the current WebState. Must remain private | 256 // Returns a WeakPtr<WebState> to the current WebState. Must remain private |
| 288 // and only call must be in WebStateWeakPtrFactory. Please consult that class | 257 // and only call must be in WebStateWeakPtrFactory. Please consult that class |
| 289 // for more details. Remove as part of http://crbug.com/556736. | 258 // for more details. Remove as part of http://crbug.com/556736. |
| 290 virtual base::WeakPtr<WebState> AsWeakPtr() = 0; | 259 virtual base::WeakPtr<WebState> AsWeakPtr() = 0; |
| 291 }; | 260 }; |
| 292 | 261 |
| 293 } // namespace web | 262 } // namespace web |
| 294 | 263 |
| 295 #endif // IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_H_ | 264 #endif // IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_H_ |
| OLD | NEW |