Commit 34041bbb authored by finnur@chromium.org's avatar finnur@chromium.org

Revert 57311 - Part 2 of the SSL InfoBubble.

- Added Certificate Information link.

- Changed iconography to be:
  Identity  : Green check mark vs. Red skull and bones
  Connection: Green padlock vs. Orange exclamation point.
  (This used to be Green checkmark and Orange Exclamation point for both sections.

- Removed the icon for the First visit section. Need to see if we want an icon for when you haven't visited the site before. Mocks show no icons when you have visited before.

BUG=52916
TEST=Open the SSL InfoBubble and notice the new iconography. Click the link and the Certificate dialog should show.

Review URL: http://codereview.chromium.org/3136031

TBR=finnur@chromium.org
Review URL: http://codereview.chromium.org/3170043

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57314 0039d316-1c4b-4281-b951-d872f2087c98
parent 2cb83c85
chrome/app/theme/pageinfo_bad.png

1.9 KB | W: | H:

chrome/app/theme/pageinfo_bad.png

1.01 KB | W: | H:

chrome/app/theme/pageinfo_bad.png
chrome/app/theme/pageinfo_bad.png
chrome/app/theme/pageinfo_bad.png
chrome/app/theme/pageinfo_bad.png
  • 2-up
  • Swipe
  • Onion skin
chrome/app/theme/pageinfo_good.png

1.29 KB | W: | H:

chrome/app/theme/pageinfo_good.png

1.42 KB | W: | H:

chrome/app/theme/pageinfo_good.png
chrome/app/theme/pageinfo_good.png
chrome/app/theme/pageinfo_good.png
chrome/app/theme/pageinfo_good.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -99,8 +99,7 @@ PageInfoModel::PageInfoModel(Profile* profile, ...@@ -99,8 +99,7 @@ PageInfoModel::PageInfoModel(Profile* profile,
state, state,
l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_IDENTITY_TITLE), l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_IDENTITY_TITLE),
head_line, head_line,
description, description));
SECTION_INFO_IDENTITY));
// Connection section. // Connection section.
// We consider anything less than 80 bits encryption to be weak encryption. // We consider anything less than 80 bits encryption to be weak encryption.
...@@ -140,9 +139,8 @@ PageInfoModel::PageInfoModel(Profile* profile, ...@@ -140,9 +139,8 @@ PageInfoModel::PageInfoModel(Profile* profile,
if (ssl.security_bits() > 0 && cipher_suite) { if (ssl.security_bits() > 0 && cipher_suite) {
bool did_fallback = (ssl.connection_status() & bool did_fallback = (ssl.connection_status() &
net::SSL_CONNECTION_SSL3_FALLBACK) != 0; net::SSL_CONNECTION_SSL3_FALLBACK) != 0;
bool no_renegotiation = bool no_renegotiation = (ssl.connection_status() &
(ssl.connection_status() & net::SSL_CONNECTION_NO_RENEGOTIATION_EXTENSION) != 0;
net::SSL_CONNECTION_NO_RENEGOTIATION_EXTENSION) != 0;
const char *key_exchange, *cipher, *mac; const char *key_exchange, *cipher, *mac;
net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, cipher_suite); net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, cipher_suite);
...@@ -183,8 +181,7 @@ PageInfoModel::PageInfoModel(Profile* profile, ...@@ -183,8 +181,7 @@ PageInfoModel::PageInfoModel(Profile* profile,
state, state,
l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_CONNECTION_TITLE), l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_CONNECTION_TITLE),
head_line, head_line,
description, description));
SECTION_INFO_CONNECTION));
// Request the number of visits. // Request the number of visits.
HistoryService* history = profile->GetHistoryService( HistoryService* history = profile->GetHistoryService(
...@@ -229,8 +226,7 @@ void PageInfoModel::OnGotVisitCountToHost(HistoryService::Handle handle, ...@@ -229,8 +226,7 @@ void PageInfoModel::OnGotVisitCountToHost(HistoryService::Handle handle,
IDS_PAGE_INFO_SECURITY_TAB_PERSONAL_HISTORY_TITLE), IDS_PAGE_INFO_SECURITY_TAB_PERSONAL_HISTORY_TITLE),
string16(), string16(),
l10n_util::GetStringUTF16( l10n_util::GetStringUTF16(
IDS_PAGE_INFO_SECURITY_TAB_FIRST_VISITED_TODAY), IDS_PAGE_INFO_SECURITY_TAB_FIRST_VISITED_TODAY)));
SECTION_INFO_FIRST_VISIT));
} else { } else {
sections_.push_back(SectionInfo( sections_.push_back(SectionInfo(
true, true,
...@@ -239,8 +235,7 @@ void PageInfoModel::OnGotVisitCountToHost(HistoryService::Handle handle, ...@@ -239,8 +235,7 @@ void PageInfoModel::OnGotVisitCountToHost(HistoryService::Handle handle,
string16(), string16(),
l10n_util::GetStringFUTF16( l10n_util::GetStringFUTF16(
IDS_PAGE_INFO_SECURITY_TAB_VISITED_BEFORE_TODAY, IDS_PAGE_INFO_SECURITY_TAB_VISITED_BEFORE_TODAY,
WideToUTF16(base::TimeFormatShortDate(first_visit))), WideToUTF16(base::TimeFormatShortDate(first_visit)))));
SECTION_INFO_FIRST_VISIT));
} }
observer_->ModelChanged(); observer_->ModelChanged();
} }
......
...@@ -18,7 +18,7 @@ class PrefService; ...@@ -18,7 +18,7 @@ class PrefService;
class Profile; class Profile;
// The model that provides the information that should be displayed in the page // The model that provides the information that should be displayed in the page
// info dialog/bubble. // info dialog.
class PageInfoModel { class PageInfoModel {
public: public:
class PageInfoModelObserver { class PageInfoModelObserver {
...@@ -29,23 +29,15 @@ class PageInfoModel { ...@@ -29,23 +29,15 @@ class PageInfoModel {
virtual ~PageInfoModelObserver() {} virtual ~PageInfoModelObserver() {}
}; };
enum SectionInfoType {
SECTION_INFO_IDENTITY = 0,
SECTION_INFO_CONNECTION,
SECTION_INFO_FIRST_VISIT,
};
struct SectionInfo { struct SectionInfo {
SectionInfo(bool state, SectionInfo(bool state,
const string16& title, const string16& title,
const string16& headline, const string16& head_line,
const string16& description, const string16& description)
SectionInfoType type)
: state(state), : state(state),
title(title), title(title),
headline(headline), head_line(head_line),
description(description), description(description) {
type(type) {
} }
bool state; // True if state is OK, false otherwise (ex of bad states: bool state; // True if state is OK, false otherwise (ex of bad states:
...@@ -55,14 +47,10 @@ class PageInfoModel { ...@@ -55,14 +47,10 @@ class PageInfoModel {
string16 title; string16 title;
// A single line describing the section, optional. // A single line describing the section, optional.
string16 headline; string16 head_line;
// The full description of what this section is. // The full description of what this section is.
string16 description; string16 description;
// The type of SectionInfo we are dealing with, for example: Identity,
// Connection, First Visit.
SectionInfoType type;
}; };
PageInfoModel(Profile* profile, PageInfoModel(Profile* profile,
......
...@@ -4,26 +4,20 @@ ...@@ -4,26 +4,20 @@
#include "chrome/browser/views/page_info_bubble_view.h" #include "chrome/browser/views/page_info_bubble_view.h"
#include "app/l10n_util.h"
#include "app/resource_bundle.h" #include "app/resource_bundle.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "chrome/browser/certificate_viewer.h"
#include "chrome/browser/views/frame/browser_view.h" #include "chrome/browser/views/frame/browser_view.h"
#include "chrome/browser/views/info_bubble.h" #include "chrome/browser/views/info_bubble.h"
#include "chrome/browser/views/toolbar_view.h" #include "chrome/browser/views/toolbar_view.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h" #include "grit/locale_settings.h"
#include "grit/theme_resources.h" #include "grit/theme_resources.h"
#include "views/controls/image_view.h" #include "views/controls/image_view.h"
#include "views/controls/label.h" #include "views/controls/label.h"
#include "views/controls/link.h"
#include "views/controls/separator.h" #include "views/controls/separator.h"
#include "views/grid_layout.h" #include "views/grid_layout.h"
#include "views/widget/widget_win.h" #include "views/widget/widget_win.h"
#include "views/window/window.h" #include "views/window/window.h"
namespace {
// Layout constants. // Layout constants.
const int kHGapToBorder = 11; const int kHGapToBorder = 11;
const int kVGapToImage = 10; const int kVGapToImage = 10;
...@@ -36,29 +30,28 @@ const int kIconOffset = 28; ...@@ -36,29 +30,28 @@ const int kIconOffset = 28;
// A section contains an image that shows a status (good or bad), a title, an // A section contains an image that shows a status (good or bad), a title, an
// optional head-line (in bold) and a description. // optional head-line (in bold) and a description.
class Section : public views::View, class Section : public views::View {
public views::LinkController {
public: public:
Section(PageInfoBubbleView* owner, Section(bool state,
const PageInfoModel::SectionInfo& section_info); const string16& headline,
const string16& description);
virtual ~Section(); virtual ~Section();
// views::View methods:
virtual int GetHeightForWidth(int w); virtual int GetHeightForWidth(int w);
virtual void Layout(); virtual void Layout();
// views::LinkController methods:
virtual void LinkActivated(views::Link* source, int event_flags);
private: private:
// Calculate the layout if |compute_bounds_only|, otherwise does Layout also. // Calculate the layout if |compute_bounds_only|, otherwise does Layout also.
gfx::Size LayoutItems(bool compute_bounds_only, int width); gfx::Size LayoutItems(bool compute_bounds_only, int width);
// The view that owns this Section object. // Whether to show the good/bad icon.
PageInfoBubbleView* owner_; bool state_;
// The information this view represents. // The first line of the description, show in bold.
PageInfoModel::SectionInfo info_; string16 headline_;
// The description, displayed below the head line.
string16 description_;
static SkBitmap* good_state_icon_; static SkBitmap* good_state_icon_;
static SkBitmap* bad_state_icon_; static SkBitmap* bad_state_icon_;
...@@ -66,7 +59,6 @@ class Section : public views::View, ...@@ -66,7 +59,6 @@ class Section : public views::View,
views::ImageView* status_image_; views::ImageView* status_image_;
views::Label* headline_label_; views::Label* headline_label_;
views::Label* description_label_; views::Label* description_label_;
views::Link* link_;
DISALLOW_COPY_AND_ASSIGN(Section); DISALLOW_COPY_AND_ASSIGN(Section);
}; };
...@@ -75,19 +67,15 @@ class Section : public views::View, ...@@ -75,19 +67,15 @@ class Section : public views::View,
SkBitmap* Section::good_state_icon_ = NULL; SkBitmap* Section::good_state_icon_ = NULL;
SkBitmap* Section::bad_state_icon_ = NULL; SkBitmap* Section::bad_state_icon_ = NULL;
} // namespace
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// PageInfoBubbleView // PageInfoBubbleView
PageInfoBubbleView::PageInfoBubbleView(gfx::NativeWindow parent_window, PageInfoBubbleView::PageInfoBubbleView(Profile* profile,
Profile* profile,
const GURL& url, const GURL& url,
const NavigationEntry::SSLStatus& ssl, const NavigationEntry::SSLStatus& ssl,
bool show_history) bool show_history)
: ALLOW_THIS_IN_INITIALIZER_LIST(model_(profile, url, ssl, : ALLOW_THIS_IN_INITIALIZER_LIST(model_(profile, url, ssl,
show_history, this)), show_history, this)),
parent_window_(parent_window),
cert_id_(ssl.cert_id()), cert_id_(ssl.cert_id()),
info_bubble_(NULL) { info_bubble_(NULL) {
LayoutSections(); LayoutSections();
...@@ -96,10 +84,6 @@ PageInfoBubbleView::PageInfoBubbleView(gfx::NativeWindow parent_window, ...@@ -96,10 +84,6 @@ PageInfoBubbleView::PageInfoBubbleView(gfx::NativeWindow parent_window,
PageInfoBubbleView::~PageInfoBubbleView() { PageInfoBubbleView::~PageInfoBubbleView() {
} }
void PageInfoBubbleView::ShowCertDialog() {
ShowCertificateViewerByID(parent_window_, cert_id_);
}
void PageInfoBubbleView::LayoutSections() { void PageInfoBubbleView::LayoutSections() {
// Remove all the existing sections. // Remove all the existing sections.
RemoveAllChildViews(true); RemoveAllChildViews(true);
...@@ -120,7 +104,7 @@ void PageInfoBubbleView::LayoutSections() { ...@@ -120,7 +104,7 @@ void PageInfoBubbleView::LayoutSections() {
layout->StartRow(0, 0); layout->StartRow(0, 0);
// TODO(finnur): Remove title from the info struct, since it is // TODO(finnur): Remove title from the info struct, since it is
// not used anymore. // not used anymore.
layout->AddView(new Section(this, info)); layout->AddView(new Section(info.state, info.head_line, info.description));
// Add separator after all sections except the last. // Add separator after all sections except the last.
if (i < count - 1) { if (i < count - 1) {
...@@ -140,7 +124,7 @@ gfx::Size PageInfoBubbleView::GetPreferredSize() { ...@@ -140,7 +124,7 @@ gfx::Size PageInfoBubbleView::GetPreferredSize() {
int count = model_.GetSectionCount(); int count = model_.GetSectionCount();
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
PageInfoModel::SectionInfo info = model_.GetSectionInfo(i); PageInfoModel::SectionInfo info = model_.GetSectionInfo(i);
Section section(this, info); Section section(info.state, info.head_line, info.description);
size.Enlarge(0, section.GetHeightForWidth(size.width())); size.Enlarge(0, section.GetHeightForWidth(size.width()));
} }
...@@ -161,43 +145,35 @@ void PageInfoBubbleView::ModelChanged() { ...@@ -161,43 +145,35 @@ void PageInfoBubbleView::ModelChanged() {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Section // Section
Section::Section(PageInfoBubbleView* owner, Section::Section(bool state,
const PageInfoModel::SectionInfo& section_info) const string16& headline,
: owner_(owner), const string16& description)
info_(section_info) { : state_(state),
headline_(headline),
description_(description) {
if (!good_state_icon_) { if (!good_state_icon_) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance(); ResourceBundle& rb = ResourceBundle::GetSharedInstance();
good_state_icon_ = rb.GetBitmapNamed(IDR_PAGEINFO_GOOD); good_state_icon_ = rb.GetBitmapNamed(IDR_PAGEINFO_GOOD);
bad_state_icon_ = rb.GetBitmapNamed(IDR_PAGEINFO_BAD); bad_state_icon_ = rb.GetBitmapNamed(IDR_PAGEINFO_BAD);
} }
if (info_.type == PageInfoModel::SECTION_INFO_IDENTITY || status_image_ = new views::ImageView();
info_.type == PageInfoModel::SECTION_INFO_CONNECTION) { status_image_->SetImage(state ? good_state_icon_ : bad_state_icon_);
status_image_ = new views::ImageView(); AddChildView(status_image_);
status_image_->SetImage(info_.state ? good_state_icon_ : bad_state_icon_);
AddChildView(status_image_);
}
headline_label_ = new views::Label(UTF16ToWideHack(info_.headline)); headline_label_ = new views::Label(UTF16ToWideHack(headline));
headline_label_->SetFont( headline_label_->SetFont(
headline_label_->font().DeriveFont(0, gfx::Font::BOLD)); headline_label_->font().DeriveFont(0, gfx::Font::BOLD));
headline_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); headline_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
AddChildView(headline_label_); AddChildView(headline_label_);
description_label_ = new views::Label(UTF16ToWideHack(info_.description)); description_label_ = new views::Label(UTF16ToWideHack(description));
description_label_->SetMultiLine(true); description_label_->SetMultiLine(true);
description_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); description_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
// Allow linebreaking in the middle of words if necessary, so that extremely // Allow linebreaking in the middle of words if necessary, so that extremely
// long hostnames (longer than one line) will still be completely shown. // long hostnames (longer than one line) will still be completely shown.
description_label_->SetAllowCharacterBreak(true); description_label_->SetAllowCharacterBreak(true);
AddChildView(description_label_); AddChildView(description_label_);
if (info_.type == PageInfoModel::SECTION_INFO_IDENTITY) {
link_ = new views::Link(
l10n_util::GetStringUTF16(IDS_PAGEINFO_CERT_INFO_BUTTON));
link_->SetController(this);
AddChildView(link_);
}
} }
Section::~Section() { Section::~Section() {
...@@ -211,22 +187,14 @@ void Section::Layout() { ...@@ -211,22 +187,14 @@ void Section::Layout() {
LayoutItems(false, width()); LayoutItems(false, width());
} }
void Section::LinkActivated(views::Link* source, int event_flags) {
owner_->ShowCertDialog();
}
gfx::Size Section::LayoutItems(bool compute_bounds_only, int width) { gfx::Size Section::LayoutItems(bool compute_bounds_only, int width) {
int x = kHGapToBorder; int x = kHGapToBorder;
int y = kVGapToImage; int y = kVGapToImage;
// Layout the image, head-line and description. // Layout the image, head-line and description.
gfx::Size size; gfx::Size size = status_image_->GetPreferredSize();
if (info_.type == PageInfoModel::SECTION_INFO_IDENTITY || if (!compute_bounds_only)
info_.type == PageInfoModel::SECTION_INFO_CONNECTION) { status_image_->SetBounds(x, y, size.width(), size.height());
size = status_image_->GetPreferredSize();
if (!compute_bounds_only)
status_image_->SetBounds(x, y, size.width(), size.height());
}
int image_height = y + size.height(); int image_height = y + size.height();
x += size.width() + kHGapImageToDescription; x += size.width() + kHGapImageToDescription;
int w = width - x - kTextPaddingRight; int w = width - x - kTextPaddingRight;
...@@ -249,11 +217,6 @@ gfx::Size Section::LayoutItems(bool compute_bounds_only, int width) { ...@@ -249,11 +217,6 @@ gfx::Size Section::LayoutItems(bool compute_bounds_only, int width) {
if (!compute_bounds_only) if (!compute_bounds_only)
description_label_->SetBounds(x, y, 0, 0); description_label_->SetBounds(x, y, 0, 0);
} }
if (info_.type == PageInfoModel::SECTION_INFO_IDENTITY) {
size = link_->GetPreferredSize();
link_->SetBounds(x, y, size.width(), size.height());
y += size.height();
}
// Make sure the image is not truncated if the text doesn't contain much. // Make sure the image is not truncated if the text doesn't contain much.
y = std::max(y, image_height); y = std::max(y, image_height);
...@@ -279,7 +242,7 @@ void ShowPageInfoBubble(gfx::NativeWindow parent, ...@@ -279,7 +242,7 @@ void ShowPageInfoBubble(gfx::NativeWindow parent,
// Show the bubble. // Show the bubble.
PageInfoBubbleView* page_info_bubble = PageInfoBubbleView* page_info_bubble =
new PageInfoBubbleView(parent, profile, url, ssl, show_history); new PageInfoBubbleView(profile, url, ssl, show_history);
InfoBubble* info_bubble = InfoBubble* info_bubble =
InfoBubble::Show(browser_view->GetWidget(), bounds, InfoBubble::Show(browser_view->GetWidget(), bounds,
BubbleBorder::TOP_LEFT, BubbleBorder::TOP_LEFT,
......
...@@ -18,15 +18,12 @@ class PageInfoBubbleView : public views::View, ...@@ -18,15 +18,12 @@ class PageInfoBubbleView : public views::View,
public PageInfoModel::PageInfoModelObserver, public PageInfoModel::PageInfoModelObserver,
public InfoBubbleDelegate { public InfoBubbleDelegate {
public: public:
PageInfoBubbleView(gfx::NativeWindow parent_window, PageInfoBubbleView(Profile* profile,
Profile* profile,
const GURL& url, const GURL& url,
const NavigationEntry::SSLStatus& ssl, const NavigationEntry::SSLStatus& ssl,
bool show_history); bool show_history);
virtual ~PageInfoBubbleView(); virtual ~PageInfoBubbleView();
// Show the certificate dialog.
void ShowCertDialog();
void set_info_bubble(InfoBubble* info_bubble) { info_bubble_ = info_bubble; } void set_info_bubble(InfoBubble* info_bubble) { info_bubble_ = info_bubble; }
...@@ -47,9 +44,6 @@ class PageInfoBubbleView : public views::View, ...@@ -47,9 +44,6 @@ class PageInfoBubbleView : public views::View,
// Layout the sections within the bubble. // Layout the sections within the bubble.
void LayoutSections(); void LayoutSections();
// The parent window of the InfoBubble showing this view.
gfx::NativeWindow parent_window_;
// The model providing the various section info. // The model providing the various section info.
PageInfoModel model_; PageInfoModel model_;
......
...@@ -217,7 +217,7 @@ void PageInfoWindowView::LayoutSections() { ...@@ -217,7 +217,7 @@ void PageInfoWindowView::LayoutSections() {
for (int i = 0; i < model_.GetSectionCount(); ++i) { for (int i = 0; i < model_.GetSectionCount(); ++i) {
PageInfoModel::SectionInfo info = model_.GetSectionInfo(i); PageInfoModel::SectionInfo info = model_.GetSectionInfo(i);
layout->StartRow(0, 0); layout->StartRow(0, 0);
layout->AddView(new Section(info.title, info.state, info.headline, layout->AddView(new Section(info.title, info.state, info.head_line,
info.description)); info.description));
layout->AddPaddingRow(0, kVerticalPadding); layout->AddPaddingRow(0, kVerticalPadding);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment