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

Unified Diff: chrome/browser/ui/panels/about_panel_bubble.cc

Issue 7011015: Show "About panel" bubble on Windows. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/panels/about_panel_bubble.cc
===================================================================
--- chrome/browser/ui/panels/about_panel_bubble.cc (revision 0)
+++ chrome/browser/ui/panels/about_panel_bubble.cc (revision 0)
@@ -0,0 +1,196 @@
+// Copyright (c) 2011 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/ui/panels/about_panel_bubble.h"
+
+#include "base/i18n/time_formatting.h"
+#include "base/logging.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/browser/ui/panels/panel_originator_delegate.h"
+#include "grit/generated_resources.h"
+#include "grit/locale_settings.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "views/controls/image_view.h"
+#include "views/controls/label.h"
+#include "views/controls/link.h"
+#include "views/controls/textfield/textfield.h"
+#include "views/window/window.h"
+
+namespace {
+
+// Extra padding to put around content over what the InfoBubble provides.
+const int kBubblePadding = 4;
+
+// Vertical spacing between two controls.
+const int kControlVerticalSpacing = 10;
+
+// Horizontal spacing between the text and the left/right of a description.
+const int kDescriptionHorizontalSpacing = 6;
+
+// Vertical spacing between the text and the top/bottom of a description.
+const int kDescriptionVertialSpacing = 4;
+
+// Horizontal spacing between two links.
+const int kLinksHorizontalSpacing = 20;
+
+// Text color of a description.
+const SkColor kDescriptionTextColor = SK_ColorBLACK;
+
+// Background color of a description.
+const SkColor kDescriptionBackgroundColor = 0xFFE8E8EE;
+
+}
+
+// AboutPanelBubbleView --------------------------------------------------------
+
+AboutPanelBubble::AboutPanelBubbleView::AboutPanelBubbleView(
+ SkBitmap icon, PanelOriginatorDelegate* originator)
+ : icon_(NULL),
+ title_(NULL),
+ install_date_(NULL),
+ description_(NULL),
+ uninstall_link_(NULL),
+ report_abuse_link_(NULL) {
+ const gfx::Font& font =
+ ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont);
+
+ icon_ = new views::ImageView();
+ icon_->SetImage(icon);
+ AddChildView(icon_);
+
+ std::string name = originator->GetOriginatorName();
+ title_ = new views::Label(UTF8ToWide(name));
+ title_->SetFont(font.DeriveFont(0, gfx::Font::BOLD));
+ title_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
+ AddChildView(title_);
+
+ install_date_ = new views::Label(UTF16ToWide(
+ l10n_util::GetStringFUTF16(
+ IDS_ABOUT_PANEL_BUBBLE_EXTENSION_INSTALL_DATE,
+ base::TimeFormatFriendlyDate(
+ originator->GetOriginatorInstallTime()))));
+ install_date_->SetMultiLine(true);
+ install_date_->SetFont(font);
+ install_date_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
+ install_date_->SizeToFit(GetPreferredSize().width() - kBubblePadding * 2);
+ AddChildView(install_date_);
+
+ description_ = new views::Textfield(views::Textfield::STYLE_MULTILINE);
+ description_->SetText(UTF8ToUTF16(originator->GetOriginatorDescription()));
+ description_->SetHeightInLines(2);
+ description_->SetHorizontalMargins(kDescriptionHorizontalSpacing,
+ kDescriptionHorizontalSpacing);
+ description_->SetVerticalMargins(kDescriptionVertialSpacing,
+ kDescriptionVertialSpacing);
+ description_->SetFont(font);
+ description_->SetTextColor(kDescriptionTextColor);
+ description_->SetBackgroundColor(kDescriptionBackgroundColor);
+ description_->RemoveBorder();
+ description_->SetReadOnly(true);
+ AddChildView(description_);
+
+ uninstall_link_ = new views::Link(UTF16ToWide(
+ l10n_util::GetStringFUTF16(IDS_ABOUT_PANEL_BUBBLE_UNINSTALL_EXTENSION,
+ UTF8ToUTF16(name))));
+ AddChildView(uninstall_link_);
+
+ report_abuse_link_ = new views::Link(UTF16ToWide(
+ l10n_util::GetStringUTF16(IDS_ABOUT_PANEL_BUBBLE_REPORT_ABUSE)));
+ AddChildView(report_abuse_link_);
+}
+
+void AboutPanelBubble::AboutPanelBubbleView::Layout() {
+ gfx::Size canvas = GetPreferredSize();
+ gfx::Size icon_size = icon_->GetPreferredSize();
+ int start_x = 2 * kBubblePadding + icon_size.width();
+ int width = canvas.width() - kBubblePadding * 3 - icon_size.width();
+
+ icon_->SetBounds(kBubblePadding,
+ kBubblePadding,
+ icon_size.width(),
+ icon_size.height());
+
+ gfx::Size pref_size = title_->GetPreferredSize();
+ title_->SetBounds(start_x,
+ kBubblePadding,
+ width,
+ pref_size.height());
+
+ int next_y = title_->y() + pref_size.height() + kControlVerticalSpacing;
+
+ pref_size = install_date_->GetPreferredSize();
+ install_date_->SetBounds(start_x,
+ next_y,
+ width,
+ pref_size.height());
+
+ next_y = install_date_->y() + install_date_->height() +
+ kControlVerticalSpacing;
+
+ pref_size = description_->GetPreferredSize();
+ description_->SetBounds(
+ start_x,
+ next_y,
+ width,
+ pref_size.height() + kDescriptionVertialSpacing * 2);
+
+ next_y = description_->y() + description_->height() +
+ kControlVerticalSpacing;
+
+ pref_size = uninstall_link_->GetPreferredSize();
+ uninstall_link_->SetBounds(start_x,
+ next_y,
+ pref_size.width(),
+ pref_size.height());
+
+ pref_size = report_abuse_link_->GetPreferredSize();
+ report_abuse_link_->SetBounds(
+ start_x + uninstall_link_->width() + kLinksHorizontalSpacing,
+ next_y,
+ pref_size.width(),
+ pref_size.height());
+}
+
+gfx::Size AboutPanelBubble::AboutPanelBubbleView::GetPreferredSize() {
+ return views::Window::GetLocalizedContentsSize(
+ IDS_ABOUTPANELBUBBLE_DIALOG_WIDTH_CHARS,
+ IDS_ABOUTPANELBUBBLE_DIALOG_HEIGHT_LINES);
+}
+
+void AboutPanelBubble::AboutPanelBubbleView::LinkClicked(views::Link* source,
+ int event_flags) {
+ NOTIMPLEMENTED();
+}
+
+// AboutPanelBubble ------------------------------------------------------------
+
+// static
+AboutPanelBubble* AboutPanelBubble::Show(
+ views::Widget* parent,
+ const gfx::Rect& position_relative_to,
+ BubbleBorder::ArrowLocation arrow_location,
+ SkBitmap icon,
+ PanelOriginatorDelegate* originator) {
+ AboutPanelBubble* bubble = new AboutPanelBubble();
+ AboutPanelBubbleView* view = new AboutPanelBubbleView(icon, originator);
+ bubble->InitBubble(
+ parent, position_relative_to, arrow_location, view, bubble);
+ return bubble;
+}
+
+AboutPanelBubble::AboutPanelBubble() {
+}
+
+bool AboutPanelBubble::CloseOnEscape() {
+ return true;
+}
+
+bool AboutPanelBubble::FadeInOnShow() {
+ return false;
+}
+
+std::wstring AboutPanelBubble::accessible_name() {
+ return L"AboutPanelBubble";
+}
Property changes on: chrome\browser\ui\panels\about_panel_bubble.cc
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698