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" | |
| 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()); | 105 // The row is laid out containing a leading-aligned label area. |
|
msw
2017/06/05 23:14:10
Actually, it seems like this layout could be great
raymes
2017/06/05 23:23:54
Done. I didn't do the optional bit because I wasn'
| |
| 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(); | 106 views::View* row = new views::View(); |
| 214 views::GridLayout* row_layout = new views::GridLayout(row); | 107 views::GridLayout* row_layout = new views::GridLayout(row); |
| 215 row->SetLayoutManager(row_layout); | 108 row->SetLayoutManager(row_layout); |
| 216 views::ColumnSet* columns = row_layout->AddColumnSet(0); | 109 views::ColumnSet* columns = row_layout->AddColumnSet(0); |
| 217 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, | 110 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, |
| 218 0, views::GridLayout::USE_PREF, 0, 0); | 111 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); | 112 row_layout->StartRow(0, 0); |
| 222 | 113 |
| 223 views::View* label_container = new views::View(); | 114 views::View* label_container = new views::View(); |
| 224 int indent = | 115 int indent = |
| 225 provider->GetDistanceMetric(DISTANCE_SUBSECTION_HORIZONTAL_INDENT); | 116 provider->GetDistanceMetric(DISTANCE_SUBSECTION_HORIZONTAL_INDENT); |
| 226 label_container->SetLayoutManager(new views::BoxLayout( | 117 label_container->SetLayoutManager(new views::BoxLayout( |
| 227 views::BoxLayout::kHorizontal, indent, 0, | 118 views::BoxLayout::kHorizontal, indent, 0, |
| 228 provider->GetDistanceMetric(DISTANCE_RELATED_LABEL_HORIZONTAL))); | 119 provider->GetDistanceMetric(DISTANCE_RELATED_LABEL_HORIZONTAL))); |
| 229 views::ImageView* icon = new views::ImageView(); | 120 views::ImageView* icon = new views::ImageView(); |
| 230 const gfx::VectorIcon& vector_id = requests[index]->GetIconId(); | 121 const gfx::VectorIcon& vector_id = requests[index]->GetIconId(); |
| 231 icon->SetImage( | 122 icon->SetImage( |
| 232 gfx::CreateVectorIcon(vector_id, kIconSize, gfx::kChromeIconGrey)); | 123 gfx::CreateVectorIcon(vector_id, kIconSize, gfx::kChromeIconGrey)); |
| 233 icon->SetTooltipText(base::string16()); // Redundant with the text fragment | 124 icon->SetTooltipText(base::string16()); // Redundant with the text fragment |
| 234 label_container->AddChildView(icon); | 125 label_container->AddChildView(icon); |
| 235 views::Label* label = | 126 views::Label* label = |
| 236 new views::Label(requests.at(index)->GetMessageTextFragment()); | 127 new views::Label(requests.at(index)->GetMessageTextFragment()); |
| 237 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 128 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 238 label_container->AddChildView(label); | 129 label_container->AddChildView(label); |
| 239 row_layout->AddView(label_container); | 130 row_layout->AddView(label_container); |
| 240 | 131 |
| 241 // Only show the toggle if every request wants to show it. | 132 // Only show the toggle if every request wants to show it. |
| 242 show_persistence_toggle = show_persistence_toggle && | 133 show_persistence_toggle = show_persistence_toggle && |
| 243 requests[index]->ShouldShowPersistenceToggle(); | 134 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 | 135 |
| 254 AddChildView(row); | 136 AddChildView(row); |
| 255 } | 137 } |
| 256 | 138 |
| 257 if (show_persistence_toggle) { | 139 if (show_persistence_toggle) { |
| 258 persist_checkbox_ = new views::Checkbox( | 140 persist_checkbox_ = new views::Checkbox( |
| 259 l10n_util::GetStringUTF16(IDS_PERMISSIONS_BUBBLE_PERSIST_TEXT)); | 141 l10n_util::GetStringUTF16(IDS_PERMISSIONS_BUBBLE_PERSIST_TEXT)); |
| 260 persist_checkbox_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 142 persist_checkbox_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 261 persist_checkbox_->SetChecked(true); | 143 persist_checkbox_->SetChecked(true); |
| 262 AddChildView(persist_checkbox_); | 144 AddChildView(persist_checkbox_); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 309 } | 191 } |
| 310 | 192 |
| 311 int PermissionsBubbleDialogDelegateView::GetDefaultDialogButton() const { | 193 int PermissionsBubbleDialogDelegateView::GetDefaultDialogButton() const { |
| 312 // To prevent permissions being accepted accidentally, and as a security | 194 // To prevent permissions being accepted accidentally, and as a security |
| 313 // measure against crbug.com/619429, permission prompts should not be accepted | 195 // measure against crbug.com/619429, permission prompts should not be accepted |
| 314 // as the default action. | 196 // as the default action. |
| 315 return ui::DIALOG_BUTTON_NONE; | 197 return ui::DIALOG_BUTTON_NONE; |
| 316 } | 198 } |
| 317 | 199 |
| 318 int PermissionsBubbleDialogDelegateView::GetDialogButtons() const { | 200 int PermissionsBubbleDialogDelegateView::GetDialogButtons() const { |
| 319 int buttons = ui::DIALOG_BUTTON_OK; | 201 return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL; |
| 320 if (!multiple_requests_) | |
| 321 buttons |= ui::DIALOG_BUTTON_CANCEL; | |
| 322 return buttons; | |
| 323 } | 202 } |
| 324 | 203 |
| 325 base::string16 PermissionsBubbleDialogDelegateView::GetDialogButtonLabel( | 204 base::string16 PermissionsBubbleDialogDelegateView::GetDialogButtonLabel( |
| 326 ui::DialogButton button) const { | 205 ui::DialogButton button) const { |
| 327 if (button == ui::DIALOG_BUTTON_CANCEL) | 206 if (button == ui::DIALOG_BUTTON_CANCEL) |
| 328 return l10n_util::GetStringUTF16(IDS_PERMISSION_DENY); | 207 return l10n_util::GetStringUTF16(IDS_PERMISSION_DENY); |
| 329 | 208 |
| 330 // The text differs based on whether OK is the only visible button. | 209 // The text differs based on whether OK is the only visible button. |
| 331 return l10n_util::GetStringUTF16(GetDialogButtons() == ui::DIALOG_BUTTON_OK | 210 return l10n_util::GetStringUTF16(GetDialogButtons() == ui::DIALOG_BUTTON_OK |
| 332 ? IDS_OK | 211 ? IDS_OK |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 347 owner_->Accept(); | 226 owner_->Accept(); |
| 348 } | 227 } |
| 349 return true; | 228 return true; |
| 350 } | 229 } |
| 351 | 230 |
| 352 bool PermissionsBubbleDialogDelegateView::Close() { | 231 bool PermissionsBubbleDialogDelegateView::Close() { |
| 353 // Neither explicit accept nor explicit deny. | 232 // Neither explicit accept nor explicit deny. |
| 354 return true; | 233 return true; |
| 355 } | 234 } |
| 356 | 235 |
| 357 void PermissionsBubbleDialogDelegateView::PermissionSelectionChanged( | |
| 358 int index, | |
| 359 bool allowed) { | |
| 360 owner_->ToggleAccept(index, allowed); | |
| 361 } | |
| 362 | |
| 363 void PermissionsBubbleDialogDelegateView::UpdateAnchor( | 236 void PermissionsBubbleDialogDelegateView::UpdateAnchor( |
| 364 views::View* anchor_view, | 237 views::View* anchor_view, |
| 365 const gfx::Point& anchor_point, | 238 const gfx::Point& anchor_point, |
| 366 views::BubbleBorder::Arrow anchor_arrow) { | 239 views::BubbleBorder::Arrow anchor_arrow) { |
| 367 set_arrow(anchor_arrow); | 240 set_arrow(anchor_arrow); |
| 368 | 241 |
| 369 // Update the border in the bubble: will either add or remove the arrow. | 242 // Update the border in the bubble: will either add or remove the arrow. |
| 370 views::BubbleFrameView* frame = | 243 views::BubbleFrameView* frame = |
| 371 views::BubbleDialogDelegateView::GetBubbleFrameView(); | 244 views::BubbleDialogDelegateView::GetBubbleFrameView(); |
| 372 views::BubbleBorder::Arrow adjusted_arrow = anchor_arrow; | 245 views::BubbleBorder::Arrow adjusted_arrow = anchor_arrow; |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 396 delegate_ = delegate; | 269 delegate_ = delegate; |
| 397 } | 270 } |
| 398 | 271 |
| 399 void PermissionPromptImpl::Show() { | 272 void PermissionPromptImpl::Show() { |
| 400 DCHECK(browser_); | 273 DCHECK(browser_); |
| 401 DCHECK(browser_->window()); | 274 DCHECK(browser_->window()); |
| 402 | 275 |
| 403 if (bubble_delegate_) | 276 if (bubble_delegate_) |
| 404 bubble_delegate_->CloseBubble(); | 277 bubble_delegate_->CloseBubble(); |
| 405 | 278 |
| 406 bubble_delegate_ = new PermissionsBubbleDialogDelegateView( | 279 bubble_delegate_ = |
| 407 this, delegate_->Requests(), delegate_->AcceptStates()); | 280 new PermissionsBubbleDialogDelegateView(this, delegate_->Requests()); |
| 408 | 281 |
| 409 // Set |parent_window| because some valid anchors can become hidden. | 282 // Set |parent_window| because some valid anchors can become hidden. |
| 410 bubble_delegate_->set_parent_window( | 283 bubble_delegate_->set_parent_window( |
| 411 platform_util::GetViewForWindow(browser_->window()->GetNativeWindow())); | 284 platform_util::GetViewForWindow(browser_->window()->GetNativeWindow())); |
| 412 | 285 |
| 413 // Compensate for vertical padding in the anchor view's image. Note this is | 286 // Compensate for vertical padding in the anchor view's image. Note this is |
| 414 // ignored whenever the anchor view is null. | 287 // ignored whenever the anchor view is null. |
| 415 bubble_delegate_->set_anchor_view_insets(gfx::Insets( | 288 bubble_delegate_->set_anchor_view_insets(gfx::Insets( |
| 416 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); | 289 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); |
| 417 | 290 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 476 | 349 |
| 477 void PermissionPromptImpl::Accept() { | 350 void PermissionPromptImpl::Accept() { |
| 478 if (delegate_) | 351 if (delegate_) |
| 479 delegate_->Accept(); | 352 delegate_->Accept(); |
| 480 } | 353 } |
| 481 | 354 |
| 482 void PermissionPromptImpl::Deny() { | 355 void PermissionPromptImpl::Deny() { |
| 483 if (delegate_) | 356 if (delegate_) |
| 484 delegate_->Deny(); | 357 delegate_->Deny(); |
| 485 } | 358 } |
| 486 | |
| 487 Profile* PermissionPromptImpl::GetProfile() { | |
| 488 return browser_->profile(); | |
| 489 } | |
| OLD | NEW |