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/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 "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
11 #include "chrome/browser/extensions/api/web_request/web_request_api.h" | 11 #include "chrome/browser/extensions/api/web_request/web_request_api.h" |
12 #include "chrome/browser/extensions/api/webview/webview_api.h" | 12 #include "chrome/browser/extensions/api/webview/webview_api.h" |
13 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" | 13 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
14 #include "chrome/browser/extensions/extension_renderer_state.h" | 14 #include "chrome/browser/extensions/extension_renderer_state.h" |
15 #include "chrome/browser/extensions/menu_manager.h" | 15 #include "chrome/browser/extensions/menu_manager.h" |
16 #include "chrome/browser/extensions/script_executor.h" | 16 #include "chrome/browser/extensions/script_executor.h" |
17 #include "chrome/browser/favicon/favicon_tab_helper.h" | 17 #include "chrome/browser/favicon/favicon_tab_helper.h" |
18 #include "chrome/browser/guest_view/guest_view_constants.h" | 18 #include "chrome/browser/guest_view/guest_view_constants.h" |
19 #include "chrome/browser/guest_view/guest_view_manager.h" | 19 #include "chrome/browser/guest_view/guest_view_manager.h" |
20 #include "chrome/browser/guest_view/web_view/web_view_constants.h" | 20 #include "chrome/browser/guest_view/web_view/web_view_constants.h" |
21 #include "chrome/browser/guest_view/web_view/web_view_permission_types.h" | 21 #include "chrome/browser/guest_view/web_view/web_view_permission_types.h" |
22 #include "chrome/browser/renderer_context_menu/context_menu_delegate.h" | 22 #include "chrome/browser/renderer_context_menu/context_menu_delegate.h" |
23 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" | 23 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" |
24 #include "chrome/common/chrome_version_info.h" | 24 #include "chrome/common/chrome_version_info.h" |
25 #include "chrome/common/render_messages.h" | 25 #include "chrome/common/render_messages.h" |
26 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
27 #include "content/public/browser/child_process_security_policy.h" | 27 #include "content/public/browser/child_process_security_policy.h" |
28 #include "content/public/browser/geolocation_permission_context.h" | 28 #include "content/public/browser/geolocation_permission_context.h" |
| 29 #include "content/public/browser/host_zoom_map.h" |
29 #include "content/public/browser/native_web_keyboard_event.h" | 30 #include "content/public/browser/native_web_keyboard_event.h" |
30 #include "content/public/browser/navigation_entry.h" | 31 #include "content/public/browser/navigation_entry.h" |
31 #include "content/public/browser/notification_details.h" | 32 #include "content/public/browser/notification_details.h" |
32 #include "content/public/browser/notification_service.h" | 33 #include "content/public/browser/notification_service.h" |
33 #include "content/public/browser/notification_source.h" | 34 #include "content/public/browser/notification_source.h" |
34 #include "content/public/browser/notification_types.h" | 35 #include "content/public/browser/notification_types.h" |
35 #include "content/public/browser/render_process_host.h" | 36 #include "content/public/browser/render_process_host.h" |
36 #include "content/public/browser/resource_request_details.h" | 37 #include "content/public/browser/resource_request_details.h" |
37 #include "content/public/browser/site_instance.h" | 38 #include "content/public/browser/site_instance.h" |
38 #include "content/public/browser/storage_partition.h" | 39 #include "content/public/browser/storage_partition.h" |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 break; | 564 break; |
564 } | 565 } |
565 default: | 566 default: |
566 NOTREACHED() << "Unexpected notification sent."; | 567 NOTREACHED() << "Unexpected notification sent."; |
567 break; | 568 break; |
568 } | 569 } |
569 } | 570 } |
570 | 571 |
571 void WebViewGuest::SetZoom(double zoom_factor) { | 572 void WebViewGuest::SetZoom(double zoom_factor) { |
572 double zoom_level = content::ZoomFactorToZoomLevel(zoom_factor); | 573 double zoom_level = content::ZoomFactorToZoomLevel(zoom_factor); |
573 guest_web_contents()->SetZoomLevel(zoom_level); | 574 content::HostZoomMap::SetZoomLevel(guest_web_contents(), zoom_level); |
574 | 575 |
575 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 576 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
576 args->SetDouble(webview::kOldZoomFactor, current_zoom_factor_); | 577 args->SetDouble(webview::kOldZoomFactor, current_zoom_factor_); |
577 args->SetDouble(webview::kNewZoomFactor, zoom_factor); | 578 args->SetDouble(webview::kNewZoomFactor, zoom_factor); |
578 DispatchEvent( | 579 DispatchEvent( |
579 new GuestViewBase::Event(webview::kEventZoomChange, args.Pass())); | 580 new GuestViewBase::Event(webview::kEventZoomChange, args.Pass())); |
580 | 581 |
581 current_zoom_factor_ = zoom_factor; | 582 current_zoom_factor_ = zoom_factor; |
582 } | 583 } |
583 | 584 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 guest_web_contents()->GetController().GetCurrentEntryIndex()); | 799 guest_web_contents()->GetController().GetCurrentEntryIndex()); |
799 args->SetInteger(webview::kInternalEntryCount, | 800 args->SetInteger(webview::kInternalEntryCount, |
800 guest_web_contents()->GetController().GetEntryCount()); | 801 guest_web_contents()->GetController().GetEntryCount()); |
801 args->SetInteger(webview::kInternalProcessId, | 802 args->SetInteger(webview::kInternalProcessId, |
802 guest_web_contents()->GetRenderProcessHost()->GetID()); | 803 guest_web_contents()->GetRenderProcessHost()->GetID()); |
803 DispatchEvent( | 804 DispatchEvent( |
804 new GuestViewBase::Event(webview::kEventLoadCommit, args.Pass())); | 805 new GuestViewBase::Event(webview::kEventLoadCommit, args.Pass())); |
805 | 806 |
806 // Update the current zoom factor for the new page. | 807 // Update the current zoom factor for the new page. |
807 current_zoom_factor_ = content::ZoomLevelToZoomFactor( | 808 current_zoom_factor_ = content::ZoomLevelToZoomFactor( |
808 guest_web_contents()->GetZoomLevel()); | 809 content::HostZoomMap::GetZoomLevel(guest_web_contents())); |
809 | 810 |
810 if (is_main_frame) { | 811 if (is_main_frame) { |
811 chromevox_injected_ = false; | 812 chromevox_injected_ = false; |
812 main_frame_id_ = frame_id; | 813 main_frame_id_ = frame_id; |
813 } | 814 } |
814 } | 815 } |
815 | 816 |
816 void WebViewGuest::DidFailProvisionalLoad( | 817 void WebViewGuest::DidFailProvisionalLoad( |
817 int64 frame_id, | 818 int64 frame_id, |
818 const base::string16& frame_unique_name, | 819 const base::string16& frame_unique_name, |
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1409 bool allow, | 1410 bool allow, |
1410 const std::string& user_input) { | 1411 const std::string& user_input) { |
1411 WebViewGuest* guest = | 1412 WebViewGuest* guest = |
1412 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); | 1413 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); |
1413 if (!guest) | 1414 if (!guest) |
1414 return; | 1415 return; |
1415 | 1416 |
1416 if (!allow) | 1417 if (!allow) |
1417 guest->Destroy(); | 1418 guest->Destroy(); |
1418 } | 1419 } |
OLD | NEW |