Chromium Code Reviews| Index: chrome/browser/ui/views/website_settings/permissions_bubble_view.cc |
| diff --git a/chrome/browser/ui/views/website_settings/permissions_bubble_view.cc b/chrome/browser/ui/views/website_settings/permissions_bubble_view.cc |
| index fb6b22f822113694cd6c10cea3f0c0692f2aa216..3a9ba62d9b522b1b6334b0a39e03de7aad82af7c 100644 |
| --- a/chrome/browser/ui/views/website_settings/permissions_bubble_view.cc |
| +++ b/chrome/browser/ui/views/website_settings/permissions_bubble_view.cc |
| @@ -167,6 +167,44 @@ int CustomizeAllowComboboxModel::GetDefaultIndex() const { |
| return INDEX_ALLOW; |
| } |
| +// A combobox originating on the Allow button allowing for granular geolocation |
| +// sharing. |
| +class GeolocationAllowComboboxModel : public ui::ComboboxModel { |
| + public: |
| + enum Item { |
| + INDEX_ALLOW = 0, |
|
meacer
2014/08/11 18:15:50
I think you'll want to rename this to EXACT or som
mhm
2014/08/13 20:48:22
Done.
|
| + INDEX_CITY = 1, |
| + INDEX_STATE = 2, |
| + INDEX_COUNTRY = 3 |
| + }; |
| + |
| + GeolocationAllowComboboxModel() {} |
| + virtual ~GeolocationAllowComboboxModel() {} |
| + |
| + virtual int GetItemCount() const OVERRIDE; |
| + virtual base::string16 GetItemAt(int index) OVERRIDE; |
| + virtual int GetDefaultIndex() const OVERRIDE; |
| +}; |
| + |
| +int GeolocationAllowComboboxModel::GetItemCount() const { |
| + return 4; |
| +} |
| + |
| +base::string16 GeolocationAllowComboboxModel::GetItemAt(int index) { |
| + if (index == INDEX_ALLOW) |
|
meacer
2014/08/11 18:15:50
Might want to use switch here.
mhm
2014/08/13 20:48:22
Done.
|
| + return l10n_util::GetStringUTF16(IDS_PERMISSION_ALLOW); |
| + else if (index == INDEX_CITY) |
| + return l10n_util::GetStringUTF16(IDS_PERMISSION_CITY); |
| + else if (index == INDEX_STATE) |
| + return l10n_util::GetStringUTF16(IDS_PERMISSION_STATE); |
| + else |
| + return l10n_util::GetStringUTF16(IDS_PERMISSION_COUNTRY); |
| +} |
| + |
| +int GeolocationAllowComboboxModel::GetDefaultIndex() const { |
| + return INDEX_ALLOW; |
| +} |
| + |
| /////////////////////////////////////////////////////////////////////////////// |
| // View implementation for the permissions bubble. |
| class PermissionsBubbleDelegateView : public views::BubbleDelegateView, |
| @@ -207,6 +245,7 @@ class PermissionsBubbleDelegateView : public views::BubbleDelegateView, |
| views::Button* allow_; |
| views::Button* deny_; |
| views::Combobox* allow_combobox_; |
| + views::Combobox* geolocation_combobox_; |
| base::string16 hostname_; |
| scoped_ptr<PermissionMenuModel> menu_button_model_; |
| std::vector<PermissionCombobox*> customize_comboboxes_; |
| @@ -224,7 +263,8 @@ PermissionsBubbleDelegateView::PermissionsBubbleDelegateView( |
| owner_(owner), |
| allow_(NULL), |
| deny_(NULL), |
| - allow_combobox_(NULL) { |
| + allow_combobox_(NULL), |
| + geolocation_combobox_(NULL) { |
| DCHECK(!requests.empty()); |
| RemoveAllChildViews(true); |
| @@ -243,6 +283,7 @@ PermissionsBubbleDelegateView::PermissionsBubbleDelegateView( |
| net::UnescapeRule::SPACES, NULL, NULL, NULL); |
| ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| + |
| for (size_t index = 0; index < requests.size(); index++) { |
| DCHECK(index < accept_state.size()); |
| // The row is laid out containing a leading-aligned label area and a |
| @@ -324,10 +365,20 @@ PermissionsBubbleDelegateView::PermissionsBubbleDelegateView( |
| base::string16 allow_text = l10n_util::GetStringUTF16(IDS_PERMISSION_ALLOW); |
| if (requests.size() == 1) { |
| - views::LabelButton* allow_button = new views::LabelButton(this, allow_text); |
| - allow_button->SetStyle(views::Button::STYLE_BUTTON); |
| - button_layout->AddView(allow_button); |
| - allow_ = allow_button; |
| + if (requests[0]->GetType() == PermissionBubbleRequest::Type::kGeolocation) { |
| + views::Combobox* geolocation_combobox = |
| + new views::Combobox(new GeolocationAllowComboboxModel()); |
| + geolocation_combobox->set_listener(this); |
| + geolocation_combobox->SetStyle(views::Combobox::STYLE_ACTION); |
| + button_layout->AddView(geolocation_combobox); |
| + geolocation_combobox_ = geolocation_combobox; |
| + } else { |
| + views::LabelButton* allow_button = |
| + new views::LabelButton(this, allow_text); |
| + allow_button->SetStyle(views::Button::STYLE_BUTTON); |
| + button_layout->AddView(allow_button); |
| + allow_ = allow_button; |
| + } |
| } else { |
| views::Combobox* allow_combobox = new views::Combobox( |
| new CustomizeAllowComboboxModel()); |
| @@ -411,6 +462,19 @@ void PermissionsBubbleDelegateView::OnPerformAction( |
| else if (combobox->selected_index() == |
| CustomizeAllowComboboxModel::INDEX_ALLOW) |
| owner_->Accept(); |
| + } else if (combobox == geolocation_combobox_) { |
| + if (combobox->selected_index() == |
| + GeolocationAllowComboboxModel::INDEX_ALLOW) |
| + owner_->Accept(); |
| + else if (combobox->selected_index() == |
| + GeolocationAllowComboboxModel::INDEX_CITY) |
| + ; |
| + else if (combobox->selected_index() == |
| + GeolocationAllowComboboxModel::INDEX_STATE) |
| + ; |
| + else if (combobox->selected_index() == |
| + GeolocationAllowComboboxModel::INDEX_COUNTRY) |
| + ; |
| } |
| } |