Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1239)

Unified Diff: chrome/browser/ui/views/location_bar/metro_pin_view.cc

Issue 10800054: Add pin icon to the omnibar in windows 8 metro mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/location_bar/metro_pin_view.cc
diff --git a/chrome/browser/ui/views/location_bar/metro_pin_view.cc b/chrome/browser/ui/views/location_bar/metro_pin_view.cc
new file mode 100644
index 0000000000000000000000000000000000000000..693a4f609e9937df2e535671a8bb621ca49269ce
--- /dev/null
+++ b/chrome/browser/ui/views/location_bar/metro_pin_view.cc
@@ -0,0 +1,72 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/views/location_bar/metro_pin_view.h"
+
+#include "base/utf_string_conversions.h"
+#include "chrome/app/chrome_command_ids.h"
+#include "chrome/browser/command_updater.h"
+#include "chrome/browser/ui/view_ids.h"
+#include "chrome/browser/ui/views/browser_dialogs.h"
+#include "grit/generated_resources.h"
+#include "grit/theme_resources.h"
+#include "ui/base/accessibility/accessible_view_state.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/resource/resource_bundle.h"
+
+MetroPinView::MetroPinView(CommandUpdater* command_updater)
+ : command_updater_(command_updater) {
+ set_id(VIEW_ID_STAR_BUTTON);
sky 2012/07/20 16:46:41 This isn't the right id.
benwells 2012/07/23 08:03:43 Done.
+ SetIsPinned(false);
+ set_accessibility_focusable(true);
+ TouchableLocationBarView::Init(this);
+}
+
+MetroPinView::~MetroPinView() {
+}
+
+void MetroPinView::SetIsPinned(bool is_pinned) {
+ SetTooltipText(l10n_util::GetStringUTF16(
+ is_pinned ? IDS_TOOLTIP_METRO_PINNED : IDS_TOOLTIP_METRO_PIN));
+ SetImage(ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
+ is_pinned ? IDR_METRO_PINNED : IDR_METRO_PIN));
+}
+
+int MetroPinView::GetBuiltInHorizontalPadding() const {
+ return GetBuiltInHorizontalPaddingImpl();
+}
+
+void MetroPinView::GetAccessibleState(ui::AccessibleViewState* state) {
+ state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_METRO_PIN);
+ state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON;
+}
+
+bool MetroPinView::OnMousePressed(const views::MouseEvent& event) {
+ // We want to show the bubble on mouse release; that is the standard behavior
sky 2012/07/20 16:46:41 The reason StarView isn't a button is that it show
benwells 2012/07/23 08:03:43 Cool, that's much better!
+ // for buttons.
+ return true;
+}
+
+void MetroPinView::OnMouseReleased(const views::MouseEvent& event) {
+ if (event.IsOnlyLeftMouseButton() && HitTest(event.location()))
+ command_updater_->ExecuteCommand(IDC_METRO_PIN_TO_START_SCREEN);
+}
+
+ui::GestureStatus MetroPinView::OnGestureEvent(
+ const views::GestureEvent& event) {
+ if (event.type() == ui::ET_GESTURE_TAP) {
+ command_updater_->ExecuteCommand(IDC_METRO_PIN_TO_START_SCREEN);
+ return ui::GESTURE_STATUS_CONSUMED;
+ }
+ return ui::GESTURE_STATUS_UNKNOWN;
+}
+
+bool MetroPinView::OnKeyPressed(const views::KeyEvent& event) {
+ if (event.key_code() == ui::VKEY_SPACE ||
+ event.key_code() == ui::VKEY_RETURN) {
+ command_updater_->ExecuteCommand(IDC_METRO_PIN_TO_START_SCREEN);
+ return true;
+ }
+ return false;
+}

Powered by Google App Engine
This is Rietveld 408576698