OLD | NEW |
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_guest.h" | 5 #include "chrome/browser/guest_view/web_view/web_view_guest.h" |
6 | 6 |
7 #include "base/debug/stack_trace.h" | |
8 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
9 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
10 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
11 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
12 #include "chrome/browser/extensions/api/web_request/web_request_api.h" | 11 #include "chrome/browser/extensions/api/web_request/web_request_api.h" |
13 #include "chrome/browser/extensions/api/webview/webview_api.h" | 12 #include "chrome/browser/extensions/api/webview/webview_api.h" |
14 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" | 13 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
15 #include "chrome/browser/extensions/extension_renderer_state.h" | 14 #include "chrome/browser/extensions/extension_renderer_state.h" |
16 #include "chrome/browser/extensions/menu_manager.h" | 15 #include "chrome/browser/extensions/menu_manager.h" |
17 #include "chrome/browser/extensions/script_executor.h" | 16 #include "chrome/browser/extensions/script_executor.h" |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 void WebViewGuest::FindReply(WebContents* source, | 422 void WebViewGuest::FindReply(WebContents* source, |
424 int request_id, | 423 int request_id, |
425 int number_of_matches, | 424 int number_of_matches, |
426 const gfx::Rect& selection_rect, | 425 const gfx::Rect& selection_rect, |
427 int active_match_ordinal, | 426 int active_match_ordinal, |
428 bool final_update) { | 427 bool final_update) { |
429 find_helper_.FindReply(request_id, number_of_matches, selection_rect, | 428 find_helper_.FindReply(request_id, number_of_matches, selection_rect, |
430 active_match_ordinal, final_update); | 429 active_match_ordinal, final_update); |
431 } | 430 } |
432 | 431 |
433 void WebViewGuest::GuestProcessGone(base::TerminationStatus status) { | |
434 // Cancel all find sessions in progress. | |
435 find_helper_.CancelAllFindSessions(); | |
436 | |
437 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | |
438 args->SetInteger(webview::kProcessId, | |
439 guest_web_contents()->GetRenderProcessHost()->GetID()); | |
440 args->SetString(webview::kReason, TerminationStatusToString(status)); | |
441 DispatchEvent(new GuestViewBase::Event(webview::kEventExit, args.Pass())); | |
442 } | |
443 | |
444 void WebViewGuest::HandleKeyboardEvent( | 432 void WebViewGuest::HandleKeyboardEvent( |
445 WebContents* source, | 433 WebContents* source, |
446 const content::NativeWebKeyboardEvent& event) { | 434 const content::NativeWebKeyboardEvent& event) { |
447 if (!attached()) | 435 if (!attached()) |
448 return; | 436 return; |
449 | 437 |
450 if (HandleKeyboardShortcuts(event)) | 438 if (HandleKeyboardShortcuts(event)) |
451 return; | 439 return; |
452 | 440 |
453 // Send the unhandled keyboard events back to the embedder to reprocess them. | 441 // Send the unhandled keyboard events back to the embedder to reprocess them. |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 bool WebViewGuest::OnMessageReceived(const IPC::Message& message, | 857 bool WebViewGuest::OnMessageReceived(const IPC::Message& message, |
870 RenderFrameHost* render_frame_host) { | 858 RenderFrameHost* render_frame_host) { |
871 bool handled = true; | 859 bool handled = true; |
872 IPC_BEGIN_MESSAGE_MAP(WebViewGuest, message) | 860 IPC_BEGIN_MESSAGE_MAP(WebViewGuest, message) |
873 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_UpdateFrameName, OnUpdateFrameName) | 861 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_UpdateFrameName, OnUpdateFrameName) |
874 IPC_MESSAGE_UNHANDLED(handled = false) | 862 IPC_MESSAGE_UNHANDLED(handled = false) |
875 IPC_END_MESSAGE_MAP() | 863 IPC_END_MESSAGE_MAP() |
876 return handled; | 864 return handled; |
877 } | 865 } |
878 | 866 |
| 867 void WebViewGuest::RenderProcessGone(base::TerminationStatus status) { |
| 868 // Cancel all find sessions in progress. |
| 869 find_helper_.CancelAllFindSessions(); |
| 870 |
| 871 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 872 args->SetInteger(webview::kProcessId, |
| 873 guest_web_contents()->GetRenderProcessHost()->GetID()); |
| 874 args->SetString(webview::kReason, TerminationStatusToString(status)); |
| 875 DispatchEvent(new GuestViewBase::Event(webview::kEventExit, args.Pass())); |
| 876 } |
| 877 |
879 void WebViewGuest::WebContentsDestroyed() { | 878 void WebViewGuest::WebContentsDestroyed() { |
880 // Clean up custom context menu items for this guest. | 879 // Clean up custom context menu items for this guest. |
881 extensions::MenuManager* menu_manager = extensions::MenuManager::Get( | 880 extensions::MenuManager* menu_manager = extensions::MenuManager::Get( |
882 Profile::FromBrowserContext(browser_context())); | 881 Profile::FromBrowserContext(browser_context())); |
883 menu_manager->RemoveAllContextItems(extensions::MenuItem::ExtensionKey( | 882 menu_manager->RemoveAllContextItems(extensions::MenuItem::ExtensionKey( |
884 embedder_extension_id(), view_instance_id())); | 883 embedder_extension_id(), view_instance_id())); |
885 | 884 |
886 RemoveWebViewFromExtensionRendererState(web_contents()); | 885 RemoveWebViewFromExtensionRendererState(web_contents()); |
887 } | 886 } |
888 | 887 |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1410 bool allow, | 1409 bool allow, |
1411 const std::string& user_input) { | 1410 const std::string& user_input) { |
1412 WebViewGuest* guest = | 1411 WebViewGuest* guest = |
1413 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); | 1412 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); |
1414 if (!guest) | 1413 if (!guest) |
1415 return; | 1414 return; |
1416 | 1415 |
1417 if (!allow) | 1416 if (!allow) |
1418 guest->Destroy(); | 1417 guest->Destroy(); |
1419 } | 1418 } |
OLD | NEW |