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

Side by Side Diff: chrome/browser/ui/views/location_bar/zoom_bubble_view.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/views/location_bar/zoom_bubble_view.h" 5 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h"
6 6
7 #include "chrome/browser/chrome_page_zoom.h" 7 #include "chrome/browser/chrome_page_zoom.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/zoom/zoom_controller.h" 9 #include "chrome/browser/ui/zoom/zoom_controller.h"
10 #include "grit/generated_resources.h" 10 #include "grit/generated_resources.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // Compensate for built-in vertical padding in the anchor view's image. 77 // Compensate for built-in vertical padding in the anchor view's image.
78 set_anchor_insets(gfx::Insets(5, 0, 5, 0)); 78 set_anchor_insets(gfx::Insets(5, 0, 5, 0));
79 set_use_focusless(auto_close); 79 set_use_focusless(auto_close);
80 set_notify_enter_exit_on_child(true); 80 set_notify_enter_exit_on_child(true);
81 } 81 }
82 82
83 ZoomBubbleView::~ZoomBubbleView() { 83 ZoomBubbleView::~ZoomBubbleView() {
84 } 84 }
85 85
86 void ZoomBubbleView::Refresh() { 86 void ZoomBubbleView::Refresh() {
87 int zoom_percent = tab_contents_->zoom_controller()->zoom_percent(); 87 ZoomController* zoom_controller =
88 ZoomController::FromWebContents(tab_contents_->web_contents());
89 int zoom_percent = zoom_controller->zoom_percent();
88 label_->SetText( 90 label_->SetText(
89 l10n_util::GetStringFUTF16Int(IDS_TOOLTIP_ZOOM, zoom_percent)); 91 l10n_util::GetStringFUTF16Int(IDS_TOOLTIP_ZOOM, zoom_percent));
90 StartTimerIfNecessary(); 92 StartTimerIfNecessary();
91 } 93 }
92 94
93 void ZoomBubbleView::Close() { 95 void ZoomBubbleView::Close() {
94 GetWidget()->Close(); 96 GetWidget()->Close();
95 } 97 }
96 98
97 void ZoomBubbleView::StartTimerIfNecessary() { 99 void ZoomBubbleView::StartTimerIfNecessary() {
(...skipping 25 matching lines...) Expand all
123 void ZoomBubbleView::ButtonPressed(views::Button* sender, 125 void ZoomBubbleView::ButtonPressed(views::Button* sender,
124 const ui::Event& event) { 126 const ui::Event& event) {
125 chrome_page_zoom::Zoom(tab_contents_->web_contents(), 127 chrome_page_zoom::Zoom(tab_contents_->web_contents(),
126 content::PAGE_ZOOM_RESET); 128 content::PAGE_ZOOM_RESET);
127 } 129 }
128 130
129 void ZoomBubbleView::Init() { 131 void ZoomBubbleView::Init() {
130 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 132 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical,
131 0, 0, views::kRelatedControlVerticalSpacing)); 133 0, 0, views::kRelatedControlVerticalSpacing));
132 134
133 int zoom_percent = tab_contents_->zoom_controller()->zoom_percent(); 135 ZoomController* zoom_controller =
136 ZoomController::FromWebContents(tab_contents_->web_contents());
137 int zoom_percent = zoom_controller->zoom_percent();
134 label_ = new views::Label( 138 label_ = new views::Label(
135 l10n_util::GetStringFUTF16Int(IDS_TOOLTIP_ZOOM, zoom_percent)); 139 l10n_util::GetStringFUTF16Int(IDS_TOOLTIP_ZOOM, zoom_percent));
136 gfx::Font font = label_->font().DeriveFont(kPercentageFontIncrease); 140 gfx::Font font = label_->font().DeriveFont(kPercentageFontIncrease);
137 label_->SetFont(font); 141 label_->SetFont(font);
138 AddChildView(label_); 142 AddChildView(label_);
139 143
140 AddChildView(new views::Separator()); 144 AddChildView(new views::Separator());
141 145
142 views::TextButton* set_default_button = new views::TextButton( 146 views::TextButton* set_default_button = new views::TextButton(
143 this, l10n_util::GetStringUTF16(IDS_ZOOM_SET_DEFAULT)); 147 this, l10n_util::GetStringUTF16(IDS_ZOOM_SET_DEFAULT));
144 set_default_button->set_alignment(views::TextButtonBase::ALIGN_CENTER); 148 set_default_button->set_alignment(views::TextButtonBase::ALIGN_CENTER);
145 AddChildView(set_default_button); 149 AddChildView(set_default_button);
146 150
147 StartTimerIfNecessary(); 151 StartTimerIfNecessary();
148 } 152 }
149 153
150 void ZoomBubbleView::WindowClosing() { 154 void ZoomBubbleView::WindowClosing() {
151 // |zoom_bubble_| can be a new bubble by this point (as Close(); doesn't 155 // |zoom_bubble_| can be a new bubble by this point (as Close(); doesn't
152 // call this right away). Only set to NULL when it's this bubble. 156 // call this right away). Only set to NULL when it's this bubble.
153 if (zoom_bubble_ == this) 157 if (zoom_bubble_ == this)
154 zoom_bubble_ = NULL; 158 zoom_bubble_ = NULL;
155 } 159 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/location_bar/location_bar_view.cc ('k') | chrome/browser/ui/zoom/zoom_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698