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

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

Issue 11418043: Remove TabContents from OmniboxEditController and friends. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cros Created 8 years, 1 month 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"
9 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
10 #include "grit/generated_resources.h" 9 #include "grit/generated_resources.h"
11 #include "ui/base/animation/slide_animation.h" 10 #include "ui/base/animation/slide_animation.h"
12 #include "ui/base/animation/tween.h" 11 #include "ui/base/animation/tween.h"
13 #include "ui/base/l10n/l10n_util.h" 12 #include "ui/base/l10n/l10n_util.h"
14 13
15 // Animation time to open the button. 14 // Animation time to open the button.
16 const int kMoveTimeMs = 150; 15 const int kMoveTimeMs = 150;
17 16
18 WebIntentsButtonView::WebIntentsButtonView(LocationBarView* parent, 17 WebIntentsButtonView::WebIntentsButtonView(LocationBarView* parent,
19 const int background_images[], 18 const int background_images[],
20 const gfx::Font& font, 19 const gfx::Font& font,
21 SkColor font_color) 20 SkColor font_color)
22 : LocationBarDecorationView(parent, background_images, font, font_color) { 21 : LocationBarDecorationView(parent, background_images, font, font_color) {
23 } 22 }
24 23
25 void WebIntentsButtonView::Update(TabContents* tab_contents) { 24 void WebIntentsButtonView::Update(content::WebContents* web_contents) {
26 WebIntentPickerController* web_intent_picker_controller = 25 WebIntentPickerController* web_intent_picker_controller =
27 tab_contents ? WebIntentPickerController::FromWebContents( 26 web_contents ? WebIntentPickerController::FromWebContents(web_contents)
28 tab_contents->web_contents())
29 : NULL; 27 : NULL;
30 if (!web_intent_picker_controller || 28 if (!web_intent_picker_controller ||
31 !web_intent_picker_controller->ShowLocationBarPickerButton()) { 29 !web_intent_picker_controller->ShowLocationBarPickerButton()) {
32 SetVisible(false); 30 SetVisible(false);
33 return; 31 return;
34 } 32 }
35 33
36 int animated_string_id = IDS_INTENT_PICKER_USE_ANOTHER_SERVICE; 34 int animated_string_id = IDS_INTENT_PICKER_USE_ANOTHER_SERVICE;
37 string16 animated_text = l10n_util::GetStringUTF16(animated_string_id); 35 string16 animated_text = l10n_util::GetStringUTF16(animated_string_id);
38 SetTooltipText(animated_text); 36 SetTooltipText(animated_text);
39 SetVisible(true); 37 SetVisible(true);
40 38
41 // Set the flag to always draw text before we start to draw the label, 39 // Set the flag to always draw text before we start to draw the label,
42 // to avoid any possible race. 40 // to avoid any possible race.
43 AlwaysDrawText(); 41 AlwaysDrawText();
44 42
45 if (!web_intent_picker_controller->location_bar_picker_button_indicated()) { 43 if (!web_intent_picker_controller->location_bar_picker_button_indicated()) {
46 StartLabelAnimation(animated_text, kMoveTimeMs); 44 StartLabelAnimation(animated_text, kMoveTimeMs);
47 web_intent_picker_controller->SetLocationBarPickerButtonIndicated(); 45 web_intent_picker_controller->SetLocationBarPickerButtonIndicated();
48 } 46 }
49 } 47 }
50 48
51 void WebIntentsButtonView::OnClick(LocationBarView* parent) { 49 void WebIntentsButtonView::OnClick(LocationBarView* parent) {
52 TabContents* tab_contents = parent->GetTabContents(); 50 content::WebContents* web_contents = parent->GetWebContents();
53 if (!tab_contents) 51 if (!web_contents)
54 return; 52 return;
55 53
56 WebIntentPickerController::FromWebContents(tab_contents->web_contents())-> 54 WebIntentPickerController::FromWebContents(web_contents)->
57 LocationBarPickerButtonClicked(); 55 LocationBarPickerButtonClicked();
58 } 56 }
59 57
60 int WebIntentsButtonView::GetTextAnimationSize(double state, int text_size) { 58 int WebIntentsButtonView::GetTextAnimationSize(double state, int text_size) {
61 if (state < 1.0) { 59 if (state < 1.0) {
62 return static_cast<int>(text_size * state); 60 return static_cast<int>(text_size * state);
63 } 61 }
64 62
65 return text_size; 63 return text_size;
66 } 64 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/location_bar/web_intents_button_view.h ('k') | chrome/browser/ui/views/location_bar/zoom_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698