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/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
|
msw
2017/06/05 20:22:20
nit: remove this
raymes
2017/06/05 22:46:28
Done.
| |
| 15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_dialogs.h" | 16 #include "chrome/browser/ui/browser_dialogs.h" |
| 17 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
| 18 #include "chrome/browser/ui/layout_constants.h" | 18 #include "chrome/browser/ui/layout_constants.h" |
| 19 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h" | 19 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h" |
| 20 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" | 20 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" |
| 21 #include "chrome/browser/ui/views/page_info/permission_selector_row.h" | 21 #include "chrome/browser/ui/views/page_info/permission_selector_row.h" |
| 22 #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" |
| 23 #include "chrome/grit/generated_resources.h" | 23 #include "chrome/grit/generated_resources.h" |
| 24 #include "components/strings/grit/components_strings.h" | 24 #include "components/strings/grit/components_strings.h" |
| 25 #include "components/url_formatter/elide_url.h" | 25 #include "components/url_formatter/elide_url.h" |
| 26 #include "ui/accessibility/ax_node_data.h" | 26 #include "ui/accessibility/ax_node_data.h" |
| 27 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
| 28 #include "ui/base/models/combobox_model.h" | 28 #include "ui/base/models/combobox_model.h" |
|
msw
2017/06/05 20:22:19
nit: remove
raymes
2017/06/05 22:46:29
Done.
| |
| 29 #include "ui/base/resource/resource_bundle.h" | 29 #include "ui/base/resource/resource_bundle.h" |
| 30 #include "ui/gfx/color_palette.h" | 30 #include "ui/gfx/color_palette.h" |
| 31 #include "ui/gfx/paint_vector_icon.h" | 31 #include "ui/gfx/paint_vector_icon.h" |
| 32 #include "ui/gfx/text_constants.h" | 32 #include "ui/gfx/text_constants.h" |
| 33 #include "ui/views/background.h" | 33 #include "ui/views/background.h" |
| 34 #include "ui/views/bubble/bubble_dialog_delegate.h" | 34 #include "ui/views/bubble/bubble_dialog_delegate.h" |
| 35 #include "ui/views/bubble/bubble_frame_view.h" | 35 #include "ui/views/bubble/bubble_frame_view.h" |
| 36 #include "ui/views/controls/button/checkbox.h" | 36 #include "ui/views/controls/button/checkbox.h" |
| 37 #include "ui/views/controls/button/menu_button.h" | 37 #include "ui/views/controls/button/menu_button.h" |
|
msw
2017/06/05 20:22:20
nit: remove
raymes
2017/06/05 22:46:29
Done.
| |
| 38 #include "ui/views/controls/button/menu_button_listener.h" | 38 #include "ui/views/controls/button/menu_button_listener.h" |
|
msw
2017/06/05 20:22:20
nit: remove
raymes
2017/06/05 22:46:29
Done.
| |
| 39 #include "ui/views/controls/combobox/combobox.h" | 39 #include "ui/views/controls/combobox/combobox.h" |
|
msw
2017/06/05 20:22:19
nit: remove
raymes
2017/06/05 22:46:29
Done.
| |
| 40 #include "ui/views/controls/combobox/combobox_listener.h" | 40 #include "ui/views/controls/combobox/combobox_listener.h" |
|
msw
2017/06/05 20:22:20
nit: remove
raymes
2017/06/05 22:46:29
Done.
| |
| 41 #include "ui/views/controls/label.h" | 41 #include "ui/views/controls/label.h" |
| 42 #include "ui/views/controls/menu/menu_runner.h" | 42 #include "ui/views/controls/menu/menu_runner.h" |
|
msw
2017/06/05 20:22:19
nit: remove
raymes
2017/06/05 22:46:29
Done.
| |
| 43 #include "ui/views/layout/box_layout.h" | 43 #include "ui/views/layout/box_layout.h" |
| 44 #include "ui/views/layout/grid_layout.h" | 44 #include "ui/views/layout/grid_layout.h" |
| 45 | 45 |
| 46 namespace { | 46 namespace { |
| 47 | 47 |
| 48 // (Square) pixel size of icon. | 48 // (Square) pixel size of icon. |
| 49 const int kIconSize = 18; | 49 const int kIconSize = 18; |
| 50 | 50 |
| 51 } // namespace | 51 } // namespace |
| 52 | 52 |
| 53 // This class is a MenuButton which is given a PermissionMenuModel. It | |
| 54 // shows the current checked item in the menu model, and notifies its listener | |
| 55 // about any updates to the state of the selection. | |
| 56 // TODO(gbillock): refactor PermissionMenuButton to work like this and re-use? | |
| 57 class PermissionCombobox : public views::MenuButton, | |
| 58 public views::MenuButtonListener { | |
| 59 public: | |
| 60 // Get notifications when the selection changes. | |
| 61 class Listener { | |
| 62 public: | |
| 63 virtual void PermissionSelectionChanged(int index, bool allowed) = 0; | |
| 64 }; | |
| 65 | |
| 66 PermissionCombobox(Profile* profile, | |
| 67 Listener* listener, | |
| 68 int index, | |
| 69 const GURL& url, | |
| 70 ContentSetting setting); | |
| 71 ~PermissionCombobox() override; | |
| 72 | |
| 73 int index() const { return index_; } | |
| 74 | |
| 75 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; | |
| 76 | |
| 77 // MenuButtonListener: | |
| 78 void OnMenuButtonClicked(views::MenuButton* source, | |
| 79 const gfx::Point& point, | |
| 80 const ui::Event* event) override; | |
| 81 | |
| 82 // Callback when a permission's setting is changed. | |
| 83 void PermissionChanged(const PageInfoUI::PermissionInfo& permission); | |
| 84 | |
| 85 private: | |
| 86 int index_; | |
| 87 Listener* listener_; | |
| 88 std::unique_ptr<PermissionMenuModel> model_; | |
| 89 std::unique_ptr<views::MenuRunner> menu_runner_; | |
| 90 }; | |
| 91 | |
| 92 PermissionCombobox::PermissionCombobox(Profile* profile, | |
| 93 Listener* listener, | |
| 94 int index, | |
| 95 const GURL& url, | |
| 96 ContentSetting setting) | |
| 97 : MenuButton(base::string16(), this, true), | |
| 98 index_(index), | |
| 99 listener_(listener), | |
| 100 model_(new PermissionMenuModel( | |
| 101 profile, | |
| 102 url, | |
| 103 setting, | |
| 104 base::Bind(&PermissionCombobox::PermissionChanged, | |
| 105 base::Unretained(this)))) { | |
| 106 SetText(model_->GetLabelAt(model_->GetIndexOfCommandId(setting))); | |
| 107 SizeToPreferredSize(); | |
| 108 } | |
| 109 | |
| 110 PermissionCombobox::~PermissionCombobox() {} | |
| 111 | |
| 112 void PermissionCombobox::GetAccessibleNodeData(ui::AXNodeData* node_data) { | |
| 113 MenuButton::GetAccessibleNodeData(node_data); | |
| 114 node_data->SetValue(GetText()); | |
| 115 } | |
| 116 | |
| 117 void PermissionCombobox::OnMenuButtonClicked(views::MenuButton* source, | |
| 118 const gfx::Point& point, | |
| 119 const ui::Event* event) { | |
| 120 menu_runner_.reset( | |
| 121 new views::MenuRunner(model_.get(), views::MenuRunner::HAS_MNEMONICS)); | |
| 122 | |
| 123 gfx::Point p(point); | |
| 124 p.Offset(-source->width(), 0); | |
| 125 menu_runner_->RunMenuAt(source->GetWidget()->GetTopLevelWidget(), this, | |
| 126 gfx::Rect(p, gfx::Size()), views::MENU_ANCHOR_TOPLEFT, | |
| 127 ui::MENU_SOURCE_NONE); | |
| 128 } | |
| 129 | |
| 130 void PermissionCombobox::PermissionChanged( | |
| 131 const PageInfoUI::PermissionInfo& permission) { | |
| 132 SetText(model_->GetLabelAt(model_->GetIndexOfCommandId(permission.setting))); | |
| 133 SizeToPreferredSize(); | |
| 134 | |
| 135 listener_->PermissionSelectionChanged( | |
| 136 index_, permission.setting == CONTENT_SETTING_ALLOW); | |
| 137 } | |
| 138 | |
| 139 /////////////////////////////////////////////////////////////////////////////// | 53 /////////////////////////////////////////////////////////////////////////////// |
| 140 // View implementation for the permissions bubble. | 54 // View implementation for the permissions bubble. |
| 141 class PermissionsBubbleDialogDelegateView | 55 class PermissionsBubbleDialogDelegateView |
| 142 : public views::BubbleDialogDelegateView, | 56 : public views::BubbleDialogDelegateView { |
| 143 public PermissionCombobox::Listener { | |
| 144 public: | 57 public: |
| 145 PermissionsBubbleDialogDelegateView( | 58 PermissionsBubbleDialogDelegateView( |
| 146 PermissionPromptImpl* owner, | 59 PermissionPromptImpl* owner, |
| 147 const std::vector<PermissionRequest*>& requests, | 60 const std::vector<PermissionRequest*>& requests); |
| 148 const std::vector<bool>& accept_state); | |
| 149 ~PermissionsBubbleDialogDelegateView() override; | 61 ~PermissionsBubbleDialogDelegateView() override; |
| 150 | 62 |
| 151 void CloseBubble(); | 63 void CloseBubble(); |
| 152 void SizeToContents(); | 64 void SizeToContents(); |
| 153 | 65 |
| 154 // BubbleDialogDelegateView: | 66 // BubbleDialogDelegateView: |
| 155 bool ShouldShowCloseButton() const override; | 67 bool ShouldShowCloseButton() const override; |
| 156 const gfx::FontList& GetTitleFontList() const override; | 68 const gfx::FontList& GetTitleFontList() const override; |
| 157 base::string16 GetWindowTitle() const override; | 69 base::string16 GetWindowTitle() const override; |
| 158 void OnWidgetDestroying(views::Widget* widget) override; | 70 void OnWidgetDestroying(views::Widget* widget) override; |
| 159 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; | 71 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; |
| 160 bool Cancel() override; | 72 bool Cancel() override; |
| 161 bool Accept() override; | 73 bool Accept() override; |
| 162 bool Close() override; | 74 bool Close() override; |
| 163 int GetDefaultDialogButton() const override; | 75 int GetDefaultDialogButton() const override; |
| 164 int GetDialogButtons() const override; | 76 int GetDialogButtons() const override; |
| 165 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; | 77 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; |
| 166 | 78 |
| 167 // PermissionCombobox::Listener: | |
| 168 void PermissionSelectionChanged(int index, bool allowed) override; | |
| 169 | |
| 170 // Updates the anchor's arrow and view. Also repositions the bubble so it's | 79 // Updates the anchor's arrow and view. Also repositions the bubble so it's |
| 171 // displayed in the correct location. | 80 // displayed in the correct location. |
| 172 void UpdateAnchor(views::View* anchor_view, | 81 void UpdateAnchor(views::View* anchor_view, |
| 173 const gfx::Point& anchor_point, | 82 const gfx::Point& anchor_point, |
| 174 views::BubbleBorder::Arrow anchor_arrow); | 83 views::BubbleBorder::Arrow anchor_arrow); |
| 175 | 84 |
| 176 private: | 85 private: |
| 177 PermissionPromptImpl* owner_; | 86 PermissionPromptImpl* owner_; |
| 178 bool multiple_requests_; | |
| 179 base::string16 display_origin_; | 87 base::string16 display_origin_; |
| 180 std::unique_ptr<PermissionMenuModel> menu_button_model_; | 88 std::unique_ptr<PermissionMenuModel> menu_button_model_; |
|
msw
2017/06/05 20:22:20
nit: remove this?
raymes
2017/06/05 22:46:28
Done.
| |
| 181 std::vector<PermissionCombobox*> customize_comboboxes_; | |
| 182 views::Checkbox* persist_checkbox_; | 89 views::Checkbox* persist_checkbox_; |
| 183 | 90 |
| 184 DISALLOW_COPY_AND_ASSIGN(PermissionsBubbleDialogDelegateView); | 91 DISALLOW_COPY_AND_ASSIGN(PermissionsBubbleDialogDelegateView); |
| 185 }; | 92 }; |
| 186 | 93 |
| 187 PermissionsBubbleDialogDelegateView::PermissionsBubbleDialogDelegateView( | 94 PermissionsBubbleDialogDelegateView::PermissionsBubbleDialogDelegateView( |
| 188 PermissionPromptImpl* owner, | 95 PermissionPromptImpl* owner, |
| 189 const std::vector<PermissionRequest*>& requests, | 96 const std::vector<PermissionRequest*>& requests) |
|
msw
2017/06/05 20:22:19
q: does it make sense to change this to just one r
raymes
2017/06/05 22:46:28
There can still be multiple requests for the mic+c
| |
| 190 const std::vector<bool>& accept_state) | 97 : owner_(owner), persist_checkbox_(nullptr) { |
| 191 : owner_(owner), | |
| 192 multiple_requests_(requests.size() > 1), | |
| 193 persist_checkbox_(nullptr) { | |
| 194 DCHECK(!requests.empty()); | 98 DCHECK(!requests.empty()); |
| 195 | 99 |
| 196 set_close_on_deactivate(false); | 100 set_close_on_deactivate(false); |
| 197 | 101 |
| 198 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get(); | 102 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get(); |
| 199 SetLayoutManager(new views::BoxLayout( | 103 SetLayoutManager(new views::BoxLayout( |
| 200 views::BoxLayout::kVertical, 0, 0, | 104 views::BoxLayout::kVertical, 0, 0, |
| 201 provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL))); | 105 provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL))); |
| 202 | 106 |
| 203 display_origin_ = url_formatter::FormatUrlForSecurityDisplay( | 107 display_origin_ = url_formatter::FormatUrlForSecurityDisplay( |
| 204 requests[0]->GetOrigin(), | 108 requests[0]->GetOrigin(), |
| 205 url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC); | 109 url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC); |
| 206 | 110 |
| 207 bool show_persistence_toggle = true; | 111 bool show_persistence_toggle = true; |
| 208 for (size_t index = 0; index < requests.size(); index++) { | 112 for (size_t index = 0; index < requests.size(); index++) { |
| 209 DCHECK(index < accept_state.size()); | |
| 210 // The row is laid out containing a leading-aligned label area and a | 113 // The row is laid out containing a leading-aligned label area and a |
| 211 // trailing column which will be filled if there are multiple permission | 114 // trailing column which will be filled if there are multiple permission |
| 212 // requests. | 115 // requests. |
| 213 views::View* row = new views::View(); | 116 views::View* row = new views::View(); |
| 214 views::GridLayout* row_layout = new views::GridLayout(row); | 117 views::GridLayout* row_layout = new views::GridLayout(row); |
| 215 row->SetLayoutManager(row_layout); | 118 row->SetLayoutManager(row_layout); |
| 216 views::ColumnSet* columns = row_layout->AddColumnSet(0); | 119 views::ColumnSet* columns = row_layout->AddColumnSet(0); |
| 217 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, | 120 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, |
| 218 0, views::GridLayout::USE_PREF, 0, 0); | 121 0, views::GridLayout::USE_PREF, 0, 0); |
| 219 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::FILL, | 122 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::FILL, |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 234 label_container->AddChildView(icon); | 137 label_container->AddChildView(icon); |
| 235 views::Label* label = | 138 views::Label* label = |
| 236 new views::Label(requests.at(index)->GetMessageTextFragment()); | 139 new views::Label(requests.at(index)->GetMessageTextFragment()); |
| 237 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 140 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 238 label_container->AddChildView(label); | 141 label_container->AddChildView(label); |
| 239 row_layout->AddView(label_container); | 142 row_layout->AddView(label_container); |
| 240 | 143 |
| 241 // Only show the toggle if every request wants to show it. | 144 // Only show the toggle if every request wants to show it. |
| 242 show_persistence_toggle = show_persistence_toggle && | 145 show_persistence_toggle = show_persistence_toggle && |
| 243 requests[index]->ShouldShowPersistenceToggle(); | 146 requests[index]->ShouldShowPersistenceToggle(); |
| 244 if (requests.size() > 1) { | 147 row_layout->AddView(new views::View()); |
|
msw
2017/06/05 20:22:19
What's this doing? Should we be just skipping/merg
raymes
2017/06/05 22:46:28
Sorry I'm not a views expert by any means! That ma
| |
| 245 PermissionCombobox* combobox = new PermissionCombobox( | |
| 246 owner->GetProfile(), this, index, requests[index]->GetOrigin(), | |
| 247 accept_state[index] ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); | |
| 248 row_layout->AddView(combobox); | |
| 249 customize_comboboxes_.push_back(combobox); | |
| 250 } else { | |
| 251 row_layout->AddView(new views::View()); | |
| 252 } | |
| 253 | 148 |
| 254 AddChildView(row); | 149 AddChildView(row); |
| 255 } | 150 } |
| 256 | 151 |
| 257 if (show_persistence_toggle) { | 152 if (show_persistence_toggle) { |
| 258 persist_checkbox_ = new views::Checkbox( | 153 persist_checkbox_ = new views::Checkbox( |
| 259 l10n_util::GetStringUTF16(IDS_PERMISSIONS_BUBBLE_PERSIST_TEXT)); | 154 l10n_util::GetStringUTF16(IDS_PERMISSIONS_BUBBLE_PERSIST_TEXT)); |
| 260 persist_checkbox_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 155 persist_checkbox_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 261 persist_checkbox_->SetChecked(true); | 156 persist_checkbox_->SetChecked(true); |
| 262 AddChildView(persist_checkbox_); | 157 AddChildView(persist_checkbox_); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 309 } | 204 } |
| 310 | 205 |
| 311 int PermissionsBubbleDialogDelegateView::GetDefaultDialogButton() const { | 206 int PermissionsBubbleDialogDelegateView::GetDefaultDialogButton() const { |
| 312 // To prevent permissions being accepted accidentally, and as a security | 207 // To prevent permissions being accepted accidentally, and as a security |
| 313 // measure against crbug.com/619429, permission prompts should not be accepted | 208 // measure against crbug.com/619429, permission prompts should not be accepted |
| 314 // as the default action. | 209 // as the default action. |
| 315 return ui::DIALOG_BUTTON_NONE; | 210 return ui::DIALOG_BUTTON_NONE; |
| 316 } | 211 } |
| 317 | 212 |
| 318 int PermissionsBubbleDialogDelegateView::GetDialogButtons() const { | 213 int PermissionsBubbleDialogDelegateView::GetDialogButtons() const { |
| 319 int buttons = ui::DIALOG_BUTTON_OK; | 214 return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL; |
| 320 if (!multiple_requests_) | |
| 321 buttons |= ui::DIALOG_BUTTON_CANCEL; | |
| 322 return buttons; | |
| 323 } | 215 } |
| 324 | 216 |
| 325 base::string16 PermissionsBubbleDialogDelegateView::GetDialogButtonLabel( | 217 base::string16 PermissionsBubbleDialogDelegateView::GetDialogButtonLabel( |
| 326 ui::DialogButton button) const { | 218 ui::DialogButton button) const { |
| 327 if (button == ui::DIALOG_BUTTON_CANCEL) | 219 if (button == ui::DIALOG_BUTTON_CANCEL) |
| 328 return l10n_util::GetStringUTF16(IDS_PERMISSION_DENY); | 220 return l10n_util::GetStringUTF16(IDS_PERMISSION_DENY); |
| 329 | 221 |
| 330 // The text differs based on whether OK is the only visible button. | 222 // The text differs based on whether OK is the only visible button. |
| 331 return l10n_util::GetStringUTF16(GetDialogButtons() == ui::DIALOG_BUTTON_OK | 223 return l10n_util::GetStringUTF16(GetDialogButtons() == ui::DIALOG_BUTTON_OK |
| 332 ? IDS_OK | 224 ? IDS_OK |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 347 owner_->Accept(); | 239 owner_->Accept(); |
| 348 } | 240 } |
| 349 return true; | 241 return true; |
| 350 } | 242 } |
| 351 | 243 |
| 352 bool PermissionsBubbleDialogDelegateView::Close() { | 244 bool PermissionsBubbleDialogDelegateView::Close() { |
| 353 // Neither explicit accept nor explicit deny. | 245 // Neither explicit accept nor explicit deny. |
| 354 return true; | 246 return true; |
| 355 } | 247 } |
| 356 | 248 |
| 357 void PermissionsBubbleDialogDelegateView::PermissionSelectionChanged( | |
| 358 int index, | |
| 359 bool allowed) { | |
| 360 owner_->ToggleAccept(index, allowed); | |
| 361 } | |
| 362 | |
| 363 void PermissionsBubbleDialogDelegateView::UpdateAnchor( | 249 void PermissionsBubbleDialogDelegateView::UpdateAnchor( |
| 364 views::View* anchor_view, | 250 views::View* anchor_view, |
| 365 const gfx::Point& anchor_point, | 251 const gfx::Point& anchor_point, |
| 366 views::BubbleBorder::Arrow anchor_arrow) { | 252 views::BubbleBorder::Arrow anchor_arrow) { |
| 367 set_arrow(anchor_arrow); | 253 set_arrow(anchor_arrow); |
| 368 | 254 |
| 369 // Update the border in the bubble: will either add or remove the arrow. | 255 // Update the border in the bubble: will either add or remove the arrow. |
| 370 views::BubbleFrameView* frame = | 256 views::BubbleFrameView* frame = |
| 371 views::BubbleDialogDelegateView::GetBubbleFrameView(); | 257 views::BubbleDialogDelegateView::GetBubbleFrameView(); |
| 372 views::BubbleBorder::Arrow adjusted_arrow = anchor_arrow; | 258 views::BubbleBorder::Arrow adjusted_arrow = anchor_arrow; |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 396 delegate_ = delegate; | 282 delegate_ = delegate; |
| 397 } | 283 } |
| 398 | 284 |
| 399 void PermissionPromptImpl::Show() { | 285 void PermissionPromptImpl::Show() { |
| 400 DCHECK(browser_); | 286 DCHECK(browser_); |
| 401 DCHECK(browser_->window()); | 287 DCHECK(browser_->window()); |
| 402 | 288 |
| 403 if (bubble_delegate_) | 289 if (bubble_delegate_) |
| 404 bubble_delegate_->CloseBubble(); | 290 bubble_delegate_->CloseBubble(); |
| 405 | 291 |
| 406 bubble_delegate_ = new PermissionsBubbleDialogDelegateView( | 292 bubble_delegate_ = |
| 407 this, delegate_->Requests(), delegate_->AcceptStates()); | 293 new PermissionsBubbleDialogDelegateView(this, delegate_->Requests()); |
| 408 | 294 |
| 409 // Set |parent_window| because some valid anchors can become hidden. | 295 // Set |parent_window| because some valid anchors can become hidden. |
| 410 bubble_delegate_->set_parent_window( | 296 bubble_delegate_->set_parent_window( |
| 411 platform_util::GetViewForWindow(browser_->window()->GetNativeWindow())); | 297 platform_util::GetViewForWindow(browser_->window()->GetNativeWindow())); |
| 412 | 298 |
| 413 // Compensate for vertical padding in the anchor view's image. Note this is | 299 // Compensate for vertical padding in the anchor view's image. Note this is |
| 414 // ignored whenever the anchor view is null. | 300 // ignored whenever the anchor view is null. |
| 415 bubble_delegate_->set_anchor_view_insets(gfx::Insets( | 301 bubble_delegate_->set_anchor_view_insets(gfx::Insets( |
| 416 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); | 302 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); |
| 417 | 303 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 477 void PermissionPromptImpl::Accept() { | 363 void PermissionPromptImpl::Accept() { |
| 478 if (delegate_) | 364 if (delegate_) |
| 479 delegate_->Accept(); | 365 delegate_->Accept(); |
| 480 } | 366 } |
| 481 | 367 |
| 482 void PermissionPromptImpl::Deny() { | 368 void PermissionPromptImpl::Deny() { |
| 483 if (delegate_) | 369 if (delegate_) |
| 484 delegate_->Deny(); | 370 delegate_->Deny(); |
| 485 } | 371 } |
| 486 | 372 |
| 487 Profile* PermissionPromptImpl::GetProfile() { | 373 Profile* PermissionPromptImpl::GetProfile() { |
|
msw
2017/06/05 20:22:19
nit: remove this
raymes
2017/06/05 22:46:28
Done.
| |
| 488 return browser_->profile(); | 374 return browser_->profile(); |
| 489 } | 375 } |
| OLD | NEW |