Commit 19de1d79 authored by benwells@chromium.org's avatar benwells@chromium.org

Add pin icon to the omnibar in windows 8 metro mode.

The pin icon allows pinning and unpinning the start screen. The icon used changes depending on whether the page is currently pinned or not.

BUG=129598
TEST=Test pages can be pinned and unpinned from metro mode


Review URL: https://chromiumcodereview.appspot.com/10800054

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148511 0039d316-1c4b-4281-b951-d872f2087c98
parent 4186d875
......@@ -36,7 +36,7 @@
// Window management commands
#define IDC_NEW_WINDOW 34000
#define IDC_NEW_INCOGNITO_WINDOW 34001
#define IDC_PIN_TO_START_SCREEN 34005
#define IDC_METRO_PIN_TO_START_SCREEN 34005
#define IDC_CLOSE_WINDOW 34012
#define IDC_ALWAYS_ON_TOP 34013
#define IDC_NEW_TAB 34014
......
......@@ -945,10 +945,10 @@ Psst! Incognito mode <ph name="SHORTCUT_KEY">$1<ex>(Ctrl+Shift+N)</ex></ph> may
<message name="IDS_NEW_INCOGNITO_WINDOW" desc="The text label of the New incognito window menu item">
New &amp;incognito window
</message>
<message name="IDS_PIN_TO_START_SCREEN" desc="The text label of the Pin to start screen menu item">
<message name="IDS_METRO_PIN_TO_START_SCREEN" desc="The text label of the Pin to start screen menu item">
Pin to Start Screen
</message>
<message name="IDS_UNPIN_FROM_START_SCREEN" desc="The text label of the unpin from start screen menu item">
<message name="IDS_METRO_UNPIN_FROM_START_SCREEN" desc="The text label of the unpin from start screen menu item">
Unpin from Start Screen
</message>
<message name="IDS_EDIT2" desc="The text label before the cut/copy/paste buttons in the merged menu">
......@@ -1037,10 +1037,10 @@ Psst! Incognito mode <ph name="SHORTCUT_KEY">$1<ex>(Ctrl+Shift+N)</ex></ph> may
<message name="IDS_NEW_INCOGNITO_WINDOW" desc="In Title Case: The text label of the New incognito window menu item">
New &amp;Incognito Window
</message>
<message name="IDS_PIN_TO_START_SCREEN" desc="In Title Case: The text label of the Pin to start screen menu item">
<message name="IDS_METRO_PIN_TO_START_SCREEN" desc="In Title Case: The text label of the Pin to start screen menu item">
Pin to Start Screen
</message>
<message name="IDS_UNPIN_FROM_START_SCREEN" desc="In Title Case: The text label of the Unpin from start screen menu item">
<message name="IDS_METRO_UNPIN_FROM_START_SCREEN" desc="In Title Case: The text label of the Unpin from start screen menu item">
Unpin from Start Screen
</message>
<message name="IDS_UNDO" desc="In Title Case: The text label of the Undo menu item">
......@@ -6392,6 +6392,12 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_TOOLTIP_HOME" desc="The tooltip for the home button">
Open the home page
</message>
<message name="IDS_TOOLTIP_METRO_PIN" desc="The tooltip for the pin button">
Pin this page to the start menu
</message>
<message name="IDS_TOOLTIP_METRO_PINNED" desc="The tooltip for the pin button when the page is pinned">
Unpin this page from the start menu
</message>
<message name="IDS_TOOLTIP_RELOAD" desc="The tooltip for reload button">
Reload this page
</message>
......@@ -6448,6 +6454,9 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_ACCNAME_LOCATION" desc="The accessible name for the location bar edit field.">
Address
</message>
<message name="IDS_ACCNAME_METRO_PIN" desc="The accessible name for the pin button.">
Pin
</message>
<message name="IDS_ACCNAME_STAR" desc="The accessible name for the bookmark button.">
Bookmark
</message>
......
......@@ -497,6 +497,10 @@
<structure type="chrome_scaled_image" name="IDR_PANEL_RESTORE" file="panel_restore.png" />
<structure type="chrome_scaled_image" name="IDR_PANEL_RESTORE_C" file="panel_restore_click.png" />
<structure type="chrome_scaled_image" name="IDR_PANEL_RESTORE_H" file="panel_restore_hover.png" />
<if expr="is_win">
<structure type="chrome_scaled_image" name="IDR_METRO_PIN" file="metro_pin.png" />
<structure type="chrome_scaled_image" name="IDR_METRO_PINNED" file="metro_pinned.png" />
</if>
<structure type="chrome_scaled_image" name="IDR_PLUGIN" file="plugin.png" />
<structure type="chrome_scaled_image" name="IDR_PRERENDER" file="prerender_succeed_icon.png" />
<structure type="chrome_scaled_image" name="IDR_PRERENDER_FAIL_ICON" file="prerender_fail_icon.png" />
......
......@@ -351,7 +351,7 @@ void BrowserCommandController::ExecuteCommandWithDisposition(
case IDC_BOOKMARK_PAGE:
BookmarkCurrentPage(browser_);
break;
case IDC_PIN_TO_START_SCREEN:
case IDC_METRO_PIN_TO_START_SCREEN:
TogglePagePinnedToStartScreen(browser_);
break;
case IDC_BOOKMARK_ALL_TABS:
......@@ -930,7 +930,7 @@ void BrowserCommandController::UpdateCommandsForBookmarkEditing() {
CanBookmarkCurrentPage(browser_));
command_updater_.UpdateCommandEnabled(IDC_BOOKMARK_ALL_TABS,
CanBookmarkAllTabs(browser_));
command_updater_.UpdateCommandEnabled(IDC_PIN_TO_START_SCREEN,
command_updater_.UpdateCommandEnabled(IDC_METRO_PIN_TO_START_SCREEN,
true);
}
......
......@@ -71,7 +71,8 @@ class ViewIDTest : public InProcessBrowserTest {
i == VIEW_ID_CONTENTS_SPLIT ||
i == VIEW_ID_FEEDBACK_BUTTON ||
i == VIEW_ID_OMNIBOX ||
i == VIEW_ID_CHROME_TO_MOBILE_BUTTON) {
i == VIEW_ID_CHROME_TO_MOBILE_BUTTON ||
i == VIEW_ID_METRO_PIN) {
continue;
}
......
......@@ -44,7 +44,8 @@ IN_PROC_BROWSER_TEST_F(ViewIDTest, Basic) {
i == VIEW_ID_BOOKMARK_BAR_ELEMENT ||
i == VIEW_ID_TAB ||
i == VIEW_ID_FEEDBACK_BUTTON ||
i == VIEW_ID_OMNIBOX) {
i == VIEW_ID_OMNIBOX ||
i == VIEW_ID_METRO_PIN) {
continue;
}
......
......@@ -6,6 +6,7 @@
#include "base/logging.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/ui/metro_pinned_state_observer.h"
#include "content/public/browser/web_contents.h"
#if defined(OS_WIN)
......@@ -14,7 +15,8 @@
MetroPinTabHelper::MetroPinTabHelper(content::WebContents* web_contents)
: content::WebContentsObserver(web_contents),
is_pinned_(false) {}
is_pinned_(false),
observer_(NULL) {}
MetroPinTabHelper::~MetroPinTabHelper() {}
......@@ -40,8 +42,7 @@ void MetroPinTabHelper::TogglePinnedToStartScreen() {
// TODO(benwells): This will update the state incorrectly if the user
// cancels. To fix this some sort of callback needs to be introduced as
// the pinning happens on another thread.
is_pinned_ = !is_pinned_;
return;
SetIsPinned(!is_pinned_);
}
#endif
}
......@@ -66,9 +67,16 @@ void MetroPinTabHelper::UpdatePinnedStateForCurrentURL() {
}
GURL url = web_contents()->GetURL();
is_pinned_ = metro_is_pinned_to_start_screen(UTF8ToUTF16(url.spec())) != 0;
SetIsPinned(metro_is_pinned_to_start_screen(UTF8ToUTF16(url.spec())) != 0);
VLOG(1) << __FUNCTION__ << " with url " << UTF8ToUTF16(url.spec())
<< " result: " << is_pinned_;
}
#endif
}
void MetroPinTabHelper::SetIsPinned(bool is_pinned) {
bool was_pinned = is_pinned_;
is_pinned_ = is_pinned;
if (observer_ && is_pinned_ != was_pinned)
observer_->MetroPinnedStateChanged(web_contents(), is_pinned_);
}
......@@ -7,14 +7,20 @@
#include "content/public/browser/web_contents_observer.h"
class MetroPinnedStateObserver;
// Per-tab class to help manage metro pinning.
class MetroPinTabHelper : public content::WebContentsObserver {
public:
explicit MetroPinTabHelper(content::WebContents* tab_contents);
explicit MetroPinTabHelper(content::WebContents* web_contents);
virtual ~MetroPinTabHelper();
bool is_pinned() const { return is_pinned_; }
void set_observer(MetroPinnedStateObserver* observer) {
observer_ = observer;
}
void TogglePinnedToStartScreen();
// content::WebContentsObserver overrides:
......@@ -26,9 +32,15 @@ class MetroPinTabHelper : public content::WebContentsObserver {
// Queries the metro driver about the pinned state of the current URL.
void UpdatePinnedStateForCurrentURL();
// Update the pinned state and notify the delegate.
void SetIsPinned(bool is_pinned);
// Whether the current URL is pinned to the metro start screen.
bool is_pinned_;
// The observer that we inform when the |is_pinned_| state changes.
MetroPinnedStateObserver* observer_;
DISALLOW_COPY_AND_ASSIGN(MetroPinTabHelper);
};
......
// 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.
#ifndef CHROME_BROWSER_UI_METRO_PINNED_STATE_OBSERVER_H_
#define CHROME_BROWSER_UI_METRO_PINNED_STATE_OBSERVER_H_
namespace content {
class WebContents;
}
// Objects implement this interface to get notified about changes in the
// metro pinned state.
class MetroPinnedStateObserver {
public:
// Notification that the pinned state of the current URL changed.
virtual void MetroPinnedStateChanged(content::WebContents* source,
bool is_pinned) = 0;
protected:
virtual ~MetroPinnedStateObserver() {}
};
#endif // CHROME_BROWSER_UI_METRO_PINNED_STATE_OBSERVER_H_
......@@ -242,7 +242,7 @@ bool WrenchMenuModel::IsItemForCommandIdDynamic(int command_id) const {
command_id == IDC_VIEW_BACKGROUND_PAGES ||
command_id == IDC_UPGRADE_DIALOG ||
command_id == IDC_SHOW_SYNC_SETUP ||
command_id == IDC_PIN_TO_START_SCREEN;
command_id == IDC_METRO_PIN_TO_START_SCREEN;
}
string16 WrenchMenuModel::GetLabelForCommandId(int command_id) const {
......@@ -284,11 +284,11 @@ string16 WrenchMenuModel::GetLabelForCommandId(int command_id) const {
return l10n_util::GetStringFUTF16(IDS_SYNC_MENU_PRE_SYNCED_LABEL,
l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME));
}
case IDC_PIN_TO_START_SCREEN: {
int string_id = IDS_PIN_TO_START_SCREEN;
case IDC_METRO_PIN_TO_START_SCREEN: {
int string_id = IDS_METRO_PIN_TO_START_SCREEN;
TabContents* tab_contents = chrome::GetActiveTabContents(browser_);
if (tab_contents && tab_contents->metro_pin_tab_helper()->is_pinned()) {
string_id = IDS_UNPIN_FROM_START_SCREEN;
string_id = IDS_METRO_UNPIN_FROM_START_SCREEN;
}
return l10n_util::GetStringUTF16(string_id);
}
......@@ -384,11 +384,11 @@ bool WrenchMenuModel::IsCommandIdVisible(int command_id) const {
return false;
loaded_modules->AcknowledgeConflictNotification();
return true;
} else if (command_id == IDC_PIN_TO_START_SCREEN) {
} else if (command_id == IDC_METRO_PIN_TO_START_SCREEN) {
return base::win::IsMetroProcess();
#else
if (command_id == IDC_VIEW_INCOMPATIBILITIES ||
command_id == IDC_PIN_TO_START_SCREEN) {
command_id == IDC_METRO_PIN_TO_START_SCREEN) {
return false;
#endif
} else if (command_id == IDC_UPGRADE_DIALOG) {
......@@ -461,7 +461,8 @@ void WrenchMenuModel::Build() {
AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, IDS_NEW_INCOGNITO_WINDOW);
#endif
AddItemWithStringId(IDC_PIN_TO_START_SCREEN, IDS_PIN_TO_START_SCREEN);
AddItemWithStringId(IDC_METRO_PIN_TO_START_SCREEN,
IDS_METRO_PIN_TO_START_SCREEN);
bookmark_sub_menu_model_.reset(new BookmarkSubMenuModel(this, browser_));
AddSubMenuWithStringId(IDC_BOOKMARKS_MENU, IDS_BOOKMARKS_MENU,
bookmark_sub_menu_model_.get());
......
......@@ -46,6 +46,7 @@ enum ViewID {
VIEW_ID_FEEDBACK_BUTTON,
VIEW_ID_OMNIBOX,
VIEW_ID_CHROME_TO_MOBILE_BUTTON,
VIEW_ID_METRO_PIN,
// The Bookmark Bar.
VIEW_ID_BOOKMARK_BAR,
......
......@@ -39,6 +39,7 @@
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window_state.h"
#include "chrome/browser/ui/metro_pin_tab_helper.h"
#include "chrome/browser/ui/omnibox/omnibox_popup_model.h"
#include "chrome/browser/ui/omnibox/omnibox_popup_view.h"
#include "chrome/browser/ui/omnibox/omnibox_view.h"
......@@ -943,6 +944,8 @@ void BrowserView::UpdateReloadStopState(bool is_loading, bool force) {
void BrowserView::UpdateToolbar(TabContents* contents,
bool should_restore_state) {
toolbar_->Update(contents->web_contents(), should_restore_state);
GetLocationBarView()->SetMetroPinnedState(
contents->metro_pin_tab_helper()->is_pinned());
}
void BrowserView::FocusToolbar() {
......@@ -1413,7 +1416,14 @@ ToolbarView* BrowserView::GetToolbarView() const {
///////////////////////////////////////////////////////////////////////////////
// BrowserView, TabStripModelObserver implementation:
void BrowserView::TabInsertedAt(TabContents* contents,
int index,
bool foreground) {
contents->metro_pin_tab_helper()->set_observer(this);
}
void BrowserView::TabDetachedAt(TabContents* contents, int index) {
contents->metro_pin_tab_helper()->set_observer(NULL);
// We use index here rather than comparing |contents| because by this time
// the model has already removed |contents| from its list, so
// browser_->GetActiveWebContents() will return NULL or something else.
......@@ -1450,6 +1460,8 @@ void BrowserView::TabReplacedAt(TabStripModel* tab_strip_model,
TabContents* old_contents,
TabContents* new_contents,
int index) {
new_contents->metro_pin_tab_helper()->set_observer(this);
if (index != browser_->tab_strip_model()->active_index())
return;
......@@ -1873,6 +1885,12 @@ void BrowserView::OnSysColorChange() {
browser::MaybeShowInvertBubbleView(browser_.get(), contents_);
}
void BrowserView::MetroPinnedStateChanged(content::WebContents* contents,
bool is_pinned) {
if (contents == chrome::GetActiveWebContents(browser()))
GetLocationBarView()->SetMetroPinnedState(is_pinned);
}
int BrowserView::GetOTRIconResourceID() const {
int otr_resource_id = IDR_OTR_ICON;
if (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) {
......
......@@ -16,6 +16,7 @@
#include "chrome/browser/infobars/infobar_container.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/metro_pinned_state_observer.h"
#include "chrome/browser/ui/search/search_types.h"
#include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
#include "chrome/browser/ui/views/frame/browser_frame.h"
......@@ -92,7 +93,8 @@ class BrowserView : public BrowserWindow,
public views::ClientView,
public InfoBarContainer::Delegate,
public views::SingleSplitViewListener,
public gfx::SysColorChangeListener {
public gfx::SysColorChangeListener,
public MetroPinnedStateObserver {
public:
// The browser view's class name.
static const char kViewClassName[];
......@@ -352,6 +354,9 @@ class BrowserView : public BrowserWindow,
virtual ToolbarView* GetToolbarView() const OVERRIDE;
// Overridden from TabStripModelObserver:
virtual void TabInsertedAt(TabContents* contents,
int index,
bool foreground) OVERRIDE;
virtual void TabDetachedAt(TabContents* contents, int index) OVERRIDE;
virtual void TabDeactivated(TabContents* contents) OVERRIDE;
virtual void ActiveTabChanged(TabContents* old_contents,
......@@ -413,6 +418,10 @@ class BrowserView : public BrowserWindow,
// gfx::ScopedSysColorChangeListener overrides:
virtual void OnSysColorChange() OVERRIDE;
// MetroPinnedStateObserver overrides:
virtual void MetroPinnedStateChanged(content::WebContents* contents,
bool is_pinned) OVERRIDE;
// Returns the resource ID to use for the OTR icon, which depends on
// which layout is being shown and whether we are full-screen.
int GetOTRIconResourceID() const;
......
......@@ -42,6 +42,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"
......@@ -75,6 +76,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
......@@ -182,6 +187,7 @@ LocationBarView::LocationBarView(Profile* profile,
star_view_(NULL),
action_box_button_view_(NULL),
chrome_to_mobile_view_(NULL),
metro_pin_view_(NULL),
mode_(mode),
show_focus_rect_(false),
template_url_service_(NULL),
......@@ -230,7 +236,6 @@ void LocationBarView::Init(views::View* popup_parent_view) {
location_icon_view_ = new LocationIconView(this);
AddChildView(location_icon_view_);
location_icon_view_->SetVisible(true);
location_icon_view_->set_drag_controller(this);
ev_bubble_view_ =
......@@ -281,7 +286,15 @@ void LocationBarView::Init(views::View* popup_parent_view) {
// hidden in popups and in the app launcher.
star_view_ = new StarView(command_updater_);
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_);
}
#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.
......@@ -501,6 +514,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);
}
......@@ -655,6 +673,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();
......@@ -743,6 +764,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();
......@@ -1126,6 +1155,8 @@ void LocationBarView::RefreshPageActionViews() {
page_action_views_.resize(page_actions_.size());
View* right_anchor = chrome_to_mobile_view_;
if (!right_anchor)
right_anchor = metro_pin_view_;
if (!right_anchor)
right_anchor = star_view_;
if (!right_anchor)
......
......@@ -42,6 +42,7 @@ class GURL;
class InstantController;
class KeywordHintView;
class LocationIconView;
class MetroPinView;
class PageActionWithBadgeView;
class PageActionImageView;
class Profile;
......@@ -209,6 +210,9 @@ class LocationBarView : public LocationBar,
// Shows the bookmark bubble.
void ShowStarBubble(const GURL& url, bool newly_bookmarked);
// Toggles the metro pin on or off.
void SetMetroPinnedState(bool is_pinned);
// Shows the Chrome To Mobile bubble.
void ShowChromeToMobileBubble();
......@@ -526,6 +530,9 @@ class LocationBarView : public LocationBar,
// The Chrome To Mobile page action icon view.
ChromeToMobileView* chrome_to_mobile_view_;
// The button to pin the page to the Metro start screen.
MetroPinView* metro_pin_view_;
// The mode that dictates how the bar shows.
Mode mode_;
......
// 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)
: ALLOW_THIS_IN_INITIALIZER_LIST(ImageButton(this)),
command_updater_(command_updater) {
set_id(VIEW_ID_METRO_PIN);
SetImageAlignment(ALIGN_CENTER, ALIGN_MIDDLE);
SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_METRO_PIN));
TouchableLocationBarView::Init(this);
SetIsPinned(false);
}
MetroPinView::~MetroPinView() {}
void MetroPinView::SetIsPinned(bool is_pinned) {
SetTooltipText(l10n_util::GetStringUTF16(
is_pinned ? IDS_TOOLTIP_METRO_PINNED : IDS_TOOLTIP_METRO_PIN));
SetImage(BS_NORMAL, ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
is_pinned ? IDR_METRO_PINNED : IDR_METRO_PIN));
}
void MetroPinView::ButtonPressed(Button* sender, const views::Event& event) {
command_updater_->ExecuteCommand(IDC_METRO_PIN_TO_START_SCREEN);
}
int MetroPinView::GetBuiltInHorizontalPadding() const {
return GetBuiltInHorizontalPaddingImpl();
}
// 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.
#ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_METRO_PIN_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_METRO_PIN_VIEW_H_
#include "chrome/browser/ui/views/location_bar/touchable_location_bar_view.h"
#include "ui/views/controls/button/image_button.h"
class CommandUpdater;
class MetroPinView
: public views::ImageButton,
public views::ButtonListener,
public TouchableLocationBarView {
public:
explicit MetroPinView(CommandUpdater* command_updater);
virtual ~MetroPinView();
// When the page is already pinned, clicking the pin view will cause the page
// to become unpinned.
void SetIsPinned(bool is_pinned);
// views::ButtonListener.
virtual void ButtonPressed(Button* sender,
const views::Event& event) OVERRIDE;
// TouchableLocationBarView.
virtual int GetBuiltInHorizontalPadding() const OVERRIDE;
private:
// The CommandUpdater for the Browser object that owns the location bar.
CommandUpdater* command_updater_;
DISALLOW_IMPLICIT_CONSTRUCTORS(MetroPinView);
};
#endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_METRO_PIN_VIEW_H_
......@@ -3258,6 +3258,7 @@
'browser/ui/login/login_prompt.h',
'browser/ui/media_stream_infobar_delegate.h',
'browser/ui/media_stream_infobar_delegate.cc',
'browser/ui/metro_pinned_state_observer.h',
'browser/ui/metro_pin_tab_helper.cc',
'browser/ui/metro_pin_tab_helper.h',
'browser/ui/network_profile_bubble.cc',
......@@ -3730,6 +3731,8 @@
'browser/ui/views/location_bar/location_bar_view.h',
'browser/ui/views/location_bar/location_icon_view.cc',
'browser/ui/views/location_bar/location_icon_view.h',
'browser/ui/views/location_bar/metro_pin_view.cc',
'browser/ui/views/location_bar/metro_pin_view.h',
'browser/ui/views/location_bar/page_action_image_view.cc',
'browser/ui/views/location_bar/page_action_image_view.h',
'browser/ui/views/location_bar/page_action_with_badge_view.cc',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment