| 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_layout_provider.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 ChromeLayoutProvider* provider = ChromeLayoutProvider::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 provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL))); |
| 204 LayoutDelegate::Metric:: | |
| 205 RELATED_CONTROL_VERTICAL_SPACING))); | |
| 206 | 204 |
| 207 display_origin_ = url_formatter::FormatUrlForSecurityDisplay( | 205 display_origin_ = url_formatter::FormatUrlForSecurityDisplay( |
| 208 requests[0]->GetOrigin(), | 206 requests[0]->GetOrigin(), |
| 209 url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC); | 207 url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC); |
| 210 | 208 |
| 211 bool show_persistence_toggle = true; | 209 bool show_persistence_toggle = true; |
| 212 for (size_t index = 0; index < requests.size(); index++) { | 210 for (size_t index = 0; index < requests.size(); index++) { |
| 213 DCHECK(index < accept_state.size()); | 211 DCHECK(index < accept_state.size()); |
| 214 // The row is laid out containing a leading-aligned label area and a | 212 // 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 | 213 // trailing column which will be filled if there are multiple permission |
| 216 // requests. | 214 // requests. |
| 217 views::View* row = new views::View(); | 215 views::View* row = new views::View(); |
| 218 views::GridLayout* row_layout = new views::GridLayout(row); | 216 views::GridLayout* row_layout = new views::GridLayout(row); |
| 219 row->SetLayoutManager(row_layout); | 217 row->SetLayoutManager(row_layout); |
| 220 views::ColumnSet* columns = row_layout->AddColumnSet(0); | 218 views::ColumnSet* columns = row_layout->AddColumnSet(0); |
| 221 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, | 219 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, |
| 222 0, views::GridLayout::USE_PREF, 0, 0); | 220 0, views::GridLayout::USE_PREF, 0, 0); |
| 223 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::FILL, | 221 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::FILL, |
| 224 100, views::GridLayout::USE_PREF, 0, 0); | 222 100, views::GridLayout::USE_PREF, 0, 0); |
| 225 row_layout->StartRow(0, 0); | 223 row_layout->StartRow(0, 0); |
| 226 | 224 |
| 227 views::View* label_container = new views::View(); | 225 views::View* label_container = new views::View(); |
| 228 int indent = layout_delegate->GetMetric( | 226 int indent = |
| 229 LayoutDelegate::Metric::SUBSECTION_HORIZONTAL_INDENT); | 227 provider->GetDistanceMetric(DISTANCE_SUBSECTION_HORIZONTAL_INDENT); |
| 230 label_container->SetLayoutManager(new views::BoxLayout( | 228 label_container->SetLayoutManager(new views::BoxLayout( |
| 231 views::BoxLayout::kHorizontal, indent, 0, | 229 views::BoxLayout::kHorizontal, indent, 0, |
| 232 layout_delegate->GetMetric( | 230 provider->GetDistanceMetric(DISTANCE_RELATED_LABEL_HORIZONTAL))); |
| 233 LayoutDelegate::Metric::RELATED_LABEL_HORIZONTAL_SPACING))); | |
| 234 views::ImageView* icon = new views::ImageView(); | 231 views::ImageView* icon = new views::ImageView(); |
| 235 const gfx::VectorIcon& vector_id = requests[index]->GetIconId(); | 232 const gfx::VectorIcon& vector_id = requests[index]->GetIconId(); |
| 236 icon->SetImage( | 233 icon->SetImage( |
| 237 gfx::CreateVectorIcon(vector_id, kIconSize, gfx::kChromeIconGrey)); | 234 gfx::CreateVectorIcon(vector_id, kIconSize, gfx::kChromeIconGrey)); |
| 238 icon->SetTooltipText(base::string16()); // Redundant with the text fragment | 235 icon->SetTooltipText(base::string16()); // Redundant with the text fragment |
| 239 label_container->AddChildView(icon); | 236 label_container->AddChildView(icon); |
| 240 views::Label* label = | 237 views::Label* label = |
| 241 new views::Label(requests.at(index)->GetMessageTextFragment()); | 238 new views::Label(requests.at(index)->GetMessageTextFragment()); |
| 242 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 239 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 243 label_container->AddChildView(label); | 240 label_container->AddChildView(label); |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 } | 492 } |
| 496 | 493 |
| 497 void PermissionPromptImpl::Deny() { | 494 void PermissionPromptImpl::Deny() { |
| 498 if (delegate_) | 495 if (delegate_) |
| 499 delegate_->Deny(); | 496 delegate_->Deny(); |
| 500 } | 497 } |
| 501 | 498 |
| 502 Profile* PermissionPromptImpl::GetProfile() { | 499 Profile* PermissionPromptImpl::GetProfile() { |
| 503 return browser_->profile(); | 500 return browser_->profile(); |
| 504 } | 501 } |
| OLD | NEW |