Home | History | Annotate | Download | only in bookmarks
      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.
      4 
      5 #include "chrome/browser/bookmarks/bookmark_stats.h"
      6 
      7 #include "base/metrics/histogram.h"
      8 #include "components/bookmarks/browser/bookmark_model.h"
      9 #include "content/public/browser/user_metrics.h"
     10 
     11 void RecordBookmarkLaunch(const BookmarkNode* node,
     12                           BookmarkLaunchLocation location) {
     13   if (location == BOOKMARK_LAUNCH_LOCATION_DETACHED_BAR ||
     14       location == BOOKMARK_LAUNCH_LOCATION_ATTACHED_BAR) {
     15     content::RecordAction(
     16         base::UserMetricsAction("ClickedBookmarkBarURLButton"));
     17   }
     18   UMA_HISTOGRAM_ENUMERATION(
     19       "Bookmarks.LaunchLocation", location, BOOKMARK_LAUNCH_LOCATION_LIMIT);
     20 
     21   if (!node)
     22     return;
     23 
     24   // In the cases where a bookmark node is provided, record the depth of the
     25   // bookmark in the tree.
     26   int depth = 0;
     27   for (const BookmarkNode* iter = node; iter != NULL; iter = iter->parent()) {
     28     depth++;
     29   }
     30   // Record |depth - 2| to offset the invisible root node and permanent nodes
     31   // (Bookmark Bar, Mobile Bookmarks or Other Bookmarks)
     32   UMA_HISTOGRAM_COUNTS("Bookmarks.LaunchDepth", depth - 2);
     33 }
     34 
     35 void RecordBookmarkFolderOpen(BookmarkLaunchLocation location) {
     36   if (location == BOOKMARK_LAUNCH_LOCATION_DETACHED_BAR ||
     37       location == BOOKMARK_LAUNCH_LOCATION_ATTACHED_BAR) {
     38     content::RecordAction(
     39         base::UserMetricsAction("ClickedBookmarkBarFolder"));
     40   }
     41 }
     42 
     43 void RecordBookmarkAppsPageOpen(BookmarkLaunchLocation location) {
     44   if (location == BOOKMARK_LAUNCH_LOCATION_DETACHED_BAR ||
     45       location == BOOKMARK_LAUNCH_LOCATION_ATTACHED_BAR) {
     46     content::RecordAction(
     47         base::UserMetricsAction("ClickedBookmarkBarAppsShortcutButton"));
     48   }
     49 }
     50