| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_WEB_VIEW_FRAME_TREE_DELEGATE_H_ | |
| 6 #define COMPONENTS_WEB_VIEW_FRAME_TREE_DELEGATE_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include <string> | |
| 11 | |
| 12 #include "base/callback_forward.h" | |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "components/mus/public/interfaces/window_tree.mojom.h" | |
| 15 #include "components/web_view/public/interfaces/frame.mojom.h" | |
| 16 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" | |
| 17 #include "url/gurl.h" | |
| 18 | |
| 19 namespace web_view { | |
| 20 | |
| 21 class Frame; | |
| 22 class FrameUserData; | |
| 23 | |
| 24 namespace mojom { | |
| 25 class HTMLMessageEvent; | |
| 26 } | |
| 27 | |
| 28 class FrameTreeDelegate { | |
| 29 public: | |
| 30 // Callback from CanNavigateFrame(). The uint32_t is the id of the app the | |
| 31 // FrameClient comes from; typically the content handler id. | |
| 32 using CanNavigateFrameCallback = | |
| 33 base::Callback<void(uint32_t, | |
| 34 mojom::FrameClient*, | |
| 35 scoped_ptr<FrameUserData>, | |
| 36 mus::mojom::WindowTreeClientPtr)>; | |
| 37 | |
| 38 // Called when a Frame creates a new child Frame. |frame_tree_client| is the | |
| 39 // FrameClient for the new frame. | |
| 40 virtual scoped_ptr<FrameUserData> CreateUserDataForNewFrame( | |
| 41 mojom::FrameClientPtr frame_client) = 0; | |
| 42 | |
| 43 // Returns whether a request to post a message from |source| to |target| | |
| 44 // is allowed. |source| and |target| are never null. | |
| 45 virtual bool CanPostMessageEventToFrame(const Frame* source, | |
| 46 const Frame* target, | |
| 47 mojom::HTMLMessageEvent* event) = 0; | |
| 48 | |
| 49 virtual void LoadingStateChanged(bool loading, double progress) = 0; | |
| 50 | |
| 51 virtual void TitleChanged(const mojo::String& title) = 0; | |
| 52 | |
| 53 // |source| is requesting a navigation. If |target_type| is | |
| 54 // |EXISTING_FRAME| then |target_frame| identifies the frame to perform the | |
| 55 // navigation in, otherwise |target_frame| is not used. |target_frame| may | |
| 56 // be null, even for |EXISTING_FRAME|. | |
| 57 // TODO(sky): this needs to distinguish between navigate in source, vs new | |
| 58 // background tab, vs new foreground tab. | |
| 59 virtual void NavigateTopLevel(Frame* source, mojo::URLRequestPtr request) = 0; | |
| 60 | |
| 61 // Asks the client if navigation is allowed. If the navigation is allowed | |
| 62 // |callback| should be called to continue the navigation. |callback| | |
| 63 // may be called synchronously or asynchronously. In the callback | |
| 64 // mus::mojom::WindowTreeClientPtr should only be set if an app other than | |
| 65 // frame->app_id() is used to render |request|. | |
| 66 virtual void CanNavigateFrame(Frame* target, | |
| 67 mojo::URLRequestPtr request, | |
| 68 const CanNavigateFrameCallback& callback) = 0; | |
| 69 | |
| 70 // Invoked when a navigation in |frame| has been initiated. | |
| 71 virtual void DidStartNavigation(Frame* frame) = 0; | |
| 72 | |
| 73 // Invoked when blink has started displaying the frame. | |
| 74 virtual void DidCommitProvisionalLoad(Frame* frame) = 0; | |
| 75 | |
| 76 // Invoked when the frame has changed its own URL. | |
| 77 virtual void DidNavigateLocally(Frame* source, const GURL& url) = 0; | |
| 78 | |
| 79 // Notification of various frame state changes. Generally only useful for | |
| 80 // tests. | |
| 81 virtual void DidCreateFrame(Frame* frame); | |
| 82 virtual void DidDestroyFrame(Frame* frame); | |
| 83 | |
| 84 // Invoked when the Window embedded in a Frame premuturely stops rendering | |
| 85 // to |frame|'s Window. This could mean any of the following: | |
| 86 // . The app crashed. | |
| 87 // . There is no app that renders the url. | |
| 88 // . The app is still alive, but is shutting down. | |
| 89 // Frame does nothing in response to this, but the delegate may wish to take | |
| 90 // action. | |
| 91 virtual void OnWindowEmbeddedInFrameDisconnected(Frame* frame); | |
| 92 | |
| 93 // Reports the current find state back to our owner. | |
| 94 virtual void OnFindInFrameCountUpdated(int32_t request_id, | |
| 95 Frame* frame, | |
| 96 int32_t count, | |
| 97 bool final_update); | |
| 98 virtual void OnFindInPageSelectionUpdated(int32_t request_id, | |
| 99 Frame* frame, | |
| 100 int32_t active_match_ordinal); | |
| 101 | |
| 102 protected: | |
| 103 virtual ~FrameTreeDelegate() {} | |
| 104 }; | |
| 105 | |
| 106 } // namespace web_view | |
| 107 | |
| 108 #endif // COMPONENTS_WEB_VIEW_FRAME_TREE_DELEGATE_H_ | |
| OLD | NEW |