Revert "Fix broken channel icon in chrome://help on CrOS" and try again
[chromium-blink-merge.git] / ios / public / provider / web / web_controller_provider.h
blob4d9f81ba800fa2e14156eb7ef779d915049ef4a6
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.
5 #ifndef IOS_PUBLIC_PROVIDER_WEB_WEB_CONTROLLER_PROVIDER_H_
6 #define IOS_PUBLIC_PROVIDER_WEB_WEB_CONTROLLER_PROVIDER_H_
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"
13 namespace web {
14 class BrowserState;
15 class WebState;
18 namespace ios {
20 class WebControllerProviderFactory;
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();
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();
37 // Determines whether JavaScript dialogs are allowed.
38 virtual bool SuppressesDialogs() const;
39 virtual void SetSuppressesDialogs(bool should_suppress_dialogs) {}
41 // Triggers a load of |url|.
42 virtual void LoadURL(const GURL& url) {}
44 // Returns the WebState associated with this web controller.
45 virtual web::WebState* GetWebState() const;
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);
54 class WebControllerProviderFactory {
55 public:
56 WebControllerProviderFactory();
57 virtual ~WebControllerProviderFactory();
59 // Vends WebControllerProviders created using |browser_state|, passing
60 // ownership to callers.
61 virtual scoped_ptr<WebControllerProvider> CreateWebControllerProvider(
62 web::BrowserState* browser_state);
65 } // namespace ios
67 #endif // IOS_PUBLIC_PROVIDER_WEB_WEB_CONTROLLER_PROVIDER_H_