summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-08 21:10:55 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-08 21:10:55 +0000
commit45134197a411fd9e02986c9e11d7b6d876891f23 (patch)
treec46c08306d7424b3a607ca0d06b2742d7e879c68 /chrome/browser/views
parent7d74aaab9390a7502dac835ddcd2a5175224702e (diff)
downloadchromium_src-45134197a411fd9e02986c9e11d7b6d876891f23.zip
chromium_src-45134197a411fd9e02986c9e11d7b6d876891f23.tar.gz
chromium_src-45134197a411fd9e02986c9e11d7b6d876891f23.tar.bz2
Show an app modal dialog when the cookie policy is ASK.
This hooks up the dialog for cookies and localstorage. It also includes support for remembering the decision, and in the case of cookies, support is added for forcing a cookie to be a stored as a session cookie. BUG=34625,34572 Review URL: http://codereview.chromium.org/583004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38393 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r--chrome/browser/views/cookie_info_view.cc49
-rw-r--r--chrome/browser/views/cookie_info_view.h4
-rw-r--r--chrome/browser/views/cookie_prompt_view.cc66
-rw-r--r--chrome/browser/views/cookie_prompt_view.h9
4 files changed, 53 insertions, 75 deletions
diff --git a/chrome/browser/views/cookie_info_view.cc b/chrome/browser/views/cookie_info_view.cc
index da51988..2f7970b 100644
--- a/chrome/browser/views/cookie_info_view.cc
+++ b/chrome/browser/views/cookie_info_view.cc
@@ -16,7 +16,6 @@
#include "chrome/browser/profile.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
-#include "net/base/cookie_monster.h"
#include "views/border.h"
#include "views/grid_layout.h"
#include "views/controls/label.h"
@@ -90,38 +89,22 @@ void CookieInfoView::SetCookie(
}
void CookieInfoView::SetCookieString(
- const std::string& domain,
- const net::CookieMonster::ParsedCookie& cookie) {
- name_value_field_->SetText(UTF8ToWide(cookie.Name()));
- content_value_field_->SetText(UTF8ToWide(cookie.Value()));
- domain_value_field_->SetText(UTF8ToWide(domain));
- path_value_field_->SetText(UTF8ToWide(cookie.Path()));
- created_value_field_->SetText(
- base::TimeFormatFriendlyDateAndTime(base::Time::Now()));
-
- std::wstring expire_text = cookie.HasExpires() ?
- base::TimeFormatFriendlyDateAndTime(
- net::CookieMonster::ParseCookieTime(cookie.Expires())) :
- l10n_util::GetString(IDS_COOKIES_COOKIE_EXPIRES_SESSION);
-
- if (editable_expiration_date_) {
- expire_combo_values_.clear();
- if (cookie.HasExpires())
- expire_combo_values_.push_back(expire_text);
- expire_combo_values_.push_back(
- l10n_util::GetString(IDS_COOKIES_COOKIE_EXPIRES_SESSION));
- expires_value_combobox_->ModelChanged();
- expires_value_combobox_->SetSelectedItem(0);
- expires_value_combobox_->SetEnabled(true);
- } else {
- expires_value_field_->SetText(expire_text);
- }
-
- send_for_value_field_->SetText(cookie.IsSecure() ?
- l10n_util::GetString(IDS_COOKIES_COOKIE_SENDFOR_SECURE) :
- l10n_util::GetString(IDS_COOKIES_COOKIE_SENDFOR_ANY));
- EnableCookieDisplay(true);
- Layout();
+ const std::string& host,
+ const std::string& cookie_line) {
+ net::CookieMonster::ParsedCookie pc(cookie_line);
+ net::CookieMonster::CanonicalCookie cookie(
+ pc.Name(),
+ pc.Value(),
+ pc.Path(),
+ pc.IsSecure(),
+ pc.IsHttpOnly(),
+ base::Time::Now(), // creation time
+ base::Time(), // last access time is unused
+ pc.HasExpires(),
+ pc.HasExpires() ?
+ net::CookieMonster::ParseCookieTime(pc.Expires()) :
+ base::Time());
+ SetCookie(pc.HasDomain() ? pc.Domain() : host, cookie);
}
diff --git a/chrome/browser/views/cookie_info_view.h b/chrome/browser/views/cookie_info_view.h
index b0be231..f793d95 100644
--- a/chrome/browser/views/cookie_info_view.h
+++ b/chrome/browser/views/cookie_info_view.h
@@ -48,8 +48,8 @@ class CookieInfoView : public views::View,
const net::CookieMonster::CanonicalCookie& cookie_node);
// Update the display from the specified cookie string.
- void SetCookieString(const std::string& domain,
- const net::CookieMonster::ParsedCookie& cookie);
+ void SetCookieString(const std::string& host,
+ const std::string& cookie_line);
// Clears the cookie display to indicate that no or multiple cookies are
// selected.
diff --git a/chrome/browser/views/cookie_prompt_view.cc b/chrome/browser/views/cookie_prompt_view.cc
index d08fb49..9a69ad9 100644
--- a/chrome/browser/views/cookie_prompt_view.cc
+++ b/chrome/browser/views/cookie_prompt_view.cc
@@ -34,33 +34,33 @@ static const int kCookiePromptViewInsetSize = 5;
// CookiePromptView, public:
CookiePromptView::CookiePromptView(
- CookiePromptModalDialog* parent,
- gfx::NativeWindow root_window,
- Profile* profile,
- const GURL& url,
- const std::string& cookie_line,
- CookiePromptModalDialogDelegate* delegate)
- : parent_(parent),
- root_window_(root_window),
- profile_(profile),
- delegate_(delegate) {
- cookie_ui_ = true;
- net::CookieMonster::ParsedCookie cookie(cookie_line);
- InitializeViewResources(cookie.HasDomain() ? cookie.Domain() : url.host());
+ CookiePromptModalDialog* parent,
+ gfx::NativeWindow root_window,
+ Profile* profile,
+ const std::string& host,
+ const std::string& cookie_line,
+ CookiePromptModalDialogDelegate* delegate)
+ : cookie_ui_(true),
+ parent_(parent),
+ root_window_(root_window),
+ profile_(profile),
+ cookie_line_(cookie_line),
+ delegate_(delegate) {
+ InitializeViewResources(host);
}
CookiePromptView::CookiePromptView(
- CookiePromptModalDialog* parent,
- gfx::NativeWindow root_window,
- Profile* profile,
- const BrowsingDataLocalStorageHelper::LocalStorageInfo& storage_info,
- CookiePromptModalDialogDelegate* delegate)
- : parent_(parent),
- root_window_(root_window),
- profile_(profile),
- local_storage_info_(storage_info),
- delegate_(delegate) {
- cookie_ui_ = false;
+ CookiePromptModalDialog* parent,
+ gfx::NativeWindow root_window,
+ Profile* profile,
+ const BrowsingDataLocalStorageHelper::LocalStorageInfo& storage_info,
+ CookiePromptModalDialogDelegate* delegate)
+ : cookie_ui_(false),
+ parent_(parent),
+ root_window_(root_window),
+ profile_(profile),
+ local_storage_info_(storage_info),
+ delegate_(delegate) {
InitializeViewResources(storage_info.host);
}
@@ -165,12 +165,13 @@ CookiePromptView::CookiePromptView(Profile* profile,
}
void CookiePromptView::Init() {
+ std::wstring display_host = UTF8ToWide(host_);
views::Label* description_label = new views::Label(l10n_util::GetStringF(
cookie_ui_ ? IDS_COOKIE_ALERT_LABEL : IDS_DATA_ALERT_LABEL,
- display_domain_));
+ display_host));
int radio_group_id = 0;
remember_radio_ = new views::RadioButton(
- l10n_util::GetStringF(IDS_COOKIE_ALERT_REMEMBER_RADIO, display_domain_),
+ l10n_util::GetStringF(IDS_COOKIE_ALERT_REMEMBER_RADIO, display_host),
radio_group_id);
remember_radio_->set_listener(this);
ask_radio_ = new views::RadioButton(
@@ -263,7 +264,7 @@ void CookiePromptView::Init() {
layout->AddView(cookie_info_view, 1, 1, GridLayout::FILL,
GridLayout::CENTER);
- cookie_info_view->SetCookieString(domain_, cookie_line_);
+ cookie_info_view->SetCookieString(host_, cookie_line_);
info_view_ = cookie_info_view;
} else {
LocalStorageInfoView* local_storage_info_view = new LocalStorageInfoView();
@@ -296,14 +297,11 @@ void CookiePromptView::ToggleDetailsViewExpand() {
Layout();
}
-void CookiePromptView::InitializeViewResources(const std::string& domain) {
- domain_ = domain;
- std::string display_domain = domain;
- if (!domain.empty() && domain[0] == '.')
- display_domain = display_domain.substr(1);
- display_domain_ = UTF8ToWide(display_domain);
+void CookiePromptView::InitializeViewResources(const std::string& host) {
+ DCHECK(host.empty() || host[0] != '.');
+ host_ = host;
title_ = l10n_util::GetStringF(
cookie_ui_ ? IDS_COOKIE_ALERT_TITLE : IDS_DATA_ALERT_TITLE,
- display_domain_);
+ UTF8ToWide(host_));
}
diff --git a/chrome/browser/views/cookie_prompt_view.h b/chrome/browser/views/cookie_prompt_view.h
index 756687e..14560bc 100644
--- a/chrome/browser/views/cookie_prompt_view.h
+++ b/chrome/browser/views/cookie_prompt_view.h
@@ -42,7 +42,7 @@ class CookiePromptView : public views::View,
CookiePromptModalDialog* parent,
gfx::NativeWindow root_window,
Profile* profile,
- const GURL& url,
+ const std::string& host,
const std::string& cookie_line,
CookiePromptModalDialogDelegate* delegate);
@@ -135,11 +135,8 @@ class CookiePromptView : public views::View,
// The Profile for which Cookies are displayed.
Profile* profile_;
- // Cookie / local storage domain.
- std::string domain_;
-
- // Domain name formatted for displaying (removed leading '.').
- std::wstring display_domain_;
+ // Cookie / local storage host.
+ std::string host_;
// Displayed cookie. Only used when |cookie_ui_| is true.
std::string cookie_line_;