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

Side by Side Diff: android_webview/browser/renderer_host/aw_render_view_host_ext.cc

Issue 11860014: Android WebView visited link highlighting implementation part 1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to crrev.com/11884034. AddObserver fix. Created 7 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "android_webview/browser/renderer_host/aw_render_view_host_ext.h" 5 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h"
6 6
7 #include "android_webview/common/render_view_messages.h" 7 #include "android_webview/common/render_view_messages.h"
8 #include "base/android/scoped_java_ref.h" 8 #include "base/android/scoped_java_ref.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "content/public/browser/render_process_host.h" 11 #include "content/public/browser/render_process_host.h"
12 #include "content/public/browser/user_metrics.h" 12 #include "content/public/browser/user_metrics.h"
13 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
14 #include "content/public/common/frame_navigate_params.h"
14 15
15 namespace android_webview { 16 namespace android_webview {
16 17
17 AwRenderViewHostExt::AwRenderViewHostExt(content::WebContents* contents, 18 AwRenderViewHostExt::AwRenderViewHostExt(content::WebContents* contents,
18 Client* client) 19 Client* client)
19 : content::WebContentsObserver(contents), 20 : content::WebContentsObserver(contents),
20 has_new_hit_test_data_(false), 21 has_new_hit_test_data_(false),
22 visitedlink_master_(contents->GetBrowserContext(), this),
21 client_(client) { 23 client_(client) {
24 visitedlink_master_.Init();
22 } 25 }
23 26
24 AwRenderViewHostExt::~AwRenderViewHostExt() {} 27 AwRenderViewHostExt::~AwRenderViewHostExt() {
28 }
25 29
26 void AwRenderViewHostExt::DocumentHasImages(DocumentHasImagesResult result) { 30 void AwRenderViewHostExt::DocumentHasImages(DocumentHasImagesResult result) {
27 DCHECK(CalledOnValidThread()); 31 DCHECK(CalledOnValidThread());
28 if (!web_contents()->GetRenderViewHost()) { 32 if (!web_contents()->GetRenderViewHost()) {
29 result.Run(false); 33 result.Run(false);
30 return; 34 return;
31 } 35 }
32 static int next_id = 1; 36 static int next_id = 1;
33 int this_id = next_id++; 37 int this_id = next_id++;
34 pending_document_has_images_requests_[this_id] = result; 38 pending_document_has_images_requests_[this_id] = result;
(...skipping 29 matching lines...) Expand all
64 void AwRenderViewHostExt::RenderViewGone(base::TerminationStatus status) { 68 void AwRenderViewHostExt::RenderViewGone(base::TerminationStatus status) {
65 DCHECK(CalledOnValidThread()); 69 DCHECK(CalledOnValidThread());
66 for (std::map<int, DocumentHasImagesResult>::iterator pending_req = 70 for (std::map<int, DocumentHasImagesResult>::iterator pending_req =
67 pending_document_has_images_requests_.begin(); 71 pending_document_has_images_requests_.begin();
68 pending_req != pending_document_has_images_requests_.end(); 72 pending_req != pending_document_has_images_requests_.end();
69 ++pending_req) { 73 ++pending_req) {
70 pending_req->second.Run(false); 74 pending_req->second.Run(false);
71 } 75 }
72 } 76 }
73 77
78 void AwRenderViewHostExt::DidNavigateAnyFrame(
79 const content::LoadCommittedDetails& details,
80 const content::FrameNavigateParams& params) {
81 DCHECK(CalledOnValidThread());
82
83 visitedlink_master_.AddURL(params.base_url);
84 }
85
74 bool AwRenderViewHostExt::OnMessageReceived(const IPC::Message& message) { 86 bool AwRenderViewHostExt::OnMessageReceived(const IPC::Message& message) {
75 bool handled = true; 87 bool handled = true;
76 IPC_BEGIN_MESSAGE_MAP(AwRenderViewHostExt, message) 88 IPC_BEGIN_MESSAGE_MAP(AwRenderViewHostExt, message)
77 IPC_MESSAGE_HANDLER(AwViewHostMsg_DocumentHasImagesResponse, 89 IPC_MESSAGE_HANDLER(AwViewHostMsg_DocumentHasImagesResponse,
78 OnDocumentHasImagesResponse) 90 OnDocumentHasImagesResponse)
79 IPC_MESSAGE_HANDLER(AwViewHostMsg_UpdateHitTestData, 91 IPC_MESSAGE_HANDLER(AwViewHostMsg_UpdateHitTestData,
80 OnUpdateHitTestData) 92 OnUpdateHitTestData)
81 IPC_MESSAGE_HANDLER(AwViewHostMsg_PictureUpdated, 93 IPC_MESSAGE_HANDLER(AwViewHostMsg_PictureUpdated,
82 OnPictureUpdated) 94 OnPictureUpdated)
83 IPC_MESSAGE_UNHANDLED(handled = false) 95 IPC_MESSAGE_UNHANDLED(handled = false)
84 IPC_END_MESSAGE_MAP() 96 IPC_END_MESSAGE_MAP()
85 97
86 return handled ? true : WebContentsObserver::OnMessageReceived(message); 98 return handled ? true : WebContentsObserver::OnMessageReceived(message);
87 } 99 }
88 100
101 bool AwRenderViewHostExt::PersistToDisk() const {
102 // Persistence of VisitedLink database is handled by the embedding app.
joth 2013/01/14 23:40:35 would it be possible/useful to mention which funct
103 return false;
104 }
105
106 bool AwRenderViewHostExt::AreEquivalentContexts(
107 content::BrowserContext* context1,
108 content::BrowserContext* context2) {
109 DCHECK(CalledOnValidThread());
110
111 // Raw pointer comparison since Android WebView does not have sub-contexts
112 // like incognito.
113 return context1 == context2;
114 }
115
116 void AwRenderViewHostExt::RebuildTable(
117 const scoped_refptr<URLEnumerator>& enumerator) {
118 DCHECK(CalledOnValidThread());
119
120 // Android WebView rebuilds from WebChromeClient which can change in the
121 // lifetime of this WebView and may not yet be set here. This initialization
122 // path is not used.
joth 2013/01/14 23:40:35 (ditto, ish. i.e. how does the restore from disk c
123 enumerator->OnComplete(true);
124 }
125
89 void AwRenderViewHostExt::OnDocumentHasImagesResponse(int msg_id, 126 void AwRenderViewHostExt::OnDocumentHasImagesResponse(int msg_id,
90 bool has_images) { 127 bool has_images) {
91 DCHECK(CalledOnValidThread()); 128 DCHECK(CalledOnValidThread());
92 std::map<int, DocumentHasImagesResult>::iterator pending_req = 129 std::map<int, DocumentHasImagesResult>::iterator pending_req =
93 pending_document_has_images_requests_.find(msg_id); 130 pending_document_has_images_requests_.find(msg_id);
94 if (pending_req == pending_document_has_images_requests_.end()) { 131 if (pending_req == pending_document_has_images_requests_.end()) {
95 DLOG(WARNING) << "unexpected DocumentHasImages Response: " << msg_id; 132 DLOG(WARNING) << "unexpected DocumentHasImages Response: " << msg_id;
96 } else { 133 } else {
97 pending_req->second.Run(has_images); 134 pending_req->second.Run(has_images);
98 pending_document_has_images_requests_.erase(pending_req); 135 pending_document_has_images_requests_.erase(pending_req);
99 } 136 }
100 } 137 }
101 138
102 void AwRenderViewHostExt::OnUpdateHitTestData( 139 void AwRenderViewHostExt::OnUpdateHitTestData(
103 const AwHitTestData& hit_test_data) { 140 const AwHitTestData& hit_test_data) {
104 DCHECK(CalledOnValidThread()); 141 DCHECK(CalledOnValidThread());
105 last_hit_test_data_ = hit_test_data; 142 last_hit_test_data_ = hit_test_data;
106 has_new_hit_test_data_ = true; 143 has_new_hit_test_data_ = true;
107 } 144 }
108 145
109 void AwRenderViewHostExt::OnPictureUpdated() { 146 void AwRenderViewHostExt::OnPictureUpdated() {
110 if (client_) 147 if (client_)
111 client_->OnPictureUpdated(web_contents()->GetRenderProcessHost()->GetID(), 148 client_->OnPictureUpdated(web_contents()->GetRenderProcessHost()->GetID(),
112 routing_id()); 149 routing_id());
113 } 150 }
114 151
115 } // namespace android_webview 152 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/browser/renderer_host/aw_render_view_host_ext.h ('k') | android_webview/renderer/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698