| 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 | 272 |
| 272 // Set |parent_window| because some valid anchors can become hidden. | 273 // Set |parent_window| because some valid anchors can become hidden. |
| 273 bubble_delegate_->set_parent_window( | 274 bubble_delegate_->set_parent_window( |
| 274 platform_util::GetViewForWindow(browser_->window()->GetNativeWindow())); | 275 platform_util::GetViewForWindow(browser_->window()->GetNativeWindow())); |
| 275 | 276 |
| 276 // Compensate for vertical padding in the anchor view's image. Note this is | 277 // Compensate for vertical padding in the anchor view's image. Note this is |
| 277 // ignored whenever the anchor view is null. | 278 // ignored whenever the anchor view is null. |
| 278 bubble_delegate_->set_anchor_view_insets(gfx::Insets( | 279 bubble_delegate_->set_anchor_view_insets(gfx::Insets( |
| 279 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); | 280 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); |
| 280 | 281 |
| 281 views::BubbleDialogDelegateView::CreateBubble(bubble_delegate_)->Show(); | 282 views::Widget* widget = |
| 283 views::BubbleDialogDelegateView::CreateBubble(bubble_delegate_); |
| 284 // If a browser window (or popup) other than the bubble parent has focus, |
| 285 // don't take focus. |
| 286 if (browser_->window()->IsActive()) |
| 287 widget->Show(); |
| 288 else |
| 289 widget->ShowInactive(); |
| 290 |
| 282 bubble_delegate_->SizeToContents(); | 291 bubble_delegate_->SizeToContents(); |
| 283 | 292 |
| 284 bubble_delegate_->UpdateAnchor(GetAnchorView(), | 293 bubble_delegate_->UpdateAnchor(GetAnchorView(), |
| 285 GetAnchorPoint(), | 294 GetAnchorPoint(), |
| 286 GetAnchorArrow()); | 295 GetAnchorArrow()); |
| 287 } | 296 } |
| 288 | 297 |
| 289 bool PermissionPromptImpl::CanAcceptRequestUpdate() { | 298 bool PermissionPromptImpl::CanAcceptRequestUpdate() { |
| 290 return !(bubble_delegate_ && bubble_delegate_->IsMouseHovered()); | 299 return !(bubble_delegate_ && bubble_delegate_->IsMouseHovered()); |
| 291 } | 300 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 | 343 |
| 335 void PermissionPromptImpl::Accept() { | 344 void PermissionPromptImpl::Accept() { |
| 336 if (delegate_) | 345 if (delegate_) |
| 337 delegate_->Accept(); | 346 delegate_->Accept(); |
| 338 } | 347 } |
| 339 | 348 |
| 340 void PermissionPromptImpl::Deny() { | 349 void PermissionPromptImpl::Deny() { |
| 341 if (delegate_) | 350 if (delegate_) |
| 342 delegate_->Deny(); | 351 delegate_->Deny(); |
| 343 } | 352 } |
| OLD | NEW |