Upstream WebController/WebStateImpl in ios/web/
[chromium-blink-merge.git] / ios / web / web_state / web_controller_observer_bridge.h
blobec89d43f480ceb18d7b7d13f28ce1add35e6f20c
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 #include "ios/web/public/web_state/web_state_observer.h"
12 @class CRWWebController;
13 @protocol CRWWebControllerObserver;
14 class GURL;
16 namespace base {
17 class DictionaryValue;
20 namespace web {
22 class WebState;
24 // This class allows to register a CRWWebControllerObserver instance as
25 // a WebStateObserver.
26 // It listens to WebStateObserver calls and forwards them to the underlying
27 // CRWWebControllerObserver.
28 // TODO(droger): Remove this class once all CRWWebControllerObserver have been
29 // converted to WebStateObserver and WebState::ScriptCommandCallback.
30 class WebControllerObserverBridge : public WebStateObserver {
31 public:
32 // |web_controller_observer| and |web_controller| must not be nil, and must
33 // outlive this WebControllerObserverBridge.
34 WebControllerObserverBridge(
35 id<CRWWebControllerObserver> web_controller_observer,
36 WebState* web_state,
37 CRWWebController* web_controller);
39 ~WebControllerObserverBridge() override;
41 // Gets the underlying CRWWebControllerObserver.
42 id<CRWWebControllerObserver> web_controller_observer() const {
43 return web_controller_observer_;
46 private:
47 // WebStateObserver implementation.
48 void PageLoaded(PageLoadCompletionStatus load_completion_status) override;
50 // Callback for script commands.
51 bool ScriptCommandReceived(const base::DictionaryValue& value,
52 const GURL& url,
53 bool user_is_interacting);
55 id<CRWWebControllerObserver> web_controller_observer_; // Weak.
56 CRWWebController* web_controller_; // Weak.
57 std::string script_command_callback_prefix_;
59 DISALLOW_COPY_AND_ASSIGN(WebControllerObserverBridge);
62 } // namespace web
64 #endif // IOS_WEB_WEB_STATE_WEB_CONTROLLER_OBSERVER_BRIDGE_H_