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

Side by Side Diff: chrome/browser/ui/gtk/zoom_bubble_gtk.cc

Issue 10959054: Switch ZoomTabHelper to use WebContentsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 2 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/gtk/zoom_bubble_gtk.h" 5 #include "chrome/browser/ui/gtk/zoom_bubble_gtk.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/prefs/pref_service.h" 8 #include "chrome/browser/prefs/pref_service.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/gtk/gtk_theme_service.h" 10 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 tab_contents_(tab_contents) { 69 tab_contents_(tab_contents) {
70 GtkThemeService* theme_service = 70 GtkThemeService* theme_service =
71 GtkThemeService::GetFrom(Profile::FromBrowserContext( 71 GtkThemeService::GetFrom(Profile::FromBrowserContext(
72 tab_contents->web_contents()->GetBrowserContext())); 72 tab_contents->web_contents()->GetBrowserContext()));
73 73
74 event_box_ = gtk_event_box_new(); 74 event_box_ = gtk_event_box_new();
75 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_), FALSE); 75 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_), FALSE);
76 GtkWidget* container = gtk_vbox_new(FALSE, 0); 76 GtkWidget* container = gtk_vbox_new(FALSE, 0);
77 gtk_container_add(GTK_CONTAINER(event_box_), container); 77 gtk_container_add(GTK_CONTAINER(event_box_), container);
78 78
79 int zoom_percent = tab_contents->zoom_controller()->zoom_percent(); 79 ZoomController* zoom_controller =
80 ZoomController::FromWebContents(tab_contents->web_contents());
81 int zoom_percent = zoom_controller->zoom_percent();
80 std::string percentage_text = UTF16ToUTF8(l10n_util::GetStringFUTF16Int( 82 std::string percentage_text = UTF16ToUTF8(l10n_util::GetStringFUTF16Int(
81 IDS_TOOLTIP_ZOOM, zoom_percent)); 83 IDS_TOOLTIP_ZOOM, zoom_percent));
82 label_ = theme_service->BuildLabel(percentage_text, ui::kGdkBlack); 84 label_ = theme_service->BuildLabel(percentage_text, ui::kGdkBlack);
83 gtk_widget_modify_font(label_, pango_font_description_from_string("13")); 85 gtk_widget_modify_font(label_, pango_font_description_from_string("13"));
84 gtk_misc_set_padding(GTK_MISC(label_), 86 gtk_misc_set_padding(GTK_MISC(label_),
85 ui::kControlSpacing, ui::kControlSpacing); 87 ui::kControlSpacing, ui::kControlSpacing);
86 gtk_box_pack_start(GTK_BOX(container), label_, FALSE, FALSE, 0); 88 gtk_box_pack_start(GTK_BOX(container), label_, FALSE, FALSE, 0);
87 89
88 GtkWidget* separator = gtk_hseparator_new(); 90 GtkWidget* separator = gtk_hseparator_new();
89 gtk_box_pack_start(GTK_BOX(container), separator, FALSE, FALSE, 0); 91 gtk_box_pack_start(GTK_BOX(container), separator, FALSE, FALSE, 0);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 StartTimerIfNecessary(); 142 StartTimerIfNecessary();
141 } 143 }
142 144
143 ZoomBubbleGtk::~ZoomBubbleGtk() { 145 ZoomBubbleGtk::~ZoomBubbleGtk() {
144 DCHECK_EQ(g_bubble, this); 146 DCHECK_EQ(g_bubble, this);
145 // Set singleton pointer to NULL. 147 // Set singleton pointer to NULL.
146 g_bubble = NULL; 148 g_bubble = NULL;
147 } 149 }
148 150
149 void ZoomBubbleGtk::Refresh() { 151 void ZoomBubbleGtk::Refresh() {
150 int zoom_percent = tab_contents_->zoom_controller()->zoom_percent(); 152 ZoomController* zoom_controller =
153 ZoomController::FromWebContents(tab_contents_->web_contents());
154 int zoom_percent = zoom_controller->zoom_percent();
151 string16 text = 155 string16 text =
152 l10n_util::GetStringFUTF16Int(IDS_TOOLTIP_ZOOM, zoom_percent); 156 l10n_util::GetStringFUTF16Int(IDS_TOOLTIP_ZOOM, zoom_percent);
153 gtk_label_set_text(GTK_LABEL(g_bubble->label_), UTF16ToUTF8(text).c_str()); 157 gtk_label_set_text(GTK_LABEL(g_bubble->label_), UTF16ToUTF8(text).c_str());
154 StartTimerIfNecessary(); 158 StartTimerIfNecessary();
155 } 159 }
156 160
157 void ZoomBubbleGtk::StartTimerIfNecessary() { 161 void ZoomBubbleGtk::StartTimerIfNecessary() {
158 if (!auto_close_ || mouse_inside_) 162 if (!auto_close_ || mouse_inside_)
159 return; 163 return;
160 164
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 StopTimerIfNecessary(); 202 StopTimerIfNecessary();
199 return FALSE; 203 return FALSE;
200 } 204 }
201 205
202 gboolean ZoomBubbleGtk::OnMouseLeave(GtkWidget* widget, 206 gboolean ZoomBubbleGtk::OnMouseLeave(GtkWidget* widget,
203 GdkEventCrossing* event) { 207 GdkEventCrossing* event) {
204 mouse_inside_ = false; 208 mouse_inside_ = false;
205 StartTimerIfNecessary(); 209 StartTimerIfNecessary();
206 return FALSE; 210 return FALSE;
207 } 211 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/location_bar_view_gtk.cc ('k') | chrome/browser/ui/tab_contents/tab_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698