Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: chrome/browser/ui/views/website_settings/permission_prompt_impl.cc

Issue 2654123004: harmony: partly harmonize permissions bubble (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_window.h" 16 #include "chrome/browser/ui/browser_window.h"
17 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h" 17 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h"
18 #include "chrome/browser/ui/views/harmony/layout_delegate.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"
23 #include "ui/accessibility/ax_node_data.h" 24 #include "ui/accessibility/ax_node_data.h"
24 #include "ui/base/l10n/l10n_util.h" 25 #include "ui/base/l10n/l10n_util.h"
25 #include "ui/base/models/combobox_model.h" 26 #include "ui/base/models/combobox_model.h"
26 #include "ui/base/resource/resource_bundle.h" 27 #include "ui/base/resource/resource_bundle.h"
27 #include "ui/gfx/color_palette.h" 28 #include "ui/gfx/color_palette.h"
28 #include "ui/gfx/paint_vector_icon.h" 29 #include "ui/gfx/paint_vector_icon.h"
29 #include "ui/gfx/text_constants.h" 30 #include "ui/gfx/text_constants.h"
30 #include "ui/gfx/vector_icons_public.h" 31 #include "ui/gfx/vector_icons_public.h"
32 #include "ui/views/background.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"
33 #include "ui/views/controls/button/checkbox.h" 35 #include "ui/views/controls/button/checkbox.h"
34 #include "ui/views/controls/button/menu_button.h" 36 #include "ui/views/controls/button/menu_button.h"
35 #include "ui/views/controls/button/menu_button_listener.h" 37 #include "ui/views/controls/button/menu_button_listener.h"
36 #include "ui/views/controls/combobox/combobox.h" 38 #include "ui/views/controls/combobox/combobox.h"
37 #include "ui/views/controls/combobox/combobox_listener.h" 39 #include "ui/views/controls/combobox/combobox_listener.h"
38 #include "ui/views/controls/label.h" 40 #include "ui/views/controls/label.h"
39 #include "ui/views/controls/menu/menu_runner.h" 41 #include "ui/views/controls/menu/menu_runner.h"
40 #include "ui/views/layout/box_layout.h" 42 #include "ui/views/layout/box_layout.h"
41 #include "ui/views/layout/grid_layout.h" 43 #include "ui/views/layout/grid_layout.h"
42 #include "ui/views/layout/layout_constants.h" 44 #include "ui/views/layout/layout_constants.h"
43 45
44 namespace { 46 namespace {
45 47
46 // Spacing between major items should be 9px.
47 const int kItemMajorSpacing = 9;
48
49 // (Square) pixel size of icon. 48 // (Square) pixel size of icon.
50 const int kIconSize = 18; 49 const int kIconSize = 18;
51 50
52 } // namespace 51 } // namespace
53 52
54 // This class is a MenuButton which is given a PermissionMenuModel. It 53 // This class is a MenuButton which is given a PermissionMenuModel. It
55 // shows the current checked item in the menu model, and notifies its listener 54 // shows the current checked item in the menu model, and notifies its listener
56 // about any updates to the state of the selection. 55 // about any updates to the state of the selection.
57 // TODO(gbillock): refactor PermissionMenuButton to work like this and re-use? 56 // TODO(gbillock): refactor PermissionMenuButton to work like this and re-use?
58 class PermissionCombobox : public views::MenuButton, 57 class PermissionCombobox : public views::MenuButton,
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 PermissionPromptImpl* owner, 190 PermissionPromptImpl* owner,
192 const std::vector<PermissionRequest*>& requests, 191 const std::vector<PermissionRequest*>& requests,
193 const std::vector<bool>& accept_state) 192 const std::vector<bool>& accept_state)
194 : owner_(owner), 193 : owner_(owner),
195 multiple_requests_(requests.size() > 1), 194 multiple_requests_(requests.size() > 1),
196 persist_checkbox_(nullptr) { 195 persist_checkbox_(nullptr) {
197 DCHECK(!requests.empty()); 196 DCHECK(!requests.empty());
198 197
199 set_close_on_deactivate(false); 198 set_close_on_deactivate(false);
200 199
201 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 200 LayoutDelegate* layout_delegate = LayoutDelegate::Get();
202 kItemMajorSpacing)); 201 SetLayoutManager(
202 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0,
203 layout_delegate->GetLayoutDistance(
204 LayoutDelegate::LayoutDistanceType::
205 RELATED_CONTROL_VERTICAL_SPACING)));
203 206
204 display_origin_ = url_formatter::FormatUrlForSecurityDisplay( 207 display_origin_ = url_formatter::FormatUrlForSecurityDisplay(
205 requests[0]->GetOrigin(), 208 requests[0]->GetOrigin(),
206 url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC); 209 url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC);
207 210
208 bool show_persistence_toggle = true; 211 bool show_persistence_toggle = true;
209 for (size_t index = 0; index < requests.size(); index++) { 212 for (size_t index = 0; index < requests.size(); index++) {
210 DCHECK(index < accept_state.size()); 213 DCHECK(index < accept_state.size());
211 // The row is laid out containing a leading-aligned label area and a 214 // The row is laid out containing a leading-aligned label area and a
212 // trailing column which will be filled if there are multiple permission 215 // trailing column which will be filled if there are multiple permission
213 // requests. 216 // requests.
214 views::View* row = new views::View(); 217 views::View* row = new views::View();
215 views::GridLayout* row_layout = new views::GridLayout(row); 218 views::GridLayout* row_layout = new views::GridLayout(row);
216 row->SetLayoutManager(row_layout); 219 row->SetLayoutManager(row_layout);
217 views::ColumnSet* columns = row_layout->AddColumnSet(0); 220 views::ColumnSet* columns = row_layout->AddColumnSet(0);
218 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 221 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL,
219 0, views::GridLayout::USE_PREF, 0, 0); 222 0, views::GridLayout::USE_PREF, 0, 0);
220 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::FILL, 223 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::FILL,
221 100, views::GridLayout::USE_PREF, 0, 0); 224 100, views::GridLayout::USE_PREF, 0, 0);
222 row_layout->StartRow(0, 0); 225 row_layout->StartRow(0, 0);
223 226
224 views::View* label_container = new views::View(); 227 views::View* label_container = new views::View();
228 int indent = layout_delegate->UseExtraDialogPadding()
229 ? layout_delegate->GetLayoutDistance(
230 LayoutDelegate::LayoutDistanceType::
231 RELATED_CONTROL_HORIZONTAL_SPACING)
Peter Kasting 2017/01/26 21:54:29 This changes the indent for non-Harmony from 10 px
Elly Fong-Jones 2017/01/30 19:47:34 CHECKBOX_INDENT already was 0 in Harmony and kChec
232 : 0;
225 label_container->SetLayoutManager(new views::BoxLayout( 233 label_container->SetLayoutManager(new views::BoxLayout(
226 views::BoxLayout::kHorizontal, views::kCheckboxIndent, 0, 234 views::BoxLayout::kHorizontal, indent, 0,
227 views::kItemLabelSpacing)); 235 layout_delegate->GetLayoutDistance(
236 LayoutDelegate::LayoutDistanceType::ITEM_LABEL_SPACING)));
228 views::ImageView* icon = new views::ImageView(); 237 views::ImageView* icon = new views::ImageView();
229 gfx::VectorIconId vector_id = requests[index]->GetIconId(); 238 gfx::VectorIconId vector_id = requests[index]->GetIconId();
230 if (vector_id != gfx::VectorIconId::VECTOR_ICON_NONE) { 239 if (vector_id != gfx::VectorIconId::VECTOR_ICON_NONE) {
231 icon->SetImage( 240 icon->SetImage(
232 gfx::CreateVectorIcon(vector_id, kIconSize, gfx::kChromeIconGrey)); 241 gfx::CreateVectorIcon(vector_id, kIconSize, gfx::kChromeIconGrey));
233 } 242 }
234 icon->SetTooltipText(base::string16()); // Redundant with the text fragment 243 icon->SetTooltipText(base::string16()); // Redundant with the text fragment
235 label_container->AddChildView(icon); 244 label_container->AddChildView(icon);
236 views::Label* label = 245 views::Label* label =
237 new views::Label(requests.at(index)->GetMessageTextFragment()); 246 new views::Label(requests.at(index)->GetMessageTextFragment());
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 } 491 }
483 492
484 void PermissionPromptImpl::Deny() { 493 void PermissionPromptImpl::Deny() {
485 if (delegate_) 494 if (delegate_)
486 delegate_->Deny(); 495 delegate_->Deny();
487 } 496 }
488 497
489 Profile* PermissionPromptImpl::GetProfile() { 498 Profile* PermissionPromptImpl::GetProfile() {
490 return browser_->profile(); 499 return browser_->profile();
491 } 500 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698