Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(360)

Side by Side Diff: components/web_view/web_view_impl.cc

Issue 1371773003: mandoline: Add find in page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Final documentation changes. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/web_view/web_view_impl.h ('k') | mandoline/ui/desktop_ui/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "components/web_view/web_view_impl.h" 5 #include "components/web_view/web_view_impl.h"
6 6
7 #include <queue>
8
9 #include "base/bind.h"
7 #include "base/command_line.h" 10 #include "base/command_line.h"
8 #include "components/devtools_service/public/cpp/switches.h" 11 #include "components/devtools_service/public/cpp/switches.h"
9 #include "components/mus/public/cpp/scoped_view_ptr.h" 12 #include "components/mus/public/cpp/scoped_view_ptr.h"
10 #include "components/mus/public/cpp/view.h" 13 #include "components/mus/public/cpp/view.h"
11 #include "components/mus/public/cpp/view_tree_connection.h" 14 #include "components/mus/public/cpp/view_tree_connection.h"
12 #include "components/web_view/client_initiated_frame_connection.h" 15 #include "components/web_view/client_initiated_frame_connection.h"
13 #include "components/web_view/frame.h" 16 #include "components/web_view/frame.h"
14 #include "components/web_view/frame_connection.h" 17 #include "components/web_view/frame_connection.h"
15 #include "components/web_view/frame_devtools_agent.h" 18 #include "components/web_view/frame_devtools_agent.h"
16 #include "components/web_view/frame_tree.h" 19 #include "components/web_view/frame_tree.h"
(...skipping 20 matching lines...) Expand all
37 // WebViewImpl, public: 40 // WebViewImpl, public:
38 41
39 WebViewImpl::WebViewImpl(mojo::ApplicationImpl* app, 42 WebViewImpl::WebViewImpl(mojo::ApplicationImpl* app,
40 mojom::WebViewClientPtr client, 43 mojom::WebViewClientPtr client,
41 mojo::InterfaceRequest<mojom::WebView> request) 44 mojo::InterfaceRequest<mojom::WebView> request)
42 : app_(app), 45 : app_(app),
43 client_(client.Pass()), 46 client_(client.Pass()),
44 binding_(this, request.Pass()), 47 binding_(this, request.Pass()),
45 root_(nullptr), 48 root_(nullptr),
46 content_(nullptr), 49 content_(nullptr),
47 navigation_controller_(this) { 50 navigation_controller_(this),
51 find_controller_(this) {
48 if (EnableRemoteDebugging()) 52 if (EnableRemoteDebugging())
49 devtools_agent_.reset(new FrameDevToolsAgent(app_, this)); 53 devtools_agent_.reset(new FrameDevToolsAgent(app_, this));
50 OnDidNavigate(); 54 OnDidNavigate();
51 } 55 }
52 56
53 WebViewImpl::~WebViewImpl() { 57 WebViewImpl::~WebViewImpl() {
54 if (content_) 58 if (content_)
55 content_->RemoveObserver(this); 59 content_->RemoveObserver(this);
56 if (root_) { 60 if (root_) {
57 root_->RemoveObserver(this); 61 root_->RemoveObserver(this);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 107
104 void WebViewImpl::LoadRequest(mojo::URLRequestPtr request) { 108 void WebViewImpl::LoadRequest(mojo::URLRequestPtr request) {
105 navigation_controller_.LoadURL(request.Pass()); 109 navigation_controller_.LoadURL(request.Pass());
106 } 110 }
107 111
108 void WebViewImpl::GetViewTreeClient( 112 void WebViewImpl::GetViewTreeClient(
109 mojo::InterfaceRequest<mojo::ViewTreeClient> view_tree_client) { 113 mojo::InterfaceRequest<mojo::ViewTreeClient> view_tree_client) {
110 mus::ViewTreeConnection::Create(this, view_tree_client.Pass()); 114 mus::ViewTreeConnection::Create(this, view_tree_client.Pass());
111 } 115 }
112 116
117 void WebViewImpl::Find(int32_t request_id, const mojo::String& search_text) {
118 find_controller_.Find(request_id, search_text);
119 }
120
121 void WebViewImpl::StopFinding() {
122 find_controller_.StopFinding();
123 }
124
113 void WebViewImpl::GoBack() { 125 void WebViewImpl::GoBack() {
114 if (!navigation_controller_.CanGoBack()) 126 if (!navigation_controller_.CanGoBack())
115 return; 127 return;
116 navigation_controller_.GoBack(); 128 navigation_controller_.GoBack();
117 } 129 }
118 130
119 void WebViewImpl::GoForward() { 131 void WebViewImpl::GoForward() {
120 if (!navigation_controller_.CanGoForward()) 132 if (!navigation_controller_.CanGoForward())
121 return; 133 return;
122 navigation_controller_.GoForward(); 134 navigation_controller_.GoForward();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 FrameConnection::CreateConnectionForCanNavigateFrame( 208 FrameConnection::CreateConnectionForCanNavigateFrame(
197 app_, target, request.Pass(), callback); 209 app_, target, request.Pass(), callback);
198 } 210 }
199 211
200 void WebViewImpl::DidStartNavigation(Frame* frame) {} 212 void WebViewImpl::DidStartNavigation(Frame* frame) {}
201 213
202 void WebViewImpl::DidCommitProvisionalLoad(Frame* frame) { 214 void WebViewImpl::DidCommitProvisionalLoad(Frame* frame) {
203 navigation_controller_.FrameDidCommitProvisionalLoad(frame); 215 navigation_controller_.FrameDidCommitProvisionalLoad(frame);
204 } 216 }
205 217
218 void WebViewImpl::DidDestroyFrame(Frame* frame) {
219 find_controller_.DidDestroyFrame(frame);
220 }
221
222 void WebViewImpl::OnFindInFrameCountUpdated(int32_t request_id,
223 Frame* frame,
224 int32_t count,
225 bool final_update) {
226 find_controller_.OnFindInFrameCountUpdated(request_id, frame, count,
227 final_update);
228 }
229
230 void WebViewImpl::OnFindInPageSelectionUpdated(int32_t request_id,
231 Frame* frame,
232 int32_t active_match_ordinal) {
233 find_controller_.OnFindInPageSelectionUpdated(request_id, frame,
234 active_match_ordinal);
235 }
236
206 //////////////////////////////////////////////////////////////////////////////// 237 ////////////////////////////////////////////////////////////////////////////////
207 // WebViewImpl, FrameDevToolsAgentDelegate implementation: 238 // WebViewImpl, FrameDevToolsAgentDelegate implementation:
208 239
209 void WebViewImpl::HandlePageNavigateRequest(const GURL& url) { 240 void WebViewImpl::HandlePageNavigateRequest(const GURL& url) {
210 mojo::URLRequestPtr request(mojo::URLRequest::New()); 241 mojo::URLRequestPtr request(mojo::URLRequest::New());
211 request->url = url.spec(); 242 request->url = url.spec();
212 client_->TopLevelNavigateRequest(request.Pass()); 243 client_->TopLevelNavigateRequest(request.Pass());
213 } 244 }
214 245
215 //////////////////////////////////////////////////////////////////////////////// 246 ////////////////////////////////////////////////////////////////////////////////
216 // WebViewImpl, NavigationControllerDelegate implementation: 247 // WebViewImpl, NavigationControllerDelegate implementation:
217 248
218 void WebViewImpl::OnNavigate(mojo::URLRequestPtr request) { 249 void WebViewImpl::OnNavigate(mojo::URLRequestPtr request) {
219 pending_load_.reset(new PendingWebViewLoad(this)); 250 pending_load_.reset(new PendingWebViewLoad(this));
220 pending_load_->Init(request.Pass()); 251 pending_load_->Init(request.Pass());
221 } 252 }
222 253
223 void WebViewImpl::OnDidNavigate() { 254 void WebViewImpl::OnDidNavigate() {
224 client_->BackForwardChanged(navigation_controller_.CanGoBack() 255 client_->BackForwardChanged(navigation_controller_.CanGoBack()
225 ? ButtonState::BUTTON_STATE_ENABLED 256 ? ButtonState::BUTTON_STATE_ENABLED
226 : ButtonState::BUTTON_STATE_DISABLED, 257 : ButtonState::BUTTON_STATE_DISABLED,
227 navigation_controller_.CanGoForward() 258 navigation_controller_.CanGoForward()
228 ? ButtonState::BUTTON_STATE_ENABLED 259 ? ButtonState::BUTTON_STATE_ENABLED
229 : ButtonState::BUTTON_STATE_DISABLED); 260 : ButtonState::BUTTON_STATE_DISABLED);
230 } 261 }
231 262
263 ////////////////////////////////////////////////////////////////////////////////
264 // WebViewImpl, FindControllerDelegate implementation:
265
266 std::deque<Frame*> WebViewImpl::GetAllFrames() {
267 std::deque<Frame*> all_frames;
268 std::queue<Frame*> frames_to_search;
269 frames_to_search.push(frame_tree_->root());
270 while (!frames_to_search.empty()) {
271 // TODO(erg): This is not in depth first order. I'm not actually sure how
272 // blink does traversal though.
273 Frame* current = frames_to_search.front();
274 frames_to_search.pop();
275 for (Frame* child : current->children())
276 frames_to_search.push(child);
277 all_frames.push_back(current);
278 }
279 return all_frames;
280 }
281
282 mojom::WebViewClient* WebViewImpl::GetWebViewClient() {
283 return client_.get();
284 }
285
232 } // namespace web_view 286 } // namespace web_view
OLDNEW
« no previous file with comments | « components/web_view/web_view_impl.h ('k') | mandoline/ui/desktop_ui/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698