Commit 88fcd542 authored by bauerb@chromium.org's avatar bauerb@chromium.org

Add UMA metrics for blocked plugins.

BUG=92170
TEST=none


Review URL: http://codereview.chromium.org/7558024

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96360 0039d316-1c4b-4281-b951-d872f2087c98
parent 396b6723
...@@ -165,13 +165,16 @@ void BlockedPlugin::OnMenuItemSelected( ...@@ -165,13 +165,16 @@ void BlockedPlugin::OnMenuItemSelected(
const webkit_glue::CustomContextMenuContext& /* ignored */, const webkit_glue::CustomContextMenuContext& /* ignored */,
unsigned id) { unsigned id) {
if (id == kMenuActionLoad) { if (id == kMenuActionLoad) {
Send(new ViewHostMsg_UserMetricsRecordAction("Plugin_Load_Menu"));
LoadPlugin(); LoadPlugin();
} else if (id == kMenuActionRemove) { } else if (id == kMenuActionRemove) {
Send(new ViewHostMsg_UserMetricsRecordAction("Plugin_Hide_Menu"));
HidePlugin(); HidePlugin();
} }
} }
void BlockedPlugin::OnLoadBlockedPlugins() { void BlockedPlugin::OnLoadBlockedPlugins() {
Send(new ViewHostMsg_UserMetricsRecordAction("Plugin_Load_UI"));
LoadPlugin(); LoadPlugin();
} }
...@@ -209,10 +212,12 @@ void BlockedPlugin::LoadPlugin() { ...@@ -209,10 +212,12 @@ void BlockedPlugin::LoadPlugin() {
} }
void BlockedPlugin::Load(const CppArgumentList& args, CppVariant* result) { void BlockedPlugin::Load(const CppArgumentList& args, CppVariant* result) {
Send(new ViewHostMsg_UserMetricsRecordAction("Plugin_Load_Click"));
LoadPlugin(); LoadPlugin();
} }
void BlockedPlugin::Hide(const CppArgumentList& args, CppVariant* result) { void BlockedPlugin::Hide(const CppArgumentList& args, CppVariant* result) {
Send(new ViewHostMsg_UserMetricsRecordAction("Plugin_Hide_Click"));
HidePlugin(); HidePlugin();
} }
......
...@@ -461,10 +461,14 @@ WebPlugin* ChromeContentRendererClient::CreatePluginImpl( ...@@ -461,10 +461,14 @@ WebPlugin* ChromeContentRendererClient::CreatePluginImpl(
observer->DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS, resource); observer->DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS, resource);
if (plugin_setting == CONTENT_SETTING_ASK) { if (plugin_setting == CONTENT_SETTING_ASK) {
render_view->Send(
new ViewHostMsg_UserMetricsRecordAction("Plugin_ClickToPlay"));
return CreatePluginPlaceholder( return CreatePluginPlaceholder(
render_view, frame, params, *group, IDR_CLICK_TO_PLAY_PLUGIN_HTML, render_view, frame, params, *group, IDR_CLICK_TO_PLAY_PLUGIN_HTML,
IDS_PLUGIN_LOAD, false, true); IDS_PLUGIN_LOAD, false, true);
} else { } else {
render_view->Send(
new ViewHostMsg_UserMetricsRecordAction("Plugin_Blocked"));
return CreatePluginPlaceholder( return CreatePluginPlaceholder(
render_view, frame, params, *group, IDR_BLOCKED_PLUGIN_HTML, render_view, frame, params, *group, IDR_BLOCKED_PLUGIN_HTML,
IDS_PLUGIN_BLOCKED, false, true); IDS_PLUGIN_BLOCKED, false, true);
......
...@@ -1041,6 +1041,13 @@ ...@@ -1041,6 +1041,13 @@
0x6cc1116fbd900ebf PasswordManager_Enabled 0x6cc1116fbd900ebf PasswordManager_Enabled
0x36bb6559696dc912 Paste 0x36bb6559696dc912 Paste
0x5d0e6942f354a06c PasteAndMatchStyle 0x5d0e6942f354a06c PasteAndMatchStyle
0x6f2cd84fa374c281 Plugin_Blocked
0xcecb82fcd8e64529 Plugin_ClickToPlay
0xc52b281d793adc6b Plugin_Hide_Click
0x838019f901a8e405 Plugin_Hide_Menu
0x007757ef58e358af Plugin_Load_Click
0xd84554ce585d6c63 Plugin_Load_Menu
0x116bd7e07524f140 Plugin_Load_UI
0x352f2d6315d52044 PrintNow 0x352f2d6315d52044 PrintNow
0xcb83fba9c48fd911 PrintPreview 0xcb83fba9c48fd911 PrintPreview
0x89ad6a22de4ca850 PrintView_PrintDialog 0x89ad6a22de4ca850 PrintView_PrintDialog
......
...@@ -305,6 +305,23 @@ def WalkDirectory(root_path, actions, extensions, callback): ...@@ -305,6 +305,23 @@ def WalkDirectory(root_path, actions, extensions, callback):
if ext in extensions: if ext in extensions:
callback(os.path.join(path, file), actions) callback(os.path.join(path, file), actions)
def GrepForMsgActions(path, actions):
"""Grep a source file for ViewHostMsg_UserMetricsRecordAction.
Arguments:
path: path to the file
actions: set of actions to add to
"""
# We look for the ViewHostMsg_UserMetricsRecordAction constructor.
# This should be on one line.
action_re = re.compile(
r'[^a-zA-Z]ViewHostMsg_UserMetricsRecordAction\("([^"]*)')
line_number = 0
for line in open(path):
match = action_re.search(line)
if match: # Plain call to RecordAction
actions.add(match.group(1))
def AddLiteralActions(actions): def AddLiteralActions(actions):
"""Add literal actions specified via calls to UserMetrics functions. """Add literal actions specified via calls to UserMetrics functions.
...@@ -334,6 +351,20 @@ def AddWebUIActions(actions): ...@@ -334,6 +351,20 @@ def AddWebUIActions(actions):
'resources') 'resources')
WalkDirectory(resources_root, actions, ('.html'), GrepForWebUIActions) WalkDirectory(resources_root, actions, ('.html'), GrepForWebUIActions)
def AddMsgActions(actions):
"""Add user actions sent via ViewHostMsg_UserMetricsRecordAction.
Arguments:
actions: set of actions to add to.
"""
EXTENSIONS = ('.cc', '.mm', '.c', '.m')
chrome_renderer_root = os.path.join(path_utils.ScriptDir(), '..', 'renderer')
content_renderer_root = os.path.join(path_utils.ScriptDir(), '..', '..',
'content', 'renderer')
WalkDirectory(chrome_renderer_root, actions, EXTENSIONS, GrepForMsgActions)
WalkDirectory(content_renderer_root, actions, EXTENSIONS, GrepForMsgActions)
def main(argv): def main(argv):
if '--hash' in argv: if '--hash' in argv:
hash_output = True hash_output = True
...@@ -361,6 +392,7 @@ def main(argv): ...@@ -361,6 +392,7 @@ def main(argv):
# AddWebKitEditorActions(actions) # AddWebKitEditorActions(actions)
AddAboutFlagsActions(actions) AddAboutFlagsActions(actions)
AddWebUIActions(actions) AddWebUIActions(actions)
AddMsgActions(actions)
AddLiteralActions(actions) AddLiteralActions(actions)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment