Chromium Code Reviews| 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/permission_bubble/permission_prompt_impl.h" | 5 #include "chrome/browser/ui/views/permission_bubble/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/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/browser_dialogs.h" | 15 #include "chrome/browser/ui/browser_dialogs.h" |
| 16 #include "chrome/browser/ui/browser_list.h" | |
| 16 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
| 17 #include "chrome/browser/ui/layout_constants.h" | 18 #include "chrome/browser/ui/layout_constants.h" |
| 18 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h" | 19 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h" |
| 19 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" | 20 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" |
| 20 #include "chrome/browser/ui/views/page_info/permission_selector_row.h" | 21 #include "chrome/browser/ui/views/page_info/permission_selector_row.h" |
| 21 #include "chrome/browser/ui/views/page_info/permission_selector_row_observer.h" | 22 #include "chrome/browser/ui/views/page_info/permission_selector_row_observer.h" |
| 22 #include "chrome/grit/generated_resources.h" | 23 #include "chrome/grit/generated_resources.h" |
| 23 #include "components/strings/grit/components_strings.h" | 24 #include "components/strings/grit/components_strings.h" |
| 24 #include "components/url_formatter/elide_url.h" | 25 #include "components/url_formatter/elide_url.h" |
| 25 #include "ui/accessibility/ax_node_data.h" | 26 #include "ui/accessibility/ax_node_data.h" |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 | 271 |
| 271 // Set |parent_window| because some valid anchors can become hidden. | 272 // Set |parent_window| because some valid anchors can become hidden. |
| 272 bubble_delegate_->set_parent_window( | 273 bubble_delegate_->set_parent_window( |
| 273 platform_util::GetViewForWindow(browser_->window()->GetNativeWindow())); | 274 platform_util::GetViewForWindow(browser_->window()->GetNativeWindow())); |
| 274 | 275 |
| 275 // Compensate for vertical padding in the anchor view's image. Note this is | 276 // Compensate for vertical padding in the anchor view's image. Note this is |
| 276 // ignored whenever the anchor view is null. | 277 // ignored whenever the anchor view is null. |
| 277 bubble_delegate_->set_anchor_view_insets(gfx::Insets( | 278 bubble_delegate_->set_anchor_view_insets(gfx::Insets( |
| 278 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); | 279 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); |
| 279 | 280 |
| 280 views::BubbleDialogDelegateView::CreateBubble(bubble_delegate_)->Show(); | 281 views::Widget* widget = |
| 282 views::BubbleDialogDelegateView::CreateBubble(bubble_delegate_); | |
| 283 if (browser_ == BrowserList::GetInstance()->GetLastActive()) { | |
|
raymes
2017/06/19 04:43:00
nit: no {} needed
tapted
2017/06/20 11:11:32
This should have a comment - it's pretty subtle wh
Timothy Loh
2017/06/21 07:17:41
I copied the BrowserList check from app_modal_dia
| |
| 284 widget->Show(); | |
| 285 } else { | |
| 286 widget->ShowInactive(); | |
| 287 } | |
| 281 bubble_delegate_->SizeToContents(); | 288 bubble_delegate_->SizeToContents(); |
| 282 | 289 |
| 283 bubble_delegate_->UpdateAnchor(GetAnchorView(), | 290 bubble_delegate_->UpdateAnchor(GetAnchorView(), |
| 284 GetAnchorPoint(), | 291 GetAnchorPoint(), |
| 285 GetAnchorArrow()); | 292 GetAnchorArrow()); |
| 286 } | 293 } |
| 287 | 294 |
| 288 bool PermissionPromptImpl::CanAcceptRequestUpdate() { | 295 bool PermissionPromptImpl::CanAcceptRequestUpdate() { |
| 289 return !(bubble_delegate_ && bubble_delegate_->IsMouseHovered()); | 296 return !(bubble_delegate_ && bubble_delegate_->IsMouseHovered()); |
| 290 } | 297 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 | 345 |
| 339 void PermissionPromptImpl::Accept() { | 346 void PermissionPromptImpl::Accept() { |
| 340 if (delegate_) | 347 if (delegate_) |
| 341 delegate_->Accept(); | 348 delegate_->Accept(); |
| 342 } | 349 } |
| 343 | 350 |
| 344 void PermissionPromptImpl::Deny() { | 351 void PermissionPromptImpl::Deny() { |
| 345 if (delegate_) | 352 if (delegate_) |
| 346 delegate_->Deny(); | 353 delegate_->Deny(); |
| 347 } | 354 } |
| OLD | NEW |