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/content_settings/tab_specific_content_settings.h" | 11 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
12 #include "chrome/browser/extensions/api/web_request/web_request_api.h" | 12 #include "chrome/browser/extensions/api/web_request/web_request_api.h" |
13 #include "chrome/browser/extensions/api/webview/webview_api.h" | 13 #include "chrome/browser/extensions/api/webview/webview_api.h" |
14 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" | 14 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
15 #include "chrome/browser/extensions/extension_renderer_state.h" | 15 #include "chrome/browser/extensions/extension_renderer_state.h" |
16 #include "chrome/browser/extensions/menu_manager.h" | 16 #include "chrome/browser/extensions/menu_manager.h" |
17 #include "chrome/browser/extensions/script_executor.h" | 17 #include "chrome/browser/extensions/script_executor.h" |
18 #include "chrome/browser/favicon/favicon_tab_helper.h" | 18 #include "chrome/browser/favicon/favicon_tab_helper.h" |
19 #include "chrome/browser/geolocation/geolocation_permission_context.h" | 19 #include "chrome/browser/geolocation/geolocation_permission_context.h" |
20 #include "chrome/browser/geolocation/geolocation_permission_context_factory.h" | 20 #include "chrome/browser/geolocation/geolocation_permission_context_factory.h" |
21 #include "chrome/browser/guest_view/guest_view_constants.h" | 21 #include "chrome/browser/guest_view/guest_view_constants.h" |
22 #include "chrome/browser/guest_view/guest_view_manager.h" | 22 #include "chrome/browser/guest_view/guest_view_manager.h" |
23 #include "chrome/browser/guest_view/web_view/web_view_constants.h" | 23 #include "chrome/browser/guest_view/web_view/web_view_constants.h" |
24 #include "chrome/browser/guest_view/web_view/web_view_permission_types.h" | 24 #include "chrome/browser/guest_view/web_view/web_view_permission_types.h" |
25 #include "chrome/browser/renderer_context_menu/context_menu_delegate.h" | 25 #include "chrome/browser/renderer_context_menu/context_menu_delegate.h" |
26 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" | 26 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" |
27 #include "chrome/browser/ui/pdf/pdf_tab_helper.h" | 27 #include "chrome/browser/ui/pdf/pdf_tab_helper.h" |
| 28 #include "chrome/browser/ui/zoom/zoom_controller.h" |
28 #include "chrome/common/chrome_version_info.h" | 29 #include "chrome/common/chrome_version_info.h" |
29 #include "chrome/common/render_messages.h" | 30 #include "chrome/common/render_messages.h" |
30 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
31 #include "content/public/browser/child_process_security_policy.h" | 32 #include "content/public/browser/child_process_security_policy.h" |
32 #include "content/public/browser/host_zoom_map.h" | |
33 #include "content/public/browser/native_web_keyboard_event.h" | 33 #include "content/public/browser/native_web_keyboard_event.h" |
34 #include "content/public/browser/navigation_entry.h" | 34 #include "content/public/browser/navigation_entry.h" |
35 #include "content/public/browser/notification_details.h" | 35 #include "content/public/browser/notification_details.h" |
36 #include "content/public/browser/notification_service.h" | 36 #include "content/public/browser/notification_service.h" |
37 #include "content/public/browser/notification_source.h" | 37 #include "content/public/browser/notification_source.h" |
38 #include "content/public/browser/notification_types.h" | 38 #include "content/public/browser/notification_types.h" |
39 #include "content/public/browser/render_process_host.h" | 39 #include "content/public/browser/render_process_host.h" |
40 #include "content/public/browser/render_view_host.h" | 40 #include "content/public/browser/render_view_host.h" |
41 #include "content/public/browser/resource_request_details.h" | 41 #include "content/public/browser/resource_request_details.h" |
42 #include "content/public/browser/site_instance.h" | 42 #include "content/public/browser/site_instance.h" |
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 args->SetInteger(webview::kInternalCurrentEntryIndex, | 964 args->SetInteger(webview::kInternalCurrentEntryIndex, |
965 guest_web_contents()->GetController().GetCurrentEntryIndex()); | 965 guest_web_contents()->GetController().GetCurrentEntryIndex()); |
966 args->SetInteger(webview::kInternalEntryCount, | 966 args->SetInteger(webview::kInternalEntryCount, |
967 guest_web_contents()->GetController().GetEntryCount()); | 967 guest_web_contents()->GetController().GetEntryCount()); |
968 args->SetInteger(webview::kInternalProcessId, | 968 args->SetInteger(webview::kInternalProcessId, |
969 guest_web_contents()->GetRenderProcessHost()->GetID()); | 969 guest_web_contents()->GetRenderProcessHost()->GetID()); |
970 DispatchEvent( | 970 DispatchEvent( |
971 new GuestViewBase::Event(webview::kEventLoadCommit, args.Pass())); | 971 new GuestViewBase::Event(webview::kEventLoadCommit, args.Pass())); |
972 | 972 |
973 // Update the current zoom factor for the new page. | 973 // Update the current zoom factor for the new page. |
974 current_zoom_factor_ = content::ZoomLevelToZoomFactor( | 974 ZoomController* zoom_controller = |
975 content::HostZoomMap::GetZoomLevel(guest_web_contents())); | 975 ZoomController::FromWebContents(guest_web_contents()); |
| 976 DCHECK(zoom_controller); |
| 977 current_zoom_factor_ = zoom_controller->GetZoomLevel(); |
976 | 978 |
977 if (is_main_frame) { | 979 if (is_main_frame) { |
978 chromevox_injected_ = false; | 980 chromevox_injected_ = false; |
979 main_frame_id_ = frame_id; | 981 main_frame_id_ = frame_id; |
980 } | 982 } |
981 } | 983 } |
982 | 984 |
983 void WebViewGuest::DidFailProvisionalLoad( | 985 void WebViewGuest::DidFailProvisionalLoad( |
984 int64 frame_id, | 986 int64 frame_id, |
985 const base::string16& frame_unique_name, | 987 const base::string16& frame_unique_name, |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1415 | 1417 |
1416 void WebViewGuest::SetName(const std::string& name) { | 1418 void WebViewGuest::SetName(const std::string& name) { |
1417 if (name_ == name) | 1419 if (name_ == name) |
1418 return; | 1420 return; |
1419 name_ = name; | 1421 name_ = name; |
1420 | 1422 |
1421 Send(new ChromeViewMsg_SetName(routing_id(), name_)); | 1423 Send(new ChromeViewMsg_SetName(routing_id(), name_)); |
1422 } | 1424 } |
1423 | 1425 |
1424 void WebViewGuest::SetZoom(double zoom_factor) { | 1426 void WebViewGuest::SetZoom(double zoom_factor) { |
| 1427 ZoomController* zoom_controller = |
| 1428 ZoomController::FromWebContents(guest_web_contents()); |
| 1429 DCHECK(zoom_controller); |
1425 double zoom_level = content::ZoomFactorToZoomLevel(zoom_factor); | 1430 double zoom_level = content::ZoomFactorToZoomLevel(zoom_factor); |
1426 content::HostZoomMap::SetZoomLevel(guest_web_contents(), zoom_level); | 1431 zoom_controller->SetZoomLevel(zoom_level); |
1427 | 1432 |
1428 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 1433 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
1429 args->SetDouble(webview::kOldZoomFactor, current_zoom_factor_); | 1434 args->SetDouble(webview::kOldZoomFactor, current_zoom_factor_); |
1430 args->SetDouble(webview::kNewZoomFactor, zoom_factor); | 1435 args->SetDouble(webview::kNewZoomFactor, zoom_factor); |
1431 DispatchEvent( | 1436 DispatchEvent( |
1432 new GuestViewBase::Event(webview::kEventZoomChange, args.Pass())); | 1437 new GuestViewBase::Event(webview::kEventZoomChange, args.Pass())); |
1433 | 1438 |
1434 current_zoom_factor_ = zoom_factor; | 1439 current_zoom_factor_ = zoom_factor; |
1435 } | 1440 } |
1436 | 1441 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1582 bool allow, | 1587 bool allow, |
1583 const std::string& user_input) { | 1588 const std::string& user_input) { |
1584 WebViewGuest* guest = | 1589 WebViewGuest* guest = |
1585 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); | 1590 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); |
1586 if (!guest) | 1591 if (!guest) |
1587 return; | 1592 return; |
1588 | 1593 |
1589 if (!allow) | 1594 if (!allow) |
1590 guest->Destroy(); | 1595 guest->Destroy(); |
1591 } | 1596 } |
OLD | NEW |