Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / views / location_bar / star_view.cc
blob368119d2ce84df528fcfa8049fbf495bf7cb636b
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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/views/location_bar/star_view.h"
7 #include "base/metrics/histogram.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/bookmarks/bookmark_stats.h"
11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/browser_commands.h"
13 #include "chrome/browser/ui/view_ids.h"
14 #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h"
15 #include "chrome/grit/generated_resources.h"
16 #include "grit/theme_resources.h"
17 #include "ui/base/l10n/l10n_util.h"
18 #include "ui/base/resource/resource_bundle.h"
20 StarView::StarView(CommandUpdater* command_updater, Browser* browser)
21 : BubbleIconView(command_updater, IDC_BOOKMARK_PAGE), browser_(browser) {
22 set_id(VIEW_ID_STAR_BUTTON);
23 SetToggled(false);
26 StarView::~StarView() {}
28 void StarView::SetToggled(bool on) {
29 SetTooltipText(l10n_util::GetStringUTF16(
30 on ? IDS_TOOLTIP_STARRED : IDS_TOOLTIP_STAR));
31 SetImage(ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
32 on ? IDR_STAR_LIT : IDR_STAR));
35 bool StarView::IsBubbleShowing() const {
36 return BookmarkBubbleView::IsShowing();
39 void StarView::OnExecuting(
40 BubbleIconView::ExecuteSource execute_source) {
41 BookmarkEntryPoint entry_point = BOOKMARK_ENTRY_POINT_STAR_MOUSE;
42 switch (execute_source) {
43 case EXECUTE_SOURCE_MOUSE:
44 entry_point = BOOKMARK_ENTRY_POINT_STAR_MOUSE;
45 break;
46 case EXECUTE_SOURCE_KEYBOARD:
47 entry_point = BOOKMARK_ENTRY_POINT_STAR_KEY;
48 break;
49 case EXECUTE_SOURCE_GESTURE:
50 entry_point = BOOKMARK_ENTRY_POINT_STAR_GESTURE;
51 break;
53 UMA_HISTOGRAM_ENUMERATION("Bookmarks.EntryPoint",
54 entry_point,
55 BOOKMARK_ENTRY_POINT_LIMIT);
58 void StarView::ExecuteCommand(ExecuteSource source) {
59 if (browser_) {
60 OnExecuting(source);
61 chrome::BookmarkCurrentPageIgnoringExtensionOverrides(browser_);
62 } else {
63 BubbleIconView::ExecuteCommand(source);