cookie_info_view.h revision 868fa2fe829687343ffae624259930155e16dbd8
1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com// Copyright (c) 2012 The Chromium Authors. All rights reserved.
28a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com// Use of this source code is governed by a BSD-style license that can be
3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com// found in the LICENSE file.
48a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com#ifndef CHROME_BROWSER_UI_VIEWS_COOKIE_INFO_VIEW_H_
6ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com#define CHROME_BROWSER_UI_VIEWS_COOKIE_INFO_VIEW_H_
78a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
88a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include <string>
9ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com#include <vector>
108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "base/basictypes.h"
128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "base/compiler_specific.h"
138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "base/strings/string16.h"
148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "ui/base/models/combobox_model.h"
158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "ui/views/controls/combobox/combobox_listener.h"
168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "ui/views/view.h"
178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comnamespace views {
198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass GridLayout;
208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass Label;
218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass Textfield;
228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comnamespace net {
258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass CanonicalCookie;
268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com///////////////////////////////////////////////////////////////////////////////
298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com// CookieInfoViewDelegate
308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com//
318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass CookieInfoViewDelegate {
328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com public:
338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  virtual void ModifyExpireDate(bool session_expire) = 0;
348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com protected:
368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  virtual ~CookieInfoViewDelegate() {}
378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com};
388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com///////////////////////////////////////////////////////////////////////////////
408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com// CookieInfoView
418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com//
428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com//  Responsible for displaying a tabular grid of Cookie information.
438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass CookieInfoView : public views::View,
448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                       public views::ComboboxListener,
458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                       public ui::ComboboxModel {
468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com public:
478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  explicit CookieInfoView(bool editable_expiration_date);
488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  virtual ~CookieInfoView();
498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // Update the display from the specified CookieNode.
518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  void SetCookie(const std::string& domain,
528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                 const net::CanonicalCookie& cookie_node);
538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // Update the display from the specified cookie string.
558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  void SetCookieString(const GURL& url, const std::string& cookie_line);
568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // Clears the cookie display to indicate that no or multiple cookies are
588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // selected.
5904423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com  void ClearCookieDisplay();
6004423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com
6104423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com  // Enables or disables the cookie property text fields.
6204423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com  void EnableCookieDisplay(bool enabled);
6304423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com
6404423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com  void set_delegate(CookieInfoViewDelegate* delegate) { delegate_ = delegate; }
6504423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com
6604423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com protected:
6704423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com  // views::View:
6804423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com  virtual void ViewHierarchyChanged(
6904423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com      const ViewHierarchyChangedDetails& details) OVERRIDE;
7004423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com
7104423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com  // views::ComboboxListener:
7204423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com  virtual void OnSelectedIndexChanged(views::Combobox* combobox) OVERRIDE;
7304423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com
7404423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com  // ui::ComboboxModel:
7504423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com  virtual int GetItemCount() const OVERRIDE;
7604423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com  virtual string16 GetItemAt(int index) OVERRIDE;
7704423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com
7804423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com private:
7904423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com  // Layout helper routines.
8004423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com  void AddLabelRow(int layout_id, views::GridLayout* layout,
8104423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com                   views::View* label, views::View* value);
8204423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com  void AddControlRow(int layout_id, views::GridLayout* layout,
8304423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com                     views::View* label, views::View* control);
8404423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com
858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // Sets up the view layout.
868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  void Init();
878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // Individual property labels
898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  views::Label* name_label_;
908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  views::Textfield* name_value_field_;
918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  views::Label* content_label_;
928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  views::Textfield* content_value_field_;
938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  views::Label* domain_label_;
948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  views::Textfield* domain_value_field_;
958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  views::Label* path_label_;
968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  views::Textfield* path_value_field_;
97b1277c96b0818550190be134fd5e9a971087120bbsalomon@google.com  views::Label* send_for_label_;
988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  views::Textfield* send_for_value_field_;
99b1277c96b0818550190be134fd5e9a971087120bbsalomon@google.com  views::Label* created_label_;
1008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  views::Textfield* created_value_field_;
1018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  views::Label* expires_label_;
1028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  views::Textfield* expires_value_field_;
1038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  views::Combobox* expires_value_combobox_;
1048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  views::View* expire_view_;
1058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // Option values for expires_value_combobox_.
1078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  std::vector<string16> expire_combo_values_;
1088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // True if expiration date can be edited. In this case we will show
1105c80ea17d4e4a795bfaeb260fc27e952ba471f1dreed@android.com  // expires_value_combobox_ instead of expires_value_field_. The cookie's
1115c80ea17d4e4a795bfaeb260fc27e952ba471f1dreed@android.com  // expiration date is editable only this class is used in
1125c80ea17d4e4a795bfaeb260fc27e952ba471f1dreed@android.com  // CookiesPromptView (alert before cookie is set), in all other cases we
1138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // don't let user directly change cookie setting.
1148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  bool editable_expiration_date_;
1158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
11616690af1c21dead3eedb25ebd0a4b9a091684ed4reed@android.com  CookieInfoViewDelegate* delegate_;
11716690af1c21dead3eedb25ebd0a4b9a091684ed4reed@android.com
11816690af1c21dead3eedb25ebd0a4b9a091684ed4reed@android.com  DISALLOW_COPY_AND_ASSIGN(CookieInfoView);
11916690af1c21dead3eedb25ebd0a4b9a091684ed4reed@android.com};
12016690af1c21dead3eedb25ebd0a4b9a091684ed4reed@android.com
12116690af1c21dead3eedb25ebd0a4b9a091684ed4reed@android.com#endif  // CHROME_BROWSER_UI_VIEWS_COOKIE_INFO_VIEW_H_
1228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com