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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/views/infobars/translate_message_infobar.cc
diff --git a/chrome/browser/views/infobars/translate_message_infobar.cc b/chrome/browser/views/infobars/translate_message_infobar.cc
new file mode 100644
index 0000000000000000000000000000000000000000..88e99f939d5304c8efcd5ea583219dfa03292664
--- /dev/null
+++ b/chrome/browser/views/infobars/translate_message_infobar.cc
@@ -0,0 +1,57 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/views/infobars/translate_message_infobar.h"
+
+#include "chrome/browser/translate/translate_infobar_delegate2.h"
+#include "chrome/browser/views/infobars/infobar_text_button.h"
+#include "views/controls/image_view.h"
+
+TranslateMessageInfoBar::TranslateMessageInfoBar(
+ TranslateInfoBarDelegate2* delegate)
+ : TranslateInfoBarBase(delegate) {
+ label_ = CreateLabel(delegate->GetMessageInfoBarText());
+ AddChildView(label_);
+
+ string16 button_text = delegate->GetMessageInfoBarButtonText();
+ if (button_text.empty()) {
+ button_ = NULL;
+ } else {
+ button_ = InfoBarTextButton::Create(this, button_text);
+ AddChildView(button_);
+ }
+}
+
+void TranslateMessageInfoBar::Layout() {
+ TranslateInfoBarBase::Layout();
+
+ int x = icon_->bounds().right() + InfoBar::kIconLabelSpacing;
+ gfx::Size label_pref_size = label_->GetPreferredSize();
+ int available_width = GetAvailableWidth() - x;
+ gfx::Size button_pref_size;
+ if (button_) {
+ button_pref_size = button_->GetPreferredSize();
+ available_width -=
+ (button_pref_size.width() + InfoBar::kButtonInLabelSpacing);
+ }
+ label_->SetBounds(x, InfoBar::OffsetY(this, label_pref_size),
+ std::min(label_pref_size.width(), available_width),
+ label_pref_size.height());
+
+ if (button_) {
+ button_->SetBounds(label_->bounds().right() +
+ InfoBar::kButtonInLabelSpacing,
+ InfoBar::OffsetY(this, button_pref_size),
+ button_pref_size.width(), button_pref_size.height());
+ }
+}
+
+void TranslateMessageInfoBar::ButtonPressed(views::Button* sender,
+ const views::Event& event) {
+ if (sender == button_) {
+ GetDelegate()->MessageInfoBarButtonPressed();
+ return;
+ }
+ TranslateInfoBarBase::ButtonPressed(sender, event);
+}
« 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