OLD | NEW |
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 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1224 } | 1224 } |
1225 | 1225 |
1226 // This method computes the minimum width of the label for displaying its text | 1226 // This method computes the minimum width of the label for displaying its text |
1227 // on 2 lines. It just breaks the string in 2 lines on the spaces and keeps the | 1227 // on 2 lines. It just breaks the string in 2 lines on the spaces and keeps the |
1228 // configuration with minimum width. | 1228 // configuration with minimum width. |
1229 void DownloadItemView::SizeLabelToMinWidth() { | 1229 void DownloadItemView::SizeLabelToMinWidth() { |
1230 if (dangerous_download_label_sized_) | 1230 if (dangerous_download_label_sized_) |
1231 return; | 1231 return; |
1232 | 1232 |
1233 base::string16 label_text = dangerous_download_label_->text(); | 1233 base::string16 label_text = dangerous_download_label_->text(); |
1234 TrimWhitespace(label_text, TRIM_ALL, &label_text); | 1234 base::TrimWhitespace(label_text, base::TRIM_ALL, &label_text); |
1235 DCHECK_EQ(base::string16::npos, label_text.find('\n')); | 1235 DCHECK_EQ(base::string16::npos, label_text.find('\n')); |
1236 | 1236 |
1237 // Make the label big so that GetPreferredSize() is not constrained by the | 1237 // Make the label big so that GetPreferredSize() is not constrained by the |
1238 // current width. | 1238 // current width. |
1239 dangerous_download_label_->SetBounds(0, 0, 1000, 1000); | 1239 dangerous_download_label_->SetBounds(0, 0, 1000, 1000); |
1240 | 1240 |
1241 // Use a const string from here. BreakIterator requies that text.data() not | 1241 // Use a const string from here. BreakIterator requies that text.data() not |
1242 // change during its lifetime. | 1242 // change during its lifetime. |
1243 const base::string16 original_text(label_text); | 1243 const base::string16 original_text(label_text); |
1244 // Using BREAK_WORD can work in most cases, but it can also break | 1244 // Using BREAK_WORD can work in most cases, but it can also break |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1338 void DownloadItemView::AnimateStateTransition(State from, State to, | 1338 void DownloadItemView::AnimateStateTransition(State from, State to, |
1339 gfx::SlideAnimation* animation) { | 1339 gfx::SlideAnimation* animation) { |
1340 if (from == NORMAL && to == HOT) { | 1340 if (from == NORMAL && to == HOT) { |
1341 animation->Show(); | 1341 animation->Show(); |
1342 } else if (from == HOT && to == NORMAL) { | 1342 } else if (from == HOT && to == NORMAL) { |
1343 animation->Hide(); | 1343 animation->Hide(); |
1344 } else if (from != to) { | 1344 } else if (from != to) { |
1345 animation->Reset((to == HOT) ? 1.0 : 0.0); | 1345 animation->Reset((to == HOT) ? 1.0 : 0.0); |
1346 } | 1346 } |
1347 } | 1347 } |
OLD | NEW |