| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/views/cookie_info_view.h" | 5 #include "chrome/browser/views/cookie_info_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "base/i18n/time_formatting.h" | 10 #include "base/i18n/time_formatting.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 const net::CookieMonster::CanonicalCookie& cookie) { | 60 const net::CookieMonster::CanonicalCookie& cookie) { |
| 61 name_value_field_->SetText(UTF8ToWide(cookie.Name())); | 61 name_value_field_->SetText(UTF8ToWide(cookie.Name())); |
| 62 content_value_field_->SetText(UTF8ToWide(cookie.Value())); | 62 content_value_field_->SetText(UTF8ToWide(cookie.Value())); |
| 63 domain_value_field_->SetText(UTF8ToWide(domain)); | 63 domain_value_field_->SetText(UTF8ToWide(domain)); |
| 64 path_value_field_->SetText(UTF8ToWide(cookie.Path())); | 64 path_value_field_->SetText(UTF8ToWide(cookie.Path())); |
| 65 created_value_field_->SetText( | 65 created_value_field_->SetText( |
| 66 base::TimeFormatFriendlyDateAndTime(cookie.CreationDate())); | 66 base::TimeFormatFriendlyDateAndTime(cookie.CreationDate())); |
| 67 | 67 |
| 68 std::wstring expire_text = cookie.DoesExpire() ? | 68 std::wstring expire_text = cookie.DoesExpire() ? |
| 69 base::TimeFormatFriendlyDateAndTime(cookie.ExpiryDate()) : | 69 base::TimeFormatFriendlyDateAndTime(cookie.ExpiryDate()) : |
| 70 l10n_util::GetString(IDS_COOKIES_COOKIE_EXPIRES_SESSION); | 70 UTF16ToWide( |
| 71 l10n_util::GetStringUTF16(IDS_COOKIES_COOKIE_EXPIRES_SESSION)); |
| 71 | 72 |
| 72 if (editable_expiration_date_) { | 73 if (editable_expiration_date_) { |
| 73 expire_combo_values_.clear(); | 74 expire_combo_values_.clear(); |
| 74 if (cookie.DoesExpire()) | 75 if (cookie.DoesExpire()) |
| 75 expire_combo_values_.push_back(expire_text); | 76 expire_combo_values_.push_back(expire_text); |
| 76 expire_combo_values_.push_back( | 77 expire_combo_values_.push_back(UTF16ToWide( |
| 77 l10n_util::GetString(IDS_COOKIES_COOKIE_EXPIRES_SESSION)); | 78 l10n_util::GetStringUTF16(IDS_COOKIES_COOKIE_EXPIRES_SESSION))); |
| 78 expires_value_combobox_->ModelChanged(); | 79 expires_value_combobox_->ModelChanged(); |
| 79 expires_value_combobox_->SetSelectedItem(0); | 80 expires_value_combobox_->SetSelectedItem(0); |
| 80 expires_value_combobox_->SetEnabled(true); | 81 expires_value_combobox_->SetEnabled(true); |
| 81 expires_value_combobox_->set_listener(this); | 82 expires_value_combobox_->set_listener(this); |
| 82 } else { | 83 } else { |
| 83 expires_value_field_->SetText(expire_text); | 84 expires_value_field_->SetText(expire_text); |
| 84 } | 85 } |
| 85 | 86 |
| 86 send_for_value_field_->SetText(cookie.IsSecure() ? | 87 send_for_value_field_->SetText(cookie.IsSecure() ? |
| 87 l10n_util::GetString(IDS_COOKIES_COOKIE_SENDFOR_SECURE) : | 88 UTF16ToWide( |
| 88 l10n_util::GetString(IDS_COOKIES_COOKIE_SENDFOR_ANY)); | 89 l10n_util::GetStringUTF16(IDS_COOKIES_COOKIE_SENDFOR_SECURE)) : |
| 90 UTF16ToWide( |
| 91 l10n_util::GetStringUTF16(IDS_COOKIES_COOKIE_SENDFOR_ANY))); |
| 89 EnableCookieDisplay(true); | 92 EnableCookieDisplay(true); |
| 90 Layout(); | 93 Layout(); |
| 91 } | 94 } |
| 92 | 95 |
| 93 void CookieInfoView::SetCookieString(const GURL& url, | 96 void CookieInfoView::SetCookieString(const GURL& url, |
| 94 const std::string& cookie_line) { | 97 const std::string& cookie_line) { |
| 95 net::CookieMonster::ParsedCookie pc(cookie_line); | 98 net::CookieMonster::ParsedCookie pc(cookie_line); |
| 96 net::CookieMonster::CanonicalCookie cookie(url, pc); | 99 net::CookieMonster::CanonicalCookie cookie(url, pc); |
| 97 SetCookie(pc.HasDomain() ? pc.Domain() : url.host(), cookie); | 100 SetCookie(pc.HasDomain() ? pc.Domain() : url.host(), cookie); |
| 98 } | 101 } |
| 99 | 102 |
| 100 | 103 |
| 101 void CookieInfoView::ClearCookieDisplay() { | 104 void CookieInfoView::ClearCookieDisplay() { |
| 102 std::wstring no_cookie_string = | 105 std::wstring no_cookie_string = |
| 103 l10n_util::GetString(IDS_COOKIES_COOKIE_NONESELECTED); | 106 UTF16ToWide(l10n_util::GetStringUTF16(IDS_COOKIES_COOKIE_NONESELECTED)); |
| 104 name_value_field_->SetText(no_cookie_string); | 107 name_value_field_->SetText(no_cookie_string); |
| 105 content_value_field_->SetText(no_cookie_string); | 108 content_value_field_->SetText(no_cookie_string); |
| 106 domain_value_field_->SetText(no_cookie_string); | 109 domain_value_field_->SetText(no_cookie_string); |
| 107 path_value_field_->SetText(no_cookie_string); | 110 path_value_field_->SetText(no_cookie_string); |
| 108 send_for_value_field_->SetText(no_cookie_string); | 111 send_for_value_field_->SetText(no_cookie_string); |
| 109 created_value_field_->SetText(no_cookie_string); | 112 created_value_field_->SetText(no_cookie_string); |
| 110 if (expires_value_field_) | 113 if (expires_value_field_) |
| 111 expires_value_field_->SetText(no_cookie_string); | 114 expires_value_field_->SetText(no_cookie_string); |
| 112 EnableCookieDisplay(false); | 115 EnableCookieDisplay(false); |
| 113 } | 116 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 void CookieInfoView::Init() { | 180 void CookieInfoView::Init() { |
| 178 // Ensure we don't run this more than once and leak memory. | 181 // Ensure we don't run this more than once and leak memory. |
| 179 DCHECK(!name_label_); | 182 DCHECK(!name_label_); |
| 180 | 183 |
| 181 SkColor border_color = color_utils::GetSysSkColor(COLOR_3DSHADOW); | 184 SkColor border_color = color_utils::GetSysSkColor(COLOR_3DSHADOW); |
| 182 views::Border* border = views::Border::CreateSolidBorder( | 185 views::Border* border = views::Border::CreateSolidBorder( |
| 183 kCookieInfoViewBorderSize, border_color); | 186 kCookieInfoViewBorderSize, border_color); |
| 184 set_border(border); | 187 set_border(border); |
| 185 | 188 |
| 186 name_label_ = new views::Label( | 189 name_label_ = new views::Label( |
| 187 l10n_util::GetString(IDS_COOKIES_COOKIE_NAME_LABEL)); | 190 UTF16ToWide(l10n_util::GetStringUTF16(IDS_COOKIES_COOKIE_NAME_LABEL))); |
| 188 name_value_field_ = new views::Textfield; | 191 name_value_field_ = new views::Textfield; |
| 189 content_label_ = new views::Label( | 192 content_label_ = new views::Label( |
| 190 l10n_util::GetString(IDS_COOKIES_COOKIE_CONTENT_LABEL)); | 193 UTF16ToWide(l10n_util::GetStringUTF16(IDS_COOKIES_COOKIE_CONTENT_LABEL))); |
| 191 content_value_field_ = new views::Textfield; | 194 content_value_field_ = new views::Textfield; |
| 192 domain_label_ = new views::Label( | 195 domain_label_ = new views::Label( |
| 193 l10n_util::GetString(IDS_COOKIES_COOKIE_DOMAIN_LABEL)); | 196 UTF16ToWide(l10n_util::GetStringUTF16(IDS_COOKIES_COOKIE_DOMAIN_LABEL))); |
| 194 domain_value_field_ = new views::Textfield; | 197 domain_value_field_ = new views::Textfield; |
| 195 path_label_ = new views::Label( | 198 path_label_ = new views::Label( |
| 196 l10n_util::GetString(IDS_COOKIES_COOKIE_PATH_LABEL)); | 199 UTF16ToWide(l10n_util::GetStringUTF16(IDS_COOKIES_COOKIE_PATH_LABEL))); |
| 197 path_value_field_ = new views::Textfield; | 200 path_value_field_ = new views::Textfield; |
| 198 send_for_label_ = new views::Label( | 201 send_for_label_ = new views::Label( |
| 199 l10n_util::GetString(IDS_COOKIES_COOKIE_SENDFOR_LABEL)); | 202 UTF16ToWide(l10n_util::GetStringUTF16(IDS_COOKIES_COOKIE_SENDFOR_LABEL))); |
| 200 send_for_value_field_ = new views::Textfield; | 203 send_for_value_field_ = new views::Textfield; |
| 201 created_label_ = new views::Label( | 204 created_label_ = new views::Label( |
| 202 l10n_util::GetString(IDS_COOKIES_COOKIE_CREATED_LABEL)); | 205 UTF16ToWide(l10n_util::GetStringUTF16(IDS_COOKIES_COOKIE_CREATED_LABEL))); |
| 203 created_value_field_ = new views::Textfield; | 206 created_value_field_ = new views::Textfield; |
| 204 expires_label_ = new views::Label( | 207 expires_label_ = new views::Label( |
| 205 l10n_util::GetString(IDS_COOKIES_COOKIE_EXPIRES_LABEL)); | 208 UTF16ToWide(l10n_util::GetStringUTF16(IDS_COOKIES_COOKIE_EXPIRES_LABEL))); |
| 206 if (editable_expiration_date_) | 209 if (editable_expiration_date_) |
| 207 expires_value_combobox_ = new views::Combobox(this); | 210 expires_value_combobox_ = new views::Combobox(this); |
| 208 else | 211 else |
| 209 expires_value_field_ = new views::Textfield; | 212 expires_value_field_ = new views::Textfield; |
| 210 | 213 |
| 211 using views::GridLayout; | 214 using views::GridLayout; |
| 212 using views::ColumnSet; | 215 using views::ColumnSet; |
| 213 | 216 |
| 214 GridLayout* layout = new GridLayout(this); | 217 GridLayout* layout = new GridLayout(this); |
| 215 layout->SetInsets(kCookieInfoViewInsetSize, | 218 layout->SetInsets(kCookieInfoViewInsetSize, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 send_for_value_field_->SetBackgroundColor(text_area_background); | 270 send_for_value_field_->SetBackgroundColor(text_area_background); |
| 268 created_value_field_->SetReadOnly(true); | 271 created_value_field_->SetReadOnly(true); |
| 269 created_value_field_->RemoveBorder(); | 272 created_value_field_->RemoveBorder(); |
| 270 created_value_field_->SetBackgroundColor(text_area_background); | 273 created_value_field_->SetBackgroundColor(text_area_background); |
| 271 if (expires_value_field_) { | 274 if (expires_value_field_) { |
| 272 expires_value_field_->SetReadOnly(true); | 275 expires_value_field_->SetReadOnly(true); |
| 273 expires_value_field_->RemoveBorder(); | 276 expires_value_field_->RemoveBorder(); |
| 274 expires_value_field_->SetBackgroundColor(text_area_background); | 277 expires_value_field_->SetBackgroundColor(text_area_background); |
| 275 } | 278 } |
| 276 } | 279 } |
| OLD | NEW |