| 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/platform_util.h" | 13 #include "chrome/browser/platform_util.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/browser_window.h" | 16 #include "chrome/browser/ui/browser_window.h" |
| 16 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h" | 17 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h" |
| 17 #include "chrome/browser/ui/views/website_settings/permission_selector_view.h" | 18 #include "chrome/browser/ui/views/website_settings/permission_selector_view.h" |
| 18 #include "chrome/browser/ui/views/website_settings/permission_selector_view_obse
rver.h" | 19 #include "chrome/browser/ui/views/website_settings/permission_selector_view_obse
rver.h" |
| 19 #include "chrome/browser/ui/website_settings/permission_bubble_request.h" | |
| 20 #include "chrome/grit/generated_resources.h" | 20 #include "chrome/grit/generated_resources.h" |
| 21 #include "components/url_formatter/elide_url.h" | 21 #include "components/url_formatter/elide_url.h" |
| 22 #include "grit/components_strings.h" | 22 #include "grit/components_strings.h" |
| 23 #include "ui/accessibility/ax_view_state.h" | 23 #include "ui/accessibility/ax_view_state.h" |
| 24 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
| 25 #include "ui/base/models/combobox_model.h" | 25 #include "ui/base/models/combobox_model.h" |
| 26 #include "ui/base/resource/resource_bundle.h" | 26 #include "ui/base/resource/resource_bundle.h" |
| 27 #include "ui/gfx/color_palette.h" | 27 #include "ui/gfx/color_palette.h" |
| 28 #include "ui/gfx/paint_vector_icon.h" | 28 #include "ui/gfx/paint_vector_icon.h" |
| 29 #include "ui/gfx/text_constants.h" | 29 #include "ui/gfx/text_constants.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 } | 140 } |
| 141 | 141 |
| 142 /////////////////////////////////////////////////////////////////////////////// | 142 /////////////////////////////////////////////////////////////////////////////// |
| 143 // View implementation for the permissions bubble. | 143 // View implementation for the permissions bubble. |
| 144 class PermissionsBubbleDialogDelegateView | 144 class PermissionsBubbleDialogDelegateView |
| 145 : public views::BubbleDialogDelegateView, | 145 : public views::BubbleDialogDelegateView, |
| 146 public PermissionCombobox::Listener { | 146 public PermissionCombobox::Listener { |
| 147 public: | 147 public: |
| 148 PermissionsBubbleDialogDelegateView( | 148 PermissionsBubbleDialogDelegateView( |
| 149 PermissionBubbleViewViews* owner, | 149 PermissionBubbleViewViews* owner, |
| 150 const std::vector<PermissionBubbleRequest*>& requests, | 150 const std::vector<PermissionRequest*>& requests, |
| 151 const std::vector<bool>& accept_state); | 151 const std::vector<bool>& accept_state); |
| 152 ~PermissionsBubbleDialogDelegateView() override; | 152 ~PermissionsBubbleDialogDelegateView() override; |
| 153 | 153 |
| 154 void CloseBubble(); | 154 void CloseBubble(); |
| 155 void SizeToContents(); | 155 void SizeToContents(); |
| 156 | 156 |
| 157 // BubbleDialogDelegateView: | 157 // BubbleDialogDelegateView: |
| 158 bool ShouldShowCloseButton() const override; | 158 bool ShouldShowCloseButton() const override; |
| 159 const gfx::FontList& GetTitleFontList() const override; | 159 const gfx::FontList& GetTitleFontList() const override; |
| 160 base::string16 GetWindowTitle() const override; | 160 base::string16 GetWindowTitle() const override; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 181 bool multiple_requests_; | 181 bool multiple_requests_; |
| 182 base::string16 display_origin_; | 182 base::string16 display_origin_; |
| 183 std::unique_ptr<PermissionMenuModel> menu_button_model_; | 183 std::unique_ptr<PermissionMenuModel> menu_button_model_; |
| 184 std::vector<PermissionCombobox*> customize_comboboxes_; | 184 std::vector<PermissionCombobox*> customize_comboboxes_; |
| 185 | 185 |
| 186 DISALLOW_COPY_AND_ASSIGN(PermissionsBubbleDialogDelegateView); | 186 DISALLOW_COPY_AND_ASSIGN(PermissionsBubbleDialogDelegateView); |
| 187 }; | 187 }; |
| 188 | 188 |
| 189 PermissionsBubbleDialogDelegateView::PermissionsBubbleDialogDelegateView( | 189 PermissionsBubbleDialogDelegateView::PermissionsBubbleDialogDelegateView( |
| 190 PermissionBubbleViewViews* owner, | 190 PermissionBubbleViewViews* owner, |
| 191 const std::vector<PermissionBubbleRequest*>& requests, | 191 const std::vector<PermissionRequest*>& requests, |
| 192 const std::vector<bool>& accept_state) | 192 const std::vector<bool>& accept_state) |
| 193 : owner_(owner), | 193 : owner_(owner), |
| 194 multiple_requests_(requests.size() > 1) { | 194 multiple_requests_(requests.size() > 1) { |
| 195 DCHECK(!requests.empty()); | 195 DCHECK(!requests.empty()); |
| 196 | 196 |
| 197 set_close_on_deactivate(false); | 197 set_close_on_deactivate(false); |
| 198 | 198 |
| 199 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, | 199 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, |
| 200 kItemMajorSpacing)); | 200 kItemMajorSpacing)); |
| 201 | 201 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 } | 378 } |
| 379 | 379 |
| 380 PermissionBubbleViewViews::~PermissionBubbleViewViews() { | 380 PermissionBubbleViewViews::~PermissionBubbleViewViews() { |
| 381 } | 381 } |
| 382 | 382 |
| 383 void PermissionBubbleViewViews::SetDelegate(Delegate* delegate) { | 383 void PermissionBubbleViewViews::SetDelegate(Delegate* delegate) { |
| 384 delegate_ = delegate; | 384 delegate_ = delegate; |
| 385 } | 385 } |
| 386 | 386 |
| 387 void PermissionBubbleViewViews::Show( | 387 void PermissionBubbleViewViews::Show( |
| 388 const std::vector<PermissionBubbleRequest*>& requests, | 388 const std::vector<PermissionRequest*>& requests, |
| 389 const std::vector<bool>& values) { | 389 const std::vector<bool>& values) { |
| 390 if (bubble_delegate_) | 390 if (bubble_delegate_) |
| 391 bubble_delegate_->CloseBubble(); | 391 bubble_delegate_->CloseBubble(); |
| 392 | 392 |
| 393 bubble_delegate_ = new PermissionsBubbleDialogDelegateView( | 393 bubble_delegate_ = new PermissionsBubbleDialogDelegateView( |
| 394 this, requests, values); | 394 this, requests, values); |
| 395 | 395 |
| 396 // Set |parent_window| because some valid anchors can become hidden. | 396 // Set |parent_window| because some valid anchors can become hidden. |
| 397 bubble_delegate_->set_parent_window( | 397 bubble_delegate_->set_parent_window( |
| 398 platform_util::GetViewForWindow(browser_->window()->GetNativeWindow())); | 398 platform_util::GetViewForWindow(browser_->window()->GetNativeWindow())); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 | 450 |
| 451 void PermissionBubbleViewViews::Accept() { | 451 void PermissionBubbleViewViews::Accept() { |
| 452 if (delegate_) | 452 if (delegate_) |
| 453 delegate_->Accept(); | 453 delegate_->Accept(); |
| 454 } | 454 } |
| 455 | 455 |
| 456 void PermissionBubbleViewViews::Deny() { | 456 void PermissionBubbleViewViews::Deny() { |
| 457 if (delegate_) | 457 if (delegate_) |
| 458 delegate_->Deny(); | 458 delegate_->Deny(); |
| 459 } | 459 } |
| OLD | NEW |