summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarkusheintz@chromium.org <markusheintz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-11 14:27:33 +0000
committermarkusheintz@chromium.org <markusheintz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-11 14:27:33 +0000
commitbc19fbe4c947c7ce5ee5f19d0ae13e91dd5c38a3 (patch)
tree04c04d7a35c76e17cd13b81dc3d73fc02ab291e2
parente5b5c6e90f3b850542a5bfd010cf0370f1a34f6a (diff)
downloadchromium_src-bc19fbe4c947c7ce5ee5f19d0ae13e91dd5c38a3.zip
chromium_src-bc19fbe4c947c7ce5ee5f19d0ae13e91dd5c38a3.tar.gz
chromium_src-bc19fbe4c947c7ce5ee5f19d0ae13e91dd5c38a3.tar.bz2
Add views implementation of the WebsiteSettingsUI.
BUG=113688 TEST=PageInfoBubble is replaced by WebsiteSettingsUI if cmd arg --enable-website-settings is used. Review URL: https://chromiumcodereview.appspot.com/10456017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141407 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/generated_resources.grd9
-rw-r--r--chrome/browser/ui/gtk/website_settings_popup_gtk.cc28
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc4
-rw-r--r--chrome/browser/ui/views/website_settings_popup_view.cc620
-rw-r--r--chrome/browser/ui/views/website_settings_popup_view.h146
-rw-r--r--chrome/browser/ui/website_settings/website_settings_ui.cc34
-rw-r--r--chrome/browser/ui/website_settings/website_settings_ui.h7
-rw-r--r--chrome/chrome_browser.gypi2
8 files changed, 825 insertions, 25 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index f42c47c..a54505c 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -260,6 +260,15 @@ are declared in build/common.gypi.
<message name="IDS_WEBSITE_SETTINGS_THIRD_PARTY_SITE_DATA" desc="The label of the counts for allowed and blocked third party cookies and site data.">
Others
</message>
+ <message name="IDS_WEBSITE_SETTINGS_SITE_DATA_STATS_LINE" desc="The label text with the number of allowed and blocked cookies and site data objects.">
+ <ph name="DATA_SOURCE">$1<ex>foo.bar.org</ex></ph> (<ph name="ALLOWED_COUNT">$2<ex>6</ex></ph> Allowed / <ph name="BLOCKED_COUNT">$3<ex>0</ex></ph> Blocked)
+ </message>
+ <message name="IDS_WEBSITE_SETTINGS_DEFAULT_PERMISSION_LABEL" desc="The label for the global default setting that is used in a permissions dropdown.">
+ Use global default (<ph name="PERMISSION_VALUE">$1<ex>ALLOW</ex></ph>)
+ </message>
+ <message name="IDS_WEBSITE_SETTINGS_PERMISSION_LABEL" desc="The label for a permission value that is used in the permisisons dropdown.">
+ Always <ph name="PERMISSION_VALUE">$1<ex>ALLOW</ex></ph>
+ </message>
<message name="IDS_SHOWFULLHISTORY_LINK" desc="The label of the Show Full History link at the bottom of the back/forward menu.">
Show Full History
diff --git a/chrome/browser/ui/gtk/website_settings_popup_gtk.cc b/chrome/browser/ui/gtk/website_settings_popup_gtk.cc
index ec74b5e..b6099b9 100644
--- a/chrome/browser/ui/gtk/website_settings_popup_gtk.cc
+++ b/chrome/browser/ui/gtk/website_settings_popup_gtk.cc
@@ -38,33 +38,13 @@ namespace {
const GdkColor kBackgroundColor = GDK_COLOR_RGB(0xff, 0xff, 0xff);
std::string PermissionTypeToString(ContentSettingsType type) {
- switch (type) {
- case CONTENT_SETTINGS_TYPE_POPUPS:
- return l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_TYPE_POPUPS);
- case CONTENT_SETTINGS_TYPE_PLUGINS:
- return l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_TYPE_PLUGINS);
- case CONTENT_SETTINGS_TYPE_GEOLOCATION:
- return l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_TYPE_LOCATION);
- case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
- return l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_TYPE_NOTIFICATIONS);
- default:
- NOTREACHED();
- return "";
- }
+ return l10n_util::GetStringUTF8(
+ WebsiteSettingsUI::PermissionTypeToUIStringID(type));
}
std::string PermissionValueToString(ContentSetting value) {
- switch (value) {
- case CONTENT_SETTING_ALLOW:
- return l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_PERMISSION_ALLOW);
- case CONTENT_SETTING_BLOCK:
- return l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_PERMISSION_BLOCK);
- case CONTENT_SETTING_ASK:
- return l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_PERMISSION_ASK);
- default:
- NOTREACHED();
- return "";
- }
+ return l10n_util::GetStringUTF8(
+ WebsiteSettingsUI::PermissionValueToUIStringID(value));
}
} // namespace
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index c3a7a10..05a94df 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -59,6 +59,7 @@
#include "chrome/browser/ui/views/tabs/tab_strip.h"
#include "chrome/browser/ui/views/toolbar_view.h"
#include "chrome/browser/ui/views/update_recommended_message_box.h"
+#include "chrome/browser/ui/views/website_settings_popup_view.h"
#include "chrome/browser/ui/webui/feedback_ui.h"
#include "chrome/browser/ui/window_sizer.h"
#include "chrome/common/chrome_notification_types.h"
@@ -1148,6 +1149,9 @@ void BrowserView::ShowWebsiteSettings(Profile* profile,
const GURL& url,
const content::SSLStatus& ssl,
bool show_history) {
+ WebsiteSettingsPopupView::ShowPopup(
+ GetLocationBarView()->location_icon_view(), profile,
+ tab_contents_wrapper, url, ssl);
}
void BrowserView::ShowAppMenu() {
diff --git a/chrome/browser/ui/views/website_settings_popup_view.cc b/chrome/browser/ui/views/website_settings_popup_view.cc
new file mode 100644
index 0000000..5fc828d
--- /dev/null
+++ b/chrome/browser/ui/views/website_settings_popup_view.cc
@@ -0,0 +1,620 @@
+// Copyright (c) 2012 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/views/website_settings_popup_view.h"
+
+#include "base/string_number_conversions.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/website_settings/website_settings.h"
+#include "chrome/browser/ui/views/collected_cookies_views.h"
+#include "chrome/browser/ui/tab_contents/tab_contents.h"
+#include "chrome/common/content_settings_types.h"
+#include "content/public/browser/cert_store.h"
+#include "googleurl/src/gurl.h"
+#include "grit/generated_resources.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/models/combobox_model.h"
+#include "ui/gfx/font.h"
+#include "ui/views/controls/combobox/combobox.h"
+#include "ui/views/controls/label.h"
+#include "ui/views/controls/link.h"
+#include "ui/views/controls/tabbed_pane/tabbed_pane.h"
+#include "ui/views/layout/box_layout.h"
+#include "ui/views/layout/grid_layout.h"
+#include "ui/views/layout/layout_manager.h"
+#include "ui/views/view.h"
+
+namespace {
+
+// In order to make the arrow of the bubble point directly at the location icon
+// in the Omnibox rather then the bottom border of the Omnibox, the position of
+// the bubble must be adjusted. This is the number of pixel the bubble must be
+// moved towards the top of the screen (starting from the bottom border of the
+// Omnibox).
+const int kLocationIconBottomMargin = 5;
+
+const int kPopupWidth = 300;
+
+string16 PermissionTypeToString(ContentSettingsType type) {
+ return l10n_util::GetStringUTF16(
+ WebsiteSettingsUI::PermissionTypeToUIStringID(type));
+}
+
+string16 PermissionValueToString(ContentSetting value) {
+ return l10n_util::GetStringUTF16(
+ WebsiteSettingsUI::PermissionValueToUIStringID(value));
+}
+
+} // namespace
+
+namespace website_settings {
+
+// A |ComboboxModel| implementation that is used for |Combobox|es that allow
+// selecting a setting for a given site permission.
+class PermissionComboboxModel : public ui::ComboboxModel {
+ public:
+ // Creates a combobox model that provides all possible settings for the given
+ // |site_permission|.
+ PermissionComboboxModel(ContentSettingsType site_permission,
+ ContentSetting default_setting);
+ virtual ~PermissionComboboxModel();
+
+ // Returns the setting for the given |index|.
+ ContentSetting GetSettingAt(int index) const;
+
+ // Returns the site permission for which the combobox model provides
+ // settings.
+ ContentSettingsType site_permission() const {
+ return site_permission_;
+ }
+
+ // ui::ComboboxModel implementations.
+ virtual int GetItemCount() const OVERRIDE;
+ virtual string16 GetItemAt(int index) OVERRIDE;
+
+ private:
+ // The site permission (the |ContentSettingsType|) for which the combobox
+ // model provides settings.
+ ContentSettingsType site_permission_;
+
+ // The global default setting for the |site_permission_|.
+ ContentSetting default_setting_;
+
+ // All possible valid setting for the |site_permission_|.
+ std::vector<ContentSetting> settings_;
+
+ DISALLOW_COPY_AND_ASSIGN(PermissionComboboxModel);
+};
+
+PermissionComboboxModel::PermissionComboboxModel(
+ ContentSettingsType site_permission,
+ ContentSetting default_setting)
+ : site_permission_(site_permission),
+ default_setting_(default_setting){
+ settings_.push_back(CONTENT_SETTING_DEFAULT);
+ settings_.push_back(CONTENT_SETTING_ALLOW);
+ settings_.push_back(CONTENT_SETTING_BLOCK);
+ if (site_permission == CONTENT_SETTINGS_TYPE_GEOLOCATION ||
+ site_permission == CONTENT_SETTINGS_TYPE_NOTIFICATIONS)
+ settings_.push_back(CONTENT_SETTING_ASK);
+}
+
+PermissionComboboxModel::~PermissionComboboxModel() {
+}
+
+ContentSetting PermissionComboboxModel::GetSettingAt(int index) const {
+ if (index < static_cast<int>(settings_.size()))
+ return settings_[index];
+ NOTREACHED();
+ return CONTENT_SETTING_DEFAULT;
+}
+
+int PermissionComboboxModel::GetItemCount() const {
+ return settings_.size();
+}
+
+string16 PermissionComboboxModel::GetItemAt(int index) {
+ if (index == 0) {
+ return l10n_util::GetStringFUTF16(
+ IDS_WEBSITE_SETTINGS_DEFAULT_PERMISSION_LABEL,
+ PermissionValueToString(default_setting_));
+ }
+ if (index < static_cast<int>(settings_.size())) {
+ return l10n_util::GetStringFUTF16(
+ IDS_WEBSITE_SETTINGS_PERMISSION_LABEL,
+ PermissionValueToString(settings_[index]));
+ }
+ NOTREACHED();
+ return string16();
+}
+
+} // namespace website_settings
+
+// |PopupHeader| is the UI element (view) that represents the header of the
+// |WebsiteSettingsPopupView|. The header shows the status of the site's
+// identity check and the name of the site's identity.
+class PopupHeader : public views::View {
+ public:
+ PopupHeader();
+ virtual ~PopupHeader();
+
+ // Sets the name of the site's identity.
+ void SetIdentityName(const string16& name);
+
+ // Sets the status text for the identity check of this site.
+ void SetIdentityStatus(const string16& status_text);
+
+ private:
+ // The label that displays the name of the site's identity.
+ views::Label* name_;
+ // The label that displays the status of the identity check for this site.
+ views::Label* status_;
+
+ DISALLOW_COPY_AND_ASSIGN(PopupHeader);
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// Popup Header
+////////////////////////////////////////////////////////////////////////////////
+
+PopupHeader::PopupHeader() : name_(NULL), status_(NULL) {
+ views::GridLayout* layout = new views::GridLayout(this);
+ SetLayoutManager(layout);
+ const int label_column = 0;
+ views::ColumnSet* column_set = layout->AddColumnSet(label_column);
+ column_set->AddColumn(views::GridLayout::FILL,
+ views::GridLayout::FILL,
+ 1,
+ views::GridLayout::USE_PREF,
+ 0,
+ 0);
+
+ layout->AddPaddingRow(0, 8);
+
+ layout->StartRow(0, label_column);
+ name_ = new views::Label(string16());
+ name_->SetFont(name_->font().DeriveFont(0, gfx::Font::BOLD));
+ layout->AddView(name_, 1, 1, views::GridLayout::LEADING,
+ views::GridLayout::CENTER);
+
+ layout->AddPaddingRow(0, 4);
+
+ status_ = new views::Label(string16());
+ layout->StartRow(0, label_column);
+ layout->AddView(status_,
+ 1,
+ 1,
+ views::GridLayout::LEADING,
+ views::GridLayout::CENTER);
+}
+
+PopupHeader::~PopupHeader() {
+}
+
+void PopupHeader::SetIdentityName(const string16& name) {
+ name_->SetText(name);
+}
+
+void PopupHeader::SetIdentityStatus(const string16& status) {
+ status_->SetText(status);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// WebsiteSettingsPopupView
+///////////////////////////////////////////////////////////////////////////////
+
+WebsiteSettingsPopupView::~WebsiteSettingsPopupView() {
+}
+
+// static
+void WebsiteSettingsPopupView::ShowPopup(views::View* anchor_view,
+ Profile* profile,
+ TabContents* tab_contents,
+ const GURL& url,
+ const content::SSLStatus& ssl) {
+ new WebsiteSettingsPopupView(anchor_view, profile, tab_contents, url, ssl);
+}
+
+WebsiteSettingsPopupView::WebsiteSettingsPopupView(
+ views::View* anchor_view,
+ Profile* profile,
+ TabContents* tab_contents,
+ const GURL& url,
+ const content::SSLStatus& ssl)
+ : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT),
+ tab_contents_(tab_contents),
+ header_(NULL),
+ tabbed_pane_(NULL),
+ site_data_content_(NULL),
+ cookie_dialog_link_(NULL),
+ permissions_content_(NULL),
+ identity_info_text_(NULL),
+ connection_info_text_(NULL),
+ page_info_text_(NULL) {
+ views::GridLayout* layout = new views::GridLayout(this);
+ SetLayoutManager(layout);
+ const int content_column = 0;
+ views::ColumnSet* column_set = layout->AddColumnSet(content_column);
+ column_set->AddColumn(views::GridLayout::FILL,
+ views::GridLayout::FILL,
+ 1,
+ views::GridLayout::USE_PREF,
+ 0,
+ 0);
+
+ header_ = new PopupHeader();
+ layout->StartRow(1, content_column);
+ layout->AddView(header_);
+
+ layout->AddPaddingRow(1, 10);
+
+ tabbed_pane_ = new views::TabbedPane();
+ layout->StartRow(1, content_column);
+ layout->AddView(tabbed_pane_);
+ // Tabs must be added after the tabbed_pane_ was added to the views hierachy.
+ // Adding the |tabbed_pane_| to the views hierachy triggers the
+ // initialization of the native tab UI element. If the native tab UI element
+ // is not initalized adding a tab will result in a NULL pointer excetion.
+ tabbed_pane_->AddTab(
+ l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TAB_LABEL_PERMISSIONS),
+ CreatePermissionsTab());
+ tabbed_pane_->AddTab(
+ l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TAB_LABEL_IDENTITY),
+ CreateIdentityTab());
+ tabbed_pane_->SelectTabAt(0);
+ tabbed_pane_->set_listener(this);
+
+ views::BubbleDelegateView::CreateBubble(this);
+ this->Show();
+ SizeToContents();
+
+ presenter_.reset(new WebsiteSettings(this, profile,
+ tab_contents->content_settings(), url,
+ ssl, content::CertStore::GetInstance()));
+}
+
+void WebsiteSettingsPopupView::SetCookieInfo(
+ const CookieInfoList& cookie_info_list) {
+ site_data_content_->RemoveAllChildViews(true);
+
+ views::GridLayout* layout = new views::GridLayout(site_data_content_);
+ site_data_content_->SetLayoutManager(layout);
+
+ const int site_data_content_column = 0;
+ views::ColumnSet* column_set =
+ layout->AddColumnSet(site_data_content_column);
+ column_set->AddColumn(views::GridLayout::FILL,
+ views::GridLayout::FILL,
+ 1,
+ views::GridLayout::USE_PREF,
+ 0,
+ 0);
+
+ for (CookieInfoList::const_iterator it = cookie_info_list.begin();
+ it != cookie_info_list.end();
+ ++it) {
+ string16 label_text = l10n_util::GetStringFUTF16(
+ IDS_WEBSITE_SETTINGS_SITE_DATA_STATS_LINE,
+ UTF8ToUTF16(it->cookie_source),
+ base::IntToString16(it->allowed),
+ base::IntToString16(it->allowed));
+ layout->StartRow(1, site_data_content_column);
+ layout->AddView(new views::Label(label_text),
+ 1,
+ 1,
+ views::GridLayout::LEADING,
+ views::GridLayout::CENTER);
+
+ layout->AddPaddingRow(1, 4);
+ }
+
+ layout->Layout(site_data_content_);
+ SizeToContents();
+}
+
+void WebsiteSettingsPopupView::SetPermissionInfo(
+ const PermissionInfoList& permission_info_list) {
+ permissions_content_->RemoveAllChildViews(true);
+
+ views::GridLayout* layout =
+ new views::GridLayout(permissions_content_);
+ permissions_content_->SetLayoutManager(layout);
+ const int content_column = 0;
+ views::ColumnSet* column_set =
+ layout->AddColumnSet(content_column);
+ column_set->AddColumn(views::GridLayout::FILL,
+ views::GridLayout::FILL,
+ 1,
+ views::GridLayout::USE_PREF,
+ 0,
+ 0);
+ for (PermissionInfoList::const_iterator permission =
+ permission_info_list.begin();
+ permission != permission_info_list.end();
+ ++permission) {
+ views::Label* label =
+ new views::Label(PermissionTypeToString(permission->type));
+
+ // The |ComboboxModel| is not owned by the |Combobox|. Therefore all models
+ // are stored in a scoped vector so that they are be deleted when the popup
+ // is destroyed.
+ combobox_models_->push_back(new website_settings::PermissionComboboxModel(
+ permission->type, permission->default_setting));
+ views::Combobox* combobox = new views::Combobox(
+ combobox_models_->back());
+ switch (permission->setting) {
+ case CONTENT_SETTING_DEFAULT:
+ combobox->SetSelectedIndex(0);
+ break;
+ case CONTENT_SETTING_ALLOW:
+ combobox->SetSelectedIndex(1);
+ break;
+ case CONTENT_SETTING_BLOCK:
+ combobox->SetSelectedIndex(2);
+ break;
+ default:
+ combobox->SetSelectedIndex(4);
+ break;
+ }
+ combobox->set_listener(this);
+
+ layout->StartRow(1, content_column);
+ layout->AddView(CreatePermissionRow(label, combobox),
+ 1,
+ 1,
+ views::GridLayout::LEADING,
+ views::GridLayout::CENTER);
+
+ }
+
+ SizeToContents();
+}
+
+void WebsiteSettingsPopupView::SetIdentityInfo(
+ const IdentityInfo& identity_info) {
+ string16 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::GetStringUTF16(IDS_WEBSITE_SETTINGS_IDENTITY_VERIFIED);
+ break;
+ default:
+ identity_status_text =
+ l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_IDENTITY_NOT_VERIFIED);
+ break;
+ }
+ header_->SetIdentityName(UTF8ToUTF16(identity_info.site_identity));
+ header_->SetIdentityStatus(identity_status_text);
+
+ identity_info_text_->SetText(
+ UTF8ToUTF16(identity_info.identity_status_description));
+
+ connection_info_text_->SetText(
+ UTF8ToUTF16(identity_info.connection_status_description));
+
+ GetLayoutManager()->Layout(this);
+ SizeToContents();
+}
+
+gfx::Size WebsiteSettingsPopupView::GetPreferredSize() {
+ int height = 0;
+ if (header_)
+ height += header_->GetPreferredSize().height();
+ if (tabbed_pane_)
+ height += tabbed_pane_->GetPreferredSize().height();
+
+ return gfx::Size(kPopupWidth, height);
+}
+
+void WebsiteSettingsPopupView::SetFirstVisit(const string16& first_visit) {
+ page_info_text_->SetText(first_visit);
+}
+
+gfx::Rect WebsiteSettingsPopupView::GetAnchorRect() {
+ // Compensate for some built-in padding in the icon. This will make the arrow
+ // point to the middle of the icon.
+ gfx::Rect anchor(BubbleDelegateView::GetAnchorRect());
+ anchor.Inset(0, anchor_view() ? kLocationIconBottomMargin : 0);
+ return anchor;
+}
+
+void WebsiteSettingsPopupView::OnSelectedIndexChanged(
+ views::Combobox* combobox) {
+ website_settings::PermissionComboboxModel* model =
+ static_cast<website_settings::PermissionComboboxModel*>(combobox->model());
+ DCHECK(model);
+ presenter_->OnSitePermissionChanged(
+ model->site_permission(),
+ model->GetSettingAt(combobox->selected_index()));
+}
+
+void WebsiteSettingsPopupView::LinkClicked(views::Link* source,
+ int event_flags) {
+ DCHECK_EQ(cookie_dialog_link_, source);
+ new CollectedCookiesViews(tab_contents_);
+ GetWidget()->CloseNow();
+}
+
+void WebsiteSettingsPopupView::TabSelectedAt(int index) {
+ tabbed_pane_->GetSelectedTab()->Layout();
+ SizeToContents();
+}
+
+views::View* WebsiteSettingsPopupView::CreatePermissionsTab() {
+ views::View* pane = new views::View();
+ pane->SetLayoutManager(
+ new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 1));
+
+ cookie_dialog_link_ = new views::Link(
+ l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_SHOW_SITE_DATA));
+ cookie_dialog_link_->set_listener(this);
+ site_data_content_ = new views::View();
+ views::View* site_data_section =
+ CreateSection(l10n_util::GetStringUTF16(
+ IDS_WEBSITE_SETTINGS_TITLE_SITE_DATA),
+ site_data_content_,
+ cookie_dialog_link_);
+ pane->AddChildView(site_data_section);
+
+ permissions_content_ = new views::View();
+ views::View* permissions_section =
+ CreateSection(l10n_util::GetStringUTF16(
+ IDS_WEBSITE_SETTINGS_TITLE_SITE_PERMISSIONS),
+ permissions_content_,
+ NULL);
+ pane->AddChildView(permissions_section);
+ return pane;
+}
+
+views::View* WebsiteSettingsPopupView::CreateIdentityTab() {
+ views::View* pane = new views::View();
+ pane->SetLayoutManager(
+ new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 1));
+
+ // Add Identity section.
+ views::View* section_content = new views::View();
+ views::GridLayout* layout =
+ new views::GridLayout(section_content);
+ section_content->SetLayoutManager(layout);
+ const int content_column = 0;
+ views::ColumnSet* column_set =
+ layout->AddColumnSet(content_column);
+ column_set->AddColumn(views::GridLayout::FILL,
+ views::GridLayout::FILL,
+ 1,
+ views::GridLayout::USE_PREF,
+ 0,
+ 0);
+ identity_info_text_ = CreateTextLabel(string16());
+ layout->StartRow(1, content_column);
+ layout->AddView(identity_info_text_, 1, 1, views::GridLayout::LEADING,
+ views::GridLayout::CENTER);
+ views::View* section =
+ CreateSection(l10n_util::GetStringUTF16(
+ IDS_WEBSITE_SETTINGS_TITEL_IDENTITY),
+ section_content,
+ NULL);
+ pane->AddChildView(section);
+
+ // Add connection section.
+ section_content = new views::View();
+ layout = new views::GridLayout(section_content);
+ section_content->SetLayoutManager(layout);
+ column_set = layout->AddColumnSet(content_column);
+ column_set->AddColumn(views::GridLayout::FILL,
+ views::GridLayout::FILL,
+ 1,
+ views::GridLayout::USE_PREF,
+ 0,
+ 0);
+ connection_info_text_ = CreateTextLabel(string16());
+ layout->StartRow(1, content_column);
+ layout->AddView(connection_info_text_, 1, 1, views::GridLayout::LEADING,
+ views::GridLayout::CENTER);
+ section = CreateSection(l10n_util::GetStringUTF16(
+ IDS_WEBSITE_SETTINGS_TITEL_CONNECTION),
+ section_content,
+ NULL);
+ pane->AddChildView(section);
+
+ // Add page info section.
+ section_content = new views::View();
+ layout = new views::GridLayout(section_content);
+ section_content->SetLayoutManager(layout);
+ column_set = layout->AddColumnSet(content_column);
+ column_set->AddColumn(views::GridLayout::FILL,
+ views::GridLayout::FILL,
+ 1,
+ views::GridLayout::USE_PREF,
+ 0,
+ 0);
+ page_info_text_ = CreateTextLabel(string16());
+ layout->StartRow(1, content_column);
+ layout->AddView(page_info_text_, 1, 1, views::GridLayout::LEADING,
+ views::GridLayout::CENTER);
+ section = CreateSection(l10n_util::GetStringUTF16(
+ IDS_PAGE_INFO_SITE_INFO_TITLE),
+ section_content,
+ NULL);
+ pane->AddChildView(section);
+
+ return pane;
+}
+
+views::View* WebsiteSettingsPopupView::CreateSection(
+ const string16& headline_text,
+ views::View* content,
+ views::Link* link) {
+ views::View* container = new views::View();
+ views::GridLayout* layout = new views::GridLayout(container);
+ container->SetLayoutManager(layout);
+ const int content_column = 0;
+ views::ColumnSet* column_set = layout->AddColumnSet(content_column);
+ column_set->AddColumn(views::GridLayout::FILL,
+ views::GridLayout::FILL,
+ 1,
+ views::GridLayout::USE_PREF,
+ 0,
+ 0);
+
+ layout->AddPaddingRow(1, 4);
+ layout->StartRow(1, content_column);
+ views::Label* headline = new views::Label(headline_text);
+ headline->SetFont(headline->font().DeriveFont(0, gfx::Font::BOLD));
+ layout->AddView(headline, 1, 1, views::GridLayout::LEADING,
+ views::GridLayout::CENTER);
+
+ layout->AddPaddingRow(1, 4);
+ layout->StartRow(1, content_column);
+ layout->AddView(content, 1, 1, views::GridLayout::LEADING,
+ views::GridLayout::CENTER);
+
+ if (link) {
+ layout->AddPaddingRow(1, 4);
+ layout->StartRow(1, content_column);
+ layout->AddView(link, 1, 1, views::GridLayout::LEADING,
+ views::GridLayout::CENTER);
+ }
+
+ return container;
+}
+
+views::View* WebsiteSettingsPopupView::CreatePermissionRow(
+ views::Label* label,
+ views::Combobox* combobox) {
+ views::View* container = new views::View();
+ views::GridLayout* layout = new views::GridLayout(container);
+ container->SetLayoutManager(layout);
+ const int two_column_layout = 0;
+ views::ColumnSet* column_set = layout->AddColumnSet(two_column_layout);
+ column_set->AddColumn(views::GridLayout::FILL,
+ views::GridLayout::FILL,
+ 1,
+ views::GridLayout::USE_PREF,
+ 0,
+ 0);
+ column_set->AddPaddingColumn(0, 8);
+ column_set->AddColumn(views::GridLayout::FILL,
+ views::GridLayout::FILL,
+ 1,
+ views::GridLayout::USE_PREF,
+ 0,
+ 0);
+
+ layout->StartRow(1, two_column_layout);
+ layout->AddView(label);
+ layout->AddView(combobox);
+ return container;
+}
+
+views::Label* WebsiteSettingsPopupView::CreateTextLabel(const string16& text) {
+ views::Label* label = new views::Label(text);
+ label->SetMultiLine(true);
+ label->SetAllowCharacterBreak(true);
+ label->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
+ return label;
+}
diff --git a/chrome/browser/ui/views/website_settings_popup_view.h b/chrome/browser/ui/views/website_settings_popup_view.h
new file mode 100644
index 0000000..0afc861
--- /dev/null
+++ b/chrome/browser/ui/views/website_settings_popup_view.h
@@ -0,0 +1,146 @@
+// Copyright (c) 2012 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.
+
+#ifndef CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_POPUP_VIEW_H_
+#define CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_POPUP_VIEW_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/scoped_vector.h"
+#include "chrome/browser/ui/website_settings/website_settings_ui.h"
+#include "ui/views/bubble/bubble_delegate.h"
+#include "ui/views/controls/combobox/combobox_listener.h"
+#include "ui/views/controls/link_listener.h"
+#include "ui/views/controls/tabbed_pane/tabbed_pane_listener.h"
+
+class GURL;
+class PopupHeader;
+class Profile;
+class TabContents;
+
+namespace content {
+struct SSLStatus;
+}
+
+namespace views {
+class Combobox;
+class Link;
+class Label;
+class TabbedPane;
+class View;
+}
+
+namespace website_settings {
+class PermissionComboboxModel;
+}
+
+// The views implementation of the website settings UI.
+class WebsiteSettingsPopupView : public WebsiteSettingsUI,
+ public views::BubbleDelegateView,
+ public views::ComboboxListener,
+ public views::LinkListener,
+ public views::TabbedPaneListener {
+ public:
+ virtual ~WebsiteSettingsPopupView();
+
+ static void ShowPopup(views::View* anchor_view,
+ Profile* profile,
+ TabContents* tab_contents,
+ const GURL& gurl,
+ const content::SSLStatus& ssl);
+
+ private:
+ WebsiteSettingsPopupView(views::View* anchor_view,
+ Profile* profile,
+ TabContents* tab_contents,
+ const GURL& url,
+ const content::SSLStatus& ssl);
+
+ // WebsiteSettingsUI implementations.
+ 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;
+ virtual void SetFirstVisit(const string16& first_visit) OVERRIDE;
+
+ // views::View implementation.
+ virtual gfx::Size GetPreferredSize() OVERRIDE;
+
+ // views::BubbleDelegate implementations.
+ virtual gfx::Rect GetAnchorRect() OVERRIDE;
+
+ // views::ComboboxListener implementation.
+ virtual void OnSelectedIndexChanged(views::Combobox* combobox) OVERRIDE;
+
+ // LinkListener implementation.
+ virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
+
+ // views::TabbedPaneListener implementations.
+ virtual void TabSelectedAt(int index) OVERRIDE;
+
+ // Each tab contains several sections with a |headline| followed by the
+ // section |contents| and an optional |link|. This method creates a section
+ // for the given |headline|, |contents| and |link|. |link| can be NULL if the
+ // section should not contain a link.
+ views::View* CreateSection(const string16& headline,
+ views::View* contents,
+ views::Link* link) WARN_UNUSED_RESULT;
+
+ // Creates a single row for the "Permissions" section from the "Permissions"
+ // tab. Such a row contains a |permissions_label| with the name of the
+ // permission and a |combobox| that allows to select setting for the given
+ // permission. The ownership of the returned view is transferred to the
+ // caller.
+ views::View* CreatePermissionRow(
+ views::Label* permission_label,
+ views::Combobox* combobox) WARN_UNUSED_RESULT;
+
+ // Creates the contents of the "Permissions" tab. The ownership of the
+ // returned view is transferred to the caller.
+ views::View* CreatePermissionsTab() WARN_UNUSED_RESULT;
+
+ // Creates the contents of the "Identity" tab. The ownership of the returned
+ // view is transferred to the caller.
+ views::View* CreateIdentityTab() WARN_UNUSED_RESULT;
+
+ // Creates a multiline text label that is initialized with the given |text|.
+ // The ownership of the returned label is transferred to the caller.
+ views::Label* CreateTextLabel(const string16& text) WARN_UNUSED_RESULT;
+
+ // The tab contents of the current tab. The popup can't live longer than a
+ // tab.
+ TabContents* tab_contents_; // Weak pointer.
+
+ // The presenter that controlls the Website Settings UI.
+ scoped_ptr<WebsiteSettings> presenter_;
+
+ // The view |PopupHeader| is owned by the popup contents view.
+ PopupHeader* header_;
+
+ // The |TabbedPane| that contains the tabs of the Website Settings UI.
+ views::TabbedPane* tabbed_pane_;
+
+ // The view that contains the contents of the "Cookies and Site data" section
+ // from the "Permissions" tab.
+ views::View* site_data_content_;
+ // The link that opend the "Cookies" dialog.
+ views::Link* cookie_dialog_link_;
+ // The view that contains the contents of the "Permissions" section from the
+ // "Permissions" tab.
+ views::View* permissions_content_;
+
+ views::Label* identity_info_text_;
+ views::Label* connection_info_text_;
+ views::Label* page_info_text_;
+
+ // A |ComboboxModel| is not owned by a |Combobox|. Therefor the popup owns
+ // all |PermissionComboboxModels| and deletes them when it is destroyed.
+ ScopedVector<website_settings::PermissionComboboxModel> combobox_models_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsPopupView);
+};
+
+#endif // CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_POPUP_VIEW_H_
diff --git a/chrome/browser/ui/website_settings/website_settings_ui.cc b/chrome/browser/ui/website_settings/website_settings_ui.cc
index abe2dd8..88da299 100644
--- a/chrome/browser/ui/website_settings/website_settings_ui.cc
+++ b/chrome/browser/ui/website_settings/website_settings_ui.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/ui/website_settings/website_settings_ui.h"
+#include "grit/generated_resources.h"
+
WebsiteSettingsUI::CookieInfo::CookieInfo()
: allowed(-1), blocked(-1) {
}
@@ -22,3 +24,35 @@ WebsiteSettingsUI::IdentityInfo::IdentityInfo()
WebsiteSettingsUI::~WebsiteSettingsUI() {
}
+
+// static
+int WebsiteSettingsUI::PermissionTypeToUIStringID(ContentSettingsType type) {
+ switch (type) {
+ case CONTENT_SETTINGS_TYPE_POPUPS:
+ return IDS_WEBSITE_SETTINGS_TYPE_POPUPS;
+ case CONTENT_SETTINGS_TYPE_PLUGINS:
+ return IDS_WEBSITE_SETTINGS_TYPE_PLUGINS;
+ case CONTENT_SETTINGS_TYPE_GEOLOCATION:
+ return IDS_WEBSITE_SETTINGS_TYPE_LOCATION;
+ case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
+ return IDS_WEBSITE_SETTINGS_TYPE_NOTIFICATIONS;
+ default:
+ NOTREACHED();
+ return -1;
+ }
+}
+
+// static
+int WebsiteSettingsUI::PermissionValueToUIStringID(ContentSetting value) {
+ switch (value) {
+ case CONTENT_SETTING_ALLOW:
+ return IDS_WEBSITE_SETTINGS_PERMISSION_ALLOW;
+ case CONTENT_SETTING_BLOCK:
+ return IDS_WEBSITE_SETTINGS_PERMISSION_BLOCK;
+ case CONTENT_SETTING_ASK:
+ return IDS_WEBSITE_SETTINGS_PERMISSION_ASK;
+ default:
+ NOTREACHED();
+ return -1;
+ }
+}
diff --git a/chrome/browser/ui/website_settings/website_settings_ui.h b/chrome/browser/ui/website_settings/website_settings_ui.h
index 083e245d..096e5c6 100644
--- a/chrome/browser/ui/website_settings/website_settings_ui.h
+++ b/chrome/browser/ui/website_settings/website_settings_ui.h
@@ -20,7 +20,6 @@ class GURL;
class PermissionInfoList;
class Profile;
class TabContents;
-typedef TabContents TabContentsWrapper;
class WebsiteSettings;
namespace content {
@@ -84,6 +83,12 @@ class WebsiteSettingsUI {
virtual ~WebsiteSettingsUI();
+ // Returns the resource ID of the UI string for the given permission |type|.
+ static int PermissionTypeToUIStringID(ContentSettingsType type);
+
+ // Returns the resource ID of the UI string for the given permission |value|.
+ static int PermissionValueToUIStringID(ContentSetting value);
+
// Sets cookie information.
virtual void SetCookieInfo(const CookieInfoList& cookie_info_list) = 0;
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 42b41eb..91bf9ef 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -3689,6 +3689,8 @@
'browser/ui/views/web_dialog_view.cc',
'browser/ui/views/web_dialog_view.h',
'browser/ui/views/web_intent_picker_views.cc',
+ 'browser/ui/views/website_settings_popup_view.cc',
+ 'browser/ui/views/website_settings_popup_view.h',
'browser/ui/views/wrench_menu.cc',
'browser/ui/views/wrench_menu.h',
'browser/ui/web_applications/web_app_ui.cc',