1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/bookmarks/bookmark_stats.h"
7 #include "base/metrics/histogram.h"
8 #include "components/bookmarks/browser/bookmark_model.h"
9 #include "content/public/browser/user_metrics.h"
11 using bookmarks::BookmarkNode
;
13 void RecordBookmarkLaunch(const BookmarkNode
* node
,
14 BookmarkLaunchLocation location
) {
15 if (location
== BOOKMARK_LAUNCH_LOCATION_DETACHED_BAR
||
16 location
== BOOKMARK_LAUNCH_LOCATION_ATTACHED_BAR
) {
17 content::RecordAction(
18 base::UserMetricsAction("ClickedBookmarkBarURLButton"));
20 UMA_HISTOGRAM_ENUMERATION(
21 "Bookmarks.LaunchLocation", location
, BOOKMARK_LAUNCH_LOCATION_LIMIT
);
26 // In the cases where a bookmark node is provided, record the depth of the
27 // bookmark in the tree.
29 for (const BookmarkNode
* iter
= node
; iter
!= NULL
; iter
= iter
->parent()) {
32 // Record |depth - 2| to offset the invisible root node and permanent nodes
33 // (Bookmark Bar, Mobile Bookmarks or Other Bookmarks)
34 UMA_HISTOGRAM_COUNTS("Bookmarks.LaunchDepth", depth
- 2);
37 void RecordBookmarkFolderOpen(BookmarkLaunchLocation location
) {
38 if (location
== BOOKMARK_LAUNCH_LOCATION_DETACHED_BAR
||
39 location
== BOOKMARK_LAUNCH_LOCATION_ATTACHED_BAR
) {
40 content::RecordAction(
41 base::UserMetricsAction("ClickedBookmarkBarFolder"));
45 void RecordBookmarkAppsPageOpen(BookmarkLaunchLocation location
) {
46 if (location
== BOOKMARK_LAUNCH_LOCATION_DETACHED_BAR
||
47 location
== BOOKMARK_LAUNCH_LOCATION_ATTACHED_BAR
) {
48 content::RecordAction(
49 base::UserMetricsAction("ClickedBookmarkBarAppsShortcutButton"));