website_settings_popup_view.h revision d0247b1b59f9c528cb6df88b4f2b9afaf80d181e
160ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany// Copyright (c) 2012 The Chromium Authors. All rights reserved.
260ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany// Use of this source code is governed by a BSD-style license that can be
360ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany// found in the LICENSE file.
460ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany
560ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany#ifndef CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_WEBSITE_SETTINGS_POPUP_VIEW_H_
660ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany#define CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_WEBSITE_SETTINGS_POPUP_VIEW_H_
760ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany
860ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany#include "base/basictypes.h"
960ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany#include "base/compiler_specific.h"
1060ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany#include "base/memory/scoped_ptr.h"
1160ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany#include "base/memory/weak_ptr.h"
1260ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany#include "base/strings/string16.h"
1360ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany#include "chrome/browser/ui/views/website_settings/permission_selector_view_observer.h"
1460ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany#include "chrome/browser/ui/website_settings/website_settings_ui.h"
1560ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany#include "ui/views/bubble/bubble_delegate.h"
1660ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany#include "ui/views/controls/button/button.h"
1760ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany#include "ui/views/controls/link_listener.h"
1860ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany#include "ui/views/controls/tabbed_pane/tabbed_pane_listener.h"
1960ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany
2060ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryanyclass Browser;
2160ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryanyclass GURL;
22d04a8d4b33ff316ca4cf961e06c9e312eff8e64fChandler Carruthclass PermissionSelectorView;
23d04a8d4b33ff316ca4cf961e06c9e312eff8e64fChandler Carruthclass PopupHeaderView;
24d04a8d4b33ff316ca4cf961e06c9e312eff8e64fChandler Carruthclass Profile;
25d04a8d4b33ff316ca4cf961e06c9e312eff8e64fChandler Carruth
26d04a8d4b33ff316ca4cf961e06c9e312eff8e64fChandler Carruthnamespace content {
27d04a8d4b33ff316ca4cf961e06c9e312eff8e64fChandler Carruthstruct SSLStatus;
280b8c9a80f20772c3793201ab5b251d3520b9cea3Chandler Carruthclass WebContents;
290b8c9a80f20772c3793201ab5b251d3520b9cea3Chandler Carruth}
300b8c9a80f20772c3793201ab5b251d3520b9cea3Chandler Carruth
31f464481db0c3b5404004b510921ca454803fd1d0Kostya Serebryanynamespace views {
320b8c9a80f20772c3793201ab5b251d3520b9cea3Chandler Carruthclass Link;
330b8c9a80f20772c3793201ab5b251d3520b9cea3Chandler Carruthclass TabbedPane;
340b8c9a80f20772c3793201ab5b251d3520b9cea3Chandler Carruthclass Widget;
350b8c9a80f20772c3793201ab5b251d3520b9cea3Chandler Carruth}
360b8c9a80f20772c3793201ab5b251d3520b9cea3Chandler Carruth
376e590e3f61b101554f97d6ab257c802c9ec49862Kostya Serebryany// The views implementation of the website settings UI.
3860ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryanyclass WebsiteSettingsPopupView
3960ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany    : public PermissionSelectorViewObserver,
4052eb699220aa00696b5c4a1a67141a8bcc8a4e68Kostya Serebryany      public views::BubbleDelegateView,
41e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany      public views::ButtonListener,
4260ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany      public views::LinkListener,
4360ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany      public views::TabbedPaneListener,
4460ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany      public WebsiteSettingsUI {
4560ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany public:
46dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines  virtual ~WebsiteSettingsPopupView();
47dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines
4841d876cea3b5212e5ee8bc25c13c6eab54a4a93cKostya Serebryany  static void ShowPopup(views::View* anchor_view,
4941d876cea3b5212e5ee8bc25c13c6eab54a4a93cKostya Serebryany                        Profile* profile,
5041d876cea3b5212e5ee8bc25c13c6eab54a4a93cKostya Serebryany                        content::WebContents* web_contents,
5141d876cea3b5212e5ee8bc25c13c6eab54a4a93cKostya Serebryany                        const GURL& url,
5241d876cea3b5212e5ee8bc25c13c6eab54a4a93cKostya Serebryany                        const content::SSLStatus& ssl,
5341d876cea3b5212e5ee8bc25c13c6eab54a4a93cKostya Serebryany                        Browser* browser);
5441d876cea3b5212e5ee8bc25c13c6eab54a4a93cKostya Serebryany
5541d876cea3b5212e5ee8bc25c13c6eab54a4a93cKostya Serebryany private:
5641d876cea3b5212e5ee8bc25c13c6eab54a4a93cKostya Serebryany  WebsiteSettingsPopupView(views::View* anchor_view,
57f464481db0c3b5404004b510921ca454803fd1d0Kostya Serebryany                           Profile* profile,
58f464481db0c3b5404004b510921ca454803fd1d0Kostya Serebryany                           content::WebContents* web_contents,
59f464481db0c3b5404004b510921ca454803fd1d0Kostya Serebryany                           const GURL& url,
606e590e3f61b101554f97d6ab257c802c9ec49862Kostya Serebryany                           const content::SSLStatus& ssl,
612d5fdf81dc483e42cfad7ffbfa7492a31bb5ffd2Kostya Serebryany                           Browser* browser);
622d5fdf81dc483e42cfad7ffbfa7492a31bb5ffd2Kostya Serebryany
631dfe9b52646ce56446ecd3548dbc81068369ef3fAlexey Samsonov  // PermissionSelectorViewObserver implementation.
642d5fdf81dc483e42cfad7ffbfa7492a31bb5ffd2Kostya Serebryany  virtual void OnPermissionChanged(
652d5fdf81dc483e42cfad7ffbfa7492a31bb5ffd2Kostya Serebryany      PermissionSelectorView* selector) OVERRIDE;
662d5fdf81dc483e42cfad7ffbfa7492a31bb5ffd2Kostya Serebryany
67ab78ac1a2d55cd81e42f4688fbaa7bd689e6291fDmitry Vyukov  // views::BubbleDelegate implementation.
682d5fdf81dc483e42cfad7ffbfa7492a31bb5ffd2Kostya Serebryany  virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE;
692d5fdf81dc483e42cfad7ffbfa7492a31bb5ffd2Kostya Serebryany
702d5fdf81dc483e42cfad7ffbfa7492a31bb5ffd2Kostya Serebryany  // views::ButtonListener implementation.
712076af0184bd38185a719ea07cb10a90e8565a89Kostya Serebryany  virtual void ButtonPressed(views::Button* button,
7260ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany                             const ui::Event& event) OVERRIDE;
732076af0184bd38185a719ea07cb10a90e8565a89Kostya Serebryany
7460ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany  // views::LinkListener implementation.
7560ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany  virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
76cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines
7736b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  // views::TabbedPaneListener implementations.
7836b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  virtual void TabSelectedAt(int index) OVERRIDE;
7936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines
8060ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany  // views::View implementation.
8160ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany  virtual gfx::Size GetPreferredSize() OVERRIDE;
8260ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany
838b390ffbfdd52a23a45a21de99aa1c31f3ce623fKostya Serebryany  // WebsiteSettingsUI implementations.
84e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  virtual void SetCookieInfo(const CookieInfoList& cookie_info_list) OVERRIDE;
85e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  virtual void SetPermissionInfo(
86f464481db0c3b5404004b510921ca454803fd1d0Kostya Serebryany      const PermissionInfoList& permission_info_list) OVERRIDE;
8737cb9acac54fdebdb833dc7e2f312d8e3bb33002Kostya Serebryany  virtual void SetIdentityInfo(const IdentityInfo& identity_info) OVERRIDE;
8837cb9acac54fdebdb833dc7e2f312d8e3bb33002Kostya Serebryany  virtual void SetFirstVisit(const string16& first_visit) OVERRIDE;
89cff60c1409e36079b4bc6ecbda84565143bf00afKostya Serebryany  virtual void SetSelectedTab(TabId tab_id) OVERRIDE;
90e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany
912076af0184bd38185a719ea07cb10a90e8565a89Kostya Serebryany  // Creates the contents of the "Permissions" tab. The ownership of the
9236b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  // returned view is transferred to the caller.
93f464481db0c3b5404004b510921ca454803fd1d0Kostya Serebryany  views::View* CreatePermissionsTab() WARN_UNUSED_RESULT;
94e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany
9560ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany  // Creates the contents of the "connection" tab. The ownership of the returned
96e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  // view is transferred to the caller.
97e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  views::View* CreateConnectionTab() WARN_UNUSED_RESULT;
9860ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany
993eccaa6625a8032bee6b84706cb46ed8eb915acfKostya Serebryany  // Each tab contains several sections with a |headline| followed by the
100e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  // section |contents| and an optional |link|. This method creates a section
101e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  // for the given |headline|, |contents| and |link|. |link| can be NULL if the
102e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  // section should not contain a link.
103e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  views::View* CreateSection(const string16& headline,
1049f8a90b3ce0e248e3b68b056d4c840295facbc02Dmitry Vyukov                             views::View* contents,
1059f8a90b3ce0e248e3b68b056d4c840295facbc02Dmitry Vyukov                             views::Link* link) WARN_UNUSED_RESULT;
1069f8a90b3ce0e248e3b68b056d4c840295facbc02Dmitry Vyukov
1079f8a90b3ce0e248e3b68b056d4c840295facbc02Dmitry Vyukov  // Resets the content of a section. All children of the |section_container|
108e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  // are cleared and destroyed first. Then the |icon|, |headline|, |text| and
109ab78ac1a2d55cd81e42f4688fbaa7bd689e6291fDmitry Vyukov  // |link| are layout out properly. If the |headline| is an empty string then
110f464481db0c3b5404004b510921ca454803fd1d0Kostya Serebryany  // no headline will be displayed. The ownership of the passed |link| is
11160ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany  // transfered to the ResetConnectionSection method and the |link| is added to
11260ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany  // the views hierarchy. If the |link| is NULL then no link is be displayed.
11360ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany  void ResetConnectionSection(views::View* section_container,
11460ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany                              const gfx::Image& icon,
11560ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany                              const string16& headline,
11660ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany                              const string16& text,
11760ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany                              views::Link* link);
11860ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany  // Handles LinkClicked asynchronously.
119e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  void HandleLinkClickedAsync(views::Link* source);
120e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany
121e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  // The web contents of the current tab. The popup can't live longer than a
122e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  // tab.
123cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines  content::WebContents* web_contents_;
124cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines
12560ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany  // The Browser is used to load the help center page.
12660ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany  Browser* browser_;
127e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany
128e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  // The presenter that controlls the Website Settings UI.
129e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  scoped_ptr<WebsiteSettings> presenter_;
130e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany
131e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  PopupHeaderView* header_;  // Owned by views hierarchy.
132e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany
133e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  // The |TabbedPane| that contains the tabs of the Website Settings UI.
1348b390ffbfdd52a23a45a21de99aa1c31f3ce623fKostya Serebryany  views::TabbedPane* tabbed_pane_;
13560ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany
13660ebb1947faed42e493179e569c5db0c01d38a2aKostya Serebryany  // The view that contains the contents of the "Cookies and Site data" section
137e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  // from the "Permissions" tab.
138e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  views::View* site_data_content_;
139e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  // The link that opend the "Cookies" dialog.
140e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  views::Link* cookie_dialog_link_;
141e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  // The view that contains the contents of the "Permissions" section from the
1423eccaa6625a8032bee6b84706cb46ed8eb915acfKostya Serebryany  // "Permissions" tab.
143e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  views::View* permissions_content_;
144e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany
145e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  // The view that contains the connection tab contents.
146e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  views::View* connection_tab_;
147e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  // The view that contains the ui elements for displaying information about
148e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  // the site's identity.
149e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  views::View* identity_info_content_;
150e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  // The link to open the certificate viewer for displaying the certificate
151e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  // provided by the website. If the site does not provide a certificate then
152e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  // |certificate_dialog_link_| is NULL.
153e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  views::Link* certificate_dialog_link_;
154e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  // The id of the certificate provided by the site. If the site does not
155e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  // provide a certificate then |cert_id_| is 0.
156e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  int cert_id_;
157e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany
158e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  // The link to open the help center page that contains more information about
159e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  // the connection status icons.
160e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  views::Link* help_center_link_;
161e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany
162e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  views::View* connection_info_content_;
163e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany  views::View* page_info_content_;
164e507922779b0d0d9ed3c159306174b4e191d119aKostya Serebryany
1659f8a90b3ce0e248e3b68b056d4c840295facbc02Dmitry Vyukov  base::WeakPtrFactory<WebsiteSettingsPopupView> weak_factory_;
1669f8a90b3ce0e248e3b68b056d4c840295facbc02Dmitry Vyukov
1679f8a90b3ce0e248e3b68b056d4c840295facbc02Dmitry Vyukov  DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsPopupView);
168dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines};
169dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines
1709f8a90b3ce0e248e3b68b056d4c840295facbc02Dmitry Vyukov#endif  // CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_WEBSITE_SETTINGS_POPUP_VIEW_H_
1719f8a90b3ce0e248e3b68b056d4c840295facbc02Dmitry Vyukov