website_settings_popup_view.h revision a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7
1// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_WEBSITE_SETTINGS_POPUP_VIEW_H_
6#define CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_WEBSITE_SETTINGS_POPUP_VIEW_H_
7
8#include "base/basictypes.h"
9#include "base/compiler_specific.h"
10#include "base/memory/scoped_ptr.h"
11#include "base/memory/weak_ptr.h"
12#include "base/strings/string16.h"
13#include "chrome/browser/ui/views/website_settings/permission_selector_view_observer.h"
14#include "chrome/browser/ui/website_settings/website_settings_ui.h"
15#include "ui/views/bubble/bubble_delegate.h"
16#include "ui/views/controls/button/button.h"
17#include "ui/views/controls/link_listener.h"
18#include "ui/views/controls/tabbed_pane/tabbed_pane_listener.h"
19
20class Browser;
21class GURL;
22class PermissionSelectorView;
23class PopupHeaderView;
24class Profile;
25
26namespace content {
27struct SSLStatus;
28class WebContents;
29}
30
31namespace views {
32class Link;
33class TabbedPane;
34class Widget;
35}
36
37// The views implementation of the website settings UI.
38class WebsiteSettingsPopupView
39    : public PermissionSelectorViewObserver,
40      public views::BubbleDelegateView,
41      public views::ButtonListener,
42      public views::LinkListener,
43      public views::TabbedPaneListener,
44      public WebsiteSettingsUI {
45 public:
46  virtual ~WebsiteSettingsPopupView();
47
48  static void ShowPopup(views::View* anchor_view,
49                        Profile* profile,
50                        content::WebContents* web_contents,
51                        const GURL& url,
52                        const content::SSLStatus& ssl,
53                        Browser* browser);
54
55 private:
56  WebsiteSettingsPopupView(views::View* anchor_view,
57                           Profile* profile,
58                           content::WebContents* web_contents,
59                           const GURL& url,
60                           const content::SSLStatus& ssl,
61                           Browser* browser);
62
63  // PermissionSelectorViewObserver implementation.
64  virtual void OnPermissionChanged(
65      PermissionSelectorView* selector) OVERRIDE;
66
67  // views::BubbleDelegate implementation.
68  virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE;
69
70  // views::ButtonListener implementation.
71  virtual void ButtonPressed(views::Button* button,
72                             const ui::Event& event) OVERRIDE;
73
74  // views::LinkListener implementation.
75  virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
76
77  // views::TabbedPaneListener implementations.
78  virtual void TabSelectedAt(int index) OVERRIDE;
79
80  // views::View implementation.
81  virtual gfx::Size GetPreferredSize() OVERRIDE;
82
83  // WebsiteSettingsUI implementations.
84  virtual void SetCookieInfo(const CookieInfoList& cookie_info_list) OVERRIDE;
85  virtual void SetPermissionInfo(
86      const PermissionInfoList& permission_info_list) OVERRIDE;
87  virtual void SetIdentityInfo(const IdentityInfo& identity_info) OVERRIDE;
88  virtual void SetFirstVisit(const base::string16& first_visit) OVERRIDE;
89  virtual void SetSelectedTab(TabId tab_id) OVERRIDE;
90
91  // Creates the contents of the "Permissions" tab. The ownership of the
92  // returned view is transferred to the caller.
93  views::View* CreatePermissionsTab() WARN_UNUSED_RESULT;
94
95  // Creates the contents of the "connection" tab. The ownership of the returned
96  // view is transferred to the caller.
97  views::View* CreateConnectionTab() WARN_UNUSED_RESULT;
98
99  // Each tab contains several sections with a |headline| followed by the
100  // section |contents| and an optional |link|. This method creates a section
101  // for the given |headline|, |contents| and |link|. |link| can be NULL if the
102  // section should not contain a link.
103  views::View* CreateSection(const base::string16& headline,
104                             views::View* contents,
105                             views::Link* link) WARN_UNUSED_RESULT;
106
107  // Resets the content of a section. All children of the |section_container|
108  // are cleared and destroyed first. Then the |icon|, |headline|, |text| and
109  // |link| are layout out properly. If the |headline| is an empty string then
110  // no headline will be displayed. The ownership of the passed |link| is
111  // transfered to the ResetConnectionSection method and the |link| is added to
112  // the views hierarchy. If the |link| is NULL then no link is be displayed.
113  void ResetConnectionSection(views::View* section_container,
114                              const gfx::Image& icon,
115                              const base::string16& headline,
116                              const base::string16& text,
117                              views::Link* link);
118  // Handles LinkClicked asynchronously.
119  void HandleLinkClickedAsync(views::Link* source);
120
121  // The web contents of the current tab. The popup can't live longer than a
122  // tab.
123  content::WebContents* web_contents_;
124
125  // The Browser is used to load the help center page.
126  Browser* browser_;
127
128  // The presenter that controlls the Website Settings UI.
129  scoped_ptr<WebsiteSettings> presenter_;
130
131  PopupHeaderView* header_;  // Owned by views hierarchy.
132
133  // The |TabbedPane| that contains the tabs of the Website Settings UI.
134  views::TabbedPane* tabbed_pane_;
135
136  // The view that contains the contents of the "Cookies and Site data" section
137  // from the "Permissions" tab.
138  views::View* site_data_content_;
139  // The link that opend the "Cookies" dialog.
140  views::Link* cookie_dialog_link_;
141  // The view that contains the contents of the "Permissions" section from the
142  // "Permissions" tab.
143  views::View* permissions_content_;
144
145  // The view that contains the connection tab contents.
146  views::View* connection_tab_;
147  // The view that contains the ui elements for displaying information about
148  // the site's identity.
149  views::View* identity_info_content_;
150  // The link to open the certificate viewer for displaying the certificate
151  // provided by the website. If the site does not provide a certificate then
152  // |certificate_dialog_link_| is NULL.
153  views::Link* certificate_dialog_link_;
154  // The id of the certificate provided by the site. If the site does not
155  // provide a certificate then |cert_id_| is 0.
156  int cert_id_;
157
158  // The link to open the help center page that contains more information about
159  // the connection status icons.
160  views::Link* help_center_link_;
161
162  views::View* connection_info_content_;
163  views::View* page_info_content_;
164
165  base::WeakPtrFactory<WebsiteSettingsPopupView> weak_factory_;
166
167  DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsPopupView);
168};
169
170#endif  // CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_WEBSITE_SETTINGS_POPUP_VIEW_H_
171