| OLD | NEW |
| 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/views/location_bar/star_view.h" | 5 #include "chrome/browser/ui/views/location_bar/star_view.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_utils.h" | 10 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 11 #include "chrome/browser/command_updater.h" | 11 #include "chrome/browser/command_updater.h" |
| 12 #include "chrome/browser/ui/view_ids.h" | 12 #include "chrome/browser/ui/view_ids.h" |
| 13 #include "chrome/browser/ui/views/browser_dialogs.h" | 13 #include "chrome/browser/ui/views/browser_dialogs.h" |
| 14 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 14 #include "grit/generated_resources.h" | 15 #include "grit/generated_resources.h" |
| 15 #include "grit/theme_resources.h" | 16 #include "grit/theme_resources.h" |
| 16 #include "ui/base/accessibility/accessible_view_state.h" | 17 #include "ui/base/accessibility/accessible_view_state.h" |
| 17 #include "ui/base/events/event.h" | 18 #include "ui/base/events/event.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
| 19 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
| 20 | 21 |
| 21 StarView::StarView(CommandUpdater* command_updater) | 22 StarView::StarView(CommandUpdater* command_updater) |
| 22 : command_updater_(command_updater), | 23 : command_updater_(command_updater), |
| 23 suppress_mouse_released_action_(false) { | 24 suppress_mouse_released_action_(false) { |
| 24 set_id(VIEW_ID_STAR_BUTTON); | 25 set_id(VIEW_ID_STAR_BUTTON); |
| 25 SetToggled(false); | 26 SetToggled(false); |
| 26 set_accessibility_focusable(true); | 27 set_accessibility_focusable(true); |
| 27 TouchableLocationBarView::Init(this); | 28 LocationBarView::InitTouchableLocationBarView(this); |
| 28 } | 29 } |
| 29 | 30 |
| 30 StarView::~StarView() { | 31 StarView::~StarView() { |
| 31 } | 32 } |
| 32 | 33 |
| 33 int StarView::GetBuiltInHorizontalPadding() const { | |
| 34 return GetBuiltInHorizontalPaddingImpl(); | |
| 35 } | |
| 36 | |
| 37 void StarView::SetToggled(bool on) { | 34 void StarView::SetToggled(bool on) { |
| 38 SetTooltipText(l10n_util::GetStringUTF16( | 35 SetTooltipText(l10n_util::GetStringUTF16( |
| 39 on ? IDS_TOOLTIP_STARRED : IDS_TOOLTIP_STAR)); | 36 on ? IDS_TOOLTIP_STARRED : IDS_TOOLTIP_STAR)); |
| 40 SetImage(ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 37 SetImage(ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 41 on ? IDR_STAR_LIT : IDR_STAR)); | 38 on ? IDR_STAR_LIT : IDR_STAR)); |
| 42 } | 39 } |
| 43 | 40 |
| 44 void StarView::GetAccessibleState(ui::AccessibleViewState* state) { | 41 void StarView::GetAccessibleState(ui::AccessibleViewState* state) { |
| 45 ImageView::GetAccessibleState(state); | 42 ImageView::GetAccessibleState(state); |
| 46 state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; | 43 state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 92 |
| 96 void StarView::OnGestureEvent(ui::GestureEvent* event) { | 93 void StarView::OnGestureEvent(ui::GestureEvent* event) { |
| 97 if (event->type() == ui::ET_GESTURE_TAP) { | 94 if (event->type() == ui::ET_GESTURE_TAP) { |
| 98 UMA_HISTOGRAM_ENUMERATION("Bookmarks.EntryPoint", | 95 UMA_HISTOGRAM_ENUMERATION("Bookmarks.EntryPoint", |
| 99 bookmark_utils::ENTRY_POINT_STAR_GESTURE, | 96 bookmark_utils::ENTRY_POINT_STAR_GESTURE, |
| 100 bookmark_utils::ENTRY_POINT_LIMIT); | 97 bookmark_utils::ENTRY_POINT_LIMIT); |
| 101 command_updater_->ExecuteCommand(IDC_BOOKMARK_PAGE_FROM_STAR); | 98 command_updater_->ExecuteCommand(IDC_BOOKMARK_PAGE_FROM_STAR); |
| 102 event->SetHandled(); | 99 event->SetHandled(); |
| 103 } | 100 } |
| 104 } | 101 } |
| OLD | NEW |