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

Side by Side Diff: chrome/browser/ui/toolbar/action_box_button_controller.cc

Issue 11017042: Added UMA metrics for ActionBox (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months 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
« no previous file with comments | « no previous file | chrome/tools/chromeactions.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/toolbar/action_box_button_controller.h" 5 #include "chrome/browser/ui/toolbar/action_box_button_controller.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/metrics/histogram.h"
8 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/extensions/extension_system.h" 11 #include "chrome/browser/extensions/extension_system.h"
11 #include "chrome/browser/intents/web_intents_registry_factory.h" 12 #include "chrome/browser/intents/web_intents_registry_factory.h"
12 #include "chrome/browser/intents/web_intents_registry.h" 13 #include "chrome/browser/intents/web_intents_registry.h"
13 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_commands.h" 16 #include "chrome/browser/ui/browser_commands.h"
16 #include "chrome/browser/ui/browser_tabstrip.h" 17 #include "chrome/browser/ui/browser_tabstrip.h"
17 #include "chrome/browser/ui/toolbar/action_box_menu_model.h" 18 #include "chrome/browser/ui/toolbar/action_box_menu_model.h"
18 #include "chrome/common/chrome_notification_types.h" 19 #include "chrome/common/chrome_notification_types.h"
19 #include "chrome/common/extensions/extension.h" 20 #include "chrome/common/extensions/extension.h"
20 #include "chrome/common/extensions/extension_set.h" 21 #include "chrome/common/extensions/extension_set.h"
21 #include "content/public/browser/notification_service.h" 22 #include "content/public/browser/notification_service.h"
22 #include "content/public/browser/notification_source.h" 23 #include "content/public/browser/notification_source.h"
24 #include "content/public/browser/user_metrics.h"
23 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
24 #include "content/public/browser/web_intents_dispatcher.h" 26 #include "content/public/browser/web_intents_dispatcher.h"
25 #include "grit/generated_resources.h" 27 #include "grit/generated_resources.h"
26 #include "webkit/glue/web_intent_data.h" 28 #include "webkit/glue/web_intent_data.h"
27 #include "webkit/glue/webkit_glue.h" 29 #include "webkit/glue/webkit_glue.h"
28 30
29 namespace { 31 namespace {
30 32
33 // This indicates we need to send UMA data about the number of
34 // "Share with X" commands shown in the menu after user tried to
35 // find share extensions from web store or the first use of action
36 // box after browser starts.
37 static bool send_uma_share_command_count = true;
38
31 // Share intents get command IDs that are beyond the maximal valid command ID 39 // Share intents get command IDs that are beyond the maximal valid command ID
32 // (0xDFFF) so that they are not confused with actual commands that appear in 40 // (0xDFFF) so that they are not confused with actual commands that appear in
33 // the menu. Extensions get a reserved block of commands after share handlers. 41 // the menu. Extensions get a reserved block of commands after share handlers.
34 // For more details see: chrome/app/chrome_command_ids.h 42 // For more details see: chrome/app/chrome_command_ids.h
35 const int kMaxShareItemsToShow = 20; // TODO(skare): Show extras in submenu. 43 const int kMaxShareItemsToShow = 20; // TODO(skare): Show extras in submenu.
36 enum ActionBoxLocalCommandIds { 44 enum ActionBoxLocalCommandIds {
37 CWS_FIND_SHARE_INTENTS_COMMAND = 0xE000, 45 CWS_FIND_SHARE_INTENTS_COMMAND = 0xE000,
38 SHARE_COMMAND_FIRST, 46 SHARE_COMMAND_FIRST,
39 SHARE_COMMAND_LAST = 47 SHARE_COMMAND_LAST =
40 SHARE_COMMAND_FIRST + kMaxShareItemsToShow - 1, 48 SHARE_COMMAND_FIRST + kMaxShareItemsToShow - 1,
41 EXTENSION_COMMAND_FIRST 49 EXTENSION_COMMAND_FIRST
42 }; 50 };
43 51
44 const char kShareIntentAction[] = "http://webintents.org/share"; 52 const char kShareIntentAction[] = "http://webintents.org/share";
45 const char kShareIntentMimeType[] = "text/uri-list"; 53 const char kShareIntentMimeType[] = "text/uri-list";
46 54
47 } // namespace 55 } // namespace
48 56
57 using content::UserMetricsAction;
58
49 ActionBoxButtonController::ActionBoxButtonController(Browser* browser, 59 ActionBoxButtonController::ActionBoxButtonController(Browser* browser,
50 Delegate* delegate) 60 Delegate* delegate)
51 : browser_(browser), 61 : browser_(browser),
52 delegate_(delegate), 62 delegate_(delegate),
53 next_extension_command_id_(EXTENSION_COMMAND_FIRST) { 63 next_extension_command_id_(EXTENSION_COMMAND_FIRST) {
54 DCHECK(browser_); 64 DCHECK(browser_);
55 DCHECK(delegate_); 65 DCHECK(delegate_);
56 registrar_.Add(this, 66 registrar_.Add(this,
57 chrome::NOTIFICATION_EXTENSION_UNLOADED, 67 chrome::NOTIFICATION_EXTENSION_UNLOADED,
58 content::Source<Profile>(browser->profile())); 68 content::Source<Profile>(browser->profile()));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 // disambiguate. Choosing the first matches the picker behavior; see 103 // disambiguate. Choosing the first matches the picker behavior; see
94 // TODO in WebIntentPickerController::DispatchToInstalledExtension. 104 // TODO in WebIntentPickerController::DispatchToInstalledExtension.
95 share_intent_service_ids_[command_id] = services[0].service_url; 105 share_intent_service_ids_[command_id] = services[0].service_url;
96 menu_model->AddItem(command_id, services[0].title); 106 menu_model->AddItem(command_id, services[0].title);
97 } 107 }
98 } 108 }
99 109
100 // Add link to the Web Store to find additional share intents. 110 // Add link to the Web Store to find additional share intents.
101 menu_model->AddItemWithStringId(CWS_FIND_SHARE_INTENTS_COMMAND, 111 menu_model->AddItemWithStringId(CWS_FIND_SHARE_INTENTS_COMMAND,
102 IDS_FIND_SHARE_INTENTS); 112 IDS_FIND_SHARE_INTENTS);
113
114 content::RecordAction(UserMetricsAction("ActionBox.ClickButton"));
115 if (send_uma_share_command_count) {
116 UMA_HISTOGRAM_ENUMERATION("ActionBox.ShareCommandCount",
117 next_share_intent_command_id - SHARE_COMMAND_FIRST,
118 kMaxShareItemsToShow + 1);
119 send_uma_share_command_count = false;
120 }
103 } 121 }
104 122
105 // Add Extensions. 123 // Add Extensions.
106 next_extension_command_id_ = EXTENSION_COMMAND_FIRST; 124 next_extension_command_id_ = EXTENSION_COMMAND_FIRST;
107 extension_command_ids_.clear(); 125 extension_command_ids_.clear();
108 const extensions::ExtensionList& extensions = 126 const extensions::ExtensionList& extensions =
109 extension_service->toolbar_model()->action_box_menu_items(); 127 extension_service->toolbar_model()->action_box_menu_items();
110 for (extensions::ExtensionList::const_iterator it = extensions.begin(); 128 for (extensions::ExtensionList::const_iterator it = extensions.begin();
111 it != extensions.end(); ++it) { 129 it != extensions.end(); ++it) {
112 menu_model->AddExtension(**it, GetCommandIdForExtension(**it)); 130 menu_model->AddExtension(**it, GetCommandIdForExtension(**it));
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 } 236 }
219 237
220 void ActionBoxButtonController::NavigateToWebStoreShareIntentsList() { 238 void ActionBoxButtonController::NavigateToWebStoreShareIntentsList() {
221 const GURL& query_url = extension_urls::GetWebstoreIntentQueryURL( 239 const GURL& query_url = extension_urls::GetWebstoreIntentQueryURL(
222 kShareIntentAction, 240 kShareIntentAction,
223 kShareIntentMimeType); 241 kShareIntentMimeType);
224 chrome::NavigateParams params(browser_->profile(), query_url, 242 chrome::NavigateParams params(browser_->profile(), query_url,
225 content::PAGE_TRANSITION_LINK); 243 content::PAGE_TRANSITION_LINK);
226 params.disposition = NEW_FOREGROUND_TAB; 244 params.disposition = NEW_FOREGROUND_TAB;
227 chrome::Navigate(&params); 245 chrome::Navigate(&params);
246
247 content::RecordAction(UserMetricsAction("ActionBox.FindShareHandlers"));
248 send_uma_share_command_count = true;
228 } 249 }
OLDNEW
« no previous file with comments | « no previous file | chrome/tools/chromeactions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698