diff options
author | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-16 10:29:45 +0000 |
---|---|---|
committer | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-16 10:29:45 +0000 |
commit | fa6dbb2dc3daadc84f5ca66404386b80887f737d (patch) | |
tree | fba7cef3cb765484e95b3a43ce361c9543a1e617 | |
parent | 3afa7bc3858e305efef41a9afdb7bab0fe586157 (diff) | |
download | chromium_src-fa6dbb2dc3daadc84f5ca66404386b80887f737d.zip chromium_src-fa6dbb2dc3daadc84f5ca66404386b80887f737d.tar.gz chromium_src-fa6dbb2dc3daadc84f5ca66404386b80887f737d.tar.bz2 |
Remove the old SSL Page Info dialog from Win/Gtk. It has been replaced with the PageInfoBubble so it is not in use anymore.
BUG=59030
TEST=None
Review URL: http://codereview.chromium.org/3830001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62857 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/cocoa/browser_window_cocoa.mm | 6 | ||||
-rw-r--r-- | chrome/browser/external_tab_container_win.cc | 2 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.cc | 6 | ||||
-rw-r--r-- | chrome/browser/gtk/page_info_window_gtk.cc | 218 | ||||
-rw-r--r-- | chrome/browser/page_info_model.cc | 32 | ||||
-rw-r--r-- | chrome/browser/page_info_window.h | 10 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.cc | 6 | ||||
-rw-r--r-- | chrome/browser/views/page_info_window_view.cc | 440 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 3 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 4 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 1 |
11 files changed, 9 insertions, 719 deletions
diff --git a/chrome/browser/cocoa/browser_window_cocoa.mm b/chrome/browser/cocoa/browser_window_cocoa.mm index d339e9d..c400e11 100644 --- a/chrome/browser/cocoa/browser_window_cocoa.mm +++ b/chrome/browser/cocoa/browser_window_cocoa.mm @@ -401,11 +401,7 @@ void BrowserWindowCocoa::ShowPageInfo(Profile* profile, const GURL& url, const NavigationEntry::SSLStatus& ssl, bool show_history) { - const CommandLine* command_line(CommandLine::ForCurrentProcess()); - if (!command_line->HasSwitch(switches::kDisableNewPageInfoBubble)) - browser::ShowPageInfoBubble(window(), profile, url, ssl, show_history); - else - browser::ShowPageInfo(window(), profile, url, ssl, show_history); + browser::ShowPageInfoBubble(window(), profile, url, ssl, show_history); } void BrowserWindowCocoa::ShowAppMenu() { diff --git a/chrome/browser/external_tab_container_win.cc b/chrome/browser/external_tab_container_win.cc index 660ca4f..8db65cc 100644 --- a/chrome/browser/external_tab_container_win.cc +++ b/chrome/browser/external_tab_container_win.cc @@ -524,7 +524,7 @@ void ExternalTabContainer::ShowPageInfo(Profile* profile, const GURL& url, const NavigationEntry::SSLStatus& ssl, bool show_history) { - browser::ShowPageInfo(GetNativeView(), profile, url, ssl, show_history); + browser::ShowPageInfoBubble(GetNativeView(), profile, url, ssl, show_history); } void ExternalTabContainer::RegisterRenderViewHostForAutomation( diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc index 6771964..1bbc883 100644 --- a/chrome/browser/gtk/browser_window_gtk.cc +++ b/chrome/browser/gtk/browser_window_gtk.cc @@ -1030,11 +1030,7 @@ void BrowserWindowGtk::ShowPageInfo(Profile* profile, const GURL& url, const NavigationEntry::SSLStatus& ssl, bool show_history) { - const CommandLine* command_line(CommandLine::ForCurrentProcess()); - if (!command_line->HasSwitch(switches::kDisableNewPageInfoBubble)) - browser::ShowPageInfoBubble(window_, profile, url, ssl, show_history); - else - browser::ShowPageInfo(window_, profile, url, ssl, show_history); + browser::ShowPageInfoBubble(window_, profile, url, ssl, show_history); } void BrowserWindowGtk::ShowAppMenu() { diff --git a/chrome/browser/gtk/page_info_window_gtk.cc b/chrome/browser/gtk/page_info_window_gtk.cc deleted file mode 100644 index 2b87483..0000000 --- a/chrome/browser/gtk/page_info_window_gtk.cc +++ /dev/null @@ -1,218 +0,0 @@ -// Copyright (c) 2009 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 <gtk/gtk.h> - -#include "build/build_config.h" - -#include "app/l10n_util.h" -#include "base/compiler_specific.h" -#include "base/utf_string_conversions.h" -#include "chrome/browser/certificate_viewer.h" -#include "chrome/browser/gtk/gtk_util.h" -#include "chrome/browser/page_info_model.h" -#include "chrome/browser/page_info_window.h" -#include "grit/generated_resources.h" -#include "grit/locale_settings.h" - -namespace { - -enum { - RESPONSE_SHOW_CERT_INFO = 0, -}; - -class PageInfoWindowGtk : public PageInfoModel::PageInfoModelObserver { - public: - PageInfoWindowGtk(gfx::NativeWindow parent, - Profile* profile, - const GURL& url, - const NavigationEntry::SSLStatus& ssl, - bool show_history); - ~PageInfoWindowGtk(); - - // PageInfoModelObserver implementation: - virtual void ModelChanged(); - - // Shows the page info window. - void Show(); - - // Shows the certificate info window. - void ShowCertDialog(); - - GtkWidget* widget() { return dialog_; } - - private: - // Layouts the different sections retrieved from the model. - void InitContents(); - - // Returns a widget that contains the UI for the passed |section|. - GtkWidget* CreateSection(const PageInfoModel::SectionInfo& section); - - // The model containing the different sections to display. - PageInfoModel model_; - - // The page info dialog. - GtkWidget* dialog_; - - // The url for this dialog. Should be unique among active dialogs. - GURL url_; - - // The virtual box containing the sections. - GtkWidget* contents_; - - // The id of the certificate for this page. - int cert_id_; - - DISALLOW_COPY_AND_ASSIGN(PageInfoWindowGtk); -}; - -// We only show one page info per URL (keyed on url.spec()). -typedef std::map<std::string, PageInfoWindowGtk*> PageInfoWindowMap; -PageInfoWindowMap g_page_info_window_map; - -// Button callbacks. -void OnDialogResponse(GtkDialog* dialog, gint response_id, - PageInfoWindowGtk* page_info) { - if (response_id == RESPONSE_SHOW_CERT_INFO) { - page_info->ShowCertDialog(); - } else { - // "Close" was clicked. - gtk_widget_destroy(GTK_WIDGET(dialog)); - } -} - -void OnDestroy(GtkDialog* dialog, PageInfoWindowGtk* page_info) { - delete page_info; -} - -//////////////////////////////////////////////////////////////////////////////// -// PageInfoWindowGtk, public: -PageInfoWindowGtk::PageInfoWindowGtk(gfx::NativeWindow parent, - Profile* profile, - const GURL& url, - const NavigationEntry::SSLStatus& ssl, - bool show_history) - : ALLOW_THIS_IN_INITIALIZER_LIST(model_(profile, url, ssl, - show_history, this)), - url_(url), - contents_(NULL), - cert_id_(ssl.cert_id()) { - dialog_ = gtk_dialog_new_with_buttons( - l10n_util::GetStringUTF8(IDS_PAGEINFO_WINDOW_TITLE).c_str(), - parent, - // Non-modal. - GTK_DIALOG_NO_SEPARATOR, - NULL); - if (cert_id_) { - gtk_dialog_add_button( - GTK_DIALOG(dialog_), - l10n_util::GetStringUTF8(IDS_PAGEINFO_CERT_INFO_BUTTON).c_str(), - RESPONSE_SHOW_CERT_INFO); - } - gtk_dialog_add_button(GTK_DIALOG(dialog_), GTK_STOCK_CLOSE, - GTK_RESPONSE_CLOSE); - gtk_dialog_set_default_response(GTK_DIALOG(dialog_), GTK_RESPONSE_CLOSE); - - gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog_)->vbox), - gtk_util::kContentAreaSpacing); - g_signal_connect(dialog_, "response", G_CALLBACK(OnDialogResponse), this); - g_signal_connect(dialog_, "destroy", G_CALLBACK(OnDestroy), this); - - InitContents(); - - g_page_info_window_map[url.spec()] = this; -} - -PageInfoWindowGtk::~PageInfoWindowGtk() { - g_page_info_window_map.erase(url_.spec()); -} - -void PageInfoWindowGtk::ModelChanged() { - InitContents(); -} - -GtkWidget* PageInfoWindowGtk::CreateSection( - const PageInfoModel::SectionInfo& section) { - GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); - GtkWidget* label = gtk_label_new(UTF16ToUTF8(section.title).c_str()); - - PangoAttrList* attributes = pango_attr_list_new(); - pango_attr_list_insert(attributes, - pango_attr_weight_new(PANGO_WEIGHT_BOLD)); - gtk_label_set_attributes(GTK_LABEL(label), attributes); - pango_attr_list_unref(attributes); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - - GtkWidget* section_box = gtk_hbox_new(FALSE, 0); - GtkWidget* image = gtk_image_new_from_pixbuf( - model_.GetIconImage(section.icon_id)); - gtk_box_pack_start(GTK_BOX(section_box), image, FALSE, FALSE, - gtk_util::kControlSpacing); - gtk_misc_set_alignment(GTK_MISC(image), 0, 0); - - GtkWidget* text_box = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); - if (!section.headline.empty()) { - label = gtk_label_new(UTF16ToUTF8(section.headline).c_str()); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_box_pack_start(GTK_BOX(text_box), label, FALSE, FALSE, 0); - } - label = gtk_label_new(UTF16ToUTF8(section.description).c_str()); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); - // Allow linebreaking in the middle of words if necessary, so that extremely - // long hostnames (longer than one line) will still be completely shown. - gtk_label_set_line_wrap_mode(GTK_LABEL(label), PANGO_WRAP_WORD_CHAR); - gtk_box_pack_start(GTK_BOX(text_box), label, FALSE, FALSE, 0); - gtk_widget_set_size_request(label, 400, -1); - - gtk_box_pack_start(GTK_BOX(section_box), text_box, TRUE, TRUE, 0); - gtk_box_pack_start(GTK_BOX(vbox), section_box, TRUE, TRUE, 0); - - return vbox; -} - -void PageInfoWindowGtk::InitContents() { - if (contents_) - gtk_widget_destroy(contents_); - contents_ = gtk_vbox_new(FALSE, gtk_util::kContentAreaSpacing); - for (int i = 0; i < model_.GetSectionCount(); i++) { - gtk_box_pack_start(GTK_BOX(contents_), - CreateSection(model_.GetSectionInfo(i)), - FALSE, FALSE, 0); - } - gtk_widget_show_all(contents_); - gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog_)->vbox), contents_); -} - -void PageInfoWindowGtk::Show() { - gtk_widget_show(dialog_); -} - -void PageInfoWindowGtk::ShowCertDialog() { - ShowCertificateViewerByID(GTK_WINDOW(dialog_), cert_id_); -} - -} // namespace - -namespace browser { - -void ShowPageInfo(gfx::NativeWindow parent, - Profile* profile, - const GURL& url, - const NavigationEntry::SSLStatus& ssl, - bool show_history) { - PageInfoWindowMap::iterator iter = - g_page_info_window_map.find(url.spec()); - if (iter != g_page_info_window_map.end()) { - gtk_window_present(GTK_WINDOW(iter->second->widget())); - return; - } - - PageInfoWindowGtk* page_info_window = - new PageInfoWindowGtk(parent, profile, url, ssl, show_history); - page_info_window->Show(); -} - -} // namespace browser diff --git a/chrome/browser/page_info_model.cc b/chrome/browser/page_info_model.cc index b0d95ed..89fb5f92 100644 --- a/chrome/browser/page_info_model.cc +++ b/chrome/browser/page_info_model.cc @@ -182,18 +182,8 @@ PageInfoModel::PageInfoModel(Profile* profile, subject_name, base::IntToString16(ssl.security_bits()))); if (ssl.displayed_insecure_content() || ssl.ran_insecure_content()) { - // The old SSL dialog only had good and bad state, so for the old - // implementation we raise an error on finding mixed content. The new - // SSL info bubble has a warning state for displaying insecure content, - // so we check. The command line check will go away once we eliminate - // the old dialogs. - const CommandLine* command_line(CommandLine::ForCurrentProcess()); - if (!command_line->HasSwitch(switches::kDisableNewPageInfoBubble) && - !ssl.ran_insecure_content()) { - icon_id = ICON_STATE_WARNING_MINOR; - } else { - icon_id = ICON_STATE_ERROR; - } + icon_id = ssl.ran_insecure_content() ? + ICON_STATE_ERROR : ICON_STATE_WARNING_MINOR; description.assign(l10n_util::GetStringFUTF16( IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, description, @@ -289,13 +279,7 @@ PageInfoModel::SectionInfo PageInfoModel::GetSectionInfo(int index) { gfx::NativeImage PageInfoModel::GetIconImage(SectionStateIcon icon_id) { if (icon_id == ICON_NONE) return NULL; - // TODO(rsesek): Remove once the window is replaced with the bubble. - const CommandLine* command_line(CommandLine::ForCurrentProcess()); - if (command_line->HasSwitch(switches::kDisableNewPageInfoBubble) && - icon_id != ICON_STATE_OK) { - return icons_[ICON_STATE_WARNING_MAJOR]; - } - // The bubble uses new, various icons. + return icons_[icon_id]; } @@ -316,12 +300,7 @@ void PageInfoModel::OnGotVisitCountToHost(HistoryService::Handle handle, } // We only show the Site Information heading for the new dialogs. - string16 title; - const CommandLine* command_line(CommandLine::ForCurrentProcess()); - bool as_bubble = !command_line->HasSwitch( - switches::kDisableNewPageInfoBubble); - if (as_bubble) - title = l10n_util::GetStringUTF16(IDS_PAGE_INFO_SITE_INFO_TITLE); + string16 title = l10n_util::GetStringUTF16(IDS_PAGE_INFO_SITE_INFO_TITLE); if (!visited_before_today) { sections_.push_back(SectionInfo( @@ -334,8 +313,7 @@ void PageInfoModel::OnGotVisitCountToHost(HistoryService::Handle handle, SECTION_INFO_FIRST_VISIT)); } else { sections_.push_back(SectionInfo( - // TODO(rsesek): Remove once the window is replaced with the bubble. - as_bubble ? ICON_STATE_INFO : ICON_STATE_OK, + ICON_STATE_INFO, l10n_util::GetStringUTF16( IDS_PAGE_INFO_SECURITY_TAB_PERSONAL_HISTORY_TITLE), title, diff --git a/chrome/browser/page_info_window.h b/chrome/browser/page_info_window.h index 497f2ea..117510b 100644 --- a/chrome/browser/page_info_window.h +++ b/chrome/browser/page_info_window.h @@ -14,16 +14,6 @@ class GURL; namespace browser { -// Shows the page info using the specified information. -// |url| is the url of the page/frame the info applies to, |ssl| is the SSL -// information for that page/frame. If |show_history| is true, a section -// showing how many times that URL has been visited is added to the page info. -void ShowPageInfo(gfx::NativeWindow parent, - Profile* profile, - const GURL& url, - const NavigationEntry::SSLStatus& ssl, - bool show_history); - void ShowPageInfoBubble(gfx::NativeWindow parent, Profile* profile, const GURL& url, diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index 1ea94ae..bd3acc3 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -1225,11 +1225,7 @@ void BrowserView::ShowPageInfo(Profile* profile, parent = GetNormalBrowserWindowForBrowser(browser(), profile); #endif // defined(OS_CHROMEOS) - const CommandLine* command_line(CommandLine::ForCurrentProcess()); - if (!command_line->HasSwitch(switches::kDisableNewPageInfoBubble)) - browser::ShowPageInfoBubble(parent, profile, url, ssl, show_history); - else - browser::ShowPageInfo(parent, profile, url, ssl, show_history); + browser::ShowPageInfoBubble(parent, profile, url, ssl, show_history); } void BrowserView::ShowAppMenu() { diff --git a/chrome/browser/views/page_info_window_view.cc b/chrome/browser/views/page_info_window_view.cc deleted file mode 100644 index eee48ce..0000000 --- a/chrome/browser/views/page_info_window_view.cc +++ /dev/null @@ -1,440 +0,0 @@ -// 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 "build/build_config.h" - -#include "app/l10n_util.h" -#include "base/compiler_specific.h" -#include "base/utf_string_conversions.h" -#include "chrome/browser/cert_store.h" -#include "chrome/browser/certificate_viewer.h" -#include "chrome/browser/page_info_model.h" -#include "chrome/browser/page_info_window.h" -#include "chrome/browser/views/window.h" -#include "chrome/common/pref_names.h" -#include "grit/locale_settings.h" -#include "grit/generated_resources.h" -#include "net/base/x509_certificate.h" -#include "views/background.h" -#include "views/grid_layout.h" -#include "views/controls/button/native_button.h" -#include "views/controls/button/button.h" -#include "views/controls/image_view.h" -#include "views/controls/label.h" -#include "views/controls/separator.h" -#include "views/standard_layout.h" -#include "views/window/dialog_delegate.h" -#include "views/window/window.h" - -#if defined(OS_WIN) -#include "app/win_util.h" -#endif - -namespace { - -// Layout constants. -const int kHGapToBorder = 6; -const int kHGapTitleToSeparator = 2; -const int kVGapTitleToImage = 6; -const int kHGapImageToDescription = 6; -const int kVGapHeadLineToDescription = 2; -const int kHExtraSeparatorPadding = 2; -const int kHorizontalPadding = 10; -const int kVerticalPadding = 20; - -class PageInfoWindowView : public views::View, - public views::DialogDelegate, - public views::ButtonListener, - public PageInfoModel::PageInfoModelObserver { - public: - PageInfoWindowView(gfx::NativeWindow parent, - Profile* profile, - const GURL& url, - const NavigationEntry::SSLStatus& ssl, - bool show_history); - virtual ~PageInfoWindowView(); - - // This is the main initializer that creates the window. - virtual void Init(gfx::NativeWindow parent); - - // views::View overrides: - virtual gfx::Size GetPreferredSize(); - - // views::Window overridden method. - virtual void Show(); - - virtual void ShowCertDialog(int cert_id); - - // views::ButtonListener method. - virtual void ButtonPressed(views::Button* sender, const views::Event& event); - - // views::DialogDelegate methods: - virtual int GetDialogButtons() const; - virtual std::wstring GetWindowTitle() const; - virtual std::wstring GetWindowName() const; - virtual views::View* GetContentsView(); - virtual views::View* GetExtraView(); - virtual bool CanResize() const { return true; } - - // PageInfoModel::PageInfoModelObserver method. - virtual void ModelChanged(); - - private: - // This retrieves the sections from the model and lays them out. - void LayoutSections(); - - // Offsets the specified rectangle so it is showing on the screen and shifted - // from its original location. - void CalculateWindowBounds(gfx::Rect* bounds); - - views::NativeButton* cert_info_button_; - - // The model providing the various section info. - PageInfoModel model_; - - // The id of the certificate for this page. - int cert_id_; - - // A counter of how many page info windows are currently opened. - static int opened_window_count_; - - DISALLOW_COPY_AND_ASSIGN(PageInfoWindowView); -}; - -// A section contains an image that shows a status (good or bad), a title, an -// optional head-line (in bold) and a description. -class Section : public views::View { - public: - Section(const string16& title, - const string16& head_line, - const string16& description, - const SkBitmap* icon); - virtual ~Section(); - - virtual int GetHeightForWidth(int w); - virtual void Layout(); - - private: - // The text placed on top of the section (on the left of the separator bar). - string16 title_; - - // The first line of the description, show in bold. - string16 head_line_; - - // The description, displayed below the head line. - string16 description_; - - views::Label* title_label_; - views::Separator* separator_; - views::ImageView* status_image_; - views::Label* head_line_label_; - views::Label* description_label_; - - DISALLOW_COPY_AND_ASSIGN(Section); -}; - -// static -int PageInfoWindowView::opened_window_count_ = 0; - -} // namespace - -//////////////////////////////////////////////////////////////////////////////// -// PageInfoWindowViews - -PageInfoWindowView::PageInfoWindowView(gfx::NativeWindow parent, - Profile* profile, - const GURL& url, - const NavigationEntry::SSLStatus& ssl, - bool show_history) - : ALLOW_THIS_IN_INITIALIZER_LIST(model_(profile, url, ssl, - show_history, this)), - cert_id_(ssl.cert_id()) { - Init(parent); -} - -PageInfoWindowView::~PageInfoWindowView() { - DCHECK(opened_window_count_ > 0); - opened_window_count_--; -} - -void PageInfoWindowView::Init(gfx::NativeWindow parent) { -#if defined(OS_WIN) - DWORD sys_color = ::GetSysColor(COLOR_3DFACE); - SkColor color = SkColorSetRGB(GetRValue(sys_color), GetGValue(sys_color), - GetBValue(sys_color)); - set_background(views::Background::CreateSolidBackground(color)); -#endif - - LayoutSections(); - - if (opened_window_count_ > 0) { - // There already is a PageInfo window opened. Let's shift the location of - // the new PageInfo window so they don't overlap entirely. - // Window::Init will position the window from the stored location. - gfx::Rect bounds; - bool maximized = false; - if (GetSavedWindowBounds(&bounds) && GetSavedMaximizedState(&maximized)) { - CalculateWindowBounds(&bounds); - SaveWindowPlacement(bounds, maximized); - } - } - - browser::CreateViewsWindow(parent, gfx::Rect(), this); -} - -gfx::Size PageInfoWindowView::GetPreferredSize() { - return gfx::Size(views::Window::GetLocalizedContentsSize( - IDS_PAGEINFO_DIALOG_WIDTH_CHARS, IDS_PAGEINFO_DIALOG_HEIGHT_LINES)); -} - -void PageInfoWindowView::LayoutSections() { - // Remove all the existing sections. - RemoveAllChildViews(true); - - views::GridLayout* layout = new views::GridLayout(this); - SetLayoutManager(layout); - views::ColumnSet* columns = layout->AddColumnSet(0); - columns->AddPaddingColumn(0, kHorizontalPadding); - columns->AddColumn(views::GridLayout::FILL, // Horizontal resize. - views::GridLayout::FILL, // Vertical resize. - 1, // Resize weight. - views::GridLayout::USE_PREF, // Size type. - 0, // Ignored for USE_PREF. - 0); // Minimum size. - columns->AddPaddingColumn(0, kHorizontalPadding); - - layout->AddPaddingRow(0, kVerticalPadding); - for (int i = 0; i < model_.GetSectionCount(); ++i) { - PageInfoModel::SectionInfo info = model_.GetSectionInfo(i); - layout->StartRow(0, 0); - layout->AddView(new Section(info.title, info.headline, info.description, - model_.GetIconImage(info.icon_id))); - layout->AddPaddingRow(0, kVerticalPadding); - } - layout->AddPaddingRow(1, kVerticalPadding); - - Layout(); -} - -void PageInfoWindowView::Show() { - window()->Show(); - opened_window_count_++; -} - -int PageInfoWindowView::GetDialogButtons() const { - return MessageBoxFlags::DIALOGBUTTON_CANCEL; -} - -std::wstring PageInfoWindowView::GetWindowTitle() const { - return l10n_util::GetString(IDS_PAGEINFO_WINDOW_TITLE); -} - -std::wstring PageInfoWindowView::GetWindowName() const { - return UTF8ToWide(prefs::kPageInfoWindowPlacement); -} - -views::View* PageInfoWindowView::GetContentsView() { - return this; -} - -views::View* PageInfoWindowView::GetExtraView() { - if (!cert_id_) - return NULL; - scoped_refptr<net::X509Certificate> cert; - CertStore::GetSharedInstance()->RetrieveCert(cert_id_, &cert); - // When running with Gears, we have no os certificate, so there is no cert - // to show. Don't bother showing the cert info button in that case. - if (!cert.get() || !cert->os_cert_handle()) - return NULL; - - // The dialog sizes the extra view to fill the entire available space. - // We use a container to layout it out properly. - views::View* button_container = new views::View(); - views::GridLayout* layout = new views::GridLayout(button_container); - button_container->SetLayoutManager(layout); - - views::ColumnSet* column_set = layout->AddColumnSet(0); - column_set->AddPaddingColumn(0, kHorizontalPadding); - column_set->AddColumn(views::GridLayout::LEADING, - views::GridLayout::LEADING, 0, - views::GridLayout::USE_PREF, 0, 0); - layout->StartRow(0, 0); - layout->AddView(new views::NativeButton(this, - l10n_util::GetString(IDS_PAGEINFO_CERT_INFO_BUTTON))); - - return button_container; -} - -void PageInfoWindowView::ModelChanged() { - LayoutSections(); -} - -void PageInfoWindowView::ButtonPressed( - views::Button* sender, const views::Event& event) { - // So far we only listen for the "Certificate info" button. - DCHECK(cert_id_ != 0); - ShowCertDialog(cert_id_); -} - -void PageInfoWindowView::CalculateWindowBounds(gfx::Rect* bounds) { - const int kDefaultOffset = 15; - -#if defined(OS_WIN) - gfx::Rect monitor_bounds(win_util::GetMonitorBoundsForRect(*bounds)); - if (monitor_bounds.IsEmpty()) - return; -#else - gfx::Rect monitor_bounds(0, 0, 1024, 768); -#endif - - // If necessary, move the window so it is visible on the screen. - gfx::Rect adjusted_bounds = bounds->AdjustToFit(monitor_bounds); - if (adjusted_bounds != *bounds) { - // The bounds have moved, we are done. - *bounds = adjusted_bounds; - return; - } - - // Move the window from its specified position, trying to keep it entirely - // visible. - int x_offset, y_offset; - if (bounds->right() + kDefaultOffset >= monitor_bounds.right() && - abs(monitor_bounds.x() - bounds->x()) >= kDefaultOffset) { - x_offset = -kDefaultOffset; - } else { - x_offset = kDefaultOffset; - } - - if (bounds->bottom() + kDefaultOffset >= monitor_bounds.bottom() && - abs(monitor_bounds.y() - bounds->y()) >= kDefaultOffset) { - y_offset = -kDefaultOffset; - } else { - y_offset = kDefaultOffset; - } - - bounds->Offset(x_offset, y_offset); -} - -void PageInfoWindowView::ShowCertDialog(int cert_id) { - ShowCertificateViewerByID(window()->GetNativeWindow(), cert_id); -} - -//////////////////////////////////////////////////////////////////////////////// -// Section - -Section::Section(const string16& title, - const string16& head_line, - const string16& description, - const SkBitmap* icon) - : title_(title), - head_line_(head_line), - description_(description) { - title_label_ = new views::Label(UTF16ToWideHack(title)); - title_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); - AddChildView(title_label_); - -#if defined(OS_WIN) - separator_ = new views::Separator(); - AddChildView(separator_); -#else - NOTIMPLEMENTED(); -#endif - - status_image_ = new views::ImageView(); - status_image_->SetImage(*icon); - AddChildView(status_image_); - - head_line_label_ = new views::Label(UTF16ToWideHack(head_line)); - head_line_label_->SetFont( - head_line_label_->font().DeriveFont(0, gfx::Font::BOLD)); - head_line_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); - AddChildView(head_line_label_); - - description_label_ = new views::Label(UTF16ToWideHack(description)); - description_label_->SetMultiLine(true); - description_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); - // Allow linebreaking in the middle of words if necessary, so that extremely - // long hostnames (longer than one line) will still be completely shown. - description_label_->SetAllowCharacterBreak(true); - AddChildView(description_label_); -} - -Section::~Section() { -} - -int Section::GetHeightForWidth(int width) { - // The height of the section depends on the height of the description label - // (multi-line). We need to know the width of the description label to know - // its height. - int height = 0; - gfx::Size size = title_label_->GetPreferredSize(); - height += size.height() + kVGapTitleToImage; - - gfx::Size image_size = status_image_->GetPreferredSize(); - - int text_height = 0; - if (!head_line_label_->GetText().empty()) { - size = head_line_label_->GetPreferredSize(); - text_height = size.height() + kVGapHeadLineToDescription; - } - - int description_width = - width - image_size.width() - kHGapImageToDescription - kHGapToBorder; - text_height += description_label_->GetHeightForWidth(description_width); - - height += std::max(image_size.height(), text_height); - - return height; -} - -void Section::Layout() { - // First, layout the title and separator. - int x = 0; - int y = 0; - gfx::Size size = title_label_->GetPreferredSize(); - title_label_->SetBounds(x, y, size.width(), size.height()); - x += size.width() + kHGapTitleToSeparator; -#if defined(OS_WIN) - separator_->SetBounds(x + kHExtraSeparatorPadding, y, - width() - x - 2 * kHExtraSeparatorPadding, - size.height()); -#else - NOTIMPLEMENTED(); -#endif - - // Then the image, head-line and description. - x = kHGapToBorder; - y += title_label_->height() + kVGapTitleToImage; - size = status_image_->GetPreferredSize(); - status_image_->SetBounds(x, y, size.width(), size.height()); - x += size.width() + kHGapImageToDescription; - int w = width() - x; - if (!head_line_label_->GetText().empty()) { - size = head_line_label_->GetPreferredSize(); - head_line_label_->SetBounds(x, y, w > 0 ? w : 0, size.height()); - y += size.height() + kVGapHeadLineToDescription; - } else { - head_line_label_->SetBounds(x, y, 0, 0); - } - if (w > 0) { - description_label_->SetBounds(x, y, w, - description_label_->GetHeightForWidth(w)); - } else { - description_label_->SetBounds(x, y, 0, 0); - } -} - -namespace browser { - -void ShowPageInfo(gfx::NativeWindow parent, - Profile* profile, - const GURL& url, - const NavigationEntry::SSLStatus& ssl, - bool show_history) { - PageInfoWindowView* page_info_window = - new PageInfoWindowView(parent, profile, url, ssl, show_history); - page_info_window->Show(); -} - -} diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 7d77275..b5b3e0f 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1904,7 +1904,6 @@ 'browser/gtk/owned_widget_gtk.cc', 'browser/gtk/owned_widget_gtk.h', 'browser/gtk/page_info_bubble_gtk.cc', - 'browser/gtk/page_info_window_gtk.cc', 'browser/gtk/process_singleton_dialog.cc', 'browser/gtk/process_singleton_dialog.h', 'browser/gtk/reload_button_gtk.cc', @@ -3175,7 +3174,6 @@ 'browser/views/options/simple_content_exceptions_view.h', 'browser/views/page_info_bubble_view.cc', 'browser/views/page_info_bubble_view.h', - 'browser/views/page_info_window_view.cc', 'browser/views/pinned_contents_info_bubble.cc', 'browser/views/pinned_contents_info_bubble.h', 'browser/views/reload_button.cc', @@ -3814,7 +3812,6 @@ ['include', '^browser/views/options/options_page_view.cc'], ['include', '^browser/views/options/options_page_view.h'], ['include', '^browser/views/page_info_bubble_view.cc'], - ['include', '^browser/views/page_info_window_view.cc'], ['include', '^browser/views/panel_controller.cc'], ['include', '^browser/views/panel_controller.h'], ['include', '^browser/views/panels/panel_container.cc'], diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index d38d1b0..cff7f30 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -243,10 +243,6 @@ const char kDisableLocalStorage[] = "disable-local-storage"; // builds. const char kDisableLogging[] = "disable-logging"; -// Disable the Page Info SSL dialog as a bubble, reverting back to a separate -// window. -const char kDisableNewPageInfoBubble[] = "disable-new-page-info-bubble"; - // Whether we should prevent the new tab page from showing the first run // notification. const char kDisableNewTabFirstRun[] = "disable-new-tab-first-run"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index e5c6477..094ca73 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -80,7 +80,6 @@ extern const char kDisableJavaScript[]; extern const char kDisableJava[]; extern const char kDisableLocalStorage[]; extern const char kDisableLogging[]; -extern const char kDisableNewPageInfoBubble[]; extern const char kDisableNewTabFirstRun[]; extern const char kDisableOutdatedPlugins[]; extern const char kDisablePlugins[]; |