| 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 #import <Foundation/Foundation.h> | 10 #import <Foundation/Foundation.h> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #import "ios/web/public/web_state/web_state.h" | 13 #import "ios/web/public/web_state/web_state.h" |
| 14 | 14 |
| 15 namespace web { | 15 namespace web { |
| 16 | 16 |
| 17 struct ContextMenuParams; | 17 struct ContextMenuParams; |
| 18 class JavaScriptDialogPresenter; | 18 class JavaScriptDialogPresenter; |
| 19 | 19 |
| 20 // Objects implement this interface to get notified about changes in the | 20 // Objects implement this interface to get notified about changes in the |
| 21 // WebState and to provide necessary functionality. | 21 // WebState and to provide necessary functionality. |
| 22 class WebStateDelegate { | 22 class WebStateDelegate { |
| 23 public: | 23 public: |
| 24 WebStateDelegate(); | 24 WebStateDelegate(); |
| 25 | 25 |
| 26 // Called when |source| wants to open a new window. |url| is the URL of |
| 27 // the new window; |opener_url| is the URL of the page which requested a |
| 28 // window to be open; |initiated_by_user| is true if action was caused by the |
| 29 // user. |source| will not open a window if this method returns nil. This |
| 30 // method can not return |source|. |
| 31 virtual WebState* CreateNewWebState(WebState* source, |
| 32 const GURL& url, |
| 33 const GURL& opener_url, |
| 34 bool initiated_by_user); |
| 35 |
| 26 // Returns the WebState the URL is opened in, or nullptr if the URL wasn't | 36 // Returns the WebState the URL is opened in, or nullptr if the URL wasn't |
| 27 // opened immediately. | 37 // opened immediately. |
| 28 virtual WebState* OpenURLFromWebState(WebState*, | 38 virtual WebState* OpenURLFromWebState(WebState*, |
| 29 const WebState::OpenURLParams&); | 39 const WebState::OpenURLParams&); |
| 30 | 40 |
| 31 // Notifies the delegate that the user triggered the context menu with the | 41 // Notifies the delegate that the user triggered the context menu with the |
| 32 // given |ContextMenuParams|. Returns true if the context menu operation was | 42 // given |ContextMenuParams|. Returns true if the context menu operation was |
| 33 // handled by the delegate. | 43 // handled by the delegate. |
| 34 virtual bool HandleContextMenu(WebState* source, | 44 virtual bool HandleContextMenu(WebState* source, |
| 35 const ContextMenuParams& params); | 45 const ContextMenuParams& params); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // Called when |this| is no longer the WebStateDelegate for |source|. | 80 // Called when |this| is no longer the WebStateDelegate for |source|. |
| 71 void Detach(WebState* source); | 81 void Detach(WebState* source); |
| 72 | 82 |
| 73 // The WebStates for which |this| is currently a delegate. | 83 // The WebStates for which |this| is currently a delegate. |
| 74 std::set<WebState*> attached_states_; | 84 std::set<WebState*> attached_states_; |
| 75 }; | 85 }; |
| 76 | 86 |
| 77 } // namespace web | 87 } // namespace web |
| 78 | 88 |
| 79 #endif // IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_DELEGATE_H_ | 89 #endif // IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_DELEGATE_H_ |
| OLD | NEW |