OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "chrome/browser/ui/views/location_bar/metro_pin_view.h" |
| 6 |
| 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/app/chrome_command_ids.h" |
| 9 #include "chrome/browser/command_updater.h" |
| 10 #include "chrome/browser/ui/view_ids.h" |
| 11 #include "chrome/browser/ui/views/browser_dialogs.h" |
| 12 #include "grit/generated_resources.h" |
| 13 #include "grit/theme_resources.h" |
| 14 #include "ui/base/accessibility/accessible_view_state.h" |
| 15 #include "ui/base/l10n/l10n_util.h" |
| 16 #include "ui/base/resource/resource_bundle.h" |
| 17 |
| 18 MetroPinView::MetroPinView(CommandUpdater* command_updater) |
| 19 : ALLOW_THIS_IN_INITIALIZER_LIST(ImageButton(this)), |
| 20 command_updater_(command_updater) { |
| 21 set_id(VIEW_ID_METRO_PIN); |
| 22 SetImageAlignment(ALIGN_CENTER, ALIGN_MIDDLE); |
| 23 SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_METRO_PIN)); |
| 24 TouchableLocationBarView::Init(this); |
| 25 SetIsPinned(false); |
| 26 } |
| 27 |
| 28 MetroPinView::~MetroPinView() {} |
| 29 |
| 30 void MetroPinView::SetIsPinned(bool is_pinned) { |
| 31 SetTooltipText(l10n_util::GetStringUTF16( |
| 32 is_pinned ? IDS_TOOLTIP_METRO_PINNED : IDS_TOOLTIP_METRO_PIN)); |
| 33 SetImage(BS_NORMAL, ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 34 is_pinned ? IDR_METRO_PINNED : IDR_METRO_PIN)); |
| 35 } |
| 36 |
| 37 void MetroPinView::ButtonPressed(Button* sender, const views::Event& event) { |
| 38 command_updater_->ExecuteCommand(IDC_METRO_PIN_TO_START_SCREEN); |
| 39 } |
| 40 |
| 41 int MetroPinView::GetBuiltInHorizontalPadding() const { |
| 42 return GetBuiltInHorizontalPaddingImpl(); |
| 43 } |
OLD | NEW |