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_WEB_VIEW_IMPL_H_ | 5 #ifndef COMPONENTS_WEB_VIEW_WEB_VIEW_IMPL_H_ |
6 #define COMPONENTS_WEB_VIEW_WEB_VIEW_IMPL_H_ | 6 #define COMPONENTS_WEB_VIEW_WEB_VIEW_IMPL_H_ |
7 | 7 |
8 #include <deque> | |
8 #include <string> | 9 #include <string> |
9 | 10 |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
12 #include "components/mus/public/cpp/view_observer.h" | 13 #include "components/mus/public/cpp/view_observer.h" |
13 #include "components/mus/public/cpp/view_tree_delegate.h" | 14 #include "components/mus/public/cpp/view_tree_delegate.h" |
14 #include "components/web_view/frame_devtools_agent_delegate.h" | 15 #include "components/web_view/frame_devtools_agent_delegate.h" |
15 #include "components/web_view/frame_tree_delegate.h" | 16 #include "components/web_view/frame_tree_delegate.h" |
16 #include "components/web_view/navigation_controller.h" | 17 #include "components/web_view/navigation_controller.h" |
17 #include "components/web_view/navigation_controller_delegate.h" | 18 #include "components/web_view/navigation_controller_delegate.h" |
(...skipping 24 matching lines...) Expand all Loading... | |
42 public NavigationControllerDelegate { | 43 public NavigationControllerDelegate { |
43 public: | 44 public: |
44 WebViewImpl(mojo::ApplicationImpl* app, | 45 WebViewImpl(mojo::ApplicationImpl* app, |
45 mojom::WebViewClientPtr client, | 46 mojom::WebViewClientPtr client, |
46 mojo::InterfaceRequest<WebView> request); | 47 mojo::InterfaceRequest<WebView> request); |
47 ~WebViewImpl() override; | 48 ~WebViewImpl() override; |
48 | 49 |
49 private: | 50 private: |
50 friend class PendingWebViewLoad; | 51 friend class PendingWebViewLoad; |
51 | 52 |
53 struct MatchData { | |
54 int count; | |
55 bool final_update; | |
56 }; | |
57 | |
52 // See description above |pending_load_| for details. | 58 // See description above |pending_load_| for details. |
53 void OnLoad(const GURL& pending_url); | 59 void OnLoad(const GURL& pending_url); |
54 | 60 |
61 std::deque<Frame*> GetAllFrames(); | |
62 | |
63 // Callback method invoked by Find(). | |
64 void OnContinueFinding(int32_t request_id, const mojo::String& search_text, | |
65 bool found); | |
66 | |
55 // Overridden from WebView: | 67 // Overridden from WebView: |
56 void LoadRequest(mojo::URLRequestPtr request) override; | 68 void LoadRequest(mojo::URLRequestPtr request) override; |
57 void GetViewTreeClient( | 69 void GetViewTreeClient( |
58 mojo::InterfaceRequest<mojo::ViewTreeClient> view_tree_client) | 70 mojo::InterfaceRequest<mojo::ViewTreeClient> view_tree_client) |
59 override; | 71 override; |
72 void Find(int32_t request_id, const mojo::String& search_text) override; | |
73 void StopFinding() override; | |
60 void GoBack() override; | 74 void GoBack() override; |
61 void GoForward() override; | 75 void GoForward() override; |
62 | 76 |
63 // Overridden from mus::ViewTreeDelegate: | 77 // Overridden from mus::ViewTreeDelegate: |
64 void OnEmbed(mus::View* root) override; | 78 void OnEmbed(mus::View* root) override; |
65 void OnConnectionLost(mus::ViewTreeConnection* connection) override; | 79 void OnConnectionLost(mus::ViewTreeConnection* connection) override; |
66 | 80 |
67 // Overridden from mus::ViewObserver: | 81 // Overridden from mus::ViewObserver: |
68 void OnViewBoundsChanged(mus::View* view, | 82 void OnViewBoundsChanged(mus::View* view, |
69 const mojo::Rect& old_bounds, | 83 const mojo::Rect& old_bounds, |
70 const mojo::Rect& new_bounds) override; | 84 const mojo::Rect& new_bounds) override; |
71 void OnViewDestroyed(mus::View* view) override; | 85 void OnViewDestroyed(mus::View* view) override; |
72 | 86 |
73 // Overridden from FrameTreeDelegate: | 87 // Overridden from FrameTreeDelegate: |
74 scoped_ptr<FrameUserData> CreateUserDataForNewFrame( | 88 scoped_ptr<FrameUserData> CreateUserDataForNewFrame( |
75 mojom::FrameClientPtr frame_client) override; | 89 mojom::FrameClientPtr frame_client) override; |
76 bool CanPostMessageEventToFrame(const Frame* source, | 90 bool CanPostMessageEventToFrame(const Frame* source, |
77 const Frame* target, | 91 const Frame* target, |
78 mojom::HTMLMessageEvent* event) override; | 92 mojom::HTMLMessageEvent* event) override; |
79 void LoadingStateChanged(bool loading, double progress) override; | 93 void LoadingStateChanged(bool loading, double progress) override; |
80 void TitleChanged(const mojo::String& title) override; | 94 void TitleChanged(const mojo::String& title) override; |
81 void NavigateTopLevel(Frame* source, mojo::URLRequestPtr request) override; | 95 void NavigateTopLevel(Frame* source, mojo::URLRequestPtr request) override; |
82 void CanNavigateFrame(Frame* target, | 96 void CanNavigateFrame(Frame* target, |
83 mojo::URLRequestPtr request, | 97 mojo::URLRequestPtr request, |
84 const CanNavigateFrameCallback& callback) override; | 98 const CanNavigateFrameCallback& callback) override; |
85 void DidStartNavigation(Frame* frame) override; | 99 void DidStartNavigation(Frame* frame) override; |
86 void DidCommitProvisionalLoad(Frame* frame) override; | 100 void DidCommitProvisionalLoad(Frame* frame) override; |
101 void DidDestroyFrame(Frame* frame) override; | |
102 void OnReportFindInFrameMatchCount(int32_t request_id, | |
103 Frame* frame, | |
104 int32_t count, | |
105 bool final_update) override; | |
106 void OnReportFindInPageSelection(int32_t request_id, | |
107 Frame* frame, | |
108 int32_t active_match_ordinal) override; | |
87 | 109 |
88 // Overridden from FrameDevToolsAgent::Delegate: | 110 // Overridden from FrameDevToolsAgent::Delegate: |
89 void HandlePageNavigateRequest(const GURL& url) override; | 111 void HandlePageNavigateRequest(const GURL& url) override; |
90 | 112 |
91 // Overridden from NavigationControllerDelegate: | 113 // Overridden from NavigationControllerDelegate: |
92 void OnNavigate(mojo::URLRequestPtr request) override; | 114 void OnNavigate(mojo::URLRequestPtr request) override; |
93 void OnDidNavigate() override; | 115 void OnDidNavigate() override; |
94 | 116 |
95 mojo::ApplicationImpl* app_; | 117 mojo::ApplicationImpl* app_; |
96 mojom::WebViewClientPtr client_; | 118 mojom::WebViewClientPtr client_; |
97 mojo::StrongBinding<WebView> binding_; | 119 mojo::StrongBinding<WebView> binding_; |
98 mus::View* root_; | 120 mus::View* root_; |
99 mus::View* content_; | 121 mus::View* content_; |
100 scoped_ptr<FrameTree> frame_tree_; | 122 scoped_ptr<FrameTree> frame_tree_; |
101 | 123 |
102 // When LoadRequest() is called a PendingWebViewLoad is created to wait for | 124 // When LoadRequest() is called a PendingWebViewLoad is created to wait for |
103 // state needed to process the request. When the state is obtained OnLoad() | 125 // state needed to process the request. When the state is obtained OnLoad() |
104 // is invoked. | 126 // is invoked. |
105 scoped_ptr<PendingWebViewLoad> pending_load_; | 127 scoped_ptr<PendingWebViewLoad> pending_load_; |
106 | 128 |
107 scoped_ptr<FrameDevToolsAgent> devtools_agent_; | 129 scoped_ptr<FrameDevToolsAgent> devtools_agent_; |
108 | 130 |
109 NavigationController navigation_controller_; | 131 NavigationController navigation_controller_; |
110 | 132 |
133 // A list of Frames which we have not sent a Find() command to. Initialized | |
134 // in Find(), and read from OnContinueFinding(). | |
135 std::deque<Frame*> pending_find_frames_; | |
sky
2015/10/02 16:03:40
Can the find related code be moved into it's own c
| |
136 | |
137 // Current find | |
138 int current_find_request_; | |
139 | |
140 // The current callback data from various frames. | |
141 std::map<Frame*, MatchData> returned_find_data_; | |
142 | |
111 DISALLOW_COPY_AND_ASSIGN(WebViewImpl); | 143 DISALLOW_COPY_AND_ASSIGN(WebViewImpl); |
112 }; | 144 }; |
113 | 145 |
114 } // namespace web_view | 146 } // namespace web_view |
115 | 147 |
116 #endif // COMPONENTS_WEB_VIEW_WEB_VIEW_IMPL_H_ | 148 #endif // COMPONENTS_WEB_VIEW_WEB_VIEW_IMPL_H_ |
OLD | NEW |