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

Side by Side Diff: chrome/browser/views/infobars/translate_message_infobar.cc

Issue 2602003: Refactored the translate infobars. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Synced Created 10 years, 6 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/infobars/translate_message_infobar.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/views/infobars/translate_message_infobar.h"
6
7 #include "chrome/browser/translate/translate_infobar_delegate2.h"
8 #include "chrome/browser/views/infobars/infobar_text_button.h"
9 #include "views/controls/image_view.h"
10
11 TranslateMessageInfoBar::TranslateMessageInfoBar(
12 TranslateInfoBarDelegate2* delegate)
13 : TranslateInfoBarBase(delegate) {
14 label_ = CreateLabel(delegate->GetMessageInfoBarText());
15 AddChildView(label_);
16
17 string16 button_text = delegate->GetMessageInfoBarButtonText();
18 if (button_text.empty()) {
19 button_ = NULL;
20 } else {
21 button_ = InfoBarTextButton::Create(this, button_text);
22 AddChildView(button_);
23 }
24 }
25
26 void TranslateMessageInfoBar::Layout() {
27 TranslateInfoBarBase::Layout();
28
29 int x = icon_->bounds().right() + InfoBar::kIconLabelSpacing;
30 gfx::Size label_pref_size = label_->GetPreferredSize();
31 int available_width = GetAvailableWidth() - x;
32 gfx::Size button_pref_size;
33 if (button_) {
34 button_pref_size = button_->GetPreferredSize();
35 available_width -=
36 (button_pref_size.width() + InfoBar::kButtonInLabelSpacing);
37 }
38 label_->SetBounds(x, InfoBar::OffsetY(this, label_pref_size),
39 std::min(label_pref_size.width(), available_width),
40 label_pref_size.height());
41
42 if (button_) {
43 button_->SetBounds(label_->bounds().right() +
44 InfoBar::kButtonInLabelSpacing,
45 InfoBar::OffsetY(this, button_pref_size),
46 button_pref_size.width(), button_pref_size.height());
47 }
48 }
49
50 void TranslateMessageInfoBar::ButtonPressed(views::Button* sender,
51 const views::Event& event) {
52 if (sender == button_) {
53 GetDelegate()->MessageInfoBarButtonPressed();
54 return;
55 }
56 TranslateInfoBarBase::ButtonPressed(sender, event);
57 }
OLDNEW
« no previous file with comments | « chrome/browser/views/infobars/translate_message_infobar.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698