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

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: Change after revised button/menu implementation 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
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
31 // Share intents get command IDs that are beyond the maximal valid command ID 33 // 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 34 // (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. 35 // the menu. Extensions get a reserved block of commands after share handlers.
34 // For more details see: chrome/app/chrome_command_ids.h 36 // For more details see: chrome/app/chrome_command_ids.h
35 const int kMaxShareItemsToShow = 20; // TODO(skare): Show extras in submenu. 37 const int kMaxShareItemsToShow = 20; // TODO(skare): Show extras in submenu.
36 enum ActionBoxLocalCommandIds { 38 enum ActionBoxLocalCommandIds {
37 CWS_FIND_SHARE_INTENTS_COMMAND = 0xE000, 39 CWS_FIND_SHARE_INTENTS_COMMAND = 0xE000,
38 SHARE_COMMAND_FIRST, 40 SHARE_COMMAND_FIRST,
39 SHARE_COMMAND_LAST = 41 SHARE_COMMAND_LAST =
40 SHARE_COMMAND_FIRST + kMaxShareItemsToShow - 1, 42 SHARE_COMMAND_FIRST + kMaxShareItemsToShow - 1,
41 EXTENSION_COMMAND_FIRST 43 EXTENSION_COMMAND_FIRST
42 }; 44 };
43 45
44 const char kShareIntentAction[] = "http://webintents.org/share"; 46 const char kShareIntentAction[] = "http://webintents.org/share";
45 const char kShareIntentMimeType[] = "text/uri-list"; 47 const char kShareIntentMimeType[] = "text/uri-list";
46 48
47 } // namespace 49 } // namespace
48 50
51 using content::UserMetricsAction;
52
49 ActionBoxButtonController::ActionBoxButtonController(Browser* browser, 53 ActionBoxButtonController::ActionBoxButtonController(Browser* browser,
50 Delegate* delegate) 54 Delegate* delegate)
51 : browser_(browser), 55 : browser_(browser),
52 delegate_(delegate), 56 delegate_(delegate),
53 next_extension_command_id_(EXTENSION_COMMAND_FIRST) { 57 next_extension_command_id_(EXTENSION_COMMAND_FIRST),
58 should_send_uma_(true) {
54 DCHECK(browser_); 59 DCHECK(browser_);
55 DCHECK(delegate_); 60 DCHECK(delegate_);
56 registrar_.Add(this, 61 registrar_.Add(this,
57 chrome::NOTIFICATION_EXTENSION_UNLOADED, 62 chrome::NOTIFICATION_EXTENSION_UNLOADED,
58 content::Source<Profile>(browser->profile())); 63 content::Source<Profile>(browser->profile()));
59 } 64 }
60 65
61 ActionBoxButtonController::~ActionBoxButtonController() {} 66 ActionBoxButtonController::~ActionBoxButtonController() {}
62 67
63 void ActionBoxButtonController::OnButtonClicked() { 68 void ActionBoxButtonController::OnButtonClicked() {
(...skipping 29 matching lines...) Expand all
93 // disambiguate. Choosing the first matches the picker behavior; see 98 // disambiguate. Choosing the first matches the picker behavior; see
94 // TODO in WebIntentPickerController::DispatchToInstalledExtension. 99 // TODO in WebIntentPickerController::DispatchToInstalledExtension.
95 share_intent_service_ids_[command_id] = services[0].service_url; 100 share_intent_service_ids_[command_id] = services[0].service_url;
96 menu_model->AddItem(command_id, services[0].title); 101 menu_model->AddItem(command_id, services[0].title);
97 } 102 }
98 } 103 }
99 104
100 // Add link to the Web Store to find additional share intents. 105 // Add link to the Web Store to find additional share intents.
101 menu_model->AddItemWithStringId(CWS_FIND_SHARE_INTENTS_COMMAND, 106 menu_model->AddItemWithStringId(CWS_FIND_SHARE_INTENTS_COMMAND,
102 IDS_FIND_SHARE_INTENTS); 107 IDS_FIND_SHARE_INTENTS);
108
109 content::RecordAction(UserMetricsAction("ActionBox.ClickButton"));
110 if (should_send_uma_) {
skare_ 2012/10/17 00:29:15 logic and stat look good, perhaps call this send_u
Wei Li 2012/10/17 05:23:06 Done.
111 UMA_HISTOGRAM_ENUMERATION("ActionBox.ShareCommandCount",
112 next_share_intent_command_id - SHARE_COMMAND_FIRST,
113 SHARE_COMMAND_LAST);
skare_ 2012/10/17 00:29:15 I'm new to Chrome UMA but should this be kMaxShare
Wei Li 2012/10/17 05:23:06 Done. Nice catch. I didn't notice the start value
114 should_send_uma_ = false;
115 }
103 } 116 }
104 117
105 // Add Extensions. 118 // Add Extensions.
106 next_extension_command_id_ = EXTENSION_COMMAND_FIRST; 119 next_extension_command_id_ = EXTENSION_COMMAND_FIRST;
107 extension_command_ids_.clear(); 120 extension_command_ids_.clear();
108 const extensions::ExtensionList& extensions = 121 const extensions::ExtensionList& extensions =
109 extension_service->toolbar_model()->action_box_menu_items(); 122 extension_service->toolbar_model()->action_box_menu_items();
110 for (extensions::ExtensionList::const_iterator it = extensions.begin(); 123 for (extensions::ExtensionList::const_iterator it = extensions.begin();
111 it != extensions.end(); ++it) { 124 it != extensions.end(); ++it) {
112 menu_model->AddExtension(**it, GetCommandIdForExtension(**it)); 125 menu_model->AddExtension(**it, GetCommandIdForExtension(**it));
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 } 231 }
219 232
220 void ActionBoxButtonController::NavigateToWebStoreShareIntentsList() { 233 void ActionBoxButtonController::NavigateToWebStoreShareIntentsList() {
221 const GURL& query_url = extension_urls::GetWebstoreIntentQueryURL( 234 const GURL& query_url = extension_urls::GetWebstoreIntentQueryURL(
222 kShareIntentAction, 235 kShareIntentAction,
223 kShareIntentMimeType); 236 kShareIntentMimeType);
224 chrome::NavigateParams params(browser_->profile(), query_url, 237 chrome::NavigateParams params(browser_->profile(), query_url,
225 content::PAGE_TRANSITION_LINK); 238 content::PAGE_TRANSITION_LINK);
226 params.disposition = NEW_FOREGROUND_TAB; 239 params.disposition = NEW_FOREGROUND_TAB;
227 chrome::Navigate(&params); 240 chrome::Navigate(&params);
241
242 content::RecordAction(UserMetricsAction("ActionBox.FindShares"));
243 should_send_uma_ = true;
228 } 244 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/toolbar/action_box_button_controller.h ('k') | chrome/tools/chromeactions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698