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

Unified Diff: chrome/browser/views/infobars/infobar_text_button.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/infobar_text_button.h ('k') | chrome/browser/views/infobars/infobars.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/views/infobars/infobar_text_button.cc
diff --git a/chrome/browser/views/infobars/infobar_text_button.cc b/chrome/browser/views/infobars/infobar_text_button.cc
new file mode 100644
index 0000000000000000000000000000000000000000..35726d0ea5313e6ce4dbfc44a4d65b878dc49a0d
--- /dev/null
+++ b/chrome/browser/views/infobars/infobar_text_button.cc
@@ -0,0 +1,50 @@
+// 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/infobar_text_button.h"
+
+#include "app/l10n_util.h"
+#include "app/resource_bundle.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/browser/views/infobars/infobar_button_border.h"
+
+// static
+InfoBarTextButton* InfoBarTextButton::Create(views::ButtonListener* listener,
+ const string16& text) {
+ return new InfoBarTextButton(listener, text);
+}
+
+// static
+InfoBarTextButton* InfoBarTextButton::CreateWithMessageID(
+ views::ButtonListener* listener, int message_id) {
+ return new InfoBarTextButton(listener,
+ l10n_util::GetStringUTF16(message_id));
+}
+
+InfoBarTextButton::~InfoBarTextButton() {
+}
+
+bool InfoBarTextButton::OnMousePressed(const views::MouseEvent& e) {
+ return views::CustomButton::OnMousePressed(e);
+}
+
+InfoBarTextButton::InfoBarTextButton(views::ButtonListener* listener,
+ const string16& text)
+ // Don't use text to construct TextButton because we need to set font
+ // before setting text so that the button will resize to fit entire text.
+ : TextButton(listener, std::wstring()) {
+ set_border(new InfoBarButtonBorder);
+ SetNormalHasBorder(true); // Normal button state has border.
+ SetAnimationDuration(0); // Disable animation during state change.
+ // Set font colors for different states.
+ SetEnabledColor(SK_ColorBLACK);
+ SetHighlightColor(SK_ColorBLACK);
+ SetHoverColor(SK_ColorBLACK);
+ // Set font then text, then size button to fit text.
+ SetFont(
+ ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::MediumFont));
+ SetText(UTF16ToWideHack(text));
+ ClearMaxTextSize();
+ SizeToPreferredSize();
+}
« no previous file with comments | « chrome/browser/views/infobars/infobar_text_button.h ('k') | chrome/browser/views/infobars/infobars.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698