| 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_H_ | 5 #ifndef IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_DELEGATE_H_ |
| 6 #define IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_DELEGATE_H_ | 6 #define IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 | 11 |
| 12 namespace net { | 12 namespace net { |
| 13 class SSLInfo; | 13 class SSLInfo; |
| 14 } | 14 } |
| 15 | 15 |
| 16 namespace web { | 16 namespace web { |
| 17 | 17 |
| 18 struct ContextMenuParams; | 18 struct ContextMenuParams; |
| 19 class JavaScriptDialogPresenter; |
| 19 struct SSLStatus; | 20 struct SSLStatus; |
| 20 class WebState; | 21 class WebState; |
| 21 | 22 |
| 22 // Objects implement this interface to get notified about changes in the | 23 // Objects implement this interface to get notified about changes in the |
| 23 // WebState and to provide necessary functionality. | 24 // WebState and to provide necessary functionality. |
| 24 class WebStateDelegate { | 25 class WebStateDelegate { |
| 25 public: | 26 public: |
| 26 WebStateDelegate(); | 27 WebStateDelegate(); |
| 27 | 28 |
| 28 // Notifies the delegate that the page has made some progress loading. | 29 // Notifies the delegate that the page has made some progress loading. |
| 29 // |progress| is a value between 0.0 (nothing loaded) to 1.0 (page fully | 30 // |progress| is a value between 0.0 (nothing loaded) to 1.0 (page fully |
| 30 // loaded). | 31 // loaded). |
| 31 virtual void LoadProgressChanged(WebState* source, double progress); | 32 virtual void LoadProgressChanged(WebState* source, double progress); |
| 32 | 33 |
| 33 // Notifies the delegate that the user triggered the context menu with the | 34 // Notifies the delegate that the user triggered the context menu with the |
| 34 // given |ContextMenuParams|. Returns true if the context menu operation was | 35 // given |ContextMenuParams|. Returns true if the context menu operation was |
| 35 // handled by the delegate. | 36 // handled by the delegate. |
| 36 virtual bool HandleContextMenu(WebState* source, | 37 virtual bool HandleContextMenu(WebState* source, |
| 37 const ContextMenuParams& params); | 38 const ContextMenuParams& params); |
| 38 | 39 |
| 40 // Returns a pointer to a service to manage dialogs. May return nullptr in |
| 41 // which case dialogs aren't shown. |
| 42 // TODO(crbug.com/622084): Find better place for this method. |
| 43 virtual JavaScriptDialogPresenter* GetJavaScriptDialogPresenter( |
| 44 WebState* source); |
| 45 |
| 39 protected: | 46 protected: |
| 40 virtual ~WebStateDelegate(); | 47 virtual ~WebStateDelegate(); |
| 41 | 48 |
| 42 private: | 49 private: |
| 43 friend class WebStateImpl; | 50 friend class WebStateImpl; |
| 44 | 51 |
| 45 // Called when |this| becomes the WebStateDelegate for |source|. | 52 // Called when |this| becomes the WebStateDelegate for |source|. |
| 46 void Attach(WebState* source); | 53 void Attach(WebState* source); |
| 47 | 54 |
| 48 // Called when |this| is no longer the WebStateDelegate for |source|. | 55 // Called when |this| is no longer the WebStateDelegate for |source|. |
| 49 void Detach(WebState* source); | 56 void Detach(WebState* source); |
| 50 | 57 |
| 51 // The WebStates for which |this| is currently a delegate. | 58 // The WebStates for which |this| is currently a delegate. |
| 52 std::set<WebState*> attached_states_; | 59 std::set<WebState*> attached_states_; |
| 53 }; | 60 }; |
| 54 | 61 |
| 55 } // namespace web | 62 } // namespace web |
| 56 | 63 |
| 57 #endif // IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_DELEGATE_H_ | 64 #endif // IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_DELEGATE_H_ |
| OLD | NEW |