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 <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 // Usually a new tab is expected where this function is used, | 257 // Usually a new tab is expected where this function is used, |
258 // however users should be able to open a tab in background | 258 // however users should be able to open a tab in background |
259 // or in a new window. | 259 // or in a new window. |
260 WindowOpenDisposition ForceNewTabDispositionFromEventFlags( | 260 WindowOpenDisposition ForceNewTabDispositionFromEventFlags( |
261 int event_flags) { | 261 int event_flags) { |
262 WindowOpenDisposition disposition = | 262 WindowOpenDisposition disposition = |
263 ui::DispositionFromEventFlags(event_flags); | 263 ui::DispositionFromEventFlags(event_flags); |
264 return disposition == CURRENT_TAB ? NEW_FOREGROUND_TAB : disposition; | 264 return disposition == CURRENT_TAB ? NEW_FOREGROUND_TAB : disposition; |
265 } | 265 } |
266 | 266 |
267 // Helper function to escape "&" as "&&". | |
268 void EscapeAmpersands(base::string16* text) { | |
269 base::ReplaceChars(*text, base::ASCIIToUTF16("&"), base::ASCIIToUTF16("&&"), | |
270 text); | |
271 } | |
272 | |
273 // Returns the preference of the profile represented by the |context|. | 267 // Returns the preference of the profile represented by the |context|. |
274 PrefService* GetPrefs(content::BrowserContext* context) { | 268 PrefService* GetPrefs(content::BrowserContext* context) { |
275 return user_prefs::UserPrefs::Get(context); | 269 return user_prefs::UserPrefs::Get(context); |
276 } | 270 } |
277 | 271 |
278 bool ExtensionPatternMatch(const extensions::URLPatternSet& patterns, | 272 bool ExtensionPatternMatch(const extensions::URLPatternSet& patterns, |
279 const GURL& url) { | 273 const GURL& url) { |
280 // No patterns means no restriction, so that implicitly matches. | 274 // No patterns means no restriction, so that implicitly matches. |
281 if (patterns.is_empty()) | 275 if (patterns.is_empty()) |
282 return true; | 276 return true; |
(...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1738 | 1732 |
1739 return true; | 1733 return true; |
1740 } | 1734 } |
1741 | 1735 |
1742 base::string16 RenderViewContextMenu::PrintableSelectionText() { | 1736 base::string16 RenderViewContextMenu::PrintableSelectionText() { |
1743 return gfx::TruncateString(params_.selection_text, | 1737 return gfx::TruncateString(params_.selection_text, |
1744 kMaxSelectionTextLength, | 1738 kMaxSelectionTextLength, |
1745 gfx::WORD_BREAK); | 1739 gfx::WORD_BREAK); |
1746 } | 1740 } |
1747 | 1741 |
| 1742 void RenderViewContextMenu::EscapeAmpersands(base::string16* text) { |
| 1743 base::ReplaceChars(*text, base::ASCIIToUTF16("&"), base::ASCIIToUTF16("&&"), |
| 1744 text); |
| 1745 } |
| 1746 |
1748 // Controller functions -------------------------------------------------------- | 1747 // Controller functions -------------------------------------------------------- |
1749 | 1748 |
1750 void RenderViewContextMenu::CopyImageAt(int x, int y) { | 1749 void RenderViewContextMenu::CopyImageAt(int x, int y) { |
1751 source_web_contents_->GetRenderViewHost()->CopyImageAt(x, y); | 1750 source_web_contents_->GetRenderViewHost()->CopyImageAt(x, y); |
1752 } | 1751 } |
1753 | 1752 |
1754 void RenderViewContextMenu::GetImageThumbnailForSearch() { | 1753 void RenderViewContextMenu::GetImageThumbnailForSearch() { |
1755 RenderFrameHost* render_frame_host = GetRenderFrameHost(); | 1754 RenderFrameHost* render_frame_host = GetRenderFrameHost(); |
1756 if (!render_frame_host) | 1755 if (!render_frame_host) |
1757 return; | 1756 return; |
(...skipping 24 matching lines...) Expand all Loading... |
1782 source_web_contents_->GetRenderViewHost()-> | 1781 source_web_contents_->GetRenderViewHost()-> |
1783 ExecuteMediaPlayerActionAtLocation(location, action); | 1782 ExecuteMediaPlayerActionAtLocation(location, action); |
1784 } | 1783 } |
1785 | 1784 |
1786 void RenderViewContextMenu::PluginActionAt( | 1785 void RenderViewContextMenu::PluginActionAt( |
1787 const gfx::Point& location, | 1786 const gfx::Point& location, |
1788 const WebPluginAction& action) { | 1787 const WebPluginAction& action) { |
1789 source_web_contents_->GetRenderViewHost()-> | 1788 source_web_contents_->GetRenderViewHost()-> |
1790 ExecutePluginActionAtLocation(location, action); | 1789 ExecutePluginActionAtLocation(location, action); |
1791 } | 1790 } |
OLD | NEW |