OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/views/website_settings/permissions_bubble_view.h" | 5 #include "chrome/browser/ui/views/website_settings/permissions_bubble_view.h" |
6 | 6 |
7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
8 #include "chrome/browser/ui/views/website_settings/permission_selector_view.h" | 8 #include "chrome/browser/ui/views/website_settings/permission_selector_view.h" |
9 #include "chrome/browser/ui/views/website_settings/permission_selector_view_obse
rver.h" | 9 #include "chrome/browser/ui/views/website_settings/permission_selector_view_obse
rver.h" |
10 #include "chrome/browser/ui/website_settings/permission_bubble_request.h" | 10 #include "chrome/browser/ui/website_settings/permission_bubble_request.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 // Get notifications when the selection changes. | 58 // Get notifications when the selection changes. |
59 class Listener { | 59 class Listener { |
60 public: | 60 public: |
61 virtual void PermissionSelectionChanged(int index, bool allowed) = 0; | 61 virtual void PermissionSelectionChanged(int index, bool allowed) = 0; |
62 }; | 62 }; |
63 | 63 |
64 PermissionCombobox(Listener* listener, | 64 PermissionCombobox(Listener* listener, |
65 int index, | 65 int index, |
66 const GURL& url, | 66 const GURL& url, |
67 ContentSetting setting); | 67 ContentSetting setting); |
68 virtual ~PermissionCombobox(); | 68 ~PermissionCombobox() override; |
69 | 69 |
70 int index() const { return index_; } | 70 int index() const { return index_; } |
71 | 71 |
72 virtual void GetAccessibleState(ui::AXViewState* state) override; | 72 void GetAccessibleState(ui::AXViewState* state) override; |
73 | 73 |
74 // MenuButtonListener: | 74 // MenuButtonListener: |
75 virtual void OnMenuButtonClicked(View* source, | 75 void OnMenuButtonClicked(View* source, const gfx::Point& point) override; |
76 const gfx::Point& point) override; | |
77 | 76 |
78 // Callback when a permission's setting is changed. | 77 // Callback when a permission's setting is changed. |
79 void PermissionChanged(const WebsiteSettingsUI::PermissionInfo& permission); | 78 void PermissionChanged(const WebsiteSettingsUI::PermissionInfo& permission); |
80 | 79 |
81 private: | 80 private: |
82 int index_; | 81 int index_; |
83 Listener* listener_; | 82 Listener* listener_; |
84 scoped_ptr<PermissionMenuModel> model_; | 83 scoped_ptr<PermissionMenuModel> model_; |
85 scoped_ptr<views::MenuRunner> menu_runner_; | 84 scoped_ptr<views::MenuRunner> menu_runner_; |
86 }; | 85 }; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 // A combobox originating on the Allow button allowing for customization | 136 // A combobox originating on the Allow button allowing for customization |
138 // of permissions. | 137 // of permissions. |
139 class CustomizeAllowComboboxModel : public ui::ComboboxModel { | 138 class CustomizeAllowComboboxModel : public ui::ComboboxModel { |
140 public: | 139 public: |
141 enum Item { | 140 enum Item { |
142 INDEX_ALLOW = 0, | 141 INDEX_ALLOW = 0, |
143 INDEX_CUSTOMIZE = 1 | 142 INDEX_CUSTOMIZE = 1 |
144 }; | 143 }; |
145 | 144 |
146 CustomizeAllowComboboxModel() {} | 145 CustomizeAllowComboboxModel() {} |
147 virtual ~CustomizeAllowComboboxModel() {} | 146 ~CustomizeAllowComboboxModel() override {} |
148 | 147 |
149 virtual int GetItemCount() const override; | 148 int GetItemCount() const override; |
150 virtual base::string16 GetItemAt(int index) override; | 149 base::string16 GetItemAt(int index) override; |
151 virtual int GetDefaultIndex() const override; | 150 int GetDefaultIndex() const override; |
152 }; | 151 }; |
153 | 152 |
154 int CustomizeAllowComboboxModel::GetItemCount() const { | 153 int CustomizeAllowComboboxModel::GetItemCount() const { |
155 return 2; | 154 return 2; |
156 } | 155 } |
157 | 156 |
158 base::string16 CustomizeAllowComboboxModel::GetItemAt(int index) { | 157 base::string16 CustomizeAllowComboboxModel::GetItemAt(int index) { |
159 if (index == INDEX_ALLOW) | 158 if (index == INDEX_ALLOW) |
160 return l10n_util::GetStringUTF16(IDS_PERMISSION_ALLOW); | 159 return l10n_util::GetStringUTF16(IDS_PERMISSION_ALLOW); |
161 else | 160 else |
(...skipping 10 matching lines...) Expand all Loading... |
172 public views::ButtonListener, | 171 public views::ButtonListener, |
173 public views::ComboboxListener, | 172 public views::ComboboxListener, |
174 public PermissionCombobox::Listener { | 173 public PermissionCombobox::Listener { |
175 public: | 174 public: |
176 PermissionsBubbleDelegateView( | 175 PermissionsBubbleDelegateView( |
177 views::View* anchor, | 176 views::View* anchor, |
178 PermissionBubbleViewViews* owner, | 177 PermissionBubbleViewViews* owner, |
179 const std::vector<PermissionBubbleRequest*>& requests, | 178 const std::vector<PermissionBubbleRequest*>& requests, |
180 const std::vector<bool>& accept_state, | 179 const std::vector<bool>& accept_state, |
181 bool customization_mode); | 180 bool customization_mode); |
182 virtual ~PermissionsBubbleDelegateView(); | 181 ~PermissionsBubbleDelegateView() override; |
183 | 182 |
184 void Close(); | 183 void Close(); |
185 void SizeToContents(); | 184 void SizeToContents(); |
186 | 185 |
187 // BubbleDelegateView: | 186 // BubbleDelegateView: |
188 virtual bool ShouldShowCloseButton() const override; | 187 bool ShouldShowCloseButton() const override; |
189 virtual bool ShouldShowWindowTitle() const override; | 188 bool ShouldShowWindowTitle() const override; |
190 virtual const gfx::FontList& GetTitleFontList() const override; | 189 const gfx::FontList& GetTitleFontList() const override; |
191 virtual base::string16 GetWindowTitle() const override; | 190 base::string16 GetWindowTitle() const override; |
192 virtual void OnWidgetDestroying(views::Widget* widget) override; | 191 void OnWidgetDestroying(views::Widget* widget) override; |
193 | 192 |
194 // ButtonListener: | 193 // ButtonListener: |
195 virtual void ButtonPressed(views::Button* button, | 194 void ButtonPressed(views::Button* button, const ui::Event& event) override; |
196 const ui::Event& event) override; | |
197 | 195 |
198 // ComboboxListener: | 196 // ComboboxListener: |
199 virtual void OnPerformAction(views::Combobox* combobox) override; | 197 void OnPerformAction(views::Combobox* combobox) override; |
200 | 198 |
201 // PermissionCombobox::Listener: | 199 // PermissionCombobox::Listener: |
202 virtual void PermissionSelectionChanged(int index, bool allowed) override; | 200 void PermissionSelectionChanged(int index, bool allowed) override; |
203 | 201 |
204 private: | 202 private: |
205 PermissionBubbleViewViews* owner_; | 203 PermissionBubbleViewViews* owner_; |
206 views::Button* allow_; | 204 views::Button* allow_; |
207 views::Button* deny_; | 205 views::Button* deny_; |
208 views::Combobox* allow_combobox_; | 206 views::Combobox* allow_combobox_; |
209 base::string16 hostname_; | 207 base::string16 hostname_; |
210 scoped_ptr<PermissionMenuModel> menu_button_model_; | 208 scoped_ptr<PermissionMenuModel> menu_button_model_; |
211 std::vector<PermissionCombobox*> customize_comboboxes_; | 209 std::vector<PermissionCombobox*> customize_comboboxes_; |
212 | 210 |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 | 476 |
479 void PermissionBubbleViewViews::Deny() { | 477 void PermissionBubbleViewViews::Deny() { |
480 if (delegate_) | 478 if (delegate_) |
481 delegate_->Deny(); | 479 delegate_->Deny(); |
482 } | 480 } |
483 | 481 |
484 void PermissionBubbleViewViews::SetCustomizationMode() { | 482 void PermissionBubbleViewViews::SetCustomizationMode() { |
485 if (delegate_) | 483 if (delegate_) |
486 delegate_->SetCustomizationMode(); | 484 delegate_->SetCustomizationMode(); |
487 } | 485 } |
OLD | NEW |