| 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/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_window.h" | 16 #include "chrome/browser/ui/browser_window.h" |
| 17 #include "chrome/browser/ui/layout_constants.h" | 17 #include "chrome/browser/ui/layout_constants.h" |
| 18 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h" | 18 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h" |
| 19 #include "chrome/browser/ui/views/harmony/layout_delegate.h" | 19 #include "chrome/browser/ui/views/harmony/chrome_views_layout_delegate.h" |
| 20 #include "chrome/browser/ui/views/page_info/permission_selector_row.h" | 20 #include "chrome/browser/ui/views/page_info/permission_selector_row.h" |
| 21 #include "chrome/browser/ui/views/page_info/permission_selector_row_observer.h" | 21 #include "chrome/browser/ui/views/page_info/permission_selector_row_observer.h" |
| 22 #include "chrome/grit/generated_resources.h" | 22 #include "chrome/grit/generated_resources.h" |
| 23 #include "components/strings/grit/components_strings.h" | 23 #include "components/strings/grit/components_strings.h" |
| 24 #include "components/url_formatter/elide_url.h" | 24 #include "components/url_formatter/elide_url.h" |
| 25 #include "ui/accessibility/ax_node_data.h" | 25 #include "ui/accessibility/ax_node_data.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" |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 PermissionPromptImpl* owner, | 190 PermissionPromptImpl* owner, |
| 191 const std::vector<PermissionRequest*>& 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 persist_checkbox_(nullptr) { | 195 persist_checkbox_(nullptr) { |
| 196 DCHECK(!requests.empty()); | 196 DCHECK(!requests.empty()); |
| 197 | 197 |
| 198 set_close_on_deactivate(false); | 198 set_close_on_deactivate(false); |
| 199 | 199 |
| 200 LayoutDelegate* layout_delegate = LayoutDelegate::Get(); | 200 ChromeViewsLayoutDelegate* layout_delegate = ChromeViewsLayoutDelegate::Get(); |
| 201 SetLayoutManager( | 201 SetLayoutManager(new views::BoxLayout( |
| 202 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, | 202 views::BoxLayout::kVertical, 0, 0, |
| 203 layout_delegate->GetMetric( | 203 layout_delegate->GetDistanceMetric( |
| 204 LayoutDelegate::Metric:: | 204 ChromeDistanceMetric::RELATED_CONTROL_VERTICAL))); |
| 205 RELATED_CONTROL_VERTICAL_SPACING))); | |
| 206 | 205 |
| 207 display_origin_ = url_formatter::FormatUrlForSecurityDisplay( | 206 display_origin_ = url_formatter::FormatUrlForSecurityDisplay( |
| 208 requests[0]->GetOrigin(), | 207 requests[0]->GetOrigin(), |
| 209 url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC); | 208 url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC); |
| 210 | 209 |
| 211 bool show_persistence_toggle = true; | 210 bool show_persistence_toggle = true; |
| 212 for (size_t index = 0; index < requests.size(); index++) { | 211 for (size_t index = 0; index < requests.size(); index++) { |
| 213 DCHECK(index < accept_state.size()); | 212 DCHECK(index < accept_state.size()); |
| 214 // The row is laid out containing a leading-aligned label area and a | 213 // The row is laid out containing a leading-aligned label area and a |
| 215 // trailing column which will be filled if there are multiple permission | 214 // trailing column which will be filled if there are multiple permission |
| 216 // requests. | 215 // requests. |
| 217 views::View* row = new views::View(); | 216 views::View* row = new views::View(); |
| 218 views::GridLayout* row_layout = new views::GridLayout(row); | 217 views::GridLayout* row_layout = new views::GridLayout(row); |
| 219 row->SetLayoutManager(row_layout); | 218 row->SetLayoutManager(row_layout); |
| 220 views::ColumnSet* columns = row_layout->AddColumnSet(0); | 219 views::ColumnSet* columns = row_layout->AddColumnSet(0); |
| 221 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, | 220 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, |
| 222 0, views::GridLayout::USE_PREF, 0, 0); | 221 0, views::GridLayout::USE_PREF, 0, 0); |
| 223 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::FILL, | 222 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::FILL, |
| 224 100, views::GridLayout::USE_PREF, 0, 0); | 223 100, views::GridLayout::USE_PREF, 0, 0); |
| 225 row_layout->StartRow(0, 0); | 224 row_layout->StartRow(0, 0); |
| 226 | 225 |
| 227 views::View* label_container = new views::View(); | 226 views::View* label_container = new views::View(); |
| 228 int indent = layout_delegate->GetMetric( | 227 int indent = layout_delegate->GetDistanceMetric( |
| 229 LayoutDelegate::Metric::SUBSECTION_HORIZONTAL_INDENT); | 228 ChromeDistanceMetric::SUBSECTION_HORIZONTAL_INDENT); |
| 230 label_container->SetLayoutManager(new views::BoxLayout( | 229 label_container->SetLayoutManager(new views::BoxLayout( |
| 231 views::BoxLayout::kHorizontal, indent, 0, | 230 views::BoxLayout::kHorizontal, indent, 0, |
| 232 layout_delegate->GetMetric( | 231 layout_delegate->GetDistanceMetric( |
| 233 LayoutDelegate::Metric::RELATED_LABEL_HORIZONTAL_SPACING))); | 232 ChromeDistanceMetric::RELATED_LABEL_HORIZONTAL))); |
| 234 views::ImageView* icon = new views::ImageView(); | 233 views::ImageView* icon = new views::ImageView(); |
| 235 const gfx::VectorIcon& vector_id = requests[index]->GetIconId(); | 234 const gfx::VectorIcon& vector_id = requests[index]->GetIconId(); |
| 236 icon->SetImage( | 235 icon->SetImage( |
| 237 gfx::CreateVectorIcon(vector_id, kIconSize, gfx::kChromeIconGrey)); | 236 gfx::CreateVectorIcon(vector_id, kIconSize, gfx::kChromeIconGrey)); |
| 238 icon->SetTooltipText(base::string16()); // Redundant with the text fragment | 237 icon->SetTooltipText(base::string16()); // Redundant with the text fragment |
| 239 label_container->AddChildView(icon); | 238 label_container->AddChildView(icon); |
| 240 views::Label* label = | 239 views::Label* label = |
| 241 new views::Label(requests.at(index)->GetMessageTextFragment()); | 240 new views::Label(requests.at(index)->GetMessageTextFragment()); |
| 242 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 241 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 243 label_container->AddChildView(label); | 242 label_container->AddChildView(label); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 } | 490 } |
| 492 | 491 |
| 493 void PermissionPromptImpl::Deny() { | 492 void PermissionPromptImpl::Deny() { |
| 494 if (delegate_) | 493 if (delegate_) |
| 495 delegate_->Deny(); | 494 delegate_->Deny(); |
| 496 } | 495 } |
| 497 | 496 |
| 498 Profile* PermissionPromptImpl::GetProfile() { | 497 Profile* PermissionPromptImpl::GetProfile() { |
| 499 return browser_->profile(); | 498 return browser_->profile(); |
| 500 } | 499 } |
| OLD | NEW |