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

Unified 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: Further patch cleanup; use a WeakPtrFactory in FindController. 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 side-by-side diff with in-line comments
Download patch
Index: components/web_view/web_view_impl.cc
diff --git a/components/web_view/web_view_impl.cc b/components/web_view/web_view_impl.cc
index 8992496bbc2789309aa2883afe1d67c9f21a474b..75221a3c972bec704493466947f0ed8be8de56d4 100644
--- a/components/web_view/web_view_impl.cc
+++ b/components/web_view/web_view_impl.cc
@@ -4,6 +4,9 @@
#include "components/web_view/web_view_impl.h"
+#include <queue>
+
+#include "base/bind.h"
#include "base/command_line.h"
#include "components/devtools_service/public/cpp/switches.h"
#include "components/mus/public/cpp/scoped_view_ptr.h"
@@ -44,7 +47,8 @@ WebViewImpl::WebViewImpl(mojo::ApplicationImpl* app,
binding_(this, request.Pass()),
root_(nullptr),
content_(nullptr),
- navigation_controller_(this) {
+ navigation_controller_(this),
+ find_controller_(this) {
if (EnableRemoteDebugging())
devtools_agent_.reset(new FrameDevToolsAgent(app_, this));
OnDidNavigate();
@@ -110,6 +114,14 @@ void WebViewImpl::GetViewTreeClient(
mus::ViewTreeConnection::Create(this, view_tree_client.Pass());
}
+void WebViewImpl::Find(int32_t request_id, const mojo::String& search_text) {
+ find_controller_.Find(request_id, search_text);
+}
+
+void WebViewImpl::StopFinding() {
+ find_controller_.StopFinding();
+}
+
void WebViewImpl::GoBack() {
if (!navigation_controller_.CanGoBack())
return;
@@ -203,6 +215,25 @@ void WebViewImpl::DidCommitProvisionalLoad(Frame* frame) {
navigation_controller_.FrameDidCommitProvisionalLoad(frame);
}
+void WebViewImpl::DidDestroyFrame(Frame* frame) {
+ find_controller_.DidDestroyFrame(frame);
+}
+
+void WebViewImpl::OnReportFindInFrameMatchCount(int32_t request_id,
+ Frame* frame,
+ int32_t count,
+ bool final_update) {
+ find_controller_.OnReportFindInFrameMatchCount(request_id, frame, count,
+ final_update);
+}
+
+void WebViewImpl::OnReportFindInPageSelection(int32_t request_id,
+ Frame* frame,
+ int32_t active_match_ordinal) {
+ find_controller_.OnReportFindInPageSelection(request_id, frame,
+ active_match_ordinal);
+}
+
////////////////////////////////////////////////////////////////////////////////
// WebViewImpl, FrameDevToolsAgentDelegate implementation:
@@ -229,4 +260,27 @@ void WebViewImpl::OnDidNavigate() {
: ButtonState::BUTTON_STATE_DISABLED);
}
+////////////////////////////////////////////////////////////////////////////////
+// WebViewImpl, FindControllerDelegate implementation:
+
+std::deque<Frame*> WebViewImpl::GetAllFrames() {
+ std::deque<Frame*> all_frames;
+ std::queue<Frame*> frames_to_search;
+ frames_to_search.push(frame_tree_->root());
+ while (!frames_to_search.empty()) {
+ // TODO(erg): This is not in depth first order. I'm not actually sure how
+ // blink does traversal though.
+ Frame* current = frames_to_search.front();
+ frames_to_search.pop();
+ for (Frame* child : current->children())
+ frames_to_search.push(child);
+ all_frames.push_back(current);
+ }
+ return all_frames;
+}
+
+mojom::WebViewClient* WebViewImpl::GetWebViewClient() {
+ return client_.get();
+}
+
} // namespace web_view

Powered by Google App Engine
This is Rietveld 408576698