OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef IOS_PUBLIC_PROVIDER_WEB_WEB_CONTROLLER_PROVIDER_H_ |
| 6 #define IOS_PUBLIC_PROVIDER_WEB_WEB_CONTROLLER_PROVIDER_H_ |
| 7 |
| 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "ios/web/public/block_types.h" |
| 10 #include "ios/web/public/web_state/web_state_observer.h" |
| 11 #include "url/gurl.h" |
| 12 |
| 13 namespace web { |
| 14 class BrowserState; |
| 15 class WebState; |
| 16 } |
| 17 |
| 18 namespace ios { |
| 19 |
| 20 class WebControllerProviderFactory; |
| 21 |
| 22 // Setter and getter for the provider factory. The provider factory should be |
| 23 // set early, before any component using WebControllerProviders is called. |
| 24 void SetWebControllerProviderFactory( |
| 25 WebControllerProviderFactory* provider_factory); |
| 26 WebControllerProviderFactory* GetWebControllerProviderFactory(); |
| 27 |
| 28 // Interface that provides URL-loading and JavaScript injection with optional |
| 29 // dialog suppression. |
| 30 class WebControllerProvider { |
| 31 public: |
| 32 // Constructor for a WebControllerProvider backed by a CRWWebController |
| 33 // initialized with |browser_state|. |
| 34 explicit WebControllerProvider(web::BrowserState* browser_state); |
| 35 virtual ~WebControllerProvider(); |
| 36 |
| 37 // Determines whether JavaScript dialogs are allowed. |
| 38 virtual bool SuppressesDialogs() const; |
| 39 virtual void SetSuppressesDialogs(bool should_suppress_dialogs) {} |
| 40 |
| 41 // Triggers a load of |url|. |
| 42 virtual void LoadURL(const GURL& url) {} |
| 43 |
| 44 // Returns the WebState associated with this web controller. |
| 45 virtual web::WebState* GetWebState() const; |
| 46 |
| 47 // Injects |script| into the previously loaded page, if any, and calls |
| 48 // |completion| with the result. Calls |completion| with nil parameters |
| 49 // when there is no previously loaded page. |
| 50 virtual void InjectScript(const std::string& script, |
| 51 web::JavaScriptCompletion completion); |
| 52 }; |
| 53 |
| 54 class WebControllerProviderFactory { |
| 55 public: |
| 56 WebControllerProviderFactory(); |
| 57 virtual ~WebControllerProviderFactory(); |
| 58 |
| 59 // Vends WebControllerProviders created using |browser_state|, passing |
| 60 // ownership to callers. |
| 61 virtual scoped_ptr<WebControllerProvider> CreateWebControllerProvider( |
| 62 web::BrowserState* browser_state); |
| 63 }; |
| 64 |
| 65 } // namespace ios |
| 66 |
| 67 #endif // IOS_PUBLIC_PROVIDER_WEB_WEB_CONTROLLER_PROVIDER_H_ |
OLD | NEW |