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

Unified Diff: chrome/browser/ui/views/location_bar/location_bar_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/location_bar_view.cc
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc
index 424f5c5e50ca62297b50c809cf333cb25e92f917..00c471e473b6326f118997a655889889f1c35efe 100644
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc
@@ -43,6 +43,7 @@
#include "chrome/browser/ui/views/location_bar/ev_bubble_view.h"
#include "chrome/browser/ui/views/location_bar/keyword_hint_view.h"
#include "chrome/browser/ui/views/location_bar/location_icon_view.h"
+#include "chrome/browser/ui/views/location_bar/metro_pin_view.h"
#include "chrome/browser/ui/views/location_bar/page_action_image_view.h"
#include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h"
#include "chrome/browser/ui/views/location_bar/selected_keyword_view.h"
@@ -76,6 +77,10 @@
#include "ui/views/button_drag_utils.h"
#include "ui/views/controls/label.h"
+#if defined(OS_WIN)
+#include "base/win/metro.h"
+#endif
+
#if defined(OS_WIN) && !defined(USE_AURA)
#include "chrome/browser/ui/views/omnibox/omnibox_view_win.h"
#endif
@@ -181,6 +186,7 @@ LocationBarView::LocationBarView(Profile* profile,
keyword_hint_view_(NULL),
zoom_view_(NULL),
star_view_(NULL),
+ metro_pin_view_(NULL),
action_box_button_view_(NULL),
chrome_to_mobile_view_(NULL),
mode_(mode),
@@ -284,6 +290,16 @@ void LocationBarView::Init(views::View* popup_parent_view) {
AddChildView(star_view_);
star_view_->SetVisible(true);
+ // Add the metro pin view, if this is windows and we are running in Metro
+ // mode.
+#if defined(OS_WIN)
+ if (base::win::IsMetroProcess()) {
+ metro_pin_view_ = new MetroPinView(command_updater_);
+ AddChildView(metro_pin_view_);
+ metro_pin_view_->SetVisible(true);
sky 2012/07/20 16:46:41 Default visibility is true.
benwells 2012/07/23 08:03:43 Done. I updated some others as well.
+ }
+#endif
+
// Also disable Chrome To Mobile for off-the-record and non-synced profiles,
// or if the feature is disabled by a command line flag or chrome://flags.
if (!profile_->IsOffTheRecord() && profile_->IsSyncAccessible() &&
@@ -502,6 +518,11 @@ void LocationBarView::ShowStarBubble(const GURL& url, bool newly_bookmarked) {
chrome::ShowBookmarkBubbleView(star_view_, profile_, url, newly_bookmarked);
}
+void LocationBarView::SetMetroPinnedState(bool is_pinned) {
+ if (metro_pin_view_)
+ metro_pin_view_->SetIsPinned(is_pinned);
+}
+
void LocationBarView::SetZoomIconTooltipPercent(int zoom_percent) {
zoom_view_->SetZoomIconTooltipPercent(zoom_percent);
}
@@ -656,6 +677,9 @@ void LocationBarView::Layout() {
if (star_view_ && star_view_->visible())
entry_width -= star_view_->GetPreferredSize().width() + GetItemPadding();
+ if (metro_pin_view_ && metro_pin_view_->visible())
+ entry_width -= metro_pin_view_->GetPreferredSize().width() +
+ GetItemPadding();
if (chrome_to_mobile_view_ && chrome_to_mobile_view_->visible()) {
entry_width -= chrome_to_mobile_view_->GetPreferredSize().width() +
GetItemPadding();
@@ -744,6 +768,14 @@ void LocationBarView::Layout() {
offset -= GetItemPadding() - star_view_->GetBuiltInHorizontalPadding();
}
+ if (metro_pin_view_ && metro_pin_view_->visible()) {
+ offset += metro_pin_view_->GetBuiltInHorizontalPadding();
+ int pin_width = metro_pin_view_->GetPreferredSize().width();
+ offset -= pin_width;
+ metro_pin_view_->SetBounds(offset, location_y, pin_width, location_height);
+ offset -= GetItemPadding() - metro_pin_view_->GetBuiltInHorizontalPadding();
+ }
+
if (chrome_to_mobile_view_ && chrome_to_mobile_view_->visible()) {
offset += chrome_to_mobile_view_->GetBuiltInHorizontalPadding();
int icon_width = chrome_to_mobile_view_->GetPreferredSize().width();
@@ -1128,6 +1160,8 @@ void LocationBarView::RefreshPageActionViews() {
page_action_views_.resize(page_actions_.size());
View* right_anchor = chrome_to_mobile_view_;
sky 2012/07/20 16:46:41 1161-1168 shouldn't be in this if block.
benwells 2012/07/23 08:03:43 Sorry, I don't understand. My understanding is thi
sky 2012/07/23 16:02:17 You're right, my mistake.
if (!right_anchor)
+ right_anchor = metro_pin_view_;
+ if (!right_anchor)
right_anchor = star_view_;
if (!right_anchor)
right_anchor = action_box_button_view_;

Powered by Google App Engine
This is Rietveld 408576698