| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 12 #include "chrome/browser/permissions/permission_request.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h" | 15 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h" |
| 15 #include "chrome/browser/ui/views/frame/browser_view.h" | 16 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 16 #include "chrome/browser/ui/views/frame/top_container_view.h" | 17 #include "chrome/browser/ui/views/frame/top_container_view.h" |
| 17 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 18 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 18 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" | 19 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" |
| 19 #include "chrome/browser/ui/views/website_settings/permission_selector_view.h" | 20 #include "chrome/browser/ui/views/website_settings/permission_selector_view.h" |
| 20 #include "chrome/browser/ui/views/website_settings/permission_selector_view_obse
rver.h" | 21 #include "chrome/browser/ui/views/website_settings/permission_selector_view_obse
rver.h" |
| 21 #include "chrome/browser/ui/website_settings/permission_bubble_request.h" | |
| 22 #include "chrome/grit/generated_resources.h" | 22 #include "chrome/grit/generated_resources.h" |
| 23 #include "components/url_formatter/elide_url.h" | 23 #include "components/url_formatter/elide_url.h" |
| 24 #include "grit/components_strings.h" | 24 #include "grit/components_strings.h" |
| 25 #include "ui/accessibility/ax_view_state.h" | 25 #include "ui/accessibility/ax_view_state.h" |
| 26 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
| 27 #include "ui/base/models/combobox_model.h" | 27 #include "ui/base/models/combobox_model.h" |
| 28 #include "ui/base/resource/resource_bundle.h" | 28 #include "ui/base/resource/resource_bundle.h" |
| 29 #include "ui/gfx/color_palette.h" | 29 #include "ui/gfx/color_palette.h" |
| 30 #include "ui/gfx/paint_vector_icon.h" | 30 #include "ui/gfx/paint_vector_icon.h" |
| 31 #include "ui/gfx/text_constants.h" | 31 #include "ui/gfx/text_constants.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 /////////////////////////////////////////////////////////////////////////////// | 144 /////////////////////////////////////////////////////////////////////////////// |
| 145 // View implementation for the permissions bubble. | 145 // View implementation for the permissions bubble. |
| 146 class PermissionsBubbleDialogDelegateView | 146 class PermissionsBubbleDialogDelegateView |
| 147 : public views::BubbleDialogDelegateView, | 147 : public views::BubbleDialogDelegateView, |
| 148 public PermissionCombobox::Listener { | 148 public PermissionCombobox::Listener { |
| 149 public: | 149 public: |
| 150 PermissionsBubbleDialogDelegateView( | 150 PermissionsBubbleDialogDelegateView( |
| 151 views::View* anchor_view, | 151 views::View* anchor_view, |
| 152 views::BubbleBorder::Arrow anchor_arrow, | 152 views::BubbleBorder::Arrow anchor_arrow, |
| 153 PermissionBubbleViewViews* owner, | 153 PermissionBubbleViewViews* owner, |
| 154 const std::vector<PermissionBubbleRequest*>& requests, | 154 const std::vector<PermissionRequest*>& requests, |
| 155 const std::vector<bool>& accept_state); | 155 const std::vector<bool>& accept_state); |
| 156 ~PermissionsBubbleDialogDelegateView() override; | 156 ~PermissionsBubbleDialogDelegateView() override; |
| 157 | 157 |
| 158 void CloseBubble(); | 158 void CloseBubble(); |
| 159 void SizeToContents(); | 159 void SizeToContents(); |
| 160 | 160 |
| 161 // BubbleDialogDelegateView: | 161 // BubbleDialogDelegateView: |
| 162 bool ShouldShowCloseButton() const override; | 162 bool ShouldShowCloseButton() const override; |
| 163 const gfx::FontList& GetTitleFontList() const override; | 163 const gfx::FontList& GetTitleFontList() const override; |
| 164 base::string16 GetWindowTitle() const override; | 164 base::string16 GetWindowTitle() const override; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 186 std::unique_ptr<PermissionMenuModel> menu_button_model_; | 186 std::unique_ptr<PermissionMenuModel> menu_button_model_; |
| 187 std::vector<PermissionCombobox*> customize_comboboxes_; | 187 std::vector<PermissionCombobox*> customize_comboboxes_; |
| 188 | 188 |
| 189 DISALLOW_COPY_AND_ASSIGN(PermissionsBubbleDialogDelegateView); | 189 DISALLOW_COPY_AND_ASSIGN(PermissionsBubbleDialogDelegateView); |
| 190 }; | 190 }; |
| 191 | 191 |
| 192 PermissionsBubbleDialogDelegateView::PermissionsBubbleDialogDelegateView( | 192 PermissionsBubbleDialogDelegateView::PermissionsBubbleDialogDelegateView( |
| 193 views::View* anchor_view, | 193 views::View* anchor_view, |
| 194 views::BubbleBorder::Arrow anchor_arrow, | 194 views::BubbleBorder::Arrow anchor_arrow, |
| 195 PermissionBubbleViewViews* owner, | 195 PermissionBubbleViewViews* owner, |
| 196 const std::vector<PermissionBubbleRequest*>& requests, | 196 const std::vector<PermissionRequest*>& requests, |
| 197 const std::vector<bool>& accept_state) | 197 const std::vector<bool>& accept_state) |
| 198 : views::BubbleDialogDelegateView(anchor_view, anchor_arrow), | 198 : views::BubbleDialogDelegateView(anchor_view, anchor_arrow), |
| 199 owner_(owner), | 199 owner_(owner), |
| 200 multiple_requests_(requests.size() > 1) { | 200 multiple_requests_(requests.size() > 1) { |
| 201 DCHECK(!requests.empty()); | 201 DCHECK(!requests.empty()); |
| 202 | 202 |
| 203 set_close_on_deactivate(false); | 203 set_close_on_deactivate(false); |
| 204 | 204 |
| 205 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, | 205 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, |
| 206 kItemMajorSpacing)); | 206 kItemMajorSpacing)); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 if (browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)) | 407 if (browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)) |
| 408 return views::BubbleBorder::TOP_LEFT; | 408 return views::BubbleBorder::TOP_LEFT; |
| 409 return views::BubbleBorder::NONE; | 409 return views::BubbleBorder::NONE; |
| 410 } | 410 } |
| 411 | 411 |
| 412 void PermissionBubbleViewViews::SetDelegate(Delegate* delegate) { | 412 void PermissionBubbleViewViews::SetDelegate(Delegate* delegate) { |
| 413 delegate_ = delegate; | 413 delegate_ = delegate; |
| 414 } | 414 } |
| 415 | 415 |
| 416 void PermissionBubbleViewViews::Show( | 416 void PermissionBubbleViewViews::Show( |
| 417 const std::vector<PermissionBubbleRequest*>& requests, | 417 const std::vector<PermissionRequest*>& requests, |
| 418 const std::vector<bool>& values) { | 418 const std::vector<bool>& values) { |
| 419 if (bubble_delegate_) | 419 if (bubble_delegate_) |
| 420 bubble_delegate_->CloseBubble(); | 420 bubble_delegate_->CloseBubble(); |
| 421 | 421 |
| 422 bubble_delegate_ = new PermissionsBubbleDialogDelegateView( | 422 bubble_delegate_ = new PermissionsBubbleDialogDelegateView( |
| 423 GetAnchorView(), GetAnchorArrow(), this, requests, values); | 423 GetAnchorView(), GetAnchorArrow(), this, requests, values); |
| 424 | 424 |
| 425 // Set |parent_window| because some valid anchors can become hidden. | 425 // Set |parent_window| because some valid anchors can become hidden. |
| 426 views::Widget* widget = views::Widget::GetWidgetForNativeWindow( | 426 views::Widget* widget = views::Widget::GetWidgetForNativeWindow( |
| 427 browser_->window()->GetNativeWindow()); | 427 browser_->window()->GetNativeWindow()); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 | 471 |
| 472 void PermissionBubbleViewViews::Accept() { | 472 void PermissionBubbleViewViews::Accept() { |
| 473 if (delegate_) | 473 if (delegate_) |
| 474 delegate_->Accept(); | 474 delegate_->Accept(); |
| 475 } | 475 } |
| 476 | 476 |
| 477 void PermissionBubbleViewViews::Deny() { | 477 void PermissionBubbleViewViews::Deny() { |
| 478 if (delegate_) | 478 if (delegate_) |
| 479 delegate_->Deny(); | 479 delegate_->Deny(); |
| 480 } | 480 } |
| OLD | NEW |