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 <memory> | |
9 | |
10 // TODO(sdefresne): remove includes of web_controller_provider_factory.h and | |
11 // web_state_observer.h once downstream code has been fixed to use the correct | |
12 // includes. | |
13 #include "ios/public/provider/web/web_controller_provider_factory.h" | |
14 #include "ios/web/public/block_types.h" | |
15 #include "ios/web/public/web_state/web_state_observer.h" | |
16 #include "url/gurl.h" | |
17 | |
18 namespace web { | |
19 class BrowserState; | |
20 class WebState; | |
21 } | |
22 | |
23 namespace ios { | |
24 | |
25 class WebControllerProviderFactory; | |
26 | |
27 // Setter and getter for the provider factory. The provider factory should be | |
28 // set early, before any component using WebControllerProviders is called. | |
29 void SetWebControllerProviderFactory( | |
30 WebControllerProviderFactory* provider_factory); | |
31 WebControllerProviderFactory* GetWebControllerProviderFactory(); | |
32 | |
33 // Interface that provides URL-loading and JavaScript injection with optional | |
34 // dialog suppression. | |
35 // TODO(crbug.com/546231): Remove once JS dialog suppression is exposed via | |
36 // WebState's public interface. | |
37 class WebControllerProvider { | |
38 public: | |
39 // Constructor for a WebControllerProvider backed by a CRWWebController | |
40 // initialized with |browser_state|. | |
41 explicit WebControllerProvider(web::BrowserState* browser_state); | |
42 virtual ~WebControllerProvider(); | |
43 | |
44 // Determines whether JavaScript dialogs are allowed. | |
45 virtual bool SuppressesDialogs() const; | |
46 virtual void SetSuppressesDialogs(bool should_suppress_dialogs) {} | |
47 | |
48 // Triggers a load of |url|. | |
49 virtual void LoadURL(const GURL& url) {} | |
50 | |
51 // Returns the WebState associated with this web controller. | |
52 virtual web::WebState* GetWebState() const; | |
53 | |
54 // Injects |script| into the previously loaded page, if any, and calls | |
55 // |completion| with the result. Calls |completion| with nil parameters | |
56 // when there is no previously loaded page. | |
57 virtual void InjectScript(const std::string& script, | |
58 web::JavaScriptResultBlock completion); | |
59 }; | |
60 | |
61 } // namespace ios | |
62 | |
63 #endif // IOS_PUBLIC_PROVIDER_WEB_WEB_CONTROLLER_PROVIDER_H_ | |
OLD | NEW |