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

Side by Side Diff: chrome/browser/ui/views/translate/translate_bubble_view.cc

Issue 273223002: views: Make view::Views::GetPreferredSize() const. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More compile fix for ToT Created 6 years, 7 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/translate/translate_bubble_view.h" 5 #include "chrome/browser/ui/views/translate/translate_bubble_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 if (accelerator.key_code() == ui::VKEY_RETURN) { 236 if (accelerator.key_code() == ui::VKEY_RETURN) {
237 HandleButtonPressed(BUTTON_ID_DONE); 237 HandleButtonPressed(BUTTON_ID_DONE);
238 return true; 238 return true;
239 } 239 }
240 break; 240 break;
241 } 241 }
242 } 242 }
243 return BubbleDelegateView::AcceleratorPressed(accelerator); 243 return BubbleDelegateView::AcceleratorPressed(accelerator);
244 } 244 }
245 245
246 gfx::Size TranslateBubbleView::GetPreferredSize() { 246 gfx::Size TranslateBubbleView::GetPreferredSize() const {
247 int width = 0; 247 int width = 0;
248 for (int i = 0; i < child_count(); i++) { 248 for (int i = 0; i < child_count(); i++) {
249 views::View* child = child_at(i); 249 const views::View* child = child_at(i);
250 width = std::max(width, child->GetPreferredSize().width()); 250 width = std::max(width, child->GetPreferredSize().width());
251 } 251 }
252 int height = GetCurrentView()->GetPreferredSize().height(); 252 int height = GetCurrentView()->GetPreferredSize().height();
253 return gfx::Size(width, height); 253 return gfx::Size(width, height);
254 } 254 }
255 255
256 void TranslateBubbleView::OnPerformAction(views::Combobox* combobox) { 256 void TranslateBubbleView::OnPerformAction(views::Combobox* combobox) {
257 HandleComboboxPerformAction(static_cast<ComboboxID>(combobox->id())); 257 HandleComboboxPerformAction(static_cast<ComboboxID>(combobox->id()));
258 } 258 }
259 259
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 TranslateBubbleModel::VIEW_STATE_BEFORE_TRANSLATE) { 298 TranslateBubbleModel::VIEW_STATE_BEFORE_TRANSLATE) {
299 translate_executed_ = true; 299 translate_executed_ = true;
300 } 300 }
301 301
302 set_margins(gfx::Insets(views::kPanelVertMargin, views::kPanelHorizMargin, 302 set_margins(gfx::Insets(views::kPanelVertMargin, views::kPanelHorizMargin,
303 views::kPanelVertMargin, views::kPanelHorizMargin)); 303 views::kPanelVertMargin, views::kPanelHorizMargin));
304 304
305 translate_bubble_view_ = this; 305 translate_bubble_view_ = this;
306 } 306 }
307 307
308 views::View* TranslateBubbleView::GetCurrentView() { 308 views::View* TranslateBubbleView::GetCurrentView() const {
309 switch (model_->GetViewState()) { 309 switch (model_->GetViewState()) {
310 case TranslateBubbleModel::VIEW_STATE_BEFORE_TRANSLATE: 310 case TranslateBubbleModel::VIEW_STATE_BEFORE_TRANSLATE:
311 return before_translate_view_; 311 return before_translate_view_;
312 case TranslateBubbleModel::VIEW_STATE_TRANSLATING: 312 case TranslateBubbleModel::VIEW_STATE_TRANSLATING:
313 return translating_view_; 313 return translating_view_;
314 case TranslateBubbleModel::VIEW_STATE_AFTER_TRANSLATE: 314 case TranslateBubbleModel::VIEW_STATE_AFTER_TRANSLATE:
315 return after_translate_view_; 315 return after_translate_view_;
316 case TranslateBubbleModel::VIEW_STATE_ERROR: 316 case TranslateBubbleModel::VIEW_STATE_ERROR:
317 return error_view_; 317 return error_view_;
318 case TranslateBubbleModel::VIEW_STATE_ADVANCED: 318 case TranslateBubbleModel::VIEW_STATE_ADVANCED:
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 model_->ShouldAlwaysTranslate()); 765 model_->ShouldAlwaysTranslate());
766 } 766 }
767 767
768 base::string16 label; 768 base::string16 label;
769 if (model_->IsPageTranslatedInCurrentLanguages()) 769 if (model_->IsPageTranslatedInCurrentLanguages())
770 label = l10n_util::GetStringUTF16(IDS_DONE); 770 label = l10n_util::GetStringUTF16(IDS_DONE);
771 else 771 else
772 label = l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT); 772 label = l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT);
773 advanced_done_button_->SetText(label); 773 advanced_done_button_->SetText(label);
774 } 774 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698