Chromium Code Reviews| 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/public/java_script_dialog_callback.h" | 22 #import "ios/web/public/java_script_dialog_callback.h" |
| 23 #include "ios/web/public/java_script_dialog_type.h" | 23 #include "ios/web/public/java_script_dialog_type.h" |
| 24 #import "ios/web/public/web_state/web_state.h" | 24 #import "ios/web/public/web_state/web_state.h" |
| 25 #import "ios/web/public/web_state/web_state_delegate.h" | 25 #import "ios/web/public/web_state/web_state_delegate.h" |
| 26 #include "mojo/public/cpp/bindings/binding.h" | |
| 27 #include "services/service_manager/public/cpp/binder_registry.h" | |
| 28 #include "services/service_manager/public/interfaces/interface_provider.mojom.h" | |
| 26 #include "url/gurl.h" | 29 #include "url/gurl.h" |
| 27 | 30 |
| 28 @class CRWSessionStorage; | 31 @class CRWSessionStorage; |
| 29 @class CRWWebController; | 32 @class CRWWebController; |
| 30 @protocol CRWWebViewProxy; | 33 @protocol CRWWebViewProxy; |
| 31 @class NSURLRequest; | 34 @class NSURLRequest; |
| 32 @class NSURLResponse; | 35 @class NSURLResponse; |
| 33 | 36 |
| 34 namespace net { | 37 namespace net { |
| 35 class HttpResponseHeaders; | 38 class HttpResponseHeaders; |
| 36 } | 39 } |
| 37 | 40 |
| 38 namespace web { | 41 namespace web { |
| 39 | 42 |
| 40 class BrowserState; | 43 class BrowserState; |
| 41 struct ContextMenuParams; | 44 struct ContextMenuParams; |
| 42 struct FaviconURL; | 45 struct FaviconURL; |
| 43 struct LoadCommittedDetails; | 46 struct LoadCommittedDetails; |
| 44 class NavigationManager; | 47 class NavigationManager; |
| 45 class SessionCertificatePolicyCacheImpl; | 48 class SessionCertificatePolicyCacheImpl; |
| 46 class WebInterstitialImpl; | 49 class WebInterstitialImpl; |
| 47 class WebStatePolicyDecider; | 50 class WebStatePolicyDecider; |
| 48 class WebUIIOS; | 51 class WebUIIOS; |
| 49 | 52 |
| 53 class WebStateInterfaceProvider | |
|
Ken Rockot(use gerrit already)
2017/04/28 17:44:02
Should probably be its own header+mm per the style
| |
| 54 : public service_manager::mojom::InterfaceProvider { | |
| 55 public: | |
| 56 WebStateInterfaceProvider(); | |
| 57 ~WebStateInterfaceProvider() override; | |
| 58 | |
| 59 void Bind(service_manager::mojom::InterfaceProviderRequest request); | |
| 60 | |
| 61 service_manager::BinderRegistry* registry() { return ®istry_; } | |
| 62 | |
| 63 private: | |
| 64 // service_manager::mojom::InterfaceProvider: | |
| 65 void GetInterface(const std::string& interface_name, | |
| 66 mojo::ScopedMessagePipeHandle handle) override; | |
| 67 | |
| 68 service_manager::BinderRegistry registry_; | |
| 69 | |
| 70 mojo::Binding<service_manager::mojom::InterfaceProvider> binding_; | |
| 71 | |
| 72 DISALLOW_COPY_AND_ASSIGN(WebStateInterfaceProvider); | |
| 73 } | |
|
Ken Rockot(use gerrit already)
2017/04/28 17:44:02
;
| |
| 74 | |
| 50 // Implementation of WebState. | 75 // Implementation of WebState. |
| 51 // Generally mirrors //content's WebContents implementation. | 76 // Generally mirrors //content's WebContents implementation. |
| 52 // General notes on expected WebStateImpl ownership patterns: | 77 // General notes on expected WebStateImpl ownership patterns: |
| 53 // - Outside of tests, WebStateImpls are created | 78 // - Outside of tests, WebStateImpls are created |
| 54 // (a) By @Tab, when creating a new Tab. | 79 // (a) By @Tab, when creating a new Tab. |
| 55 // (b) By @SessionWindow, when decoding a saved session. | 80 // (b) By @SessionWindow, when decoding a saved session. |
| 56 // (c) By the Copy() method, below, used when marshalling a session | 81 // (c) By the Copy() method, below, used when marshalling a session |
| 57 // in preparation for saving. | 82 // in preparation for saving. |
| 58 // - WebControllers are the eventual long-term owners of WebStateImpls. | 83 // - WebControllers are the eventual long-term owners of WebStateImpls. |
| 59 // - SessionWindows are transient owners, passing ownership into WebControllers | 84 // - SessionWindows are transient owners, passing ownership into WebControllers |
| 60 // during session restore, and discarding owned copies of WebStateImpls after | 85 // during session restore, and discarding owned copies of WebStateImpls after |
| 61 // writing them out for session saves. | 86 // writing them out for session saves. |
| 62 class WebStateImpl : public WebState, public NavigationManagerDelegate { | 87 class WebStateImpl : public WebState, |
| 88 public NavigationManagerDelegate { | |
| 63 public: | 89 public: |
| 64 // Constructor for WebStateImpls created for new sessions. | 90 // Constructor for WebStateImpls created for new sessions. |
| 65 WebStateImpl(const CreateParams& params); | 91 WebStateImpl(const CreateParams& params); |
| 66 // Constructor for WebStatesImpls created for deserialized sessions | 92 // Constructor for WebStatesImpls created for deserialized sessions |
| 67 WebStateImpl(const CreateParams& params, CRWSessionStorage* session_storage); | 93 WebStateImpl(const CreateParams& params, CRWSessionStorage* session_storage); |
| 68 ~WebStateImpl() override; | 94 ~WebStateImpl() override; |
| 69 | 95 |
| 70 // Gets/Sets the CRWWebController that backs this object. | 96 // Gets/Sets the CRWWebController that backs this object. |
| 71 CRWWebController* GetWebController(); | 97 CRWWebController* GetWebController(); |
| 72 void SetWebController(CRWWebController* web_controller); | 98 void SetWebController(CRWWebController* web_controller); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 203 GURL GetCurrentURL(URLVerificationTrustLevel* trust_level) const override; | 229 GURL GetCurrentURL(URLVerificationTrustLevel* trust_level) const override; |
| 204 void ShowTransientContentView(CRWContentView* content_view) override; | 230 void ShowTransientContentView(CRWContentView* content_view) override; |
| 205 bool IsShowingWebInterstitial() const override; | 231 bool IsShowingWebInterstitial() const override; |
| 206 WebInterstitial* GetWebInterstitial() const override; | 232 WebInterstitial* GetWebInterstitial() const override; |
| 207 void OnPasswordInputShownOnHttp() override; | 233 void OnPasswordInputShownOnHttp() override; |
| 208 void OnCreditCardInputShownOnHttp() override; | 234 void OnCreditCardInputShownOnHttp() override; |
| 209 void AddScriptCommandCallback(const ScriptCommandCallback& callback, | 235 void AddScriptCommandCallback(const ScriptCommandCallback& callback, |
| 210 const std::string& command_prefix) override; | 236 const std::string& command_prefix) override; |
| 211 void RemoveScriptCommandCallback(const std::string& command_prefix) override; | 237 void RemoveScriptCommandCallback(const std::string& command_prefix) override; |
| 212 id<CRWWebViewProxy> GetWebViewProxy() const override; | 238 id<CRWWebViewProxy> GetWebViewProxy() const override; |
| 213 service_manager::InterfaceRegistry* GetMojoInterfaceRegistry() override; | 239 WebStateInterfaceProvider* GetWebStateInterfaceProvider() override; |
|
Ken Rockot(use gerrit already)
2017/04/28 17:44:02
need to update WebState too
| |
| 214 bool HasOpener() const override; | 240 bool HasOpener() const override; |
| 215 base::WeakPtr<WebState> AsWeakPtr() override; | 241 base::WeakPtr<WebState> AsWeakPtr() override; |
| 216 | 242 |
| 217 // Adds |interstitial|'s view to the web controller's content view. | 243 // Adds |interstitial|'s view to the web controller's content view. |
| 218 void ShowWebInterstitial(WebInterstitialImpl* interstitial); | 244 void ShowWebInterstitial(WebInterstitialImpl* interstitial); |
| 219 | 245 |
| 220 // Called to dismiss the currently-displayed transient content view. | 246 // Called to dismiss the currently-displayed transient content view. |
| 221 void ClearTransientContentView(); | 247 void ClearTransientContentView(); |
| 222 | 248 |
| 223 // Notifies the delegate that the load progress was updated. | 249 // Notifies the delegate that the load progress was updated. |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 344 // Whether this WebState has an opener. See | 370 // Whether this WebState has an opener. See |
| 345 // WebState::CreateParams::created_with_opener_ for more details. | 371 // WebState::CreateParams::created_with_opener_ for more details. |
| 346 bool created_with_opener_; | 372 bool created_with_opener_; |
| 347 | 373 |
| 348 // Member variables should appear before the WeakPtrFactory<> to ensure that | 374 // Member variables should appear before the WeakPtrFactory<> to ensure that |
| 349 // any WeakPtrs to WebStateImpl are invalidated before its member variable's | 375 // any WeakPtrs to WebStateImpl are invalidated before its member variable's |
| 350 // destructors are executed, rendering them invalid. | 376 // destructors are executed, rendering them invalid. |
| 351 base::WeakPtrFactory<WebState> weak_factory_; | 377 base::WeakPtrFactory<WebState> weak_factory_; |
| 352 | 378 |
| 353 // Mojo interface registry for this WebState. | 379 // Mojo interface registry for this WebState. |
| 354 std::unique_ptr<service_manager::InterfaceRegistry> mojo_interface_registry_; | 380 std::unique_ptr<WebStateInterfaceProvider> web_state_interface_provider_; |
| 355 | 381 |
| 356 DISALLOW_COPY_AND_ASSIGN(WebStateImpl); | 382 DISALLOW_COPY_AND_ASSIGN(WebStateImpl); |
| 357 }; | 383 }; |
| 358 | 384 |
| 359 } // namespace web | 385 } // namespace web |
| 360 | 386 |
| 361 #endif // IOS_WEB_WEB_STATE_WEB_STATE_IMPL_H_ | 387 #endif // IOS_WEB_WEB_STATE_WEB_STATE_IMPL_H_ |
| OLD | NEW |