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" |
| 20 #include "chrome/browser/geolocation/geolocation_permission_context_factory.h" |
19 #include "chrome/browser/guest_view/guest_view_constants.h" | 21 #include "chrome/browser/guest_view/guest_view_constants.h" |
20 #include "chrome/browser/guest_view/guest_view_manager.h" | 22 #include "chrome/browser/guest_view/guest_view_manager.h" |
21 #include "chrome/browser/guest_view/web_view/web_view_constants.h" | 23 #include "chrome/browser/guest_view/web_view/web_view_constants.h" |
22 #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" |
23 #include "chrome/browser/renderer_context_menu/context_menu_delegate.h" | 25 #include "chrome/browser/renderer_context_menu/context_menu_delegate.h" |
24 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" | 26 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" |
25 #include "chrome/common/chrome_version_info.h" | 27 #include "chrome/common/chrome_version_info.h" |
26 #include "chrome/common/render_messages.h" | 28 #include "chrome/common/render_messages.h" |
27 #include "content/public/browser/browser_thread.h" | 29 #include "content/public/browser/browser_thread.h" |
28 #include "content/public/browser/child_process_security_policy.h" | 30 #include "content/public/browser/child_process_security_policy.h" |
29 #include "content/public/browser/geolocation_permission_context.h" | |
30 #include "content/public/browser/host_zoom_map.h" | 31 #include "content/public/browser/host_zoom_map.h" |
31 #include "content/public/browser/native_web_keyboard_event.h" | 32 #include "content/public/browser/native_web_keyboard_event.h" |
32 #include "content/public/browser/navigation_entry.h" | 33 #include "content/public/browser/navigation_entry.h" |
33 #include "content/public/browser/notification_details.h" | 34 #include "content/public/browser/notification_details.h" |
34 #include "content/public/browser/notification_service.h" | 35 #include "content/public/browser/notification_service.h" |
35 #include "content/public/browser/notification_source.h" | 36 #include "content/public/browser/notification_source.h" |
36 #include "content/public/browser/notification_types.h" | 37 #include "content/public/browser/notification_types.h" |
37 #include "content/public/browser/render_process_host.h" | 38 #include "content/public/browser/render_process_host.h" |
38 #include "content/public/browser/render_view_host.h" | 39 #include "content/public/browser/render_view_host.h" |
39 #include "content/public/browser/resource_request_details.h" | 40 #include "content/public/browser/resource_request_details.h" |
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 const std::string& user_input) { | 750 const std::string& user_input) { |
750 // The <webview> embedder has allowed the permission. We now need to make sure | 751 // The <webview> embedder has allowed the permission. We now need to make sure |
751 // that the embedder has geolocation permission. | 752 // that the embedder has geolocation permission. |
752 RemoveBridgeID(bridge_id); | 753 RemoveBridgeID(bridge_id); |
753 | 754 |
754 if (!allow || !attached()) { | 755 if (!allow || !attached()) { |
755 callback.Run(false); | 756 callback.Run(false); |
756 return; | 757 return; |
757 } | 758 } |
758 | 759 |
759 content::GeolocationPermissionContext* geolocation_context = | 760 Profile* profile = Profile::FromBrowserContext(browser_context()); |
760 browser_context()->GetGeolocationPermissionContext(); | 761 GeolocationPermissionContextFactory::GetForProfile(profile)-> |
761 | 762 RequestGeolocationPermission( |
762 DCHECK(geolocation_context); | 763 embedder_web_contents(), |
763 geolocation_context->RequestGeolocationPermission( | 764 // The geolocation permission request here is not initiated |
764 embedder_web_contents(), | 765 // through WebGeolocationPermissionRequest. We are only interested |
765 // The geolocation permission request here is not initiated | 766 // in the fact whether the embedder/app has geolocation |
766 // through WebGeolocationPermissionRequest. We are only interested | 767 // permission. Therefore we use an invalid |bridge_id|. |
767 // in the fact whether the embedder/app has geolocation | 768 -1, |
768 // permission. Therefore we use an invalid |bridge_id|. | 769 embedder_web_contents()->GetLastCommittedURL(), |
769 -1 /* bridge_id */, | 770 user_gesture, |
770 embedder_web_contents()->GetLastCommittedURL(), | 771 callback, |
771 user_gesture, | 772 NULL); |
772 callback); | |
773 } | 773 } |
774 | 774 |
775 void WebViewGuest::CancelGeolocationPermissionRequest(int bridge_id) { | 775 void WebViewGuest::CancelGeolocationPermissionRequest(int bridge_id) { |
776 int request_id = RemoveBridgeID(bridge_id); | 776 int request_id = RemoveBridgeID(bridge_id); |
777 RequestMap::iterator request_itr = | 777 RequestMap::iterator request_itr = |
778 pending_permission_requests_.find(request_id); | 778 pending_permission_requests_.find(request_id); |
779 | 779 |
780 if (request_itr == pending_permission_requests_.end()) | 780 if (request_itr == pending_permission_requests_.end()) |
781 return; | 781 return; |
782 | 782 |
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1589 bool allow, | 1589 bool allow, |
1590 const std::string& user_input) { | 1590 const std::string& user_input) { |
1591 WebViewGuest* guest = | 1591 WebViewGuest* guest = |
1592 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); | 1592 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); |
1593 if (!guest) | 1593 if (!guest) |
1594 return; | 1594 return; |
1595 | 1595 |
1596 if (!allow) | 1596 if (!allow) |
1597 guest->Destroy(); | 1597 guest->Destroy(); |
1598 } | 1598 } |
OLD | NEW |