| 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" | 7 #include "base/debug/stack_trace.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.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/guest_view/guest_view_constants.h" | 19 #include "chrome/browser/guest_view/guest_view_constants.h" |
| 20 #include "chrome/browser/guest_view/guest_view_manager.h" | 20 #include "chrome/browser/guest_view/guest_view_manager.h" |
| 21 #include "chrome/browser/guest_view/web_view/web_view_constants.h" | 21 #include "chrome/browser/guest_view/web_view/web_view_constants.h" |
| 22 #include "chrome/browser/guest_view/web_view/web_view_permission_types.h" | 22 #include "chrome/browser/guest_view/web_view/web_view_permission_types.h" |
| 23 #include "chrome/browser/renderer_context_menu/context_menu_delegate.h" | 23 #include "chrome/browser/renderer_context_menu/context_menu_delegate.h" |
| 24 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" | 24 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" |
| 25 #include "chrome/common/chrome_version_info.h" | 25 #include "chrome/common/chrome_version_info.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 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 break; | 549 break; |
| 549 } | 550 } |
| 550 default: | 551 default: |
| 551 NOTREACHED() << "Unexpected notification sent."; | 552 NOTREACHED() << "Unexpected notification sent."; |
| 552 break; | 553 break; |
| 553 } | 554 } |
| 554 } | 555 } |
| 555 | 556 |
| 556 void WebViewGuest::SetZoom(double zoom_factor) { | 557 void WebViewGuest::SetZoom(double zoom_factor) { |
| 557 double zoom_level = content::ZoomFactorToZoomLevel(zoom_factor); | 558 double zoom_level = content::ZoomFactorToZoomLevel(zoom_factor); |
| 558 guest_web_contents()->SetZoomLevel(zoom_level); | 559 content::HostZoomMap::SetZoomLevel(guest_web_contents(), zoom_level); |
| 559 | 560 |
| 560 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 561 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 561 args->SetDouble(webview::kOldZoomFactor, current_zoom_factor_); | 562 args->SetDouble(webview::kOldZoomFactor, current_zoom_factor_); |
| 562 args->SetDouble(webview::kNewZoomFactor, zoom_factor); | 563 args->SetDouble(webview::kNewZoomFactor, zoom_factor); |
| 563 DispatchEvent( | 564 DispatchEvent( |
| 564 new GuestViewBase::Event(webview::kEventZoomChange, args.Pass())); | 565 new GuestViewBase::Event(webview::kEventZoomChange, args.Pass())); |
| 565 | 566 |
| 566 current_zoom_factor_ = zoom_factor; | 567 current_zoom_factor_ = zoom_factor; |
| 567 } | 568 } |
| 568 | 569 |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 guest_web_contents()->GetController().GetCurrentEntryIndex()); | 784 guest_web_contents()->GetController().GetCurrentEntryIndex()); |
| 784 args->SetInteger(webview::kInternalEntryCount, | 785 args->SetInteger(webview::kInternalEntryCount, |
| 785 guest_web_contents()->GetController().GetEntryCount()); | 786 guest_web_contents()->GetController().GetEntryCount()); |
| 786 args->SetInteger(webview::kInternalProcessId, | 787 args->SetInteger(webview::kInternalProcessId, |
| 787 guest_web_contents()->GetRenderProcessHost()->GetID()); | 788 guest_web_contents()->GetRenderProcessHost()->GetID()); |
| 788 DispatchEvent( | 789 DispatchEvent( |
| 789 new GuestViewBase::Event(webview::kEventLoadCommit, args.Pass())); | 790 new GuestViewBase::Event(webview::kEventLoadCommit, args.Pass())); |
| 790 | 791 |
| 791 // Update the current zoom factor for the new page. | 792 // Update the current zoom factor for the new page. |
| 792 current_zoom_factor_ = content::ZoomLevelToZoomFactor( | 793 current_zoom_factor_ = content::ZoomLevelToZoomFactor( |
| 793 guest_web_contents()->GetZoomLevel()); | 794 content::HostZoomMap::GetZoomLevel(guest_web_contents())); |
| 794 | 795 |
| 795 if (is_main_frame) { | 796 if (is_main_frame) { |
| 796 chromevox_injected_ = false; | 797 chromevox_injected_ = false; |
| 797 main_frame_id_ = frame_id; | 798 main_frame_id_ = frame_id; |
| 798 } | 799 } |
| 799 } | 800 } |
| 800 | 801 |
| 801 void WebViewGuest::DidFailProvisionalLoad( | 802 void WebViewGuest::DidFailProvisionalLoad( |
| 802 int64 frame_id, | 803 int64 frame_id, |
| 803 const base::string16& frame_unique_name, | 804 const base::string16& frame_unique_name, |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1350 bool allow, | 1351 bool allow, |
| 1351 const std::string& user_input) { | 1352 const std::string& user_input) { |
| 1352 WebViewGuest* guest = | 1353 WebViewGuest* guest = |
| 1353 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); | 1354 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); |
| 1354 if (!guest) | 1355 if (!guest) |
| 1355 return; | 1356 return; |
| 1356 | 1357 |
| 1357 if (!allow) | 1358 if (!allow) |
| 1358 guest->Destroy(); | 1359 guest->Destroy(); |
| 1359 } | 1360 } |
| OLD | NEW |