diff options
author | markusheintz@chromium.org <markusheintz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-25 09:57:41 +0000 |
---|---|---|
committer | markusheintz@chromium.org <markusheintz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-25 09:57:41 +0000 |
commit | 24c8818cc2546b92de0e7b2cdc95eba51bd99379 (patch) | |
tree | db44c21d4a4619fcc5bb437bdb63551a0665b8dd /chrome | |
parent | 31b7610edd7f86ada422938430dc5feed12cfd0c (diff) | |
download | chromium_src-24c8818cc2546b92de0e7b2cdc95eba51bd99379.zip chromium_src-24c8818cc2546b92de0e7b2cdc95eba51bd99379.tar.gz chromium_src-24c8818cc2546b92de0e7b2cdc95eba51bd99379.tar.bz2 |
Display site permissions in a tab and add a tab to display information about the site's identity and the site's connection.
UI string changes: https://chromiumcodereview.appspot.com/10180002/
BUG=113688
TEST=WebsiteSettingsTest*
Review URL: https://chromiumcodereview.appspot.com/10163002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133886 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/ui/gtk/website_settings_popup_gtk.cc | 173 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/website_settings_popup_gtk.h | 18 | ||||
-rw-r--r-- | chrome/browser/ui/website_settings_ui.cc | 5 | ||||
-rw-r--r-- | chrome/browser/ui/website_settings_ui.h | 26 | ||||
-rw-r--r-- | chrome/browser/website_settings.cc | 43 | ||||
-rw-r--r-- | chrome/browser/website_settings.h | 4 | ||||
-rw-r--r-- | chrome/browser/website_settings_unittest.cc | 6 |
7 files changed, 205 insertions, 70 deletions
diff --git a/chrome/browser/ui/gtk/website_settings_popup_gtk.cc b/chrome/browser/ui/gtk/website_settings_popup_gtk.cc index 5fe5345..f06805c 100644 --- a/chrome/browser/ui/gtk/website_settings_popup_gtk.cc +++ b/chrome/browser/ui/gtk/website_settings_popup_gtk.cc @@ -32,6 +32,10 @@ using content::OpenURLParams; namespace { +// The background color of the tabs if a theme other than the native GTK theme +// is selected. +const GdkColor kBackgroundColor = GDK_COLOR_RGB(0xff, 0xff, 0xff); + std::string PermissionTypeToString(ContentSettingsType type) { switch (type) { case CONTENT_SETTINGS_TYPE_POPUPS: @@ -74,9 +78,10 @@ WebsiteSettingsPopupGtk::WebsiteSettingsPopupGtk( profile_(profile), tab_contents_wrapper_(tab_contents_wrapper), browser_(NULL), - site_info_contents_(NULL), + header_box_(NULL), cookies_section_contents_(NULL), permissions_section_contents_(NULL), + identity_tab_contents_(NULL), presenter_(NULL) { BrowserWindowGtk* browser_window = BrowserWindowGtk::GetBrowserWindowForNativeWindow(parent); @@ -125,31 +130,59 @@ void WebsiteSettingsPopupGtk::InitContents() { gtk_util::RemoveAllChildren(contents_); } - site_info_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing); - std::string title = - l10n_util::GetStringUTF8(IDS_PAGE_INFO_SITE_INFO_TITLE); - gtk_box_pack_start(GTK_BOX(contents_), - CreateSection(title, site_info_contents_), - FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(contents_), - gtk_hseparator_new(), - FALSE, FALSE, 0); + // Create popup header. + header_box_ = gtk_vbox_new(FALSE, ui::kControlSpacing); + gtk_box_pack_start(GTK_BOX(contents_), header_box_, FALSE, FALSE, 0); + + // Create the container for the contents of the permissions tab. + GtkWidget* permission_tab_contents = gtk_vbox_new(FALSE, ui::kControlSpacing); + gtk_container_set_border_width(GTK_CONTAINER(permission_tab_contents), 10); cookies_section_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing); - title = l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_TITLE_SITE_DATA); - gtk_box_pack_start(GTK_BOX(contents_), + std::string title = l10n_util::GetStringUTF8( + IDS_WEBSITE_SETTINGS_TITLE_SITE_DATA); + gtk_box_pack_start(GTK_BOX(permission_tab_contents), CreateSection(title, cookies_section_contents_), FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(contents_), + gtk_box_pack_start(GTK_BOX(permission_tab_contents), gtk_hseparator_new(), FALSE, FALSE, 0); permissions_section_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing); title = l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_TITLE_SITE_PERMISSIONS); - gtk_box_pack_start(GTK_BOX(contents_), + gtk_box_pack_start(GTK_BOX(permission_tab_contents), CreateSection(title, permissions_section_contents_), FALSE, FALSE, 0); + // Create the container for the contents of the identity tab. + GtkWidget* info_tab = gtk_vbox_new(FALSE, ui::kControlSpacing); + identity_tab_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing); + gtk_container_set_border_width(GTK_CONTAINER(identity_tab_contents_), 10); + gtk_box_pack_start(GTK_BOX(info_tab), + identity_tab_contents_, + FALSE, FALSE, 0); + + // Create tab container and add all tabs. + GtkWidget* notebook = gtk_notebook_new(); + if (theme_service_->UsingNativeTheme()) + gtk_widget_modify_bg(notebook, GTK_STATE_NORMAL, NULL); + else + gtk_widget_modify_bg(notebook, GTK_STATE_NORMAL, &kBackgroundColor); + + GtkWidget* label = theme_service_->BuildLabel( + l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_TAB_LABEL_PERMISSIONS), + ui::kGdkBlack); + gtk_widget_show(label); + gtk_notebook_append_page( + GTK_NOTEBOOK(notebook), permission_tab_contents, label); + + label = theme_service_->BuildLabel( + l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_TAB_LABEL_IDENTITY), + ui::kGdkBlack); + gtk_widget_show(label); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), info_tab, label); + + gtk_box_pack_start(GTK_BOX(contents_), notebook, FALSE, FALSE, 0); gtk_widget_show_all(contents_); } @@ -161,18 +194,6 @@ void WebsiteSettingsPopupGtk::ClearContainer(GtkWidget* container) { } } -void WebsiteSettingsPopupGtk::SetSiteInfo(const std::string& site_info) { - DCHECK(site_info_contents_); - ClearContainer(site_info_contents_); - GtkWidget* label = theme_service_->BuildLabel(site_info, - ui::kGdkBlack); - GtkWidget* site_info_entry_box = gtk_hbox_new(FALSE, ui::kControlSpacing); - gtk_box_pack_start(GTK_BOX(site_info_entry_box), label, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(site_info_contents_), site_info_entry_box, FALSE, - FALSE, 0); - gtk_widget_show_all(site_info_contents_); -} - GtkWidget* WebsiteSettingsPopupGtk::CreateSection(std::string section_title, GtkWidget* section_content) { GtkWidget* section_box = gtk_vbox_new(FALSE, ui::kControlSpacing); @@ -209,14 +230,7 @@ void WebsiteSettingsPopupGtk::SetCookieInfo( it != cookie_info_list.end(); ++it) { GtkWidget* cookies_info = gtk_hbox_new(FALSE, 0); - - GtkWidget* label = theme_service_->BuildLabel(it->cookie_source, - ui::kGdkBlack); - gtk_label_set_selectable(GTK_LABEL(label), TRUE); - gtk_util::SetLabelWidth(label, 200); - // 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); + GtkWidget* label = CreateTextLabel(it->cookie_source, 200); gtk_box_pack_start(GTK_BOX(cookies_info), label, FALSE, FALSE, 0); std::string allowed_count = base::IntToString(it->allowed); @@ -251,6 +265,92 @@ void WebsiteSettingsPopupGtk::SetCookieInfo( gtk_widget_show_all(cookies_section_contents_); } +GtkWidget* WebsiteSettingsPopupGtk::CreateTextLabel(const std::string& text, + int width) { + GtkWidget* label = theme_service_->BuildLabel(text, ui::kGdkBlack); + gtk_util::SetLabelWidth(label, width); + gtk_label_set_selectable(GTK_LABEL(label), TRUE); + gtk_label_set_line_wrap_mode(GTK_LABEL(label), PANGO_WRAP_WORD_CHAR); + return label; +} + +void WebsiteSettingsPopupGtk::SetIdentityInfo( + const IdentityInfo& identity_info) { + // Create popup header. + DCHECK(header_box_); + ClearContainer(header_box_); + + GtkWidget* identity_label = theme_service_->BuildLabel( + identity_info.site_identity, ui::kGdkBlack); + gtk_label_set_selectable(GTK_LABEL(identity_label), TRUE); + PangoAttrList* attributes = pango_attr_list_new(); + pango_attr_list_insert(attributes, + pango_attr_weight_new(PANGO_WEIGHT_BOLD)); + gtk_label_set_attributes(GTK_LABEL(identity_label), attributes); + pango_attr_list_unref(attributes); + gtk_util::SetLabelWidth(identity_label, 400); + gtk_box_pack_start(GTK_BOX(header_box_), identity_label, FALSE, FALSE, 0); + + std::string identity_status_text; + switch (identity_info.identity_status) { + case WebsiteSettings::SITE_IDENTITY_STATUS_CERT: + case WebsiteSettings::SITE_IDENTITY_STATUS_DNSSEC_CERT: + case WebsiteSettings::SITE_IDENTITY_STATUS_EV_CERT: + identity_status_text = + l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_IDENTITY_VERIFIED); + break; + default: + identity_status_text = + l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_IDENTITY_NOT_VERIFIED); + break; + } + GtkWidget* status_label = CreateTextLabel(identity_status_text, 400); + gtk_box_pack_start( + GTK_BOX(header_box_), status_label, FALSE, FALSE, 0); + gtk_widget_show_all(header_box_); + + // Create identity tab contents. + DCHECK(identity_tab_contents_); + ClearContainer(identity_tab_contents_); + + // Create identity section. + GtkWidget* identity_description = + CreateTextLabel(identity_info.identity_status_description, 300); + GtkWidget* identity_box = gtk_vbox_new(FALSE, ui::kControlSpacing); + gtk_box_pack_start(GTK_BOX(identity_box), identity_description, FALSE, FALSE, + 0); + + // Create connection section. + GtkWidget* connection_description = + CreateTextLabel(identity_info.connection_status_description, 300); + GtkWidget* connection_box = gtk_vbox_new(FALSE, ui::kControlSpacing); + gtk_box_pack_start(GTK_BOX(connection_box), connection_description, FALSE, + FALSE, 0); + + // Add to contents. + gtk_box_pack_start( + GTK_BOX(identity_tab_contents_), CreateSection( + l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_TITEL_IDENTITY), + identity_box), + TRUE, + FALSE, + 0); + gtk_box_pack_start(GTK_BOX(identity_tab_contents_), + gtk_hseparator_new(), + FALSE, FALSE, 0); + gtk_box_pack_start( + GTK_BOX(identity_tab_contents_), + CreateSection( + l10n_util::GetStringUTF8( + IDS_WEBSITE_SETTINGS_TITEL_CONNECTION), + connection_box), + TRUE, + FALSE, + 0); + + gtk_widget_show_all(identity_tab_contents_); +} + void WebsiteSettingsPopupGtk::SetPermissionInfo( const PermissionInfoList& permission_info_list) { DCHECK(permissions_section_contents_); @@ -261,9 +361,8 @@ void WebsiteSettingsPopupGtk::SetPermissionInfo( permission != permission_info_list.end(); ++permission) { // Add a label for the permission type. - GtkWidget* label = theme_service_->BuildLabel( - PermissionTypeToString(permission->type), ui::kGdkBlack); - gtk_util::SetLabelWidth(label, 280); + GtkWidget* label = + CreateTextLabel(PermissionTypeToString(permission->type), 250); GtkWidget* hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); diff --git a/chrome/browser/ui/gtk/website_settings_popup_gtk.h b/chrome/browser/ui/gtk/website_settings_popup_gtk.h index 3cd004a..f2e69dd 100644 --- a/chrome/browser/ui/gtk/website_settings_popup_gtk.h +++ b/chrome/browser/ui/gtk/website_settings_popup_gtk.h @@ -31,10 +31,10 @@ class WebsiteSettingsPopupGtk : public WebsiteSettingsUI, // WebsiteSettingsUI implementations. virtual void SetPresenter(WebsiteSettings* presenter) OVERRIDE; - virtual void SetSiteInfo(const std::string& site_info) OVERRIDE; virtual void SetCookieInfo(const CookieInfoList& cookie_info_list) OVERRIDE; virtual void SetPermissionInfo( const PermissionInfoList& permission_info_list) OVERRIDE; + virtual void SetIdentityInfo(const IdentityInfo& identity_info) OVERRIDE; // BubbleDelegateGtk implementation. virtual void BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) OVERRIDE; @@ -46,8 +46,11 @@ class WebsiteSettingsPopupGtk : public WebsiteSettingsUI, // Removes all children of |container|. void ClearContainer(GtkWidget* container); - // Creates a popup section and returns a virtual box that contains the section - // content. + // Creates a label that contains the given |text| and has the given |width|. + GtkWidget* CreateTextLabel(const std::string& text, int width); + + // Creates a popup section and returns a virtual box that contains the + // section content. GtkWidget* CreateSection(std::string section_title, GtkWidget* section_content); @@ -82,13 +85,18 @@ class WebsiteSettingsPopupGtk : public WebsiteSettingsUI, // settings page in a new tab. Browser* browser_; - // Container for the site info section content. - GtkWidget* site_info_contents_; + // Container for the popup header content. + GtkWidget* header_box_; + // Container for the cookies and site data section content. GtkWidget* cookies_section_contents_; + // Container for the permissions section content. GtkWidget* permissions_section_contents_; + // Container for the identity tab content. + GtkWidget* identity_tab_contents_; + // The UI translates user actions to specific events and forwards them to the // |presenter_|. The |presenter_| handles these events and updates the UI. WebsiteSettings* presenter_; diff --git a/chrome/browser/ui/website_settings_ui.cc b/chrome/browser/ui/website_settings_ui.cc index efb7957..a0eb739 100644 --- a/chrome/browser/ui/website_settings_ui.cc +++ b/chrome/browser/ui/website_settings_ui.cc @@ -14,5 +14,10 @@ WebsiteSettingsUI::PermissionInfo::PermissionInfo() default_setting(CONTENT_SETTING_DEFAULT) { } +WebsiteSettingsUI::IdentityInfo::IdentityInfo() + : identity_status(WebsiteSettings::SITE_IDENTITY_STATUS_UNKNOWN), + connection_status(WebsiteSettings::SITE_CONNECTION_STATUS_UNKNOWN) { +} + WebsiteSettingsUI::~WebsiteSettingsUI() { } diff --git a/chrome/browser/ui/website_settings_ui.h b/chrome/browser/ui/website_settings_ui.h index 8368767..86b820c 100644 --- a/chrome/browser/ui/website_settings_ui.h +++ b/chrome/browser/ui/website_settings_ui.h @@ -9,6 +9,7 @@ #include <string> #include <vector> +#include "chrome/browser/website_settings.h" #include "chrome/common/content_settings.h" #include "chrome/common/content_settings_types.h" #include "ui/gfx/native_widget_types.h" @@ -58,21 +59,40 @@ class WebsiteSettingsUI { ContentSetting default_setting; }; + // |IdentityInfo| contains information about the site's identity and + // connection. + struct IdentityInfo { + IdentityInfo(); + + // The site's identity. + std::string site_identity; + // Status of the site's identity. + WebsiteSettings::SiteIdentityStatus identity_status; + // Textual description of the site's identity status that is displayed to + // the user. + std::string identity_status_description; + // Status of the site's connection. + WebsiteSettings::SiteConnectionStatus connection_status; + // Textual description of the site's connection status that is displayed to + // the user. + std::string connection_status_description; + }; + virtual ~WebsiteSettingsUI(); // Sets the |presenter| of the WebsiteSettingsUI that is responsible for // setting the data to display in the UI. virtual void SetPresenter(WebsiteSettings* presenter) = 0; - // Sets site information. - virtual void SetSiteInfo(const std::string& site_info) = 0; - // Sets cookie information. virtual void SetCookieInfo(const CookieInfoList& cookie_info_list) = 0; // Sets permision information. virtual void SetPermissionInfo( const PermissionInfoList& permission_info_list) = 0; + + // Sets site identity information. + virtual void SetIdentityInfo(const IdentityInfo& identity_info) = 0; }; class CookieInfoList : public std::vector<WebsiteSettingsUI::CookieInfo> { diff --git a/chrome/browser/website_settings.cc b/chrome/browser/website_settings.cc index 5850576..d63ccf9 100644 --- a/chrome/browser/website_settings.cc +++ b/chrome/browser/website_settings.cc @@ -84,31 +84,10 @@ WebsiteSettings::WebsiteSettings( content_settings_(profile->GetHostContentSettingsMap()) { ui_->SetPresenter(this); Init(profile, url, ssl); - // After initialization the status about the site's connection - // and it's identity must be available. - DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN); - DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN); - - // TODO(markusheintz): Add the strings below to the grd file once a decision - // has been made about the exact wording. - std::string site_info; - switch (site_identity_status_) { - case WebsiteSettings::SITE_IDENTITY_STATUS_CERT: - case WebsiteSettings::SITE_IDENTITY_STATUS_DNSSEC_CERT: - site_info = "Identity verified"; - break; - case WebsiteSettings::SITE_IDENTITY_STATUS_EV_CERT: - site_info = UTF16ToUTF8(organization_name()); - site_info += " - Identity verified"; - break; - default: - site_info = "Identity not verified"; - break; - } - ui_->SetSiteInfo(site_info); PresentSitePermissions(); PresentSiteData(); + PresentSiteIdentity(); } WebsiteSettings::~WebsiteSettings() { @@ -445,6 +424,26 @@ void WebsiteSettings::PresentSiteData() { ui_->SetCookieInfo(cookie_info_list); } +void WebsiteSettings::PresentSiteIdentity() { + // After initialization the status about the site's connection + // and it's identity must be available. + DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN); + DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN); + WebsiteSettingsUI::IdentityInfo info; + if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT) + info.site_identity = UTF16ToUTF8(organization_name()); + else + info.site_identity = site_url_.host(); + + info.connection_status = site_connection_status_; + info.connection_status_description = + UTF16ToUTF8(site_connection_details_); + info.identity_status = site_identity_status_; + info.identity_status_description = + UTF16ToUTF8(site_identity_details_); + ui_->SetIdentityInfo(info); +} + // static void WebsiteSettings::Show(gfx::NativeWindow parent, Profile* profile, diff --git a/chrome/browser/website_settings.h b/chrome/browser/website_settings.h index 3722d03..781657a 100644 --- a/chrome/browser/website_settings.h +++ b/chrome/browser/website_settings.h @@ -131,6 +131,10 @@ class WebsiteSettings : public TabSpecificContentSettings::SiteDataObserver { // Sets (presents) the information about the site's data in the |ui_|. void PresentSiteData(); + // Sets (presents) the information about the site's identity and connection + // in the |ui_|. + void PresentSiteIdentity(); + // The website settings UI displays information and controls for site // specific data (local stored objects like cookies), site specific // permissions (location, popup, plugin, etc. permissions) and site specific diff --git a/chrome/browser/website_settings_unittest.cc b/chrome/browser/website_settings_unittest.cc index 9b70c16..da121f7 100644 --- a/chrome/browser/website_settings_unittest.cc +++ b/chrome/browser/website_settings_unittest.cc @@ -57,10 +57,10 @@ class MockWebsiteSettingsUI : public WebsiteSettingsUI { public: virtual ~MockWebsiteSettingsUI() {} MOCK_METHOD1(SetPresenter, void(WebsiteSettings* presenter)); - MOCK_METHOD1(SetSiteInfo, void(const std::string& site_info)); MOCK_METHOD1(SetCookieInfo, void(const CookieInfoList& cookie_info_list)); MOCK_METHOD1(SetPermissionInfo, void(const PermissionInfoList& permission_info_list)); + MOCK_METHOD1(SetIdentityInfo, void(const IdentityInfo& identity_info)); }; class WebsiteSettingsTest : public ChromeRenderViewHostTestHarness { @@ -115,7 +115,7 @@ class WebsiteSettingsTest : public ChromeRenderViewHostTestHarness { void SetDefaultUIExpectations(MockWebsiteSettingsUI* mock_ui) { // During creation |WebsiteSettings| makes the following calls to the ui. EXPECT_CALL(*mock_ui, SetPermissionInfo(_)); - EXPECT_CALL(*mock_ui, SetSiteInfo(_)); + EXPECT_CALL(*mock_ui, SetIdentityInfo(_)); EXPECT_CALL(*mock_ui, SetPresenter(_)); EXPECT_CALL(*mock_ui, SetCookieInfo(_)); } @@ -202,7 +202,7 @@ TEST_F(WebsiteSettingsTest, OnPermissionsChanged) { TEST_F(WebsiteSettingsTest, OnSiteDataAccessed) { EXPECT_CALL(*mock_ui(), SetPermissionInfo(_)); - EXPECT_CALL(*mock_ui(), SetSiteInfo(_)); + EXPECT_CALL(*mock_ui(), SetIdentityInfo(_)); EXPECT_CALL(*mock_ui(), SetPresenter(_)); EXPECT_CALL(*mock_ui(), SetCookieInfo(_)).Times(2); |