| 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/website_settings/permissions_bubble_view.h" | 5 #include "chrome/browser/ui/views/website_settings/permissions_bubble_view.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/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 | 184 |
| 185 // Updates the anchor's arrow and view. Also repositions the bubble so it's | 185 // Updates the anchor's arrow and view. Also repositions the bubble so it's |
| 186 // displayed in the correct location. | 186 // displayed in the correct location. |
| 187 void UpdateAnchor(views::View* anchor_view, | 187 void UpdateAnchor(views::View* anchor_view, |
| 188 views::BubbleBorder::Arrow anchor_arrow); | 188 views::BubbleBorder::Arrow anchor_arrow); |
| 189 | 189 |
| 190 private: | 190 private: |
| 191 PermissionBubbleViewViews* owner_; | 191 PermissionBubbleViewViews* owner_; |
| 192 views::Button* allow_; | 192 views::Button* allow_; |
| 193 views::Button* deny_; | 193 views::Button* deny_; |
| 194 base::string16 hostname_; | 194 base::string16 display_origin_; |
| 195 scoped_ptr<PermissionMenuModel> menu_button_model_; | 195 scoped_ptr<PermissionMenuModel> menu_button_model_; |
| 196 std::vector<PermissionCombobox*> customize_comboboxes_; | 196 std::vector<PermissionCombobox*> customize_comboboxes_; |
| 197 | 197 |
| 198 DISALLOW_COPY_AND_ASSIGN(PermissionsBubbleDelegateView); | 198 DISALLOW_COPY_AND_ASSIGN(PermissionsBubbleDelegateView); |
| 199 }; | 199 }; |
| 200 | 200 |
| 201 PermissionsBubbleDelegateView::PermissionsBubbleDelegateView( | 201 PermissionsBubbleDelegateView::PermissionsBubbleDelegateView( |
| 202 views::View* anchor_view, | 202 views::View* anchor_view, |
| 203 views::BubbleBorder::Arrow anchor_arrow, | 203 views::BubbleBorder::Arrow anchor_arrow, |
| 204 PermissionBubbleViewViews* owner, | 204 PermissionBubbleViewViews* owner, |
| 205 const std::string& languages, | 205 const std::string& languages, |
| 206 const std::vector<PermissionBubbleRequest*>& requests, | 206 const std::vector<PermissionBubbleRequest*>& requests, |
| 207 const std::vector<bool>& accept_state) | 207 const std::vector<bool>& accept_state) |
| 208 : views::BubbleDelegateView(anchor_view, anchor_arrow), | 208 : views::BubbleDelegateView(anchor_view, anchor_arrow), |
| 209 owner_(owner), | 209 owner_(owner), |
| 210 allow_(nullptr), | 210 allow_(nullptr), |
| 211 deny_(nullptr) { | 211 deny_(nullptr) { |
| 212 DCHECK(!requests.empty()); | 212 DCHECK(!requests.empty()); |
| 213 | 213 |
| 214 RemoveAllChildViews(true); | 214 RemoveAllChildViews(true); |
| 215 customize_comboboxes_.clear(); | 215 customize_comboboxes_.clear(); |
| 216 set_close_on_esc(true); | 216 set_close_on_esc(true); |
| 217 set_close_on_deactivate(false); | 217 set_close_on_deactivate(false); |
| 218 | 218 |
| 219 SetLayoutManager(new views::BoxLayout( | 219 SetLayoutManager(new views::BoxLayout( |
| 220 views::BoxLayout::kVertical, kBubbleOuterMargin, 0, kItemMajorSpacing)); | 220 views::BoxLayout::kVertical, kBubbleOuterMargin, 0, kItemMajorSpacing)); |
| 221 | 221 |
| 222 hostname_ = url_formatter::FormatUrlForSecurityDisplay( | 222 display_origin_ = url_formatter::FormatUrlForSecurityDisplay( |
| 223 requests[0]->GetRequestingHostname(), languages); | 223 requests[0]->GetOrigin(), languages); |
| 224 | 224 |
| 225 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 225 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| 226 for (size_t index = 0; index < requests.size(); index++) { | 226 for (size_t index = 0; index < requests.size(); index++) { |
| 227 DCHECK(index < accept_state.size()); | 227 DCHECK(index < accept_state.size()); |
| 228 // The row is laid out containing a leading-aligned label area and a | 228 // The row is laid out containing a leading-aligned label area and a |
| 229 // trailing column which will be filled if there are multiple permission | 229 // trailing column which will be filled if there are multiple permission |
| 230 // requests. | 230 // requests. |
| 231 views::View* row = new views::View(); | 231 views::View* row = new views::View(); |
| 232 views::GridLayout* row_layout = new views::GridLayout(row); | 232 views::GridLayout* row_layout = new views::GridLayout(row); |
| 233 row->SetLayoutManager(row_layout); | 233 row->SetLayoutManager(row_layout); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 255 icon->SetTooltipText(base::string16()); // Redundant with the text fragment | 255 icon->SetTooltipText(base::string16()); // Redundant with the text fragment |
| 256 label_container->AddChildView(icon); | 256 label_container->AddChildView(icon); |
| 257 views::Label* label = | 257 views::Label* label = |
| 258 new views::Label(requests.at(index)->GetMessageTextFragment()); | 258 new views::Label(requests.at(index)->GetMessageTextFragment()); |
| 259 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 259 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 260 label_container->AddChildView(label); | 260 label_container->AddChildView(label); |
| 261 row_layout->AddView(label_container); | 261 row_layout->AddView(label_container); |
| 262 | 262 |
| 263 if (requests.size() > 1) { | 263 if (requests.size() > 1) { |
| 264 PermissionCombobox* combobox = new PermissionCombobox( | 264 PermissionCombobox* combobox = new PermissionCombobox( |
| 265 this, | 265 this, index, requests[index]->GetOrigin(), |
| 266 index, | |
| 267 requests[index]->GetRequestingHostname(), | |
| 268 accept_state[index] ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); | 266 accept_state[index] ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); |
| 269 row_layout->AddView(combobox); | 267 row_layout->AddView(combobox); |
| 270 customize_comboboxes_.push_back(combobox); | 268 customize_comboboxes_.push_back(combobox); |
| 271 } else { | 269 } else { |
| 272 row_layout->AddView(new views::View()); | 270 row_layout->AddView(new views::View()); |
| 273 } | 271 } |
| 274 | 272 |
| 275 AddChildView(row); | 273 AddChildView(row); |
| 276 } | 274 } |
| 277 | 275 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 return true; | 335 return true; |
| 338 } | 336 } |
| 339 | 337 |
| 340 const gfx::FontList& PermissionsBubbleDelegateView::GetTitleFontList() const { | 338 const gfx::FontList& PermissionsBubbleDelegateView::GetTitleFontList() const { |
| 341 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 339 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 342 return rb.GetFontList(ui::ResourceBundle::BaseFont); | 340 return rb.GetFontList(ui::ResourceBundle::BaseFont); |
| 343 } | 341 } |
| 344 | 342 |
| 345 base::string16 PermissionsBubbleDelegateView::GetWindowTitle() const { | 343 base::string16 PermissionsBubbleDelegateView::GetWindowTitle() const { |
| 346 return l10n_util::GetStringFUTF16(IDS_PERMISSIONS_BUBBLE_PROMPT, | 344 return l10n_util::GetStringFUTF16(IDS_PERMISSIONS_BUBBLE_PROMPT, |
| 347 hostname_); | 345 display_origin_); |
| 348 } | 346 } |
| 349 | 347 |
| 350 void PermissionsBubbleDelegateView::SizeToContents() { | 348 void PermissionsBubbleDelegateView::SizeToContents() { |
| 351 BubbleDelegateView::SizeToContents(); | 349 BubbleDelegateView::SizeToContents(); |
| 352 } | 350 } |
| 353 | 351 |
| 354 void PermissionsBubbleDelegateView::OnWidgetDestroying(views::Widget* widget) { | 352 void PermissionsBubbleDelegateView::OnWidgetDestroying(views::Widget* widget) { |
| 355 views::BubbleDelegateView::OnWidgetDestroying(widget); | 353 views::BubbleDelegateView::OnWidgetDestroying(widget); |
| 356 if (owner_) { | 354 if (owner_) { |
| 357 owner_->Closing(); | 355 owner_->Closing(); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 | 501 |
| 504 void PermissionBubbleViewViews::Accept() { | 502 void PermissionBubbleViewViews::Accept() { |
| 505 if (delegate_) | 503 if (delegate_) |
| 506 delegate_->Accept(); | 504 delegate_->Accept(); |
| 507 } | 505 } |
| 508 | 506 |
| 509 void PermissionBubbleViewViews::Deny() { | 507 void PermissionBubbleViewViews::Deny() { |
| 510 if (delegate_) | 508 if (delegate_) |
| 511 delegate_->Deny(); | 509 delegate_->Deny(); |
| 512 } | 510 } |
| OLD | NEW |