| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 #include "content/public/common/content_constants.h" | 105 #include "content/public/common/content_constants.h" |
| 106 #include "content/public/common/content_switches.h" | 106 #include "content/public/common/content_switches.h" |
| 107 #include "content/public/common/page_zoom.h" | 107 #include "content/public/common/page_zoom.h" |
| 108 #include "content/public/common/result_codes.h" | 108 #include "content/public/common/result_codes.h" |
| 109 #include "content/public/common/security_style.h" | 109 #include "content/public/common/security_style.h" |
| 110 #include "content/public/common/url_constants.h" | 110 #include "content/public/common/url_constants.h" |
| 111 #include "content/public/common/url_utils.h" | 111 #include "content/public/common/url_utils.h" |
| 112 #include "content/public/common/web_preferences.h" | 112 #include "content/public/common/web_preferences.h" |
| 113 #include "mojo/common/url_type_converters.h" | 113 #include "mojo/common/url_type_converters.h" |
| 114 #include "mojo/converters/geometry/geometry_type_converters.h" | 114 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 115 #include "net/base/url_util.h" |
| 115 #include "net/http/http_cache.h" | 116 #include "net/http/http_cache.h" |
| 116 #include "net/http/http_transaction_factory.h" | 117 #include "net/http/http_transaction_factory.h" |
| 117 #include "net/url_request/url_request_context.h" | 118 #include "net/url_request/url_request_context.h" |
| 118 #include "net/url_request/url_request_context_getter.h" | 119 #include "net/url_request/url_request_context_getter.h" |
| 119 #include "skia/public/type_converters.h" | 120 #include "skia/public/type_converters.h" |
| 120 #include "third_party/WebKit/public/web/WebSandboxFlags.h" | 121 #include "third_party/WebKit/public/web/WebSandboxFlags.h" |
| 121 #include "third_party/skia/include/core/SkBitmap.h" | 122 #include "third_party/skia/include/core/SkBitmap.h" |
| 122 #include "ui/base/layout.h" | 123 #include "ui/base/layout.h" |
| 123 #include "ui/gfx/display.h" | 124 #include "ui/gfx/display.h" |
| 124 #include "ui/gfx/screen.h" | 125 #include "ui/gfx/screen.h" |
| (...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 SetAccessibilityMode(RemoveAccessibilityModeFrom(accessibility_mode_, mode)); | 853 SetAccessibilityMode(RemoveAccessibilityModeFrom(accessibility_mode_, mode)); |
| 853 } | 854 } |
| 854 | 855 |
| 855 void WebContentsImpl::RequestAXTreeSnapshot(AXTreeSnapshotCallback callback) { | 856 void WebContentsImpl::RequestAXTreeSnapshot(AXTreeSnapshotCallback callback) { |
| 856 // TODO(dmazzoni): http://crbug.com/475608 This only returns the | 857 // TODO(dmazzoni): http://crbug.com/475608 This only returns the |
| 857 // accessibility tree from the main frame and everything in the | 858 // accessibility tree from the main frame and everything in the |
| 858 // same site instance. | 859 // same site instance. |
| 859 GetMainFrame()->RequestAXTreeSnapshot(callback); | 860 GetMainFrame()->RequestAXTreeSnapshot(callback); |
| 860 } | 861 } |
| 861 | 862 |
| 863 void WebContentsImpl::SetTemporaryZoomLevel(double level, bool is_temporary) { |
| 864 SendPageMessage(new PageMsg_SetZoomLevel( |
| 865 MSG_ROUTING_NONE, |
| 866 is_temporary ? PageMsg_SetZoomLevel_Command::ZOOM_SET_TEMPORARY |
| 867 : PageMsg_SetZoomLevel_Command::ZOOM_CLEAR_TEMPORARY, |
| 868 level)); |
| 869 } |
| 870 |
| 871 void WebContentsImpl::UpdateZoom(double level) { |
| 872 // Individual frames may still ignore the new zoom level if their RenderView |
| 873 // contains a plugin document or if it uses a temporary zoom level. |
| 874 SendPageMessage(new PageMsg_SetZoomLevel( |
| 875 MSG_ROUTING_NONE, |
| 876 PageMsg_SetZoomLevel_Command::ZOOM_USE_CURRENT_TEMPORARY_MODE, level)); |
| 877 } |
| 878 |
| 879 void WebContentsImpl::UpdateZoomIfNecessary(const std::string& scheme, |
| 880 const std::string& host, |
| 881 double level) { |
| 882 NavigationEntry* entry = GetController().GetLastCommittedEntry(); |
| 883 if (!entry) |
| 884 return; |
| 885 |
| 886 GURL url = HostZoomMap::GetURLFromEntry(entry); |
| 887 if (host != net::GetHostOrSpecFromURL(url) || |
| 888 (!scheme.empty() && scheme != url.scheme())) { |
| 889 return; |
| 890 } |
| 891 |
| 892 UpdateZoom(level); |
| 893 } |
| 894 |
| 862 WebUI* WebContentsImpl::CreateSubframeWebUI(const GURL& url, | 895 WebUI* WebContentsImpl::CreateSubframeWebUI(const GURL& url, |
| 863 const std::string& frame_name) { | 896 const std::string& frame_name) { |
| 864 DCHECK(!frame_name.empty()); | 897 DCHECK(!frame_name.empty()); |
| 865 return CreateWebUI(url, frame_name); | 898 return CreateWebUI(url, frame_name); |
| 866 } | 899 } |
| 867 | 900 |
| 868 WebUI* WebContentsImpl::GetWebUI() const { | 901 WebUI* WebContentsImpl::GetWebUI() const { |
| 869 WebUI* commited_web_ui = GetCommittedWebUI(); | 902 WebUI* commited_web_ui = GetCommittedWebUI(); |
| 870 return commited_web_ui ? commited_web_ui | 903 return commited_web_ui ? commited_web_ui |
| 871 : GetRenderManager()->GetNavigatingWebUI(); | 904 : GetRenderManager()->GetNavigatingWebUI(); |
| (...skipping 3040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3912 base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this), | 3945 base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this), |
| 3913 render_frame_host->GetProcess()->GetID(), | 3946 render_frame_host->GetProcess()->GetID(), |
| 3914 render_frame_host->GetRoutingID(), reply_msg, | 3947 render_frame_host->GetRoutingID(), reply_msg, |
| 3915 false)); | 3948 false)); |
| 3916 } | 3949 } |
| 3917 | 3950 |
| 3918 WebContents* WebContentsImpl::GetAsWebContents() { | 3951 WebContents* WebContentsImpl::GetAsWebContents() { |
| 3919 return this; | 3952 return this; |
| 3920 } | 3953 } |
| 3921 | 3954 |
| 3955 double WebContentsImpl::PageZoomLevel() { |
| 3956 return HostZoomMap::GetZoomLevel(this); |
| 3957 } |
| 3958 |
| 3922 bool WebContentsImpl::IsNeverVisible() { | 3959 bool WebContentsImpl::IsNeverVisible() { |
| 3923 if (!delegate_) | 3960 if (!delegate_) |
| 3924 return false; | 3961 return false; |
| 3925 return delegate_->IsNeverVisible(this); | 3962 return delegate_->IsNeverVisible(this); |
| 3926 } | 3963 } |
| 3927 | 3964 |
| 3928 RenderViewHostDelegateView* WebContentsImpl::GetDelegateView() { | 3965 RenderViewHostDelegateView* WebContentsImpl::GetDelegateView() { |
| 3929 return render_view_host_delegate_view_; | 3966 return render_view_host_delegate_view_; |
| 3930 } | 3967 } |
| 3931 | 3968 |
| (...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4836 else | 4873 else |
| 4837 WasHidden(); | 4874 WasHidden(); |
| 4838 } | 4875 } |
| 4839 | 4876 |
| 4840 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( | 4877 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( |
| 4841 JavaScriptDialogManager* dialog_manager) { | 4878 JavaScriptDialogManager* dialog_manager) { |
| 4842 dialog_manager_ = dialog_manager; | 4879 dialog_manager_ = dialog_manager; |
| 4843 } | 4880 } |
| 4844 | 4881 |
| 4845 } // namespace content | 4882 } // namespace content |
| OLD | NEW |