Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / website_settings / website_settings_popup_view.h
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 "content/public/common/signed_certificate_timestamp_id_and_status.h"
16 #include "ui/views/bubble/bubble_delegate.h"
17 #include "ui/views/controls/button/button.h"
18 #include "ui/views/controls/button/label_button.h"
19 #include "ui/views/controls/link_listener.h"
20 #include "ui/views/controls/tabbed_pane/tabbed_pane_listener.h"
21
22 class Browser;
23 class GURL;
24 class PermissionSelectorView;
25 class PopupHeaderView;
26 class Profile;
27
28 namespace content {
29 struct SSLStatus;
30 class WebContents;
31 }
32
33 namespace views {
34 class LabelButton;
35 class Link;
36 class TabbedPane;
37 class Widget;
38 }
39
40 // The views implementation of the website settings UI.
41 class WebsiteSettingsPopupView
42     : public PermissionSelectorViewObserver,
43       public views::BubbleDelegateView,
44       public views::ButtonListener,
45       public views::LinkListener,
46       public views::TabbedPaneListener,
47       public WebsiteSettingsUI {
48  public:
49   ~WebsiteSettingsPopupView() override;
50
51   static void ShowPopup(views::View* anchor_view,
52                         Profile* profile,
53                         content::WebContents* web_contents,
54                         const GURL& url,
55                         const content::SSLStatus& ssl,
56                         Browser* browser);
57
58   static bool IsPopupShowing();
59
60  private:
61   WebsiteSettingsPopupView(views::View* anchor_view,
62                            Profile* profile,
63                            content::WebContents* web_contents,
64                            const GURL& url,
65                            const content::SSLStatus& ssl,
66                            Browser* browser);
67
68   // PermissionSelectorViewObserver implementation.
69   void OnPermissionChanged(
70       const WebsiteSettingsUI::PermissionInfo& permission) override;
71
72   // views::BubbleDelegateView implementation.
73   void OnWidgetDestroying(views::Widget* widget) override;
74
75   // views::ButtonListener implementation.
76   void ButtonPressed(views::Button* button, const ui::Event& event) override;
77
78   // views::LinkListener implementation.
79   void LinkClicked(views::Link* source, int event_flags) override;
80
81   // views::TabbedPaneListener implementations.
82   void TabSelectedAt(int index) override;
83
84   // views::View implementation.
85   gfx::Size GetPreferredSize() const override;
86
87   // WebsiteSettingsUI implementations.
88   void SetCookieInfo(const CookieInfoList& cookie_info_list) override;
89   void SetPermissionInfo(
90       const PermissionInfoList& permission_info_list) override;
91   void SetIdentityInfo(const IdentityInfo& identity_info) override;
92   void SetFirstVisit(const base::string16& first_visit) override;
93   void SetSelectedTab(TabId tab_id) override;
94
95   // Creates the contents of the "Permissions" tab. The ownership of the
96   // returned view is transferred to the caller.
97   views::View* CreatePermissionsTab() WARN_UNUSED_RESULT;
98
99   // Creates the contents of the "connection" tab. The ownership of the returned
100   // view is transferred to the caller.
101   views::View* CreateConnectionTab() WARN_UNUSED_RESULT;
102
103   // Each tab contains several sections with a |headline| followed by the
104   // section |contents| and an optional |link|. This method creates a section
105   // for the given |headline|, |contents| and |link|. |link| can be NULL if the
106   // section should not contain a link.
107   views::View* CreateSection(const base::string16& headline,
108                              views::View* contents,
109                              views::Link* link) WARN_UNUSED_RESULT;
110
111   // Resets the content of a section. All children of the |section_container|
112   // are cleared and destroyed first. Then the |icon|, |headline|, |text| and
113   // |link| are layout out properly. If the |headline| is an empty string then
114   // no headline will be displayed. The ownership of the passed |link| is
115   // transfered to the ResetConnectionSection method and the |link| is added to
116   // the views hierarchy. If the |link| is NULL then no link is be displayed.
117   void ResetConnectionSection(views::View* section_container,
118                               const gfx::Image& icon,
119                               const base::string16& headline,
120                               const base::string16& text,
121                               views::Link* link,
122                               views::Link* secondary_link,
123                               views::LabelButton* reset_decisions_button);
124
125   // The web contents of the current tab. The popup can't live longer than a
126   // tab.
127   content::WebContents* web_contents_;
128
129   // The Browser is used to load the help center page.
130   Browser* browser_;
131
132   // The presenter that controlls the Website Settings UI.
133   scoped_ptr<WebsiteSettings> presenter_;
134
135   PopupHeaderView* header_;  // Owned by views hierarchy.
136
137   // The |TabbedPane| that contains the tabs of the Website Settings UI.
138   views::TabbedPane* tabbed_pane_;
139
140   // The view that contains the contents of the "Cookies and Site data" section
141   // from the "Permissions" tab.
142   views::View* site_data_content_;
143   // The link that opend the "Cookies" dialog.
144   views::Link* cookie_dialog_link_;
145   // The view that contains the contents of the "Permissions" section from the
146   // "Permissions" tab.
147   views::View* permissions_content_;
148
149   // The view that contains the connection tab contents.
150   views::View* connection_tab_;
151   // The view that contains the ui elements for displaying information about
152   // the site's identity.
153   views::View* identity_info_content_;
154   // The link to open the certificate viewer for displaying the certificate
155   // provided by the website. If the site does not provide a certificate then
156   // |certificate_dialog_link_| is NULL.
157   views::Link* certificate_dialog_link_;
158   // The link to open the signed certificate timestamps viewer for displaying
159   // Certificate Transparency info. If no such SCTs accompany the certificate
160   // then |signed_certificate_timestamps_link_| is NULL.
161   views::Link* signed_certificate_timestamps_link_;
162   // The button to reset the Allow/Deny certificate errors decision for the
163   // current host.
164   views::LabelButton* reset_decisions_button_;
165
166   // The id of the certificate provided by the site. If the site does not
167   // provide a certificate then |cert_id_| is 0.
168   int cert_id_;
169   // The IDs and validation status of Signed Certificate TImestamps provided
170   // by the site. Empty if no SCTs accompany the certificate.
171   content::SignedCertificateTimestampIDStatusList
172       signed_certificate_timestamp_ids_;
173
174   // The link to open the help center page that contains more information about
175   // the connection status icons.
176   views::Link* help_center_link_;
177
178   views::View* connection_info_content_;
179   views::View* page_info_content_;
180
181   base::WeakPtrFactory<WebsiteSettingsPopupView> weak_factory_;
182
183   DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsPopupView);
184 };
185
186 #endif  // CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_WEBSITE_SETTINGS_POPUP_VIEW_H_