Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Side by Side Diff: chrome/browser/tab_contents/render_view_context_menu.cc

Issue 8919017: Split UserMetrics into API vs. implementation. Move API to content/public. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move to content namespace. Update usages. Update extract_actions tool. Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <algorithm> 5 #include <algorithm>
6 #include <set> 6 #include <set>
7 #include <utility> 7 #include <utility>
8 8
9 #include "chrome/browser/tab_contents/render_view_context_menu.h" 9 #include "chrome/browser/tab_contents/render_view_context_menu.h"
10 10
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 #include "content/browser/child_process_security_policy.h" 58 #include "content/browser/child_process_security_policy.h"
59 #include "content/browser/download/download_manager.h" 59 #include "content/browser/download/download_manager.h"
60 #include "content/browser/download/download_stats.h" 60 #include "content/browser/download/download_stats.h"
61 #include "content/browser/download/save_package.h" 61 #include "content/browser/download/save_package.h"
62 #include "content/browser/renderer_host/render_view_host.h" 62 #include "content/browser/renderer_host/render_view_host.h"
63 #include "content/browser/renderer_host/render_widget_host_view.h" 63 #include "content/browser/renderer_host/render_widget_host_view.h"
64 #include "content/browser/speech/speech_input_preferences.h" 64 #include "content/browser/speech/speech_input_preferences.h"
65 #include "content/browser/tab_contents/navigation_details.h" 65 #include "content/browser/tab_contents/navigation_details.h"
66 #include "content/browser/tab_contents/navigation_entry.h" 66 #include "content/browser/tab_contents/navigation_entry.h"
67 #include "content/browser/tab_contents/tab_contents.h" 67 #include "content/browser/tab_contents/tab_contents.h"
68 #include "content/browser/user_metrics.h"
69 #include "content/public/browser/notification_service.h" 68 #include "content/public/browser/notification_service.h"
69 #include "content/public/browser/user_metrics.h"
70 #include "content/public/common/content_restriction.h" 70 #include "content/public/common/content_restriction.h"
71 #include "grit/generated_resources.h" 71 #include "grit/generated_resources.h"
72 #include "net/base/escape.h" 72 #include "net/base/escape.h"
73 #include "net/base/net_util.h" 73 #include "net/base/net_util.h"
74 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" 74 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h"
75 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction. h" 75 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction. h"
76 #include "ui/base/l10n/l10n_util.h" 76 #include "ui/base/l10n/l10n_util.h"
77 #include "ui/base/text/text_elider.h" 77 #include "ui/base/text/text_elider.h"
78 #include "ui/gfx/favicon_size.h" 78 #include "ui/gfx/favicon_size.h"
79 #include "webkit/glue/webmenuitem.h" 79 #include "webkit/glue/webmenuitem.h"
80 80
81 #ifdef FILE_MANAGER_EXTENSION 81 #ifdef FILE_MANAGER_EXTENSION
82 #include "chrome/browser/extensions/file_manager_util.h" 82 #include "chrome/browser/extensions/file_manager_util.h"
83 #endif 83 #endif
84 84
85 using content::UserMetricsAction;
85 using WebKit::WebContextMenuData; 86 using WebKit::WebContextMenuData;
86 using WebKit::WebMediaPlayerAction; 87 using WebKit::WebMediaPlayerAction;
87 using WebKit::WebURL; 88 using WebKit::WebURL;
88 using WebKit::WebString; 89 using WebKit::WebString;
89 90
90 namespace { 91 namespace {
91 92
92 // Usually a new tab is expected where this function is used, 93 // Usually a new tab is expected where this function is used,
93 // however users should be able to open a tab in background 94 // however users should be able to open a tab in background
94 // or in a new window. 95 // or in a new window.
(...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 return; 1368 return;
1368 } 1369 }
1369 1370
1370 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST && 1371 if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST &&
1371 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) { 1372 id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) {
1372 ProtocolHandlerRegistry::ProtocolHandlerList handlers = 1373 ProtocolHandlerRegistry::ProtocolHandlerList handlers =
1373 GetHandlersForLinkUrl(); 1374 GetHandlersForLinkUrl();
1374 if (handlers.empty()) { 1375 if (handlers.empty()) {
1375 return; 1376 return;
1376 } 1377 }
1377 UserMetrics::RecordAction( 1378 content::RecordAction(
1378 UserMetricsAction("RegisterProtocolHandler.ContextMenu_Open")); 1379 UserMetricsAction("RegisterProtocolHandler.ContextMenu_Open"));
1379 int handlerIndex = id - IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST; 1380 int handlerIndex = id - IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST;
1380 WindowOpenDisposition disposition = 1381 WindowOpenDisposition disposition =
1381 ForceNewTabDispositionFromEventFlags(event_flags); 1382 ForceNewTabDispositionFromEventFlags(event_flags);
1382 OpenURL( 1383 OpenURL(
1383 handlers[handlerIndex].TranslateUrl(params_.link_url), 1384 handlers[handlerIndex].TranslateUrl(params_.link_url),
1384 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url, 1385 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url,
1385 params_.frame_id, 1386 params_.frame_id,
1386 disposition, 1387 disposition,
1387 content::PAGE_TRANSITION_LINK); 1388 content::PAGE_TRANSITION_LINK);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 OpenURL( 1452 OpenURL(
1452 params_.src_url, 1453 params_.src_url,
1453 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url, 1454 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url,
1454 params_.frame_id, 1455 params_.frame_id,
1455 NEW_BACKGROUND_TAB, content::PAGE_TRANSITION_LINK); 1456 NEW_BACKGROUND_TAB, content::PAGE_TRANSITION_LINK);
1456 break; 1457 break;
1457 1458
1458 case IDC_CONTENT_CONTEXT_PLAYPAUSE: { 1459 case IDC_CONTENT_CONTEXT_PLAYPAUSE: {
1459 bool play = !!(params_.media_flags & WebContextMenuData::MediaPaused); 1460 bool play = !!(params_.media_flags & WebContextMenuData::MediaPaused);
1460 if (play) { 1461 if (play) {
1461 UserMetrics::RecordAction(UserMetricsAction("MediaContextMenu_Play")); 1462 content::RecordAction(UserMetricsAction("MediaContextMenu_Play"));
1462 } else { 1463 } else {
1463 UserMetrics::RecordAction(UserMetricsAction("MediaContextMenu_Pause")); 1464 content::RecordAction(UserMetricsAction("MediaContextMenu_Pause"));
1464 } 1465 }
1465 MediaPlayerActionAt(gfx::Point(params_.x, params_.y), 1466 MediaPlayerActionAt(gfx::Point(params_.x, params_.y),
1466 WebMediaPlayerAction( 1467 WebMediaPlayerAction(
1467 WebMediaPlayerAction::Play, play)); 1468 WebMediaPlayerAction::Play, play));
1468 break; 1469 break;
1469 } 1470 }
1470 1471
1471 case IDC_CONTENT_CONTEXT_MUTE: { 1472 case IDC_CONTENT_CONTEXT_MUTE: {
1472 bool mute = !(params_.media_flags & WebContextMenuData::MediaMuted); 1473 bool mute = !(params_.media_flags & WebContextMenuData::MediaMuted);
1473 if (mute) { 1474 if (mute) {
1474 UserMetrics::RecordAction(UserMetricsAction("MediaContextMenu_Mute")); 1475 content::RecordAction(UserMetricsAction("MediaContextMenu_Mute"));
1475 } else { 1476 } else {
1476 UserMetrics::RecordAction(UserMetricsAction("MediaContextMenu_Unmute")); 1477 content::RecordAction(UserMetricsAction("MediaContextMenu_Unmute"));
1477 } 1478 }
1478 MediaPlayerActionAt(gfx::Point(params_.x, params_.y), 1479 MediaPlayerActionAt(gfx::Point(params_.x, params_.y),
1479 WebMediaPlayerAction( 1480 WebMediaPlayerAction(
1480 WebMediaPlayerAction::Mute, mute)); 1481 WebMediaPlayerAction::Mute, mute));
1481 break; 1482 break;
1482 } 1483 }
1483 1484
1484 case IDC_CONTENT_CONTEXT_LOOP: 1485 case IDC_CONTENT_CONTEXT_LOOP:
1485 UserMetrics::RecordAction(UserMetricsAction("MediaContextMenu_Loop")); 1486 content::RecordAction(UserMetricsAction("MediaContextMenu_Loop"));
1486 MediaPlayerActionAt(gfx::Point(params_.x, params_.y), 1487 MediaPlayerActionAt(gfx::Point(params_.x, params_.y),
1487 WebMediaPlayerAction( 1488 WebMediaPlayerAction(
1488 WebMediaPlayerAction::Loop, 1489 WebMediaPlayerAction::Loop,
1489 !IsCommandIdChecked(IDC_CONTENT_CONTEXT_LOOP))); 1490 !IsCommandIdChecked(IDC_CONTENT_CONTEXT_LOOP)));
1490 break; 1491 break;
1491 1492
1492 case IDC_CONTENT_CONTEXT_CONTROLS: 1493 case IDC_CONTENT_CONTEXT_CONTROLS:
1493 UserMetrics::RecordAction(UserMetricsAction("MediaContextMenu_Controls")); 1494 content::RecordAction(UserMetricsAction("MediaContextMenu_Controls"));
1494 MediaPlayerActionAt( 1495 MediaPlayerActionAt(
1495 gfx::Point(params_.x, params_.y), 1496 gfx::Point(params_.x, params_.y),
1496 WebMediaPlayerAction( 1497 WebMediaPlayerAction(
1497 WebMediaPlayerAction::Controls, 1498 WebMediaPlayerAction::Controls,
1498 !IsCommandIdChecked(IDC_CONTENT_CONTEXT_CONTROLS))); 1499 !IsCommandIdChecked(IDC_CONTENT_CONTEXT_CONTROLS)));
1499 break; 1500 break;
1500 1501
1501 case IDC_BACK: 1502 case IDC_BACK:
1502 source_tab_contents_->controller().GoBack(); 1503 source_tab_contents_->controller().GoBack();
1503 break; 1504 break;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1670 dir = WebKit::WebTextDirectionRightToLeft; 1671 dir = WebKit::WebTextDirectionRightToLeft;
1671 rvh->UpdateTextDirection(dir); 1672 rvh->UpdateTextDirection(dir);
1672 rvh->NotifyTextDirection(); 1673 rvh->NotifyTextDirection();
1673 break; 1674 break;
1674 } 1675 }
1675 case IDC_CONTENT_CONTEXT_LOOK_UP_IN_DICTIONARY: 1676 case IDC_CONTENT_CONTEXT_LOOK_UP_IN_DICTIONARY:
1676 LookUpInDictionary(); 1677 LookUpInDictionary();
1677 break; 1678 break;
1678 #endif // OS_MACOSX 1679 #endif // OS_MACOSX
1679 case IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS: { 1680 case IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS: {
1680 UserMetrics::RecordAction( 1681 content::RecordAction(
1681 UserMetricsAction("RegisterProtocolHandler.ContextMenu_Settings")); 1682 UserMetricsAction("RegisterProtocolHandler.ContextMenu_Settings"));
1682 WindowOpenDisposition disposition = 1683 WindowOpenDisposition disposition =
1683 ForceNewTabDispositionFromEventFlags(event_flags); 1684 ForceNewTabDispositionFromEventFlags(event_flags);
1684 std::string url = std::string(chrome::kChromeUISettingsURL) + 1685 std::string url = std::string(chrome::kChromeUISettingsURL) +
1685 chrome::kHandlerSettingsSubPage; 1686 chrome::kHandlerSettingsSubPage;
1686 OpenURL(GURL(url), GURL(), 0, disposition, content::PAGE_TRANSITION_LINK); 1687 OpenURL(GURL(url), GURL(), 0, disposition, content::PAGE_TRANSITION_LINK);
1687 break; 1688 break;
1688 } 1689 }
1689 1690
1690 case IDC_CONTENT_CONTEXT_ADDSEARCHENGINE: { 1691 case IDC_CONTENT_CONTEXT_ADDSEARCHENGINE: {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1822 source_tab_contents_->browser_context()), 1823 source_tab_contents_->browser_context()),
1823 content::Details<content::RetargetingDetails>(&details)); 1824 content::Details<content::RetargetingDetails>(&details));
1824 } 1825 }
1825 } 1826 }
1826 1827
1827 void RenderViewContextMenu::CopyImageAt(int x, int y) { 1828 void RenderViewContextMenu::CopyImageAt(int x, int y) {
1828 source_tab_contents_->render_view_host()->CopyImageAt(x, y); 1829 source_tab_contents_->render_view_host()->CopyImageAt(x, y);
1829 } 1830 }
1830 1831
1831 void RenderViewContextMenu::Inspect(int x, int y) { 1832 void RenderViewContextMenu::Inspect(int x, int y) {
1832 UserMetrics::RecordAction(UserMetricsAction("DevTools_InspectElement")); 1833 content::RecordAction(UserMetricsAction("DevTools_InspectElement"));
1833 DevToolsWindow::InspectElement( 1834 DevToolsWindow::InspectElement(
1834 source_tab_contents_->render_view_host(), x, y); 1835 source_tab_contents_->render_view_host(), x, y);
1835 } 1836 }
1836 1837
1837 void RenderViewContextMenu::WriteURLToClipboard(const GURL& url) { 1838 void RenderViewContextMenu::WriteURLToClipboard(const GURL& url) {
1838 chrome_browser_net::WriteURLToClipboard( 1839 chrome_browser_net::WriteURLToClipboard(
1839 url, 1840 url,
1840 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), 1841 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages),
1841 g_browser_process->clipboard()); 1842 g_browser_process->clipboard());
1842 } 1843 }
1843 1844
1844 void RenderViewContextMenu::MediaPlayerActionAt( 1845 void RenderViewContextMenu::MediaPlayerActionAt(
1845 const gfx::Point& location, 1846 const gfx::Point& location,
1846 const WebMediaPlayerAction& action) { 1847 const WebMediaPlayerAction& action) {
1847 source_tab_contents_->render_view_host()-> 1848 source_tab_contents_->render_view_host()->
1848 ExecuteMediaPlayerActionAtLocation(location, action); 1849 ExecuteMediaPlayerActionAtLocation(location, action);
1849 } 1850 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698