Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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_POPUP_VIEW_H_ | |
| 6 #define CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_POPUP_VIEW_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "chrome/browser/ui/website_settings_ui.h" | |
| 10 #include "ui/base/models/combobox_model.h" | |
| 11 #include "ui/views/bubble/bubble_delegate.h" | |
| 12 #include "ui/views/controls/combobox/combobox_listener.h" | |
| 13 #include "ui/views/controls/link_listener.h" | |
| 14 #include "ui/views/controls/tabbed_pane/tabbed_pane_listener.h" | |
| 15 #include "ui/views/view.h" | |
| 16 | |
| 17 class PopupHeader; | |
| 18 class Profile; | |
| 19 class TabContentsWrapper; | |
| 20 namespace views { | |
|
Finnur
2012/05/30 11:20:04
nit: I'd put a line break before this line...
markusheintz_
2012/06/05 17:02:12
Done.
| |
| 21 class Combobox; | |
| 22 class Link; | |
| 23 class Label; | |
| 24 class TabbedPane; | |
| 25 } // namespace views | |
| 26 | |
| 27 // |PopupHeader| is the UI element (view) that represents the header of the | |
| 28 // |WebsiteSettingsPopupView|. | |
| 29 class PopupHeader : public views::View { | |
|
Finnur
2012/05/30 11:20:04
Does this need to be defined in the .h file?
markusheintz_
2012/06/05 17:02:12
I moved the class definitions back to the .cc file
| |
| 30 public: | |
| 31 PopupHeader(); | |
| 32 virtual ~PopupHeader(); | |
| 33 | |
| 34 void SetIdentityName(string16 identity); | |
|
Finnur
2012/05/30 11:20:04
Document all members and functions (here and class
markusheintz_
2012/06/05 17:02:12
Done.
| |
| 35 | |
| 36 void SetIdentityStatus(string16 status); | |
| 37 | |
| 38 // View implementation. | |
| 39 virtual gfx::Size GetPreferredSize() OVERRIDE; | |
| 40 | |
| 41 private: | |
| 42 views::Label* name_; | |
| 43 views::Label* status_; | |
| 44 | |
| 45 DISALLOW_COPY_AND_ASSIGN(PopupHeader); | |
| 46 }; | |
| 47 | |
| 48 // A |ComboboxModel| implementation that is used for |Combobox|es that allow to | |
| 49 // select a setting for a given site permission. | |
|
Finnur
2012/05/30 11:20:04
wording: allow to select -> allow selecting
markusheintz_
2012/06/05 17:02:12
Done.
| |
| 50 class PermissionComboboxModel : public ui::ComboboxModel { | |
|
Finnur
2012/05/30 11:20:04
Same here, does it need to be in the .h file?
markusheintz_
2012/06/05 17:02:12
Same as above in line 29.
| |
| 51 public: | |
| 52 // Creates a combobox model that provides all possible settings for the given | |
| 53 // |site_permission|. | |
| 54 PermissionComboboxModel(ContentSettingsType site_permission, | |
| 55 ContentSetting default_setting); | |
| 56 virtual ~PermissionComboboxModel(); | |
| 57 | |
| 58 // Returns the setting for the given |index|. | |
| 59 ContentSetting GetSettingAt(int index) const; | |
| 60 | |
| 61 // Returns the site permission for which the combobox model provides | |
| 62 // settings. | |
| 63 ContentSettingsType site_permission() const { | |
| 64 return site_permission_; | |
| 65 } | |
| 66 | |
| 67 // ui::ComboboxModel implementations. | |
| 68 virtual int GetItemCount() const OVERRIDE; | |
| 69 virtual string16 GetItemAt(int index) OVERRIDE; | |
| 70 | |
| 71 private: | |
| 72 // The site permission (the |ContentSettingsType|) for which the combobox | |
| 73 // model provides settings. | |
| 74 ContentSettingsType site_permission_; | |
| 75 | |
| 76 // The global default setting for the |site_permission_|. | |
| 77 ContentSetting default_setting_; | |
| 78 | |
| 79 // All possible valid setting for the |site_permission_|. | |
| 80 std::vector<ContentSetting> settings_; | |
| 81 | |
| 82 DISALLOW_COPY_AND_ASSIGN(PermissionComboboxModel); | |
| 83 }; | |
| 84 | |
| 85 // Views implementation of the website settings UI. The website settings UI is | |
| 86 // displayed in a popup that is positioned relative the an anchor element | |
|
Finnur
2012/05/30 11:20:04
nit: 'the' or 'an', which is it?
Also, missing per
markusheintz_
2012/06/05 17:02:12
Done.
| |
| 87 class WebsiteSettingsPopupView : public WebsiteSettingsUI, | |
| 88 public views::BubbleDelegateView, | |
| 89 public views::ComboboxListener, | |
| 90 public views::LinkListener, | |
| 91 public views::TabbedPaneListener { | |
| 92 public: | |
| 93 WebsiteSettingsPopupView(views::View* anchor_view, | |
| 94 Profile* profile, | |
| 95 TabContentsWrapper* wrapper); | |
| 96 | |
| 97 virtual ~WebsiteSettingsPopupView(); | |
| 98 | |
| 99 // WebsiteSettingsUI implementations. | |
| 100 virtual void SetPresenter(WebsiteSettings* presenter) OVERRIDE; | |
| 101 virtual void SetCookieInfo(const CookieInfoList& cookie_info_list) OVERRIDE; | |
| 102 virtual void SetPermissionInfo( | |
| 103 const PermissionInfoList& permission_info_list) OVERRIDE; | |
| 104 virtual void SetIdentityInfo(const IdentityInfo& identity_info) OVERRIDE; | |
| 105 virtual void SetFirstVisit(const string16& first_visit) OVERRIDE; | |
| 106 | |
| 107 // views::View implementation. | |
| 108 virtual gfx::Size GetPreferredSize() OVERRIDE; | |
| 109 | |
| 110 // views::BubbleDelegate implementations. | |
| 111 virtual gfx::Rect GetAnchorRect() OVERRIDE; | |
| 112 | |
| 113 // views::ComboboxListener implementation. | |
| 114 virtual void OnSelectedIndexChanged(views::Combobox* combobox) OVERRIDE; | |
| 115 | |
| 116 // LinkListener implementation. | |
| 117 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; | |
| 118 | |
| 119 // views::TabbedPaneListener implementations. | |
| 120 virtual void TabSelectedAt(int index) OVERRIDE; | |
| 121 | |
| 122 private: | |
| 123 // Each tab contains several sections with a |headline| followed by the | |
| 124 // section |contents| and an optional |link|. This method creates a section | |
| 125 // for the given |headline|, |contents| and |link|. |link| can be NULL if the | |
| 126 // section should not contain a link. | |
| 127 views::View* CreateSection(string16 headline, | |
| 128 views::View* contents, | |
| 129 views::Link* link); | |
| 130 | |
| 131 // Creates a single row for the "Permissions" section from the "Permissions" | |
| 132 // tab. Such a row contains a |permissions_label| with the name of the | |
| 133 // permission and a |combobox| that allows to select setting for the given | |
| 134 // permission. | |
| 135 views::View* CreatePermissionRow(views::Label* permission_label, | |
| 136 views::Combobox* combobox); | |
| 137 | |
| 138 // Creates the contents of the "Permissions" tab. | |
| 139 views::View* CreatePermissionsTab(); | |
| 140 | |
| 141 // Creates the contents of the "Identity" tab. | |
| 142 views::View* CreateIdentityTab(); | |
| 143 | |
| 144 // Creates a multiline text label that is initialized with the given |text|. | |
| 145 views::Label* CreateTextLabel(string16 text); | |
|
Finnur
2012/05/30 11:20:04
These Create functions... can you annotate them wi
markusheintz_
2012/06/05 17:02:12
Done.
Finnur
2012/06/06 11:55:50
Actually, you should probably also document the fa
markusheintz_
2012/06/06 13:47:03
Done. I also added a comment to the methods above.
| |
| 146 | |
| 147 TabContentsWrapper* tab_contents_wrapper_; | |
| 148 | |
| 149 // The presenter that controlls the Website Settings UI. | |
| 150 WebsiteSettings* presenter_; | |
| 151 | |
| 152 PopupHeader* header_; | |
| 153 | |
| 154 // The |TabbedPane| that contains the tabs of the Website Settings UI. | |
| 155 views::TabbedPane* tabbed_pane_; | |
| 156 | |
| 157 // The view that contains the contents of the "Cookies and Site data" section | |
| 158 // from the "Permissions" tab. | |
| 159 views::View* site_data_content_; | |
| 160 // The link that opend the "Cookies" dialog. | |
| 161 views::Link* cookie_dialog_link_; | |
| 162 // The view that contains the contents of the "Permissions" section from the | |
| 163 // "Permissions" tab. | |
| 164 views::View* permissions_content_; | |
| 165 | |
| 166 views::Label* identity_info_text_; | |
| 167 views::Label* connection_info_text_; | |
| 168 views::Label* page_info_text_; | |
| 169 | |
| 170 DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsPopupView); | |
| 171 }; | |
| 172 | |
| 173 #endif // CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_POPUP_VIEW_H_ | |
| OLD | NEW |