Fix breakages in https://codereview.chromium.org/1155713003/
[chromium-blink-merge.git] / ios / web / web_state / web_controller_observer_bridge.h
blobb1cd2f0f98ce3f227dffc3e93ba5c934ee90c00f
1 // Copyright 2014 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_WEB_WEB_STATE_WEB_CONTROLLER_OBSERVER_BRIDGE_H_
6 #define IOS_WEB_WEB_STATE_WEB_CONTROLLER_OBSERVER_BRIDGE_H_
8 #include <string>
10 #import "base/ios/weak_nsobject.h"
11 #include "ios/web/public/web_state/web_state_observer.h"
13 @class CRWWebController;
14 @protocol CRWWebControllerObserver;
15 class GURL;
17 namespace base {
18 class DictionaryValue;
21 namespace web {
23 class WebState;
25 // This class allows to register a CRWWebControllerObserver instance as
26 // a WebStateObserver.
27 // It listens to WebStateObserver calls and forwards them to the underlying
28 // CRWWebControllerObserver.
29 // TODO(droger): Remove this class once all CRWWebControllerObserver have been
30 // converted to WebStateObserver and WebState::ScriptCommandCallback.
31 class WebControllerObserverBridge : public WebStateObserver {
32 public:
33 // |web_controller_observer| and |web_controller| must not be nil, and must
34 // outlive this WebControllerObserverBridge.
35 WebControllerObserverBridge(
36 id<CRWWebControllerObserver> web_controller_observer,
37 WebState* web_state,
38 CRWWebController* web_controller);
40 ~WebControllerObserverBridge() override;
42 // Gets the underlying CRWWebControllerObserver.
43 id<CRWWebControllerObserver> web_controller_observer() const {
44 return web_controller_observer_;
47 private:
48 // WebStateObserver implementation.
49 void PageLoaded(PageLoadCompletionStatus load_completion_status) override;
51 // Callback for script commands.
52 bool ScriptCommandReceived(const base::DictionaryValue& value,
53 const GURL& url,
54 bool user_is_interacting);
56 base::WeakNSProtocol<id<CRWWebControllerObserver>> web_controller_observer_;
57 base::WeakNSObject<CRWWebController> web_controller_;
58 std::string script_command_callback_prefix_;
60 DISALLOW_COPY_AND_ASSIGN(WebControllerObserverBridge);
63 } // namespace web
65 #endif // IOS_WEB_WEB_STATE_WEB_CONTROLLER_OBSERVER_BRIDGE_H_