| 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/permission_prompt_impl.h" | 5 #include "chrome/browser/ui/views/website_settings/permission_prompt_impl.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/permissions/permission_request.h" |
| 13 #include "chrome/browser/platform_util.h" | 13 #include "chrome/browser/platform_util.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_finder.h" |
| 16 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
| 17 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h" | 18 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h" |
| 18 #include "chrome/browser/ui/views/website_settings/permission_selector_row.h" | 19 #include "chrome/browser/ui/views/website_settings/permission_selector_row.h" |
| 19 #include "chrome/browser/ui/views/website_settings/permission_selector_row_obser
ver.h" | 20 #include "chrome/browser/ui/views/website_settings/permission_selector_row_obser
ver.h" |
| 20 #include "chrome/grit/generated_resources.h" | 21 #include "chrome/grit/generated_resources.h" |
| 21 #include "components/strings/grit/components_strings.h" | 22 #include "components/strings/grit/components_strings.h" |
| 22 #include "components/url_formatter/elide_url.h" | 23 #include "components/url_formatter/elide_url.h" |
| 24 #include "content/public/browser/web_contents.h" |
| 23 #include "ui/accessibility/ax_view_state.h" | 25 #include "ui/accessibility/ax_view_state.h" |
| 24 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
| 25 #include "ui/base/models/combobox_model.h" | 27 #include "ui/base/models/combobox_model.h" |
| 26 #include "ui/base/resource/resource_bundle.h" | 28 #include "ui/base/resource/resource_bundle.h" |
| 27 #include "ui/gfx/color_palette.h" | 29 #include "ui/gfx/color_palette.h" |
| 28 #include "ui/gfx/paint_vector_icon.h" | 30 #include "ui/gfx/paint_vector_icon.h" |
| 29 #include "ui/gfx/text_constants.h" | 31 #include "ui/gfx/text_constants.h" |
| 30 #include "ui/gfx/vector_icons_public.h" | 32 #include "ui/gfx/vector_icons_public.h" |
| 31 #include "ui/views/bubble/bubble_dialog_delegate.h" | 33 #include "ui/views/bubble/bubble_dialog_delegate.h" |
| 32 #include "ui/views/bubble/bubble_frame_view.h" | 34 #include "ui/views/bubble/bubble_frame_view.h" |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 | 368 |
| 367 // Reposition the bubble based on the updated arrow and view. | 369 // Reposition the bubble based on the updated arrow and view. |
| 368 SetAnchorView(anchor_view); | 370 SetAnchorView(anchor_view); |
| 369 // The anchor rect is ignored unless |anchor_view| is nullptr. | 371 // The anchor rect is ignored unless |anchor_view| is nullptr. |
| 370 SetAnchorRect(gfx::Rect(anchor_point, gfx::Size())); | 372 SetAnchorRect(gfx::Rect(anchor_point, gfx::Size())); |
| 371 } | 373 } |
| 372 | 374 |
| 373 ////////////////////////////////////////////////////////////////////////////// | 375 ////////////////////////////////////////////////////////////////////////////// |
| 374 // PermissionPromptImpl | 376 // PermissionPromptImpl |
| 375 | 377 |
| 376 PermissionPromptImpl::PermissionPromptImpl(Browser* browser) | 378 PermissionPromptImpl::PermissionPromptImpl(content::WebContents* web_contents) |
| 377 : browser_(browser), | 379 : browser_(chrome::FindBrowserWithWebContents(web_contents)), |
| 378 delegate_(nullptr), | 380 delegate_(nullptr), |
| 379 bubble_delegate_(nullptr) { | 381 bubble_delegate_(nullptr) { |
| 380 DCHECK(browser); | 382 DCHECK(browser_); |
| 381 DCHECK(browser->window()); | 383 DCHECK(browser_->window()); |
| 382 } | 384 } |
| 383 | 385 |
| 384 PermissionPromptImpl::~PermissionPromptImpl() { | 386 PermissionPromptImpl::~PermissionPromptImpl() { |
| 385 } | 387 } |
| 386 | 388 |
| 387 void PermissionPromptImpl::SetDelegate(Delegate* delegate) { | 389 void PermissionPromptImpl::SetDelegate(Delegate* delegate) { |
| 388 delegate_ = delegate; | 390 delegate_ = delegate; |
| 389 } | 391 } |
| 390 | 392 |
| 391 void PermissionPromptImpl::Show(const std::vector<PermissionRequest*>& requests, | 393 void PermissionPromptImpl::Show(const std::vector<PermissionRequest*>& requests, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 | 455 |
| 454 void PermissionPromptImpl::Accept() { | 456 void PermissionPromptImpl::Accept() { |
| 455 if (delegate_) | 457 if (delegate_) |
| 456 delegate_->Accept(); | 458 delegate_->Accept(); |
| 457 } | 459 } |
| 458 | 460 |
| 459 void PermissionPromptImpl::Deny() { | 461 void PermissionPromptImpl::Deny() { |
| 460 if (delegate_) | 462 if (delegate_) |
| 461 delegate_->Deny(); | 463 delegate_->Deny(); |
| 462 } | 464 } |
| OLD | NEW |