Upstream version 6.35.121.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/link_listener.h"
19 #include "ui/views/controls/tabbed_pane/tabbed_pane_listener.h"
20
21 class Browser;
22 class GURL;
23 class PermissionSelectorView;
24 class PopupHeaderView;
25 class Profile;
26
27 namespace content {
28 struct SSLStatus;
29 class WebContents;
30 }
31
32 namespace views {
33 class Link;
34 class TabbedPane;
35 class Widget;
36 }
37
38 // The views implementation of the website settings UI.
39 class WebsiteSettingsPopupView
40     : public PermissionSelectorViewObserver,
41       public views::BubbleDelegateView,
42       public views::ButtonListener,
43       public views::LinkListener,
44       public views::TabbedPaneListener,
45       public WebsiteSettingsUI {
46  public:
47   virtual ~WebsiteSettingsPopupView();
48
49   static void ShowPopup(views::View* anchor_view,
50                         Profile* profile,
51                         content::WebContents* web_contents,
52                         const GURL& url,
53                         const content::SSLStatus& ssl,
54                         Browser* browser);
55
56   static bool IsPopupShowing();
57
58  private:
59   WebsiteSettingsPopupView(views::View* anchor_view,
60                            Profile* profile,
61                            content::WebContents* web_contents,
62                            const GURL& url,
63                            const content::SSLStatus& ssl,
64                            Browser* browser);
65
66   // PermissionSelectorViewObserver implementation.
67   virtual void OnPermissionChanged(
68       PermissionSelectorView* selector) OVERRIDE;
69
70   // views::BubbleDelegateView implementation.
71   virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE;
72
73   // views::ButtonListener implementation.
74   virtual void ButtonPressed(views::Button* button,
75                              const ui::Event& event) OVERRIDE;
76
77   // views::LinkListener implementation.
78   virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
79
80   // views::TabbedPaneListener implementations.
81   virtual void TabSelectedAt(int index) OVERRIDE;
82
83   // views::View implementation.
84   virtual gfx::Size GetPreferredSize() OVERRIDE;
85
86   // WebsiteSettingsUI implementations.
87   virtual void SetCookieInfo(const CookieInfoList& cookie_info_list) OVERRIDE;
88   virtual void SetPermissionInfo(
89       const PermissionInfoList& permission_info_list) OVERRIDE;
90   virtual void SetIdentityInfo(const IdentityInfo& identity_info) OVERRIDE;
91   virtual void SetFirstVisit(const base::string16& first_visit) OVERRIDE;
92   virtual void SetSelectedTab(TabId tab_id) OVERRIDE;
93
94   // Creates the contents of the "Permissions" tab. The ownership of the
95   // returned view is transferred to the caller.
96   views::View* CreatePermissionsTab() WARN_UNUSED_RESULT;
97
98   // Creates the contents of the "connection" tab. The ownership of the returned
99   // view is transferred to the caller.
100   views::View* CreateConnectionTab() WARN_UNUSED_RESULT;
101
102   // Each tab contains several sections with a |headline| followed by the
103   // section |contents| and an optional |link|. This method creates a section
104   // for the given |headline|, |contents| and |link|. |link| can be NULL if the
105   // section should not contain a link.
106   views::View* CreateSection(const base::string16& headline,
107                              views::View* contents,
108                              views::Link* link) WARN_UNUSED_RESULT;
109
110   // Resets the content of a section. All children of the |section_container|
111   // are cleared and destroyed first. Then the |icon|, |headline|, |text| and
112   // |link| are layout out properly. If the |headline| is an empty string then
113   // no headline will be displayed. The ownership of the passed |link| is
114   // transfered to the ResetConnectionSection method and the |link| is added to
115   // the views hierarchy. If the |link| is NULL then no link is be displayed.
116   void ResetConnectionSection(views::View* section_container,
117                               const gfx::Image& icon,
118                               const base::string16& headline,
119                               const base::string16& text,
120                               views::Link* link,
121                               views::Link* secondary_link);
122   // Handles LinkClicked asynchronously.
123   void HandleLinkClickedAsync(views::Link* source);
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
163   // The id of the certificate provided by the site. If the site does not
164   // provide a certificate then |cert_id_| is 0.
165   int cert_id_;
166   // The IDs and validation status of Signed Certificate TImestamps provided
167   // by the site. Empty if no SCTs accompany the certificate.
168   content::SignedCertificateTimestampIDStatusList
169       signed_certificate_timestamp_ids_;
170
171   // The link to open the help center page that contains more information about
172   // the connection status icons.
173   views::Link* help_center_link_;
174
175   views::View* connection_info_content_;
176   views::View* page_info_content_;
177
178   base::WeakPtrFactory<WebsiteSettingsPopupView> weak_factory_;
179
180   DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsPopupView);
181 };
182
183 #endif  // CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_WEBSITE_SETTINGS_POPUP_VIEW_H_