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

Side by Side Diff: chrome/browser/ui/views/location_bar/chrome_to_mobile_view.cc

Issue 9443007: Add Chrome To Mobile Service and Views Page Action. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Bail on empty GetOAuth2LoginRefreshToken(). Created 8 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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/chrome_to_mobile_view.h"
6
7 #include "base/utf_string_conversions.h"
8 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/ui/view_ids.h"
10 #include "chrome/browser/ui/views/browser_dialogs.h"
11 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
12 #include "grit/generated_resources.h"
13 #include "grit/theme_resources.h"
14 #include "grit/theme_resources_standard.h"
15 #include "ui/base/accessibility/accessible_view_state.h"
16 #include "ui/base/l10n/l10n_util.h"
17 #include "ui/base/resource/resource_bundle.h"
18
19 ChromeToMobileView::ChromeToMobileView(
20 LocationBarView* location_bar_view,
21 CommandUpdater* command_updater)
22 : location_bar_view_(location_bar_view),
23 command_updater_(command_updater) {
24 set_id(VIEW_ID_CHROME_TO_MOBILE_BUTTON);
25 set_accessibility_focusable(true);
26 SetImage(ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_STAR));
27 SetTooltipText(
28 l10n_util::GetStringUTF16(IDS_CHROME_TO_MOBILE_BUBBLE_TOOLTIP));
29 SetVisible(command_updater_->IsCommandEnabled(IDC_CHROME_TO_MOBILE_PAGE));
30 command_updater_->AddCommandObserver(IDC_CHROME_TO_MOBILE_PAGE, this);
31 }
32
33 ChromeToMobileView::~ChromeToMobileView() {
34 command_updater_->RemoveCommandObserver(IDC_CHROME_TO_MOBILE_PAGE, this);
35 }
36
37 void ChromeToMobileView::EnabledStateChangedForCommand(int id, bool enabled) {
38 DCHECK_EQ(id, IDC_CHROME_TO_MOBILE_PAGE);
39 if (enabled != visible()) {
40 SetVisible(enabled);
41 location_bar_view_->Update(NULL);
42 }
43 }
44
45 void ChromeToMobileView::GetAccessibleState(ui::AccessibleViewState* state) {
46 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_CHROME_TO_MOBILE);
47 state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON;
48 }
49
50 bool ChromeToMobileView::GetTooltipText(const gfx::Point& p,
51 string16* tooltip) const {
52 // Don't show tooltip to distract user if ChromeToMobileBubbleView is showing.
53 if (browser::IsChromeToMobileBubbleViewShowing())
54 return false;
55
56 return ImageView::GetTooltipText(p, tooltip);
57 }
58
59 bool ChromeToMobileView::OnMousePressed(const views::MouseEvent& event) {
60 // Show the bubble on mouse release; that is standard button behavior.
61 return true;
62 }
63
64 void ChromeToMobileView::OnMouseReleased(const views::MouseEvent& event) {
65 if (event.IsOnlyLeftMouseButton() && HitTest(event.location()))
66 command_updater_->ExecuteCommand(IDC_CHROME_TO_MOBILE_PAGE);
67 }
68
69 bool ChromeToMobileView::OnKeyPressed(const views::KeyEvent& event) {
70 if (event.key_code() == ui::VKEY_SPACE ||
71 event.key_code() == ui::VKEY_RETURN) {
72 command_updater_->ExecuteCommand(IDC_CHROME_TO_MOBILE_PAGE);
73 return true;
74 }
75 return false;
76 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/location_bar/chrome_to_mobile_view.h ('k') | chrome/browser/ui/views/location_bar/location_bar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698