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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 if (extensions::MimeHandlerViewGuest::FromWebContents(web_contents)) { | 390 if (extensions::MimeHandlerViewGuest::FromWebContents(web_contents)) { |
391 WebContents* top_level_web_contents = | 391 WebContents* top_level_web_contents = |
392 guest_view::GuestViewBase::GetTopLevelWebContents(web_contents); | 392 guest_view::GuestViewBase::GetTopLevelWebContents(web_contents); |
393 if (top_level_web_contents) | 393 if (top_level_web_contents) |
394 return top_level_web_contents; | 394 return top_level_web_contents; |
395 } | 395 } |
396 #endif | 396 #endif |
397 return web_contents; | 397 return web_contents; |
398 } | 398 } |
399 | 399 |
400 void WriteURLToClipboard(const GURL& url, const std::string& languages) { | 400 void WriteURLToClipboard(const GURL& url) { |
401 if (url.is_empty() || !url.is_valid()) | 401 if (url.is_empty() || !url.is_valid()) |
402 return; | 402 return; |
403 | 403 |
404 // Unescaping path and query is not a good idea because other applications | 404 // Unescaping path and query is not a good idea because other applications |
405 // may not encode non-ASCII characters in UTF-8. See crbug.com/2820. | 405 // may not encode non-ASCII characters in UTF-8. See crbug.com/2820. |
406 base::string16 text = | 406 base::string16 text = |
407 url.SchemeIs(url::kMailToScheme) | 407 url.SchemeIs(url::kMailToScheme) |
408 ? base::ASCIIToUTF16(url.path()) | 408 ? base::ASCIIToUTF16(url.path()) |
409 : url_formatter::FormatUrl( | 409 : url_formatter::FormatUrl( |
410 url, languages, url_formatter::kFormatUrlOmitNothing, | 410 url, url_formatter::kFormatUrlOmitNothing, |
411 net::UnescapeRule::NONE, nullptr, nullptr, nullptr); | 411 net::UnescapeRule::NONE, nullptr, nullptr, nullptr); |
412 | 412 |
413 ui::ScopedClipboardWriter scw(ui::CLIPBOARD_TYPE_COPY_PASTE); | 413 ui::ScopedClipboardWriter scw(ui::CLIPBOARD_TYPE_COPY_PASTE); |
414 scw.WriteURL(text); | 414 scw.WriteURL(text); |
415 } | 415 } |
416 | 416 |
417 void WriteTextToClipboard(const base::string16& text) { | 417 void WriteTextToClipboard(const base::string16& text) { |
418 ui::ScopedClipboardWriter scw(ui::CLIPBOARD_TYPE_COPY_PASTE); | 418 ui::ScopedClipboardWriter scw(ui::CLIPBOARD_TYPE_COPY_PASTE); |
419 scw.WriteText(text); | 419 scw.WriteText(text); |
420 } | 420 } |
(...skipping 1839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2260 | 2260 |
2261 void RenderViewContextMenu::Inspect(int x, int y) { | 2261 void RenderViewContextMenu::Inspect(int x, int y) { |
2262 content::RecordAction(UserMetricsAction("DevTools_InspectElement")); | 2262 content::RecordAction(UserMetricsAction("DevTools_InspectElement")); |
2263 RenderFrameHost* render_frame_host = GetRenderFrameHost(); | 2263 RenderFrameHost* render_frame_host = GetRenderFrameHost(); |
2264 if (!render_frame_host) | 2264 if (!render_frame_host) |
2265 return; | 2265 return; |
2266 DevToolsWindow::InspectElement(render_frame_host, x, y); | 2266 DevToolsWindow::InspectElement(render_frame_host, x, y); |
2267 } | 2267 } |
2268 | 2268 |
2269 void RenderViewContextMenu::WriteURLToClipboard(const GURL& url) { | 2269 void RenderViewContextMenu::WriteURLToClipboard(const GURL& url) { |
2270 ::WriteURLToClipboard( | 2270 ::WriteURLToClipboard(url); |
2271 url, GetPrefs(browser_context_)->GetString(prefs::kAcceptLanguages)); | |
2272 } | 2271 } |
2273 | 2272 |
2274 void RenderViewContextMenu::MediaPlayerActionAt( | 2273 void RenderViewContextMenu::MediaPlayerActionAt( |
2275 const gfx::Point& location, | 2274 const gfx::Point& location, |
2276 const WebMediaPlayerAction& action) { | 2275 const WebMediaPlayerAction& action) { |
2277 source_web_contents_->GetRenderViewHost()-> | 2276 source_web_contents_->GetRenderViewHost()-> |
2278 ExecuteMediaPlayerActionAtLocation(location, action); | 2277 ExecuteMediaPlayerActionAtLocation(location, action); |
2279 } | 2278 } |
2280 | 2279 |
2281 void RenderViewContextMenu::PluginActionAt( | 2280 void RenderViewContextMenu::PluginActionAt( |
2282 const gfx::Point& location, | 2281 const gfx::Point& location, |
2283 const WebPluginAction& action) { | 2282 const WebPluginAction& action) { |
2284 source_web_contents_->GetRenderViewHost()-> | 2283 source_web_contents_->GetRenderViewHost()-> |
2285 ExecutePluginActionAtLocation(location, action); | 2284 ExecutePluginActionAtLocation(location, action); |
2286 } | 2285 } |
OLD | NEW |