Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: chrome/browser/guest_view/web_view/web_view_guest.cc

Issue 301733006: Zoom Extension API (chrome) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix javascript test function signature. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/web_view/web_view_internal_api.h" 13 #include "chrome/browser/extensions/api/web_view/web_view_internal_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/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/geolocation/geolocation_permission_context.h" 18 #include "chrome/browser/geolocation/geolocation_permission_context.h"
19 #include "chrome/browser/geolocation/geolocation_permission_context_factory.h" 19 #include "chrome/browser/geolocation/geolocation_permission_context_factory.h"
20 #include "chrome/browser/guest_view/guest_view_constants.h" 20 #include "chrome/browser/guest_view/guest_view_constants.h"
21 #include "chrome/browser/guest_view/guest_view_manager.h" 21 #include "chrome/browser/guest_view/guest_view_manager.h"
22 #include "chrome/browser/guest_view/web_view/web_view_constants.h" 22 #include "chrome/browser/guest_view/web_view/web_view_constants.h"
23 #include "chrome/browser/guest_view/web_view/web_view_permission_types.h" 23 #include "chrome/browser/guest_view/web_view/web_view_permission_types.h"
24 #include "chrome/browser/guest_view/web_view/web_view_renderer_state.h" 24 #include "chrome/browser/guest_view/web_view/web_view_renderer_state.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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 int view_instance_id) { 157 int view_instance_id) {
158 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 158 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
159 ExtensionWebRequestEventRouter::GetInstance()->RemoveWebViewEventListeners( 159 ExtensionWebRequestEventRouter::GetInstance()->RemoveWebViewEventListeners(
160 profile, 160 profile,
161 extension_id, 161 extension_id,
162 embedder_process_id, 162 embedder_process_id,
163 view_instance_id); 163 view_instance_id);
164 } 164 }
165 165
166 void AttachWebViewHelpers(WebContents* contents) { 166 void AttachWebViewHelpers(WebContents* contents) {
167 // Create a zoom controller for the guest contents give it access to
168 // GetZoomLevel() and and SetZoomLevel() in WebViewGuest.
169 // TODO(wjmaclean) This currently uses the same HostZoomMap as the browser
170 // context, but we eventually want to isolate the guest contents from zoom
171 // changes outside the guest (e.g. in the main browser), so we should
172 // create a separate HostZoomMap for the guest.
173 ZoomController::CreateForWebContents(contents);
174
167 FaviconTabHelper::CreateForWebContents(contents); 175 FaviconTabHelper::CreateForWebContents(contents);
168 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents( 176 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents(
169 contents); 177 contents);
170 #if defined(ENABLE_PLUGINS) && !defined(OS_ANDROID) 178 #if defined(ENABLE_PLUGINS) && !defined(OS_ANDROID)
171 PluginPermissionHelper::CreateForWebContents(contents); 179 PluginPermissionHelper::CreateForWebContents(contents);
172 #endif 180 #endif
173 #if defined(ENABLE_PRINTING) 181 #if defined(ENABLE_PRINTING)
174 #if defined(ENABLE_FULL_PRINTING) 182 #if defined(ENABLE_FULL_PRINTING)
175 printing::PrintViewManager::CreateForWebContents(contents); 183 printing::PrintViewManager::CreateForWebContents(contents);
176 printing::PrintPreviewMessageHandler::CreateForWebContents(contents); 184 printing::PrintPreviewMessageHandler::CreateForWebContents(contents);
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 args->SetInteger(webview::kInternalCurrentEntryIndex, 1029 args->SetInteger(webview::kInternalCurrentEntryIndex,
1022 guest_web_contents()->GetController().GetCurrentEntryIndex()); 1030 guest_web_contents()->GetController().GetCurrentEntryIndex());
1023 args->SetInteger(webview::kInternalEntryCount, 1031 args->SetInteger(webview::kInternalEntryCount,
1024 guest_web_contents()->GetController().GetEntryCount()); 1032 guest_web_contents()->GetController().GetEntryCount());
1025 args->SetInteger(webview::kInternalProcessId, 1033 args->SetInteger(webview::kInternalProcessId,
1026 guest_web_contents()->GetRenderProcessHost()->GetID()); 1034 guest_web_contents()->GetRenderProcessHost()->GetID());
1027 DispatchEvent( 1035 DispatchEvent(
1028 new GuestViewBase::Event(webview::kEventLoadCommit, args.Pass())); 1036 new GuestViewBase::Event(webview::kEventLoadCommit, args.Pass()));
1029 1037
1030 // Update the current zoom factor for the new page. 1038 // Update the current zoom factor for the new page.
1031 current_zoom_factor_ = content::ZoomLevelToZoomFactor( 1039 ZoomController* zoom_controller =
1032 content::HostZoomMap::GetZoomLevel(guest_web_contents())); 1040 ZoomController::FromWebContents(guest_web_contents());
1041 DCHECK(zoom_controller);
1042 current_zoom_factor_ = zoom_controller->GetZoomLevel();
1033 1043
1034 if (!render_frame_host->GetParent()) { 1044 if (!render_frame_host->GetParent()) {
1035 chromevox_injected_ = false; 1045 chromevox_injected_ = false;
1036 main_frame_id_ = render_frame_host->GetRoutingID(); 1046 main_frame_id_ = render_frame_host->GetRoutingID();
1037 } 1047 }
1038 } 1048 }
1039 1049
1040 void WebViewGuest::DidFailProvisionalLoad( 1050 void WebViewGuest::DidFailProvisionalLoad(
1041 content::RenderFrameHost* render_frame_host, 1051 content::RenderFrameHost* render_frame_host,
1042 const GURL& validated_url, 1052 const GURL& validated_url,
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
1477 1487
1478 void WebViewGuest::SetName(const std::string& name) { 1488 void WebViewGuest::SetName(const std::string& name) {
1479 if (name_ == name) 1489 if (name_ == name)
1480 return; 1490 return;
1481 name_ = name; 1491 name_ = name;
1482 1492
1483 Send(new ChromeViewMsg_SetName(routing_id(), name_)); 1493 Send(new ChromeViewMsg_SetName(routing_id(), name_));
1484 } 1494 }
1485 1495
1486 void WebViewGuest::SetZoom(double zoom_factor) { 1496 void WebViewGuest::SetZoom(double zoom_factor) {
1497 ZoomController* zoom_controller =
1498 ZoomController::FromWebContents(guest_web_contents());
1499 DCHECK(zoom_controller);
1487 double zoom_level = content::ZoomFactorToZoomLevel(zoom_factor); 1500 double zoom_level = content::ZoomFactorToZoomLevel(zoom_factor);
1488 content::HostZoomMap::SetZoomLevel(guest_web_contents(), zoom_level); 1501 zoom_controller->SetZoomLevel(zoom_level);
1489 1502
1490 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); 1503 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
1491 args->SetDouble(webview::kOldZoomFactor, current_zoom_factor_); 1504 args->SetDouble(webview::kOldZoomFactor, current_zoom_factor_);
1492 args->SetDouble(webview::kNewZoomFactor, zoom_factor); 1505 args->SetDouble(webview::kNewZoomFactor, zoom_factor);
1493 DispatchEvent( 1506 DispatchEvent(
1494 new GuestViewBase::Event(webview::kEventZoomChange, args.Pass())); 1507 new GuestViewBase::Event(webview::kEventZoomChange, args.Pass()));
1495 1508
1496 current_zoom_factor_ = zoom_factor; 1509 current_zoom_factor_ = zoom_factor;
1497 } 1510 }
1498 1511
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1646 bool allow, 1659 bool allow,
1647 const std::string& user_input) { 1660 const std::string& user_input) {
1648 WebViewGuest* guest = 1661 WebViewGuest* guest =
1649 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); 1662 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id);
1650 if (!guest) 1663 if (!guest)
1651 return; 1664 return;
1652 1665
1653 if (!allow) 1666 if (!allow)
1654 guest->Destroy(); 1667 guest->Destroy();
1655 } 1668 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698