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

Side by Side Diff: chrome/browser/guestview/webview/webview_find_helper.cc

Issue 257823005: [Sheriff] Revert "Revert "Revert 266297 "1. Handle the case of empty embedder_extension_id...""" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/guest_view/web_view/web_view_find_helper.h" 5 #include "chrome/browser/guestview/webview/webview_find_helper.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "chrome/browser/extensions/api/webview/webview_api.h" 9 #include "chrome/browser/extensions/api/webview/webview_api.h"
10 #include "chrome/browser/guest_view/web_view/web_view_constants.h" 10 #include "chrome/browser/guestview/webview/webview_constants.h"
11 11
12 WebviewFindHelper::WebviewFindHelper(WebViewGuest* webview_guest) 12 WebviewFindHelper::WebviewFindHelper(WebViewGuest* webview_guest)
13 : webview_guest_(webview_guest), 13 : webview_guest_(webview_guest),
14 current_find_request_id_(0) { 14 current_find_request_id_(0) {
15 } 15 }
16 16
17 WebviewFindHelper::~WebviewFindHelper() { 17 WebviewFindHelper::~WebviewFindHelper() {
18 } 18 }
19 19
20 void WebviewFindHelper::CancelAllFindSessions() { 20 void WebviewFindHelper::CancelAllFindSessions() {
21 current_find_session_ = linked_ptr<WebviewFindHelper::FindInfo>(); 21 current_find_session_ = linked_ptr<WebviewFindHelper::FindInfo>();
22 while (!find_info_map_.empty()) { 22 while (!find_info_map_.empty()) {
23 find_info_map_.begin()->second->SendResponse(true /* canceled */); 23 find_info_map_.begin()->second->SendResponse(true /* canceled */);
24 find_info_map_.erase(find_info_map_.begin()); 24 find_info_map_.erase(find_info_map_.begin());
25 } 25 }
26 if (find_update_event_.get()) 26 if (find_update_event_.get())
27 DispatchFindUpdateEvent(true /* canceled */, true /* final_update */); 27 DispatchFindUpdateEvent(true /* canceled */, true /* final_update */);
28 find_update_event_.reset(); 28 find_update_event_.reset();
29 } 29 }
30 30
31 void WebviewFindHelper::DispatchFindUpdateEvent(bool canceled, 31 void WebviewFindHelper::DispatchFindUpdateEvent(bool canceled,
32 bool final_update) { 32 bool final_update) {
33 DCHECK(find_update_event_.get()); 33 DCHECK(find_update_event_.get());
34 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); 34 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
35 find_update_event_->PrepareResults(args.get()); 35 find_update_event_->PrepareResults(args.get());
36 args->SetBoolean(webview::kFindCanceled, canceled); 36 args->SetBoolean(webview::kFindCanceled, canceled);
37 args->SetBoolean(webview::kFindFinalUpdate, final_update); 37 args->SetBoolean(webview::kFindFinalUpdate, final_update);
38 DCHECK(webview_guest_); 38 DCHECK(webview_guest_);
39 webview_guest_->DispatchEvent( 39 webview_guest_->DispatchEvent(new GuestView::Event(webview::kEventFindReply,
40 new GuestViewBase::Event(webview::kEventFindReply, args.Pass())); 40 args.Pass()));
41 } 41 }
42 42
43 void WebviewFindHelper::EndFindSession(int session_request_id, bool canceled) { 43 void WebviewFindHelper::EndFindSession(int session_request_id, bool canceled) {
44 FindInfoMap::iterator session_iterator = 44 FindInfoMap::iterator session_iterator =
45 find_info_map_.find(session_request_id); 45 find_info_map_.find(session_request_id);
46 DCHECK(session_iterator != find_info_map_.end()); 46 DCHECK(session_iterator != find_info_map_.end());
47 FindInfo* find_info = session_iterator->second.get(); 47 FindInfo* find_info = session_iterator->second.get();
48 48
49 // Call the callback function of the first request of the find session. 49 // Call the callback function of the first request of the find session.
50 find_info->SendResponse(canceled); 50 find_info->SendResponse(canceled);
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 void WebviewFindHelper::FindInfo::SendResponse(bool canceled) { 270 void WebviewFindHelper::FindInfo::SendResponse(bool canceled) {
271 // Prepare the find results to pass to the callback function. 271 // Prepare the find results to pass to the callback function.
272 base::DictionaryValue results; 272 base::DictionaryValue results;
273 find_results_.PrepareResults(&results); 273 find_results_.PrepareResults(&results);
274 results.SetBoolean(webview::kFindCanceled, canceled); 274 results.SetBoolean(webview::kFindCanceled, canceled);
275 275
276 // Call the callback. 276 // Call the callback.
277 find_function_->SetResult(results.DeepCopy()); 277 find_function_->SetResult(results.DeepCopy());
278 find_function_->SendResponse(true); 278 find_function_->SendResponse(true);
279 } 279 }
OLDNEW
« no previous file with comments | « chrome/browser/guestview/webview/webview_find_helper.h ('k') | chrome/browser/guestview/webview/webview_guest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698