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

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

Issue 9837059: Cleanup for views::Label: (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 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/download/download_item_view.h" 5 #include "chrome/browser/ui/views/download/download_item_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 return size; 1056 return size;
1057 } 1057 }
1058 1058
1059 // This method computes the minimum width of the label for displaying its text 1059 // This method computes the minimum width of the label for displaying its text
1060 // on 2 lines. It just breaks the string in 2 lines on the spaces and keeps the 1060 // on 2 lines. It just breaks the string in 2 lines on the spaces and keeps the
1061 // configuration with minimum width. 1061 // configuration with minimum width.
1062 void DownloadItemView::SizeLabelToMinWidth() { 1062 void DownloadItemView::SizeLabelToMinWidth() {
1063 if (dangerous_download_label_sized_) 1063 if (dangerous_download_label_sized_)
1064 return; 1064 return;
1065 1065
1066 string16 label_text = dangerous_download_label_->GetText(); 1066 string16 label_text = dangerous_download_label_->text();
1067 TrimWhitespace(label_text, TRIM_ALL, &label_text); 1067 TrimWhitespace(label_text, TRIM_ALL, &label_text);
1068 DCHECK_EQ(string16::npos, label_text.find('\n')); 1068 DCHECK_EQ(string16::npos, label_text.find('\n'));
1069 1069
1070 // Make the label big so that GetPreferredSize() is not constrained by the 1070 // Make the label big so that GetPreferredSize() is not constrained by the
1071 // current width. 1071 // current width.
1072 dangerous_download_label_->SetBounds(0, 0, 1000, 1000); 1072 dangerous_download_label_->SetBounds(0, 0, 1000, 1000);
1073 1073
1074 // Use a const string from here. BreakIterator requies that text.data() not 1074 // Use a const string from here. BreakIterator requies that text.data() not
1075 // change during its lifetime. 1075 // change during its lifetime.
1076 const string16 original_text(label_text); 1076 const string16 original_text(label_text);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1133 1133
1134 bool DownloadItemView::InDropDownButtonXCoordinateRange(int x) { 1134 bool DownloadItemView::InDropDownButtonXCoordinateRange(int x) {
1135 if (x > drop_down_x_left_ && x < drop_down_x_right_) 1135 if (x > drop_down_x_left_ && x < drop_down_x_right_)
1136 return true; 1136 return true;
1137 return false; 1137 return false;
1138 } 1138 }
1139 1139
1140 void DownloadItemView::UpdateAccessibleName() { 1140 void DownloadItemView::UpdateAccessibleName() {
1141 string16 new_name; 1141 string16 new_name;
1142 if (IsShowingWarningDialog()) { 1142 if (IsShowingWarningDialog()) {
1143 new_name = dangerous_download_label_->GetText(); 1143 new_name = dangerous_download_label_->text();
1144 } else { 1144 } else {
1145 new_name = status_text_ + char16(' ') + 1145 new_name = status_text_ + char16(' ') +
1146 download_->GetFileNameToReportUser().LossyDisplayName(); 1146 download_->GetFileNameToReportUser().LossyDisplayName();
1147 } 1147 }
1148 1148
1149 // If the name has changed, notify assistive technology that the name 1149 // If the name has changed, notify assistive technology that the name
1150 // has changed so they can announce it immediately. 1150 // has changed so they can announce it immediately.
1151 if (new_name != accessible_name_) { 1151 if (new_name != accessible_name_) {
1152 accessible_name_ = new_name; 1152 accessible_name_ = new_name;
1153 if (GetWidget()) { 1153 if (GetWidget()) {
1154 GetWidget()->NotifyAccessibilityEvent( 1154 GetWidget()->NotifyAccessibilityEvent(
1155 this, ui::AccessibilityTypes::EVENT_NAME_CHANGED, true); 1155 this, ui::AccessibilityTypes::EVENT_NAME_CHANGED, true);
1156 } 1156 }
1157 } 1157 }
1158 } 1158 }
1159 1159
1160 void DownloadItemView::UpdateDropDownButtonPosition() { 1160 void DownloadItemView::UpdateDropDownButtonPosition() {
1161 gfx::Size size = GetPreferredSize(); 1161 gfx::Size size = GetPreferredSize();
1162 if (base::i18n::IsRTL()) { 1162 if (base::i18n::IsRTL()) {
1163 // Drop down button is glued to the left of the download shelf. 1163 // Drop down button is glued to the left of the download shelf.
1164 drop_down_x_left_ = 0; 1164 drop_down_x_left_ = 0;
1165 drop_down_x_right_ = normal_drop_down_image_set_.top->width(); 1165 drop_down_x_right_ = normal_drop_down_image_set_.top->width();
1166 } else { 1166 } else {
1167 // Drop down button is glued to the right of the download shelf. 1167 // Drop down button is glued to the right of the download shelf.
1168 drop_down_x_left_ = 1168 drop_down_x_left_ =
1169 size.width() - normal_drop_down_image_set_.top->width(); 1169 size.width() - normal_drop_down_image_set_.top->width();
1170 drop_down_x_right_ = size.width(); 1170 drop_down_x_right_ = size.width();
1171 } 1171 }
1172 } 1172 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc ('k') | chrome/browser/ui/views/find_bar_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698