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

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

Issue 10917280: Fix up views web intents location bar decoration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Correct pixel spacing Created 8 years, 3 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/location_bar/web_intents_button_view.h" 5 #include "chrome/browser/ui/views/location_bar/web_intents_button_view.h"
6 6
7 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" 7 #include "chrome/browser/ui/intents/web_intent_picker_controller.h"
8 #include "chrome/browser/ui/tab_contents/tab_contents.h" 8 #include "chrome/browser/ui/tab_contents/tab_contents.h"
9 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 9 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
10 #include "grit/generated_resources.h" 10 #include "grit/generated_resources.h"
11 #include "ui/base/animation/slide_animation.h" 11 #include "ui/base/animation/slide_animation.h"
12 #include "ui/base/animation/tween.h" 12 #include "ui/base/animation/tween.h"
13 #include "ui/base/l10n/l10n_util.h" 13 #include "ui/base/l10n/l10n_util.h"
14 #include "ui/base/resource/resource_bundle.h"
15 14
16 // Animation time to open the button. 15 // Animation time to open the button.
17 const int kMoveTimeMs = 150; 16 const int kMoveTimeMs = 150;
18 17
19 WebIntentsButtonView::WebIntentsButtonView(LocationBarView* parent, 18 WebIntentsButtonView::WebIntentsButtonView(LocationBarView* parent,
20 const int background_images[]) 19 const int background_images[])
21 : LocationBarDecorationView(parent, background_images) { 20 : LocationBarDecorationView(parent, background_images) {
22 } 21 }
23 22
24 void WebIntentsButtonView::Update(TabContents* tab_contents) { 23 void WebIntentsButtonView::Update(TabContents* tab_contents) {
25 if (!tab_contents || 24 if (!tab_contents ||
26 !tab_contents->web_intent_picker_controller() || 25 !tab_contents->web_intent_picker_controller() ||
27 !tab_contents->web_intent_picker_controller()-> 26 !tab_contents->web_intent_picker_controller()->
28 ShowLocationBarPickerTool()) { 27 ShowLocationBarPickerTool()) {
29 SetVisible(false); 28 SetVisible(false);
30 } else { 29 return;
31 SetVisible(true);
32 } 30 }
33 31
34 int animated_string_id = IDS_INTENT_PICKER_USE_ANOTHER_SERVICE; 32 int animated_string_id = IDS_INTENT_PICKER_USE_ANOTHER_SERVICE;
35 string16 animated_text = l10n_util::GetStringUTF16(animated_string_id); 33 string16 animated_text = l10n_util::GetStringUTF16(animated_string_id);
36 SetTooltipText(animated_text); 34 SetTooltipText(animated_text);
35 SetVisible(true);
37 36
37 // Mark that we want to always draw the text button before we start animating
38 // the label open.
Peter Kasting 2012/09/17 20:04:27 This comment says what the code does; I was more i
Greg Billock 2012/09/17 21:23:18 Done.
39 AlwaysDrawText();
38 StartLabelAnimation(animated_text, kMoveTimeMs); 40 StartLabelAnimation(animated_text, kMoveTimeMs);
39 AlwaysDrawText();
40 } 41 }
41 42
42 void WebIntentsButtonView::OnClick(LocationBarView* parent) { 43 void WebIntentsButtonView::OnClick(LocationBarView* parent) {
43 TabContents* tab_contents = parent->GetTabContents(); 44 TabContents* tab_contents = parent->GetTabContents();
44 if (!tab_contents) 45 if (!tab_contents)
45 return; 46 return;
46 47
47 tab_contents->web_intent_picker_controller()->LocationBarPickerToolClicked(); 48 tab_contents->web_intent_picker_controller()->LocationBarPickerToolClicked();
48 } 49 }
49 50
50 int WebIntentsButtonView::GetTextAnimationSize(double state, int text_size) { 51 int WebIntentsButtonView::GetTextAnimationSize(double state, int text_size) {
51 if (state < 1.0) { 52 if (state < 1.0) {
52 return static_cast<int>(text_size * state); 53 return static_cast<int>(text_size * state);
53 } 54 }
54 55
55 return text_size; 56 return text_size;
56 } 57 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698