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

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: 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 12 matching lines...) Expand all
23 #include "content/public/browser/storage_partition.h" 23 #include "content/public/browser/storage_partition.h"
24 #include "content/public/browser/user_metrics.h" 24 #include "content/public/browser/user_metrics.h"
25 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
26 #include "content/public/browser/web_contents_delegate.h" 26 #include "content/public/browser/web_contents_delegate.h"
27 #include "content/public/common/media_stream_request.h" 27 #include "content/public/common/media_stream_request.h"
28 #include "content/public/common/page_zoom.h" 28 #include "content/public/common/page_zoom.h"
29 #include "content/public/common/result_codes.h" 29 #include "content/public/common/result_codes.h"
30 #include "content/public/common/stop_find_action.h" 30 #include "content/public/common/stop_find_action.h"
31 #include "content/public/common/url_constants.h" 31 #include "content/public/common/url_constants.h"
32 #include "extensions/browser/api/extensions_api_client.h" 32 #include "extensions/browser/api/extensions_api_client.h"
33 #include "extensions/browser/api/web_view/web_view_internal_api.h"
33 #include "extensions/browser/extension_system.h" 34 #include "extensions/browser/extension_system.h"
34 #include "extensions/browser/guest_view/guest_view_manager.h" 35 #include "extensions/browser/guest_view/guest_view_manager.h"
35 #include "extensions/browser/guest_view/web_view/web_view_constants.h" 36 #include "extensions/browser/guest_view/web_view/web_view_constants.h"
36 #include "extensions/browser/guest_view/web_view/web_view_permission_helper.h" 37 #include "extensions/browser/guest_view/web_view/web_view_permission_helper.h"
37 #include "extensions/browser/guest_view/web_view/web_view_permission_types.h" 38 #include "extensions/browser/guest_view/web_view/web_view_permission_types.h"
38 #include "extensions/browser/guest_view/web_view/web_view_renderer_state.h" 39 #include "extensions/browser/guest_view/web_view/web_view_renderer_state.h"
39 #include "extensions/common/constants.h" 40 #include "extensions/common/constants.h"
40 #include "extensions/common/extension_messages.h" 41 #include "extensions/common/extension_messages.h"
41 #include "extensions/common/guest_view/guest_view_constants.h" 42 #include "extensions/common/guest_view/guest_view_constants.h"
42 #include "extensions/strings/grit/extensions_strings.h" 43 #include "extensions/strings/grit/extensions_strings.h"
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 DispatchEventToEmbedder( 383 DispatchEventToEmbedder(
383 new GuestViewBase::Event(webview::kEventClose, args.Pass())); 384 new GuestViewBase::Event(webview::kEventClose, args.Pass()));
384 } 385 }
385 386
386 void WebViewGuest::FindReply(WebContents* source, 387 void WebViewGuest::FindReply(WebContents* source,
387 int request_id, 388 int request_id,
388 int number_of_matches, 389 int number_of_matches,
389 const gfx::Rect& selection_rect, 390 const gfx::Rect& selection_rect,
390 int active_match_ordinal, 391 int active_match_ordinal,
391 bool final_update) { 392 bool final_update) {
392 if (web_view_guest_delegate_) { 393 find_helper_.FindReply(request_id,
393 web_view_guest_delegate_->FindReply( 394 number_of_matches,
394 source, request_id, number_of_matches, 395 selection_rect,
395 selection_rect, active_match_ordinal, final_update); 396 active_match_ordinal,
396 } 397 final_update);
397 } 398 }
398 399
399 bool WebViewGuest::HandleContextMenu( 400 bool WebViewGuest::HandleContextMenu(
400 const content::ContextMenuParams& params) { 401 const content::ContextMenuParams& params) {
401 if (!web_view_guest_delegate_) 402 if (!web_view_guest_delegate_)
402 return false; 403 return false;
403 return web_view_guest_delegate_->HandleContextMenu(params); 404 return web_view_guest_delegate_->HandleContextMenu(params);
404 } 405 }
405 406
406 void WebViewGuest::HandleKeyboardEvent( 407 void WebViewGuest::HandleKeyboardEvent(
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 540
540 double WebViewGuest::GetZoom() { 541 double WebViewGuest::GetZoom() {
541 if (!web_view_guest_delegate_) 542 if (!web_view_guest_delegate_)
542 return 1.0; 543 return 1.0;
543 return web_view_guest_delegate_->GetZoom(); 544 return web_view_guest_delegate_->GetZoom();
544 } 545 }
545 546
546 void WebViewGuest::Find( 547 void WebViewGuest::Find(
547 const base::string16& search_text, 548 const base::string16& search_text,
548 const blink::WebFindOptions& options, 549 const blink::WebFindOptions& options,
549 WebViewInternalFindFunction* find_function) { 550 scoped_refptr<WebViewInternalFindFunction> find_function) {
550 if (web_view_guest_delegate_) 551 find_helper_.Find(web_contents(), search_text, options, find_function);
551 web_view_guest_delegate_->Find(search_text, options, find_function);
552 } 552 }
553 553
554 void WebViewGuest::StopFinding(content::StopFindAction action) { 554 void WebViewGuest::StopFinding(content::StopFindAction action) {
555 if (web_view_guest_delegate_) 555 find_helper_.CancelAllFindSessions();
556 web_view_guest_delegate_->StopFinding(action); 556 web_contents()->StopFinding(action);
557 } 557 }
558 558
559 void WebViewGuest::Go(int relative_index) { 559 void WebViewGuest::Go(int relative_index) {
560 web_contents()->GetController().GoToOffset(relative_index); 560 web_contents()->GetController().GoToOffset(relative_index);
561 } 561 }
562 562
563 void WebViewGuest::Reload() { 563 void WebViewGuest::Reload() {
564 // TODO(fsamuel): Don't check for repost because we don't want to show 564 // 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 565 // Chromium's repost warning. We might want to implement a separate API
566 // for registering a callback if a repost is about to happen. 566 // 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(), 609 content::StoragePartition::OriginMatcherFunction(),
610 remove_since, 610 remove_since,
611 base::Time::Now(), 611 base::Time::Now(),
612 callback); 612 callback);
613 return true; 613 return true;
614 } 614 }
615 615
616 WebViewGuest::WebViewGuest(content::BrowserContext* browser_context, 616 WebViewGuest::WebViewGuest(content::BrowserContext* browser_context,
617 int guest_instance_id) 617 int guest_instance_id)
618 : GuestView<WebViewGuest>(browser_context, guest_instance_id), 618 : GuestView<WebViewGuest>(browser_context, guest_instance_id),
619 find_helper_(this),
619 is_overriding_user_agent_(false), 620 is_overriding_user_agent_(false),
620 javascript_dialog_helper_(this) { 621 javascript_dialog_helper_(this) {
621 web_view_guest_delegate_.reset( 622 web_view_guest_delegate_.reset(
622 ExtensionsAPIClient::Get()->CreateWebViewGuestDelegate(this)); 623 ExtensionsAPIClient::Get()->CreateWebViewGuestDelegate(this));
623 } 624 }
624 625
625 WebViewGuest::~WebViewGuest() { 626 WebViewGuest::~WebViewGuest() {
626 } 627 }
627 628
628 void WebViewGuest::DidCommitProvisionalLoadForFrame( 629 void WebViewGuest::DidCommitProvisionalLoadForFrame(
629 content::RenderFrameHost* render_frame_host, 630 content::RenderFrameHost* render_frame_host,
630 const GURL& url, 631 const GURL& url,
631 content::PageTransition transition_type) { 632 content::PageTransition transition_type) {
632 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); 633 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
633 args->SetString(guestview::kUrl, url.spec()); 634 args->SetString(guestview::kUrl, url.spec());
634 args->SetBoolean(guestview::kIsTopLevel, !render_frame_host->GetParent()); 635 args->SetBoolean(guestview::kIsTopLevel, !render_frame_host->GetParent());
635 args->SetInteger(webview::kInternalCurrentEntryIndex, 636 args->SetInteger(webview::kInternalCurrentEntryIndex,
636 web_contents()->GetController().GetCurrentEntryIndex()); 637 web_contents()->GetController().GetCurrentEntryIndex());
637 args->SetInteger(webview::kInternalEntryCount, 638 args->SetInteger(webview::kInternalEntryCount,
638 web_contents()->GetController().GetEntryCount()); 639 web_contents()->GetController().GetEntryCount());
639 args->SetInteger(webview::kInternalProcessId, 640 args->SetInteger(webview::kInternalProcessId,
640 web_contents()->GetRenderProcessHost()->GetID()); 641 web_contents()->GetRenderProcessHost()->GetID());
641 DispatchEventToEmbedder( 642 DispatchEventToEmbedder(
642 new GuestViewBase::Event(webview::kEventLoadCommit, args.Pass())); 643 new GuestViewBase::Event(webview::kEventLoadCommit, args.Pass()));
644
645 find_helper_.CancelAllFindSessions();
643 if (web_view_guest_delegate_) { 646 if (web_view_guest_delegate_) {
644 web_view_guest_delegate_->OnDidCommitProvisionalLoadForFrame( 647 web_view_guest_delegate_->OnDidCommitProvisionalLoadForFrame(
645 !render_frame_host->GetParent()); 648 !render_frame_host->GetParent());
646 } 649 }
647 } 650 }
648 651
649 void WebViewGuest::DidFailProvisionalLoad( 652 void WebViewGuest::DidFailProvisionalLoad(
650 content::RenderFrameHost* render_frame_host, 653 content::RenderFrameHost* render_frame_host,
651 const GURL& validated_url, 654 const GURL& validated_url,
652 int error_code, 655 int error_code,
(...skipping 24 matching lines...) Expand all
677 RenderFrameHost* render_frame_host) { 680 RenderFrameHost* render_frame_host) {
678 bool handled = true; 681 bool handled = true;
679 IPC_BEGIN_MESSAGE_MAP(WebViewGuest, message) 682 IPC_BEGIN_MESSAGE_MAP(WebViewGuest, message)
680 IPC_MESSAGE_HANDLER(ExtensionHostMsg_FrameNameChanged, OnFrameNameChanged) 683 IPC_MESSAGE_HANDLER(ExtensionHostMsg_FrameNameChanged, OnFrameNameChanged)
681 IPC_MESSAGE_UNHANDLED(handled = false) 684 IPC_MESSAGE_UNHANDLED(handled = false)
682 IPC_END_MESSAGE_MAP() 685 IPC_END_MESSAGE_MAP()
683 return handled; 686 return handled;
684 } 687 }
685 688
686 void WebViewGuest::RenderProcessGone(base::TerminationStatus status) { 689 void WebViewGuest::RenderProcessGone(base::TerminationStatus status) {
687 if (web_view_guest_delegate_) 690 // Cancel all find sessions in progress.
688 web_view_guest_delegate_->OnRenderProcessGone(); 691 find_helper_.CancelAllFindSessions();
689 692
690 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); 693 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
691 args->SetInteger(webview::kProcessId, 694 args->SetInteger(webview::kProcessId,
692 web_contents()->GetRenderProcessHost()->GetID()); 695 web_contents()->GetRenderProcessHost()->GetID());
693 args->SetString(webview::kReason, TerminationStatusToString(status)); 696 args->SetString(webview::kReason, TerminationStatusToString(status));
694 DispatchEventToEmbedder( 697 DispatchEventToEmbedder(
695 new GuestViewBase::Event(webview::kEventExit, args.Pass())); 698 new GuestViewBase::Event(webview::kEventExit, args.Pass()));
696 } 699 }
697 700
698 void WebViewGuest::UserAgentOverrideSet(const std::string& user_agent) { 701 void WebViewGuest::UserAgentOverrideSet(const std::string& user_agent) {
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 WebViewGuest* guest = 1096 WebViewGuest* guest =
1094 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); 1097 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id);
1095 if (!guest) 1098 if (!guest)
1096 return; 1099 return;
1097 1100
1098 if (!allow) 1101 if (!allow)
1099 guest->Destroy(); 1102 guest->Destroy();
1100 } 1103 }
1101 1104
1102 } // namespace extensions 1105 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698