OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/frame_host/render_frame_host_impl.h" | 5 #include "content/browser/frame_host/render_frame_host_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 #include "content/public/browser/permission_type.h" | 57 #include "content/public/browser/permission_type.h" |
58 #include "content/public/browser/render_process_host.h" | 58 #include "content/public/browser/render_process_host.h" |
59 #include "content/public/browser/render_widget_host_view.h" | 59 #include "content/public/browser/render_widget_host_view.h" |
60 #include "content/public/browser/stream_handle.h" | 60 #include "content/public/browser/stream_handle.h" |
61 #include "content/public/browser/user_metrics.h" | 61 #include "content/public/browser/user_metrics.h" |
62 #include "content/public/common/content_constants.h" | 62 #include "content/public/common/content_constants.h" |
63 #include "content/public/common/content_switches.h" | 63 #include "content/public/common/content_switches.h" |
64 #include "content/public/common/isolated_world_ids.h" | 64 #include "content/public/common/isolated_world_ids.h" |
65 #include "content/public/common/url_constants.h" | 65 #include "content/public/common/url_constants.h" |
66 #include "content/public/common/url_utils.h" | 66 #include "content/public/common/url_utils.h" |
67 #include "mojo/common/url_type_converters.h" | |
68 #include "mojo/converters/geometry/geometry_type_converters.h" | |
69 #include "skia/public/type_converters.h" | |
70 #include "third_party/skia/include/core/SkBitmap.h" | |
67 #include "ui/accessibility/ax_tree.h" | 71 #include "ui/accessibility/ax_tree.h" |
68 #include "ui/accessibility/ax_tree_update.h" | 72 #include "ui/accessibility/ax_tree_update.h" |
73 #include "ui/gfx/geometry/size.h" | |
69 #include "url/gurl.h" | 74 #include "url/gurl.h" |
70 | 75 |
71 #if defined(OS_ANDROID) | 76 #if defined(OS_ANDROID) |
72 #include "content/browser/mojo/service_registrar_android.h" | 77 #include "content/browser/mojo/service_registrar_android.h" |
73 #endif | 78 #endif |
74 | 79 |
75 #if defined(OS_MACOSX) | 80 #if defined(OS_MACOSX) |
76 #include "content/browser/frame_host/popup_menu_helper_mac.h" | 81 #include "content/browser/frame_host/popup_menu_helper_mac.h" |
77 #endif | 82 #endif |
78 | 83 |
(...skipping 27 matching lines...) Expand all Loading... | |
106 case blink::WebTextDirectionLeftToRight: | 111 case blink::WebTextDirectionLeftToRight: |
107 return base::i18n::LEFT_TO_RIGHT; | 112 return base::i18n::LEFT_TO_RIGHT; |
108 case blink::WebTextDirectionRightToLeft: | 113 case blink::WebTextDirectionRightToLeft: |
109 return base::i18n::RIGHT_TO_LEFT; | 114 return base::i18n::RIGHT_TO_LEFT; |
110 default: | 115 default: |
111 NOTREACHED(); | 116 NOTREACHED(); |
112 return base::i18n::UNKNOWN_DIRECTION; | 117 return base::i18n::UNKNOWN_DIRECTION; |
113 } | 118 } |
114 } | 119 } |
115 | 120 |
121 void DidDownloadImage(const WebContents::ImageDownloadCallback& callback, | |
122 int id, | |
123 const GURL& image_url, | |
124 image_downloader::DownloadResultPtr result) { | |
125 DCHECK(result); | |
126 | |
127 const std::vector<SkBitmap> images = | |
128 result->images.To<std::vector<SkBitmap>>(); | |
129 const std::vector<gfx::Size> original_image_sizes = | |
130 result->original_image_sizes.To<std::vector<gfx::Size>>(); | |
131 | |
132 callback.Run(id, result->http_status_code, image_url, images, | |
133 original_image_sizes); | |
134 } | |
135 | |
116 } // namespace | 136 } // namespace |
117 | 137 |
118 // static | 138 // static |
119 bool RenderFrameHostImpl::IsRFHStateActive(RenderFrameHostImplState rfh_state) { | 139 bool RenderFrameHostImpl::IsRFHStateActive(RenderFrameHostImplState rfh_state) { |
120 return rfh_state == STATE_DEFAULT; | 140 return rfh_state == STATE_DEFAULT; |
121 } | 141 } |
122 | 142 |
123 // static | 143 // static |
124 RenderFrameHost* RenderFrameHost::FromID(int render_process_id, | 144 RenderFrameHost* RenderFrameHost::FromID(int render_process_id, |
125 int render_frame_id) { | 145 int render_frame_id) { |
(...skipping 1719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1845 } | 1865 } |
1846 | 1866 |
1847 void RenderFrameHostImpl::InvalidateMojoConnection() { | 1867 void RenderFrameHostImpl::InvalidateMojoConnection() { |
1848 #if defined(OS_ANDROID) | 1868 #if defined(OS_ANDROID) |
1849 // The Android-specific service registry has a reference to | 1869 // The Android-specific service registry has a reference to |
1850 // |service_registry_| and thus must be torn down first. | 1870 // |service_registry_| and thus must be torn down first. |
1851 service_registry_android_.reset(); | 1871 service_registry_android_.reset(); |
1852 #endif | 1872 #endif |
1853 | 1873 |
1854 service_registry_.reset(); | 1874 service_registry_.reset(); |
1875 | |
1876 // Disconnect with ImageDownloader Mojo service in RenderFrame. | |
1877 mojo_image_downloader_.reset(); | |
1855 } | 1878 } |
1856 | 1879 |
1857 bool RenderFrameHostImpl::IsFocused() { | 1880 bool RenderFrameHostImpl::IsFocused() { |
1858 // TODO(mlamouri,kenrb): call GetRenderWidgetHost() directly when it stops | 1881 // TODO(mlamouri,kenrb): call GetRenderWidgetHost() directly when it stops |
1859 // returning nullptr in some cases. See https://crbug.com/455245. | 1882 // returning nullptr in some cases. See https://crbug.com/455245. |
1860 return RenderWidgetHostImpl::From( | 1883 return RenderWidgetHostImpl::From( |
1861 GetView()->GetRenderWidgetHost())->is_focused() && | 1884 GetView()->GetRenderWidgetHost())->is_focused() && |
1862 frame_tree_->GetFocusedFrame() && | 1885 frame_tree_->GetFocusedFrame() && |
1863 (frame_tree_->GetFocusedFrame() == frame_tree_node() || | 1886 (frame_tree_->GetFocusedFrame() == frame_tree_node() || |
1864 frame_tree_->GetFocusedFrame()->IsDescendantOf(frame_tree_node())); | 1887 frame_tree_->GetFocusedFrame()->IsDescendantOf(frame_tree_node())); |
1865 } | 1888 } |
1866 | 1889 |
1890 int RenderFrameHostImpl::DownloadImage( | |
nasko
2015/07/02 08:41:07
To avoid all the complexity of defining a callback
leonhsl(Using Gerrit)
2015/07/06 02:15:25
Done.
| |
1891 const GURL& url, | |
1892 bool is_favicon, | |
1893 uint32_t max_bitmap_size, | |
1894 bool bypass_cache, | |
1895 const WebContents::ImageDownloadCallback& callback) { | |
1896 static int next_image_download_id_ = 0; | |
1897 image_downloader::DownloadRequestPtr req = | |
1898 image_downloader::DownloadRequest::New(); | |
1899 | |
1900 if (!mojo_image_downloader_.get()) { | |
1901 GetServiceRegistry()->ConnectToRemoteService( | |
1902 mojo::GetProxy(&mojo_image_downloader_)); | |
nasko
2015/07/02 08:41:07
Can this fail? If not handled, this will cause a b
Anand Mistry (off Chromium)
2015/07/02 08:56:51
Not in a way that will cause a crash. This line wi
| |
1903 } | |
1904 | |
1905 req->url = mojo::String::From(url); | |
1906 req->is_favicon = is_favicon; | |
1907 req->max_bitmap_size = max_bitmap_size; | |
1908 req->bypass_cache = bypass_cache; | |
1909 | |
1910 mojo_image_downloader_->DownloadImage( | |
1911 req.Pass(), | |
1912 base::Bind(&DidDownloadImage, callback, ++next_image_download_id_, url)); | |
1913 return next_image_download_id_; | |
1914 } | |
1915 | |
1867 void RenderFrameHostImpl::UpdateCrossProcessIframeAccessibility( | 1916 void RenderFrameHostImpl::UpdateCrossProcessIframeAccessibility( |
1868 const std::map<int32, int>& node_to_frame_routing_id_map) { | 1917 const std::map<int32, int>& node_to_frame_routing_id_map) { |
1869 for (const auto& iter : node_to_frame_routing_id_map) { | 1918 for (const auto& iter : node_to_frame_routing_id_map) { |
1870 // This is the id of the accessibility node that has a child frame. | 1919 // This is the id of the accessibility node that has a child frame. |
1871 int32 node_id = iter.first; | 1920 int32 node_id = iter.first; |
1872 // The routing id from either a RenderFrame or a RenderFrameProxy. | 1921 // The routing id from either a RenderFrame or a RenderFrameProxy. |
1873 int frame_routing_id = iter.second; | 1922 int frame_routing_id = iter.second; |
1874 | 1923 |
1875 FrameTree* frame_tree = frame_tree_node()->frame_tree(); | 1924 FrameTree* frame_tree = frame_tree_node()->frame_tree(); |
1876 FrameTreeNode* child_frame_tree_node = frame_tree->FindByRoutingID( | 1925 FrameTreeNode* child_frame_tree_node = frame_tree->FindByRoutingID( |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2089 // We may be returning to an existing NavigationEntry that had been granted | 2138 // We may be returning to an existing NavigationEntry that had been granted |
2090 // file access. If this is a different process, we will need to grant the | 2139 // file access. If this is a different process, we will need to grant the |
2091 // access again. The files listed in the page state are validated when they | 2140 // access again. The files listed in the page state are validated when they |
2092 // are received from the renderer to prevent abuse. | 2141 // are received from the renderer to prevent abuse. |
2093 if (request_params.page_state.IsValid()) { | 2142 if (request_params.page_state.IsValid()) { |
2094 render_view_host_->GrantFileAccessFromPageState(request_params.page_state); | 2143 render_view_host_->GrantFileAccessFromPageState(request_params.page_state); |
2095 } | 2144 } |
2096 } | 2145 } |
2097 | 2146 |
2098 } // namespace content | 2147 } // namespace content |
OLD | NEW |