| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 COMPONENTS_WEB_VIEW_FRAME_TREE_DELEGATE_H_ | 5 #ifndef COMPONENTS_WEB_VIEW_FRAME_TREE_DELEGATE_H_ |
| 6 #define COMPONENTS_WEB_VIEW_FRAME_TREE_DELEGATE_H_ | 6 #define COMPONENTS_WEB_VIEW_FRAME_TREE_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "components/mus/public/interfaces/view_tree.mojom.h" | 12 #include "components/mus/public/interfaces/window_tree.mojom.h" |
| 13 #include "components/web_view/public/interfaces/frame.mojom.h" | 13 #include "components/web_view/public/interfaces/frame.mojom.h" |
| 14 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" | 14 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" |
| 15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 16 | 16 |
| 17 namespace web_view { | 17 namespace web_view { |
| 18 | 18 |
| 19 class Frame; | 19 class Frame; |
| 20 class FrameUserData; | 20 class FrameUserData; |
| 21 | 21 |
| 22 namespace mojom { | 22 namespace mojom { |
| 23 class HTMLMessageEvent; | 23 class HTMLMessageEvent; |
| 24 } | 24 } |
| 25 | 25 |
| 26 class FrameTreeDelegate { | 26 class FrameTreeDelegate { |
| 27 public: | 27 public: |
| 28 // Callback from CanNavigateFrame(). The uint32_t is the id of the app the | 28 // Callback from CanNavigateFrame(). The uint32_t is the id of the app the |
| 29 // FrameClient comes from; typically the content handler id. | 29 // FrameClient comes from; typically the content handler id. |
| 30 using CanNavigateFrameCallback = | 30 using CanNavigateFrameCallback = |
| 31 base::Callback<void(uint32_t, | 31 base::Callback<void(uint32_t, |
| 32 mojom::FrameClient*, | 32 mojom::FrameClient*, |
| 33 scoped_ptr<FrameUserData>, | 33 scoped_ptr<FrameUserData>, |
| 34 mojo::ViewTreeClientPtr)>; | 34 mus::mojom::WindowTreeClientPtr)>; |
| 35 | 35 |
| 36 // Called when a Frame creates a new child Frame. |frame_tree_client| is the | 36 // Called when a Frame creates a new child Frame. |frame_tree_client| is the |
| 37 // FrameClient for the new frame. | 37 // FrameClient for the new frame. |
| 38 virtual scoped_ptr<FrameUserData> CreateUserDataForNewFrame( | 38 virtual scoped_ptr<FrameUserData> CreateUserDataForNewFrame( |
| 39 mojom::FrameClientPtr frame_client) = 0; | 39 mojom::FrameClientPtr frame_client) = 0; |
| 40 | 40 |
| 41 // Returns whether a request to post a message from |source| to |target| | 41 // Returns whether a request to post a message from |source| to |target| |
| 42 // is allowed. |source| and |target| are never null. | 42 // is allowed. |source| and |target| are never null. |
| 43 virtual bool CanPostMessageEventToFrame(const Frame* source, | 43 virtual bool CanPostMessageEventToFrame(const Frame* source, |
| 44 const Frame* target, | 44 const Frame* target, |
| 45 mojom::HTMLMessageEvent* event) = 0; | 45 mojom::HTMLMessageEvent* event) = 0; |
| 46 | 46 |
| 47 virtual void LoadingStateChanged(bool loading, double progress) = 0; | 47 virtual void LoadingStateChanged(bool loading, double progress) = 0; |
| 48 | 48 |
| 49 virtual void TitleChanged(const mojo::String& title) = 0; | 49 virtual void TitleChanged(const mojo::String& title) = 0; |
| 50 | 50 |
| 51 // |source| is requesting a navigation. If |target_type| is | 51 // |source| is requesting a navigation. If |target_type| is |
| 52 // |EXISTING_FRAME| then |target_frame| identifies the frame to perform the | 52 // |EXISTING_FRAME| then |target_frame| identifies the frame to perform the |
| 53 // navigation in, otherwise |target_frame| is not used. |target_frame| may | 53 // navigation in, otherwise |target_frame| is not used. |target_frame| may |
| 54 // be null, even for |EXISTING_FRAME|. | 54 // be null, even for |EXISTING_FRAME|. |
| 55 // TODO(sky): this needs to distinguish between navigate in source, vs new | 55 // TODO(sky): this needs to distinguish between navigate in source, vs new |
| 56 // background tab, vs new foreground tab. | 56 // background tab, vs new foreground tab. |
| 57 virtual void NavigateTopLevel(Frame* source, mojo::URLRequestPtr request) = 0; | 57 virtual void NavigateTopLevel(Frame* source, mojo::URLRequestPtr request) = 0; |
| 58 | 58 |
| 59 // Asks the client if navigation is allowed. If the navigation is allowed | 59 // Asks the client if navigation is allowed. If the navigation is allowed |
| 60 // |callback| should be called to continue the navigation. |callback| | 60 // |callback| should be called to continue the navigation. |callback| |
| 61 // may be called synchronously or asynchronously. In the callback | 61 // may be called synchronously or asynchronously. In the callback |
| 62 // mojo::ViewTreeClientPtr should only be set if an app other than | 62 // mus::mojom::WindowTreeClientPtr should only be set if an app other than |
| 63 // frame->app_id() is used to render |request|. | 63 // frame->app_id() is used to render |request|. |
| 64 virtual void CanNavigateFrame(Frame* target, | 64 virtual void CanNavigateFrame(Frame* target, |
| 65 mojo::URLRequestPtr request, | 65 mojo::URLRequestPtr request, |
| 66 const CanNavigateFrameCallback& callback) = 0; | 66 const CanNavigateFrameCallback& callback) = 0; |
| 67 | 67 |
| 68 // Invoked when a navigation in |frame| has been initiated. | 68 // Invoked when a navigation in |frame| has been initiated. |
| 69 virtual void DidStartNavigation(Frame* frame) = 0; | 69 virtual void DidStartNavigation(Frame* frame) = 0; |
| 70 | 70 |
| 71 // Invoked when blink has started displaying the frame. | 71 // Invoked when blink has started displaying the frame. |
| 72 virtual void DidCommitProvisionalLoad(Frame* frame) = 0; | 72 virtual void DidCommitProvisionalLoad(Frame* frame) = 0; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 97 Frame* frame, | 97 Frame* frame, |
| 98 int32_t active_match_ordinal); | 98 int32_t active_match_ordinal); |
| 99 | 99 |
| 100 protected: | 100 protected: |
| 101 virtual ~FrameTreeDelegate() {} | 101 virtual ~FrameTreeDelegate() {} |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 } // namespace web_view | 104 } // namespace web_view |
| 105 | 105 |
| 106 #endif // COMPONENTS_WEB_VIEW_FRAME_TREE_DELEGATE_H_ | 106 #endif // COMPONENTS_WEB_VIEW_FRAME_TREE_DELEGATE_H_ |
| OLD | NEW |