| 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" | |
| 15 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_dialogs.h" | 15 #include "chrome/browser/ui/browser_dialogs.h" |
| 17 #include "chrome/browser/ui/browser_window.h" | 16 #include "chrome/browser/ui/browser_window.h" |
| 18 #include "chrome/browser/ui/layout_constants.h" | 17 #include "chrome/browser/ui/layout_constants.h" |
| 19 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h" | 18 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h" |
| 20 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" | 19 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" |
| 21 #include "chrome/browser/ui/views/page_info/permission_selector_row.h" | 20 #include "chrome/browser/ui/views/page_info/permission_selector_row.h" |
| 22 #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" |
| 23 #include "chrome/grit/generated_resources.h" | 22 #include "chrome/grit/generated_resources.h" |
| 24 #include "components/strings/grit/components_strings.h" | 23 #include "components/strings/grit/components_strings.h" |
| 25 #include "components/url_formatter/elide_url.h" | 24 #include "components/url_formatter/elide_url.h" |
| 26 #include "ui/accessibility/ax_node_data.h" | 25 #include "ui/accessibility/ax_node_data.h" |
| 27 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
| 28 #include "ui/base/models/combobox_model.h" | |
| 29 #include "ui/base/resource/resource_bundle.h" | 27 #include "ui/base/resource/resource_bundle.h" |
| 30 #include "ui/gfx/color_palette.h" | 28 #include "ui/gfx/color_palette.h" |
| 31 #include "ui/gfx/paint_vector_icon.h" | 29 #include "ui/gfx/paint_vector_icon.h" |
| 32 #include "ui/gfx/text_constants.h" | 30 #include "ui/gfx/text_constants.h" |
| 33 #include "ui/views/background.h" | 31 #include "ui/views/background.h" |
| 34 #include "ui/views/bubble/bubble_dialog_delegate.h" | 32 #include "ui/views/bubble/bubble_dialog_delegate.h" |
| 35 #include "ui/views/bubble/bubble_frame_view.h" | 33 #include "ui/views/bubble/bubble_frame_view.h" |
| 36 #include "ui/views/controls/button/checkbox.h" | 34 #include "ui/views/controls/button/checkbox.h" |
| 37 #include "ui/views/controls/button/menu_button.h" | |
| 38 #include "ui/views/controls/button/menu_button_listener.h" | |
| 39 #include "ui/views/controls/combobox/combobox.h" | |
| 40 #include "ui/views/controls/combobox/combobox_listener.h" | |
| 41 #include "ui/views/controls/label.h" | 35 #include "ui/views/controls/label.h" |
| 42 #include "ui/views/controls/menu/menu_runner.h" | |
| 43 #include "ui/views/layout/box_layout.h" | 36 #include "ui/views/layout/box_layout.h" |
| 44 #include "ui/views/layout/grid_layout.h" | 37 #include "ui/views/layout/grid_layout.h" |
| 45 | 38 |
| 46 namespace { | 39 namespace { |
| 47 | 40 |
| 48 // (Square) pixel size of icon. | 41 // (Square) pixel size of icon. |
| 49 const int kIconSize = 18; | 42 const int kIconSize = 18; |
| 50 | 43 |
| 51 } // namespace | 44 } // namespace |
| 52 | 45 |
| 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 /////////////////////////////////////////////////////////////////////////////// | 46 /////////////////////////////////////////////////////////////////////////////// |
| 140 // View implementation for the permissions bubble. | 47 // View implementation for the permissions bubble. |
| 141 class PermissionsBubbleDialogDelegateView | 48 class PermissionsBubbleDialogDelegateView |
| 142 : public views::BubbleDialogDelegateView, | 49 : public views::BubbleDialogDelegateView { |
| 143 public PermissionCombobox::Listener { | |
| 144 public: | 50 public: |
| 145 PermissionsBubbleDialogDelegateView( | 51 PermissionsBubbleDialogDelegateView( |
| 146 PermissionPromptImpl* owner, | 52 PermissionPromptImpl* owner, |
| 147 const std::vector<PermissionRequest*>& requests, | 53 const std::vector<PermissionRequest*>& requests); |
| 148 const std::vector<bool>& accept_state); | |
| 149 ~PermissionsBubbleDialogDelegateView() override; | 54 ~PermissionsBubbleDialogDelegateView() override; |
| 150 | 55 |
| 151 void CloseBubble(); | 56 void CloseBubble(); |
| 152 void SizeToContents(); | 57 void SizeToContents(); |
| 153 | 58 |
| 154 // BubbleDialogDelegateView: | 59 // BubbleDialogDelegateView: |
| 155 bool ShouldShowCloseButton() const override; | 60 bool ShouldShowCloseButton() const override; |
| 156 const gfx::FontList& GetTitleFontList() const override; | 61 const gfx::FontList& GetTitleFontList() const override; |
| 157 base::string16 GetWindowTitle() const override; | 62 base::string16 GetWindowTitle() const override; |
| 158 void OnWidgetDestroying(views::Widget* widget) override; | 63 void OnWidgetDestroying(views::Widget* widget) override; |
| 159 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; | 64 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; |
| 160 bool Cancel() override; | 65 bool Cancel() override; |
| 161 bool Accept() override; | 66 bool Accept() override; |
| 162 bool Close() override; | 67 bool Close() override; |
| 163 int GetDefaultDialogButton() const override; | 68 int GetDefaultDialogButton() const override; |
| 164 int GetDialogButtons() const override; | 69 int GetDialogButtons() const override; |
| 165 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; | 70 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; |
| 166 | 71 |
| 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 | 72 // Updates the anchor's arrow and view. Also repositions the bubble so it's |
| 171 // displayed in the correct location. | 73 // displayed in the correct location. |
| 172 void UpdateAnchor(views::View* anchor_view, | 74 void UpdateAnchor(views::View* anchor_view, |
| 173 const gfx::Point& anchor_point, | 75 const gfx::Point& anchor_point, |
| 174 views::BubbleBorder::Arrow anchor_arrow); | 76 views::BubbleBorder::Arrow anchor_arrow); |
| 175 | 77 |
| 176 private: | 78 private: |
| 177 PermissionPromptImpl* owner_; | 79 PermissionPromptImpl* owner_; |
| 178 bool multiple_requests_; | |
| 179 base::string16 display_origin_; | 80 base::string16 display_origin_; |
| 180 std::unique_ptr<PermissionMenuModel> menu_button_model_; | |
| 181 std::vector<PermissionCombobox*> customize_comboboxes_; | |
| 182 views::Checkbox* persist_checkbox_; | 81 views::Checkbox* persist_checkbox_; |
| 183 | 82 |
| 184 DISALLOW_COPY_AND_ASSIGN(PermissionsBubbleDialogDelegateView); | 83 DISALLOW_COPY_AND_ASSIGN(PermissionsBubbleDialogDelegateView); |
| 185 }; | 84 }; |
| 186 | 85 |
| 187 PermissionsBubbleDialogDelegateView::PermissionsBubbleDialogDelegateView( | 86 PermissionsBubbleDialogDelegateView::PermissionsBubbleDialogDelegateView( |
| 188 PermissionPromptImpl* owner, | 87 PermissionPromptImpl* owner, |
| 189 const std::vector<PermissionRequest*>& requests, | 88 const std::vector<PermissionRequest*>& requests) |
| 190 const std::vector<bool>& accept_state) | 89 : owner_(owner), persist_checkbox_(nullptr) { |
| 191 : owner_(owner), | |
| 192 multiple_requests_(requests.size() > 1), | |
| 193 persist_checkbox_(nullptr) { | |
| 194 DCHECK(!requests.empty()); | 90 DCHECK(!requests.empty()); |
| 195 | 91 |
| 196 set_close_on_deactivate(false); | 92 set_close_on_deactivate(false); |
| 197 | 93 |
| 198 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get(); | 94 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get(); |
| 199 SetLayoutManager(new views::BoxLayout( | 95 SetLayoutManager(new views::BoxLayout( |
| 200 views::BoxLayout::kVertical, 0, 0, | 96 views::BoxLayout::kVertical, 0, 0, |
| 201 provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL))); | 97 provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL))); |
| 202 | 98 |
| 203 display_origin_ = url_formatter::FormatUrlForSecurityDisplay( | 99 display_origin_ = url_formatter::FormatUrlForSecurityDisplay( |
| 204 requests[0]->GetOrigin(), | 100 requests[0]->GetOrigin(), |
| 205 url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC); | 101 url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC); |
| 206 | 102 |
| 207 bool show_persistence_toggle = true; | 103 bool show_persistence_toggle = true; |
| 208 for (size_t index = 0; index < requests.size(); index++) { | 104 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 | |
| 211 // trailing column which will be filled if there are multiple permission | |
| 212 // requests. | |
| 213 views::View* row = new views::View(); | |
| 214 views::GridLayout* row_layout = new views::GridLayout(row); | |
| 215 row->SetLayoutManager(row_layout); | |
| 216 views::ColumnSet* columns = row_layout->AddColumnSet(0); | |
| 217 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, | |
| 218 0, views::GridLayout::USE_PREF, 0, 0); | |
| 219 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::FILL, | |
| 220 100, views::GridLayout::USE_PREF, 0, 0); | |
| 221 row_layout->StartRow(0, 0); | |
| 222 | |
| 223 views::View* label_container = new views::View(); | 105 views::View* label_container = new views::View(); |
| 224 int indent = | 106 int indent = |
| 225 provider->GetDistanceMetric(DISTANCE_SUBSECTION_HORIZONTAL_INDENT); | 107 provider->GetDistanceMetric(DISTANCE_SUBSECTION_HORIZONTAL_INDENT); |
| 226 label_container->SetLayoutManager(new views::BoxLayout( | 108 label_container->SetLayoutManager(new views::BoxLayout( |
| 227 views::BoxLayout::kHorizontal, indent, 0, | 109 views::BoxLayout::kHorizontal, indent, 0, |
| 228 provider->GetDistanceMetric(DISTANCE_RELATED_LABEL_HORIZONTAL))); | 110 provider->GetDistanceMetric(DISTANCE_RELATED_LABEL_HORIZONTAL))); |
| 229 views::ImageView* icon = new views::ImageView(); | 111 views::ImageView* icon = new views::ImageView(); |
| 230 const gfx::VectorIcon& vector_id = requests[index]->GetIconId(); | 112 const gfx::VectorIcon& vector_id = requests[index]->GetIconId(); |
| 231 icon->SetImage( | 113 icon->SetImage( |
| 232 gfx::CreateVectorIcon(vector_id, kIconSize, gfx::kChromeIconGrey)); | 114 gfx::CreateVectorIcon(vector_id, kIconSize, gfx::kChromeIconGrey)); |
| 233 icon->SetTooltipText(base::string16()); // Redundant with the text fragment | 115 icon->SetTooltipText(base::string16()); // Redundant with the text fragment |
| 234 label_container->AddChildView(icon); | 116 label_container->AddChildView(icon); |
| 235 views::Label* label = | 117 views::Label* label = |
| 236 new views::Label(requests.at(index)->GetMessageTextFragment()); | 118 new views::Label(requests.at(index)->GetMessageTextFragment()); |
| 237 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 119 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 238 label_container->AddChildView(label); | 120 label_container->AddChildView(label); |
| 239 row_layout->AddView(label_container); | 121 AddChildView(label_container); |
| 240 | 122 |
| 241 // Only show the toggle if every request wants to show it. | 123 // Only show the toggle if every request wants to show it. |
| 242 show_persistence_toggle = show_persistence_toggle && | 124 show_persistence_toggle = show_persistence_toggle && |
| 243 requests[index]->ShouldShowPersistenceToggle(); | 125 requests[index]->ShouldShowPersistenceToggle(); |
| 244 if (requests.size() > 1) { | |
| 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 | |
| 254 AddChildView(row); | |
| 255 } | 126 } |
| 256 | 127 |
| 257 if (show_persistence_toggle) { | 128 if (show_persistence_toggle) { |
| 258 persist_checkbox_ = new views::Checkbox( | 129 persist_checkbox_ = new views::Checkbox( |
| 259 l10n_util::GetStringUTF16(IDS_PERMISSIONS_BUBBLE_PERSIST_TEXT)); | 130 l10n_util::GetStringUTF16(IDS_PERMISSIONS_BUBBLE_PERSIST_TEXT)); |
| 260 persist_checkbox_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 131 persist_checkbox_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 261 persist_checkbox_->SetChecked(true); | 132 persist_checkbox_->SetChecked(true); |
| 262 AddChildView(persist_checkbox_); | 133 AddChildView(persist_checkbox_); |
| 263 } | 134 } |
| 264 chrome::RecordDialogCreation(chrome::DialogIdentifier::PERMISSIONS); | 135 chrome::RecordDialogCreation(chrome::DialogIdentifier::PERMISSIONS); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 } | 180 } |
| 310 | 181 |
| 311 int PermissionsBubbleDialogDelegateView::GetDefaultDialogButton() const { | 182 int PermissionsBubbleDialogDelegateView::GetDefaultDialogButton() const { |
| 312 // To prevent permissions being accepted accidentally, and as a security | 183 // To prevent permissions being accepted accidentally, and as a security |
| 313 // measure against crbug.com/619429, permission prompts should not be accepted | 184 // measure against crbug.com/619429, permission prompts should not be accepted |
| 314 // as the default action. | 185 // as the default action. |
| 315 return ui::DIALOG_BUTTON_NONE; | 186 return ui::DIALOG_BUTTON_NONE; |
| 316 } | 187 } |
| 317 | 188 |
| 318 int PermissionsBubbleDialogDelegateView::GetDialogButtons() const { | 189 int PermissionsBubbleDialogDelegateView::GetDialogButtons() const { |
| 319 int buttons = ui::DIALOG_BUTTON_OK; | 190 return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL; |
| 320 if (!multiple_requests_) | |
| 321 buttons |= ui::DIALOG_BUTTON_CANCEL; | |
| 322 return buttons; | |
| 323 } | 191 } |
| 324 | 192 |
| 325 base::string16 PermissionsBubbleDialogDelegateView::GetDialogButtonLabel( | 193 base::string16 PermissionsBubbleDialogDelegateView::GetDialogButtonLabel( |
| 326 ui::DialogButton button) const { | 194 ui::DialogButton button) const { |
| 327 if (button == ui::DIALOG_BUTTON_CANCEL) | 195 if (button == ui::DIALOG_BUTTON_CANCEL) |
| 328 return l10n_util::GetStringUTF16(IDS_PERMISSION_DENY); | 196 return l10n_util::GetStringUTF16(IDS_PERMISSION_DENY); |
| 329 | 197 |
| 330 // The text differs based on whether OK is the only visible button. | 198 // The text differs based on whether OK is the only visible button. |
| 331 return l10n_util::GetStringUTF16(GetDialogButtons() == ui::DIALOG_BUTTON_OK | 199 return l10n_util::GetStringUTF16(GetDialogButtons() == ui::DIALOG_BUTTON_OK |
| 332 ? IDS_OK | 200 ? IDS_OK |
| (...skipping 14 matching lines...) Expand all Loading... |
| 347 owner_->Accept(); | 215 owner_->Accept(); |
| 348 } | 216 } |
| 349 return true; | 217 return true; |
| 350 } | 218 } |
| 351 | 219 |
| 352 bool PermissionsBubbleDialogDelegateView::Close() { | 220 bool PermissionsBubbleDialogDelegateView::Close() { |
| 353 // Neither explicit accept nor explicit deny. | 221 // Neither explicit accept nor explicit deny. |
| 354 return true; | 222 return true; |
| 355 } | 223 } |
| 356 | 224 |
| 357 void PermissionsBubbleDialogDelegateView::PermissionSelectionChanged( | |
| 358 int index, | |
| 359 bool allowed) { | |
| 360 owner_->ToggleAccept(index, allowed); | |
| 361 } | |
| 362 | |
| 363 void PermissionsBubbleDialogDelegateView::UpdateAnchor( | 225 void PermissionsBubbleDialogDelegateView::UpdateAnchor( |
| 364 views::View* anchor_view, | 226 views::View* anchor_view, |
| 365 const gfx::Point& anchor_point, | 227 const gfx::Point& anchor_point, |
| 366 views::BubbleBorder::Arrow anchor_arrow) { | 228 views::BubbleBorder::Arrow anchor_arrow) { |
| 367 set_arrow(anchor_arrow); | 229 set_arrow(anchor_arrow); |
| 368 | 230 |
| 369 // Update the border in the bubble: will either add or remove the arrow. | 231 // Update the border in the bubble: will either add or remove the arrow. |
| 370 views::BubbleFrameView* frame = | 232 views::BubbleFrameView* frame = |
| 371 views::BubbleDialogDelegateView::GetBubbleFrameView(); | 233 views::BubbleDialogDelegateView::GetBubbleFrameView(); |
| 372 views::BubbleBorder::Arrow adjusted_arrow = anchor_arrow; | 234 views::BubbleBorder::Arrow adjusted_arrow = anchor_arrow; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 396 delegate_ = delegate; | 258 delegate_ = delegate; |
| 397 } | 259 } |
| 398 | 260 |
| 399 void PermissionPromptImpl::Show() { | 261 void PermissionPromptImpl::Show() { |
| 400 DCHECK(browser_); | 262 DCHECK(browser_); |
| 401 DCHECK(browser_->window()); | 263 DCHECK(browser_->window()); |
| 402 | 264 |
| 403 if (bubble_delegate_) | 265 if (bubble_delegate_) |
| 404 bubble_delegate_->CloseBubble(); | 266 bubble_delegate_->CloseBubble(); |
| 405 | 267 |
| 406 bubble_delegate_ = new PermissionsBubbleDialogDelegateView( | 268 bubble_delegate_ = |
| 407 this, delegate_->Requests(), delegate_->AcceptStates()); | 269 new PermissionsBubbleDialogDelegateView(this, delegate_->Requests()); |
| 408 | 270 |
| 409 // Set |parent_window| because some valid anchors can become hidden. | 271 // Set |parent_window| because some valid anchors can become hidden. |
| 410 bubble_delegate_->set_parent_window( | 272 bubble_delegate_->set_parent_window( |
| 411 platform_util::GetViewForWindow(browser_->window()->GetNativeWindow())); | 273 platform_util::GetViewForWindow(browser_->window()->GetNativeWindow())); |
| 412 | 274 |
| 413 // Compensate for vertical padding in the anchor view's image. Note this is | 275 // Compensate for vertical padding in the anchor view's image. Note this is |
| 414 // ignored whenever the anchor view is null. | 276 // ignored whenever the anchor view is null. |
| 415 bubble_delegate_->set_anchor_view_insets(gfx::Insets( | 277 bubble_delegate_->set_anchor_view_insets(gfx::Insets( |
| 416 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); | 278 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); |
| 417 | 279 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 | 338 |
| 477 void PermissionPromptImpl::Accept() { | 339 void PermissionPromptImpl::Accept() { |
| 478 if (delegate_) | 340 if (delegate_) |
| 479 delegate_->Accept(); | 341 delegate_->Accept(); |
| 480 } | 342 } |
| 481 | 343 |
| 482 void PermissionPromptImpl::Deny() { | 344 void PermissionPromptImpl::Deny() { |
| 483 if (delegate_) | 345 if (delegate_) |
| 484 delegate_->Deny(); | 346 delegate_->Deny(); |
| 485 } | 347 } |
| 486 | |
| 487 Profile* PermissionPromptImpl::GetProfile() { | |
| 488 return browser_->profile(); | |
| 489 } | |
| OLD | NEW |