| 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_WEB_STATE_WEB_STATE_IMPL_H_ | 5 #ifndef IOS_WEB_WEB_STATE_WEB_STATE_IMPL_H_ |
| 6 #define IOS_WEB_WEB_STATE_WEB_STATE_IMPL_H_ | 6 #define IOS_WEB_WEB_STATE_WEB_STATE_IMPL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <map> | 11 #include <map> |
| 12 #include <memory> | 12 #include <memory> |
| 13 #include <string> | 13 #include <string> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/observer_list.h" | 18 #include "base/observer_list.h" |
| 19 #include "base/values.h" | 19 #include "base/values.h" |
| 20 #import "ios/web/navigation/navigation_manager_delegate.h" | 20 #import "ios/web/navigation/navigation_manager_delegate.h" |
| 21 #import "ios/web/navigation/navigation_manager_impl.h" | 21 #import "ios/web/navigation/navigation_manager_impl.h" |
| 22 #import "ios/web/net/request_tracker_impl.h" | |
| 23 #import "ios/web/public/java_script_dialog_callback.h" | 22 #import "ios/web/public/java_script_dialog_callback.h" |
| 24 #include "ios/web/public/java_script_dialog_type.h" | 23 #include "ios/web/public/java_script_dialog_type.h" |
| 25 #import "ios/web/public/web_state/web_state.h" | 24 #import "ios/web/public/web_state/web_state.h" |
| 26 #import "ios/web/public/web_state/web_state_delegate.h" | 25 #import "ios/web/public/web_state/web_state_delegate.h" |
| 27 #include "url/gurl.h" | 26 #include "url/gurl.h" |
| 28 | 27 |
| 29 @protocol CRWRequestTrackerDelegate; | 28 @protocol CRWRequestTrackerDelegate; |
| 30 @class CRWWebController; | 29 @class CRWWebController; |
| 31 @protocol CRWWebViewProxy; | 30 @protocol CRWWebViewProxy; |
| 32 @class NSURLRequest; | 31 @class NSURLRequest; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 // that is the point where MIME type is set from HTTP headers. | 187 // that is the point where MIME type is set from HTTP headers. |
| 189 void SetContentsMimeType(const std::string& mime_type); | 188 void SetContentsMimeType(const std::string& mime_type); |
| 190 | 189 |
| 191 // Returns whether the navigation corresponding to |request| should be allowed | 190 // Returns whether the navigation corresponding to |request| should be allowed |
| 192 // to continue by asking its policy deciders. Defaults to true. | 191 // to continue by asking its policy deciders. Defaults to true. |
| 193 bool ShouldAllowRequest(NSURLRequest* request); | 192 bool ShouldAllowRequest(NSURLRequest* request); |
| 194 // Returns whether the navigation corresponding to |response| should be | 193 // Returns whether the navigation corresponding to |response| should be |
| 195 // allowed to continue by asking its policy deciders. Defaults to true. | 194 // allowed to continue by asking its policy deciders. Defaults to true. |
| 196 bool ShouldAllowResponse(NSURLResponse* response); | 195 bool ShouldAllowResponse(NSURLResponse* response); |
| 197 | 196 |
| 198 // Request tracker management. For now, this exposes the RequestTracker for | |
| 199 // embedders to use. | |
| 200 // TODO(stuartmorgan): RequestTracker should become an internal detail of this | |
| 201 // class. | |
| 202 | |
| 203 // Create a new tracker using |delegate| as its delegate. | |
| 204 void InitializeRequestTracker(id<CRWRequestTrackerDelegate> delegate); | |
| 205 | |
| 206 // Close the request tracker and delete it. | |
| 207 void CloseRequestTracker(); | |
| 208 | |
| 209 // Returns the tracker for this WebStateImpl. | |
| 210 RequestTrackerImpl* GetRequestTracker(); | |
| 211 | |
| 212 // Lazily creates (if necessary) and returns |request_group_id_|. | |
| 213 // IMPORTANT: This should not be used for anything other than associating this | |
| 214 // instance to network requests. | |
| 215 // This function is only intended to be used in web/. | |
| 216 // TODO(stuartmorgan): Move this method in an implementation file in web/. | |
| 217 NSString* GetRequestGroupID(); | |
| 218 | |
| 219 // WebState: | 197 // WebState: |
| 220 WebStateDelegate* GetDelegate() override; | 198 WebStateDelegate* GetDelegate() override; |
| 221 void SetDelegate(WebStateDelegate* delegate) override; | 199 void SetDelegate(WebStateDelegate* delegate) override; |
| 222 bool IsWebUsageEnabled() const override; | 200 bool IsWebUsageEnabled() const override; |
| 223 void SetWebUsageEnabled(bool enabled) override; | 201 void SetWebUsageEnabled(bool enabled) override; |
| 224 bool ShouldSuppressDialogs() const override; | 202 bool ShouldSuppressDialogs() const override; |
| 225 void SetShouldSuppressDialogs(bool should_suppress) override; | 203 void SetShouldSuppressDialogs(bool should_suppress) override; |
| 226 UIView* GetView() override; | 204 UIView* GetView() override; |
| 227 BrowserState* GetBrowserState() const override; | 205 BrowserState* GetBrowserState() const override; |
| 228 void OpenURL(const WebState::OpenURLParams& params) override; | 206 void OpenURL(const WebState::OpenURLParams& params) override; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 scoped_refptr<net::HttpResponseHeaders> http_response_headers_; | 331 scoped_refptr<net::HttpResponseHeaders> http_response_headers_; |
| 354 std::string mime_type_; | 332 std::string mime_type_; |
| 355 std::string content_language_header_; | 333 std::string content_language_header_; |
| 356 | 334 |
| 357 // Weak pointer to the interstitial page being displayed, if any. | 335 // Weak pointer to the interstitial page being displayed, if any. |
| 358 WebInterstitialImpl* interstitial_; | 336 WebInterstitialImpl* interstitial_; |
| 359 | 337 |
| 360 // Returned by reference. | 338 // Returned by reference. |
| 361 base::string16 empty_string16_; | 339 base::string16 empty_string16_; |
| 362 | 340 |
| 363 // Request tracker associted with this object. | |
| 364 scoped_refptr<RequestTrackerImpl> request_tracker_; | |
| 365 | |
| 366 // A number identifying this object. This number is injected into the user | |
| 367 // agent to allow the network layer to know which web view requests originated | |
| 368 // from. | |
| 369 base::scoped_nsobject<NSString> request_group_id_; | |
| 370 | |
| 371 // Callbacks associated to command prefixes. | 341 // Callbacks associated to command prefixes. |
| 372 std::map<std::string, ScriptCommandCallback> script_command_callbacks_; | 342 std::map<std::string, ScriptCommandCallback> script_command_callbacks_; |
| 373 | 343 |
| 374 // Member variables should appear before the WeakPtrFactory<> to ensure that | 344 // Member variables should appear before the WeakPtrFactory<> to ensure that |
| 375 // any WeakPtrs to WebStateImpl are invalidated before its member variable's | 345 // any WeakPtrs to WebStateImpl are invalidated before its member variable's |
| 376 // destructors are executed, rendering them invalid. | 346 // destructors are executed, rendering them invalid. |
| 377 base::WeakPtrFactory<WebState> weak_factory_; | 347 base::WeakPtrFactory<WebState> weak_factory_; |
| 378 | 348 |
| 379 // Mojo interface registry for this WebState. | 349 // Mojo interface registry for this WebState. |
| 380 std::unique_ptr<service_manager::InterfaceRegistry> mojo_interface_registry_; | 350 std::unique_ptr<service_manager::InterfaceRegistry> mojo_interface_registry_; |
| 381 | 351 |
| 382 // Image Fetcher used to images. | 352 // Image Fetcher used to images. |
| 383 std::unique_ptr<ImageDataFetcher> image_fetcher_; | 353 std::unique_ptr<ImageDataFetcher> image_fetcher_; |
| 384 | 354 |
| 385 DISALLOW_COPY_AND_ASSIGN(WebStateImpl); | 355 DISALLOW_COPY_AND_ASSIGN(WebStateImpl); |
| 386 }; | 356 }; |
| 387 | 357 |
| 388 } // namespace web | 358 } // namespace web |
| 389 | 359 |
| 390 #endif // IOS_WEB_WEB_STATE_WEB_STATE_IMPL_H_ | 360 #endif // IOS_WEB_WEB_STATE_WEB_STATE_IMPL_H_ |
| OLD | NEW |