Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_DELEGATE_BRIDGE_H_ | 5 #ifndef IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_DELEGATE_BRIDGE_H_ |
| 6 #define IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_DELEGATE_BRIDGE_H_ | 6 #define IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_DELEGATE_BRIDGE_H_ |
| 7 | 7 |
| 8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
| 9 | 9 |
| 10 #import "base/ios/weak_nsobject.h" | 10 #import "base/ios/weak_nsobject.h" |
| 11 #include "ios/web/public/web_state/web_state_delegate.h" | 11 #include "ios/web/public/web_state/web_state_delegate.h" |
| 12 | 12 |
| 13 // Objective-C interface for web::WebStateDelegate. | 13 // Objective-C interface for web::WebStateDelegate. |
| 14 @protocol CRWWebStateDelegate<NSObject> | 14 @protocol CRWWebStateDelegate<NSObject> |
| 15 @optional | 15 @optional |
| 16 | 16 |
| 17 // Called when the page has made some progress loading. |progress| is a value | 17 // Called when the page has made some progress loading. |progress| is a value |
| 18 // between 0.0 (nothing loaded) to 1.0 (page fully loaded). | 18 // between 0.0 (nothing loaded) to 1.0 (page fully loaded). |
| 19 - (void)webState:(web::WebState*)webState didChangeProgress:(double)progress; | 19 - (void)webState:(web::WebState*)webState didChangeProgress:(double)progress; |
| 20 | 20 |
| 21 // Called when the user triggers the context menu with the given | 21 // Called when the user triggers the context menu with the given |
| 22 // |ContextMenuParams|. Returns YES if the context menu operation was | 22 // |ContextMenuParams|. Returns YES if the context menu operation was |
| 23 // handled by the delegate. If this method is not implemented, the system | 23 // handled by the delegate. If this method is not implemented, the system |
| 24 // context menu will be displayed. | 24 // context menu will be displayed. |
| 25 - (BOOL)webState:(web::WebState*)webState | 25 - (BOOL)webState:(web::WebState*)webState |
| 26 handleContextMenu:(const web::ContextMenuParams&)params; | 26 handleContextMenu:(const web::ContextMenuParams&)params; |
| 27 | 27 |
| 28 // Returns a pointer to a service to manage dialogs. May return nil in which | |
| 29 // case dialogs aren't shown. | |
| 30 - (web::DialogPresenter*)dialogPresenterForWebState:(web::WebState*)webState; | |
|
Eugene But (OOO till 7-30)
2016/06/24 17:04:52
Could you please leave the line-break
michaeldo
2016/06/27 20:30:10
Done.
| |
| 28 @end | 31 @end |
| 29 | 32 |
| 30 namespace web { | 33 namespace web { |
| 31 | 34 |
| 32 // Adapter to use an id<CRWWebStateDelegate> as a web::WebStateDelegate. | 35 // Adapter to use an id<CRWWebStateDelegate> as a web::WebStateDelegate. |
| 33 class WebStateDelegateBridge : public web::WebStateDelegate { | 36 class WebStateDelegateBridge : public web::WebStateDelegate { |
| 34 public: | 37 public: |
| 35 explicit WebStateDelegateBridge(id<CRWWebStateDelegate> delegate); | 38 explicit WebStateDelegateBridge(id<CRWWebStateDelegate> delegate); |
| 36 ~WebStateDelegateBridge() override; | 39 ~WebStateDelegateBridge() override; |
| 37 | 40 |
| 38 // web::WebStateDelegate methods. | 41 // web::WebStateDelegate methods. |
| 39 void LoadProgressChanged(WebState* source, double progress) override; | 42 void LoadProgressChanged(WebState* source, double progress) override; |
| 40 bool HandleContextMenu(WebState* source, | 43 bool HandleContextMenu(WebState* source, |
| 41 const ContextMenuParams& params) override; | 44 const ContextMenuParams& params) override; |
| 45 DialogPresenter* GetDialogPresenter(WebState* source) override; | |
| 42 | 46 |
| 43 private: | 47 private: |
| 44 // CRWWebStateDelegate which receives forwarded calls. | 48 // CRWWebStateDelegate which receives forwarded calls. |
| 45 base::WeakNSProtocol<id<CRWWebStateDelegate>> delegate_; | 49 base::WeakNSProtocol<id<CRWWebStateDelegate>> delegate_; |
| 46 DISALLOW_COPY_AND_ASSIGN(WebStateDelegateBridge); | 50 DISALLOW_COPY_AND_ASSIGN(WebStateDelegateBridge); |
| 47 }; | 51 }; |
| 48 | 52 |
| 49 } // web | 53 } // web |
| 50 | 54 |
| 51 #endif // IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_DELEGATE_BRIDGE_H_ | 55 #endif // IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_DELEGATE_BRIDGE_H_ |
| OLD | NEW |