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

Side by Side Diff: extensions/browser/guest_view/web_view/web_view_guest.cc

Issue 579563002: Find working in app_shell. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase+cleanup Created 6 years, 3 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
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 "extensions/browser/guest_view/web_view/web_view_guest.h" 5 #include "extensions/browser/guest_view/web_view/web_view_guest.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/public/browser/browser_context.h" 10 #include "content/public/browser/browser_context.h"
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 DispatchEventToEmbedder( 382 DispatchEventToEmbedder(
383 new GuestViewBase::Event(webview::kEventClose, args.Pass())); 383 new GuestViewBase::Event(webview::kEventClose, args.Pass()));
384 } 384 }
385 385
386 void WebViewGuest::FindReply(WebContents* source, 386 void WebViewGuest::FindReply(WebContents* source,
387 int request_id, 387 int request_id,
388 int number_of_matches, 388 int number_of_matches,
389 const gfx::Rect& selection_rect, 389 const gfx::Rect& selection_rect,
390 int active_match_ordinal, 390 int active_match_ordinal,
391 bool final_update) { 391 bool final_update) {
392 if (web_view_guest_delegate_) { 392 find_helper_.FindReply(request_id,
393 web_view_guest_delegate_->FindReply( 393 number_of_matches,
394 source, request_id, number_of_matches, 394 selection_rect,
395 selection_rect, active_match_ordinal, final_update); 395 active_match_ordinal,
396 } 396 final_update);
397 } 397 }
398 398
399 bool WebViewGuest::HandleContextMenu( 399 bool WebViewGuest::HandleContextMenu(
400 const content::ContextMenuParams& params) { 400 const content::ContextMenuParams& params) {
401 if (!web_view_guest_delegate_) 401 if (!web_view_guest_delegate_)
402 return false; 402 return false;
403 return web_view_guest_delegate_->HandleContextMenu(params); 403 return web_view_guest_delegate_->HandleContextMenu(params);
404 } 404 }
405 405
406 void WebViewGuest::HandleKeyboardEvent( 406 void WebViewGuest::HandleKeyboardEvent(
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 break; 536 break;
537 } 537 }
538 } 538 }
539 539
540 double WebViewGuest::GetZoom() { 540 double WebViewGuest::GetZoom() {
541 if (!web_view_guest_delegate_) 541 if (!web_view_guest_delegate_)
542 return 1.0; 542 return 1.0;
543 return web_view_guest_delegate_->GetZoom(); 543 return web_view_guest_delegate_->GetZoom();
544 } 544 }
545 545
546 void WebViewGuest::Find( 546 void WebViewGuest::Find(const base::string16& search_text,
547 const base::string16& search_text, 547 const blink::WebFindOptions& options,
548 const blink::WebFindOptions& options, 548 WebViewInternalFindFunction* find_function) {
549 WebViewInternalFindFunction* find_function) { 549 find_helper_.Find(web_contents(), search_text, options, find_function);
550 if (web_view_guest_delegate_)
551 web_view_guest_delegate_->Find(search_text, options, find_function);
552 } 550 }
553 551
554 void WebViewGuest::StopFinding(content::StopFindAction action) { 552 void WebViewGuest::StopFinding(content::StopFindAction action) {
555 if (web_view_guest_delegate_) 553 find_helper_.CancelAllFindSessions();
556 web_view_guest_delegate_->StopFinding(action); 554 web_contents()->StopFinding(action);
557 } 555 }
558 556
559 void WebViewGuest::Go(int relative_index) { 557 void WebViewGuest::Go(int relative_index) {
560 web_contents()->GetController().GoToOffset(relative_index); 558 web_contents()->GetController().GoToOffset(relative_index);
561 } 559 }
562 560
563 void WebViewGuest::Reload() { 561 void WebViewGuest::Reload() {
564 // TODO(fsamuel): Don't check for repost because we don't want to show 562 // TODO(fsamuel): Don't check for repost because we don't want to show
565 // Chromium's repost warning. We might want to implement a separate API 563 // Chromium's repost warning. We might want to implement a separate API
566 // for registering a callback if a repost is about to happen. 564 // for registering a callback if a repost is about to happen.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 content::StoragePartition::OriginMatcherFunction(), 607 content::StoragePartition::OriginMatcherFunction(),
610 remove_since, 608 remove_since,
611 base::Time::Now(), 609 base::Time::Now(),
612 callback); 610 callback);
613 return true; 611 return true;
614 } 612 }
615 613
616 WebViewGuest::WebViewGuest(content::BrowserContext* browser_context, 614 WebViewGuest::WebViewGuest(content::BrowserContext* browser_context,
617 int guest_instance_id) 615 int guest_instance_id)
618 : GuestView<WebViewGuest>(browser_context, guest_instance_id), 616 : GuestView<WebViewGuest>(browser_context, guest_instance_id),
617 find_helper_(this),
619 is_overriding_user_agent_(false), 618 is_overriding_user_agent_(false),
620 javascript_dialog_helper_(this) { 619 javascript_dialog_helper_(this) {
621 web_view_guest_delegate_.reset( 620 web_view_guest_delegate_.reset(
622 ExtensionsAPIClient::Get()->CreateWebViewGuestDelegate(this)); 621 ExtensionsAPIClient::Get()->CreateWebViewGuestDelegate(this));
623 } 622 }
624 623
625 WebViewGuest::~WebViewGuest() { 624 WebViewGuest::~WebViewGuest() {
626 } 625 }
627 626
628 void WebViewGuest::DidCommitProvisionalLoadForFrame( 627 void WebViewGuest::DidCommitProvisionalLoadForFrame(
629 content::RenderFrameHost* render_frame_host, 628 content::RenderFrameHost* render_frame_host,
630 const GURL& url, 629 const GURL& url,
631 content::PageTransition transition_type) { 630 content::PageTransition transition_type) {
632 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); 631 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
633 args->SetString(guestview::kUrl, url.spec()); 632 args->SetString(guestview::kUrl, url.spec());
634 args->SetBoolean(guestview::kIsTopLevel, !render_frame_host->GetParent()); 633 args->SetBoolean(guestview::kIsTopLevel, !render_frame_host->GetParent());
635 args->SetInteger(webview::kInternalCurrentEntryIndex, 634 args->SetInteger(webview::kInternalCurrentEntryIndex,
636 web_contents()->GetController().GetCurrentEntryIndex()); 635 web_contents()->GetController().GetCurrentEntryIndex());
637 args->SetInteger(webview::kInternalEntryCount, 636 args->SetInteger(webview::kInternalEntryCount,
638 web_contents()->GetController().GetEntryCount()); 637 web_contents()->GetController().GetEntryCount());
639 args->SetInteger(webview::kInternalProcessId, 638 args->SetInteger(webview::kInternalProcessId,
640 web_contents()->GetRenderProcessHost()->GetID()); 639 web_contents()->GetRenderProcessHost()->GetID());
641 DispatchEventToEmbedder( 640 DispatchEventToEmbedder(
642 new GuestViewBase::Event(webview::kEventLoadCommit, args.Pass())); 641 new GuestViewBase::Event(webview::kEventLoadCommit, args.Pass()));
642
643 find_helper_.CancelAllFindSessions();
643 if (web_view_guest_delegate_) { 644 if (web_view_guest_delegate_) {
644 web_view_guest_delegate_->OnDidCommitProvisionalLoadForFrame( 645 web_view_guest_delegate_->OnDidCommitProvisionalLoadForFrame(
645 !render_frame_host->GetParent()); 646 !render_frame_host->GetParent());
646 } 647 }
647 } 648 }
648 649
649 void WebViewGuest::DidFailProvisionalLoad( 650 void WebViewGuest::DidFailProvisionalLoad(
650 content::RenderFrameHost* render_frame_host, 651 content::RenderFrameHost* render_frame_host,
651 const GURL& validated_url, 652 const GURL& validated_url,
652 int error_code, 653 int error_code,
(...skipping 24 matching lines...) Expand all
677 RenderFrameHost* render_frame_host) { 678 RenderFrameHost* render_frame_host) {
678 bool handled = true; 679 bool handled = true;
679 IPC_BEGIN_MESSAGE_MAP(WebViewGuest, message) 680 IPC_BEGIN_MESSAGE_MAP(WebViewGuest, message)
680 IPC_MESSAGE_HANDLER(ExtensionHostMsg_FrameNameChanged, OnFrameNameChanged) 681 IPC_MESSAGE_HANDLER(ExtensionHostMsg_FrameNameChanged, OnFrameNameChanged)
681 IPC_MESSAGE_UNHANDLED(handled = false) 682 IPC_MESSAGE_UNHANDLED(handled = false)
682 IPC_END_MESSAGE_MAP() 683 IPC_END_MESSAGE_MAP()
683 return handled; 684 return handled;
684 } 685 }
685 686
686 void WebViewGuest::RenderProcessGone(base::TerminationStatus status) { 687 void WebViewGuest::RenderProcessGone(base::TerminationStatus status) {
687 if (web_view_guest_delegate_) 688 // Cancel all find sessions in progress.
688 web_view_guest_delegate_->OnRenderProcessGone(); 689 find_helper_.CancelAllFindSessions();
689 690
690 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); 691 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
691 args->SetInteger(webview::kProcessId, 692 args->SetInteger(webview::kProcessId,
692 web_contents()->GetRenderProcessHost()->GetID()); 693 web_contents()->GetRenderProcessHost()->GetID());
693 args->SetString(webview::kReason, TerminationStatusToString(status)); 694 args->SetString(webview::kReason, TerminationStatusToString(status));
694 DispatchEventToEmbedder( 695 DispatchEventToEmbedder(
695 new GuestViewBase::Event(webview::kEventExit, args.Pass())); 696 new GuestViewBase::Event(webview::kEventExit, args.Pass()));
696 } 697 }
697 698
698 void WebViewGuest::UserAgentOverrideSet(const std::string& user_agent) { 699 void WebViewGuest::UserAgentOverrideSet(const std::string& user_agent) {
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 WebViewGuest* guest = 1094 WebViewGuest* guest =
1094 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); 1095 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id);
1095 if (!guest) 1096 if (!guest)
1096 return; 1097 return;
1097 1098
1098 if (!allow) 1099 if (!allow)
1099 guest->Destroy(); 1100 guest->Destroy();
1100 } 1101 }
1101 1102
1102 } // namespace extensions 1103 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698