| 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/renderer_context_menu/render_view_context_menu.h" | 5 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 2151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2162 BrowserContext::GetDownloadManager(browser_context_)->DownloadUrl( | 2162 BrowserContext::GetDownloadManager(browser_context_)->DownloadUrl( |
| 2163 std::move(dl_params)); | 2163 std::move(dl_params)); |
| 2164 } | 2164 } |
| 2165 | 2165 |
| 2166 void RenderViewContextMenu::ExecSaveAs() { | 2166 void RenderViewContextMenu::ExecSaveAs() { |
| 2167 bool is_large_data_url = params_.has_image_contents && | 2167 bool is_large_data_url = params_.has_image_contents && |
| 2168 params_.src_url.is_empty(); | 2168 params_.src_url.is_empty(); |
| 2169 if (params_.media_type == WebContextMenuData::MediaTypeCanvas || | 2169 if (params_.media_type == WebContextMenuData::MediaTypeCanvas || |
| 2170 (params_.media_type == WebContextMenuData::MediaTypeImage && | 2170 (params_.media_type == WebContextMenuData::MediaTypeImage && |
| 2171 is_large_data_url)) { | 2171 is_large_data_url)) { |
| 2172 source_web_contents_->GetRenderViewHost()->SaveImageAt( | 2172 RenderFrameHost* frame_host = GetRenderFrameHost(); |
| 2173 params_.x, params_.y); | 2173 if (frame_host) |
| 2174 frame_host->SaveImageAt(params_.x, params_.y); |
| 2174 } else { | 2175 } else { |
| 2175 RecordDownloadSource(DOWNLOAD_INITIATED_BY_CONTEXT_MENU); | 2176 RecordDownloadSource(DOWNLOAD_INITIATED_BY_CONTEXT_MENU); |
| 2176 const GURL& url = params_.src_url; | 2177 const GURL& url = params_.src_url; |
| 2177 content::Referrer referrer = CreateReferrer(url, params_); | 2178 content::Referrer referrer = CreateReferrer(url, params_); |
| 2178 | 2179 |
| 2179 std::string headers; | 2180 std::string headers; |
| 2180 DataReductionProxyChromeSettings* settings = | 2181 DataReductionProxyChromeSettings* settings = |
| 2181 DataReductionProxyChromeSettingsFactory::GetForBrowserContext( | 2182 DataReductionProxyChromeSettingsFactory::GetForBrowserContext( |
| 2182 browser_context_); | 2183 browser_context_); |
| 2183 if (params_.media_type == WebContextMenuData::MediaTypeImage && | 2184 if (params_.media_type == WebContextMenuData::MediaTypeImage && |
| 2184 settings && settings->CanUseDataReductionProxy(params_.src_url)) { | 2185 settings && settings->CanUseDataReductionProxy(params_.src_url)) { |
| 2185 headers = data_reduction_proxy::kDataReductionPassThroughHeader; | 2186 headers = data_reduction_proxy::kDataReductionPassThroughHeader; |
| 2186 } | 2187 } |
| 2187 | 2188 |
| 2188 source_web_contents_->SaveFrameWithHeaders(url, referrer, headers); | 2189 source_web_contents_->SaveFrameWithHeaders(url, referrer, headers); |
| 2189 } | 2190 } |
| 2190 } | 2191 } |
| 2191 | 2192 |
| 2192 | 2193 |
| 2193 void RenderViewContextMenu::ExecCopyLinkText() { | 2194 void RenderViewContextMenu::ExecCopyLinkText() { |
| 2194 ui::ScopedClipboardWriter scw(ui::CLIPBOARD_TYPE_COPY_PASTE); | 2195 ui::ScopedClipboardWriter scw(ui::CLIPBOARD_TYPE_COPY_PASTE); |
| 2195 scw.WriteText(params_.link_text); | 2196 scw.WriteText(params_.link_text); |
| 2196 } | 2197 } |
| 2197 | 2198 |
| 2198 void RenderViewContextMenu::ExecCopyImageAt() { | 2199 void RenderViewContextMenu::ExecCopyImageAt() { |
| 2199 source_web_contents_->GetRenderViewHost()->CopyImageAt(params_.x, params_.y); | 2200 RenderFrameHost* frame_host = GetRenderFrameHost(); |
| 2201 if (frame_host) |
| 2202 frame_host->CopyImageAt(params_.x, params_.y); |
| 2200 } | 2203 } |
| 2201 | 2204 |
| 2202 void RenderViewContextMenu::ExecSearchWebForImage() { | 2205 void RenderViewContextMenu::ExecSearchWebForImage() { |
| 2203 CoreTabHelper* core_tab_helper = | 2206 CoreTabHelper* core_tab_helper = |
| 2204 CoreTabHelper::FromWebContents(source_web_contents_); | 2207 CoreTabHelper::FromWebContents(source_web_contents_); |
| 2205 if (!core_tab_helper) | 2208 if (!core_tab_helper) |
| 2206 return; | 2209 return; |
| 2207 RenderFrameHost* render_frame_host = GetRenderFrameHost(); | 2210 RenderFrameHost* render_frame_host = GetRenderFrameHost(); |
| 2208 if (!render_frame_host) | 2211 if (!render_frame_host) |
| 2209 return; | 2212 return; |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2387 source_web_contents_->GetRenderViewHost()-> | 2390 source_web_contents_->GetRenderViewHost()-> |
| 2388 ExecuteMediaPlayerActionAtLocation(location, action); | 2391 ExecuteMediaPlayerActionAtLocation(location, action); |
| 2389 } | 2392 } |
| 2390 | 2393 |
| 2391 void RenderViewContextMenu::PluginActionAt( | 2394 void RenderViewContextMenu::PluginActionAt( |
| 2392 const gfx::Point& location, | 2395 const gfx::Point& location, |
| 2393 const WebPluginAction& action) { | 2396 const WebPluginAction& action) { |
| 2394 source_web_contents_->GetRenderViewHost()-> | 2397 source_web_contents_->GetRenderViewHost()-> |
| 2395 ExecutePluginActionAtLocation(location, action); | 2398 ExecutePluginActionAtLocation(location, action); |
| 2396 } | 2399 } |
| OLD | NEW |