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

Side by Side Diff: chrome/browser/views/download_item_view.cc

Issue 1528032: Add download item tooltips on linux/win. (Closed)
Patch Set: fix compile Created 10 years, 8 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
« no previous file with comments | « chrome/browser/views/download_item_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/views/download_item_view.h" 5 #include "chrome/browser/views/download_item_view.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_CENTER_TOP), 204 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_CENTER_TOP),
205 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_CENTER_MIDDLE), 205 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_CENTER_MIDDLE),
206 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_CENTER_BOTTOM), 206 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_CENTER_BOTTOM),
207 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_RIGHT_TOP_NO_DD), 207 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_RIGHT_TOP_NO_DD),
208 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_RIGHT_MIDDLE_NO_DD), 208 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_RIGHT_MIDDLE_NO_DD),
209 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_RIGHT_BOTTOM_NO_DD) 209 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_RIGHT_BOTTOM_NO_DD)
210 }; 210 };
211 dangerous_mode_body_image_set_ = dangerous_mode_body_image_set; 211 dangerous_mode_body_image_set_ = dangerous_mode_body_image_set;
212 212
213 LoadIcon(); 213 LoadIcon();
214 tooltip_text_ = download_->GetFileName().value();
214 215
215 font_ = ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont); 216 font_ = ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont);
216 box_height_ = std::max<int>(2 * kVerticalPadding + font_.height() + 217 box_height_ = std::max<int>(2 * kVerticalPadding + font_.height() +
217 kVerticalTextPadding + font_.height(), 218 kVerticalTextPadding + font_.height(),
218 2 * kVerticalPadding + 219 2 * kVerticalPadding +
219 normal_body_image_set_.top_left->height() + 220 normal_body_image_set_.top_left->height() +
220 normal_body_image_set_.bottom_left->height()); 221 normal_body_image_set_.bottom_left->height());
221 222
222 if (download_util::kSmallProgressIconSize > box_height_) 223 if (download_util::kSmallProgressIconSize > box_height_)
223 box_y_ = (download_util::kSmallProgressIconSize - box_height_) / 2; 224 box_y_ = (download_util::kSmallProgressIconSize - box_height_) / 2;
224 else 225 else
225 box_y_ = kVerticalPadding; 226 box_y_ = kVerticalPadding;
226 227
227 gfx::Size size = GetPreferredSize(); 228 gfx::Size size = GetPreferredSize();
228 if (UILayoutIsRightToLeft()) { 229 if (UILayoutIsRightToLeft()) {
229 // Drop down button is glued to the left of the download shelf. 230 // Drop down button is glued to the left of the download shelf.
230 drop_down_x_left_ = 0; 231 drop_down_x_left_ = 0;
231 drop_down_x_right_ = normal_drop_down_image_set_.top->width(); 232 drop_down_x_right_ = normal_drop_down_image_set_.top->width();
232 } else { 233 } else {
233 // Drop down button is glued to the right of the download shelf. 234 // Drop down button is glued to the right of the download shelf.
234 drop_down_x_left_ = 235 drop_down_x_left_ =
235 size.width() - normal_drop_down_image_set_.top->width(); 236 size.width() - normal_drop_down_image_set_.top->width();
236 drop_down_x_right_ = size.width(); 237 drop_down_x_right_ = size.width();
237 } 238 }
238 239
239 body_hover_animation_.reset(new SlideAnimation(this)); 240 body_hover_animation_.reset(new SlideAnimation(this));
240 drop_hover_animation_.reset(new SlideAnimation(this)); 241 drop_hover_animation_.reset(new SlideAnimation(this));
241 242
242 if (download->safety_state() == DownloadItem::DANGEROUS) { 243 if (download->safety_state() == DownloadItem::DANGEROUS) {
244 tooltip_text_.clear();
243 body_state_ = DANGEROUS; 245 body_state_ = DANGEROUS;
244 drop_down_state_ = DANGEROUS; 246 drop_down_state_ = DANGEROUS;
245 247
246 warning_icon_ = rb.GetBitmapNamed(IDR_WARNING); 248 warning_icon_ = rb.GetBitmapNamed(IDR_WARNING);
247 save_button_ = new views::NativeButton(this, l10n_util::GetString( 249 save_button_ = new views::NativeButton(this, l10n_util::GetString(
248 download->is_extension_install() ? 250 download->is_extension_install() ?
249 IDS_CONTINUE_EXTENSION_DOWNLOAD : IDS_SAVE_DOWNLOAD)); 251 IDS_CONTINUE_EXTENSION_DOWNLOAD : IDS_SAVE_DOWNLOAD));
250 save_button_->set_ignore_minimum_size(true); 252 save_button_->set_ignore_minimum_size(true);
251 discard_button_ = new views::NativeButton( 253 discard_button_ = new views::NativeButton(
252 this, l10n_util::GetString(IDS_DISCARD_DOWNLOAD)); 254 this, l10n_util::GetString(IDS_DISCARD_DOWNLOAD));
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 save_button_ = NULL; 723 save_button_ = NULL;
722 RemoveChildView(discard_button_); 724 RemoveChildView(discard_button_);
723 delete discard_button_; 725 delete discard_button_;
724 discard_button_ = NULL; 726 discard_button_ = NULL;
725 RemoveChildView(dangerous_download_label_); 727 RemoveChildView(dangerous_download_label_);
726 delete dangerous_download_label_; 728 delete dangerous_download_label_;
727 dangerous_download_label_ = NULL; 729 dangerous_download_label_ = NULL;
728 730
729 // We need to load the icon now that the download_ has the real path. 731 // We need to load the icon now that the download_ has the real path.
730 LoadIcon(); 732 LoadIcon();
733 tooltip_text_ = download_->GetFileName().value();
731 734
732 // Force the shelf to layout again as our size has changed. 735 // Force the shelf to layout again as our size has changed.
733 parent_->Layout(); 736 parent_->Layout();
734 parent_->SchedulePaint(); 737 parent_->SchedulePaint();
735 } 738 }
736 739
737 gfx::Size DownloadItemView::GetPreferredSize() { 740 gfx::Size DownloadItemView::GetPreferredSize() {
738 int width, height; 741 int width, height;
739 742
740 // First, we set the height to the height of two rows or text plus margins. 743 // First, we set the height to the height of two rows or text plus margins.
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 if (icon_bitmap) 920 if (icon_bitmap)
918 GetParent()->SchedulePaint(); 921 GetParent()->SchedulePaint();
919 } 922 }
920 923
921 void DownloadItemView::LoadIcon() { 924 void DownloadItemView::LoadIcon() {
922 IconManager* im = g_browser_process->icon_manager(); 925 IconManager* im = g_browser_process->icon_manager();
923 im->LoadIcon(download_->full_path(), IconLoader::SMALL, &icon_consumer_, 926 im->LoadIcon(download_->full_path(), IconLoader::SMALL, &icon_consumer_,
924 NewCallback(this, &DownloadItemView::OnExtractIconComplete)); 927 NewCallback(this, &DownloadItemView::OnExtractIconComplete));
925 } 928 }
926 929
930 bool DownloadItemView::GetTooltipText(const gfx::Point& p,
931 std::wstring* tooltip) {
932 if (tooltip_text_.empty())
933 return false;
934
935 tooltip->assign(tooltip_text_);
936 return true;
937 }
938
927 gfx::Size DownloadItemView::GetButtonSize() { 939 gfx::Size DownloadItemView::GetButtonSize() {
928 DCHECK(save_button_ && discard_button_); 940 DCHECK(save_button_ && discard_button_);
929 gfx::Size size; 941 gfx::Size size;
930 942
931 // We cache the size when successfully retrieved, not for performance reasons 943 // We cache the size when successfully retrieved, not for performance reasons
932 // but because if this DownloadItemView is being animated while the tab is 944 // but because if this DownloadItemView is being animated while the tab is
933 // not showing, the native buttons are not parented and their preferred size 945 // not showing, the native buttons are not parented and their preferred size
934 // is 0, messing-up the layout. 946 // is 0, messing-up the layout.
935 if (cached_button_size_.width() != 0) 947 if (cached_button_size_.width() != 0)
936 return cached_button_size_; 948 return cached_button_size_;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 void DownloadItemView::Reenable() { 1008 void DownloadItemView::Reenable() {
997 disabled_while_opening_ = false; 1009 disabled_while_opening_ = false;
998 SetEnabled(true); // Triggers a repaint. 1010 SetEnabled(true); // Triggers a repaint.
999 } 1011 }
1000 1012
1001 bool DownloadItemView::InDropDownButtonXCoordinateRange(int x) { 1013 bool DownloadItemView::InDropDownButtonXCoordinateRange(int x) {
1002 if (x > drop_down_x_left_ && x < drop_down_x_right_) 1014 if (x > drop_down_x_left_ && x < drop_down_x_right_)
1003 return true; 1015 return true;
1004 return false; 1016 return false;
1005 } 1017 }
OLDNEW
« no previous file with comments | « chrome/browser/views/download_item_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698