Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/content_setting_bubble_contents.h" | 5 #include "chrome/browser/ui/views/content_setting_bubble_contents.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 #include "components/content_settings/core/browser/host_content_settings_map.h" | 22 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 23 #include "components/strings/grit/components_strings.h" | 23 #include "components/strings/grit/components_strings.h" |
| 24 #include "content/public/browser/plugin_service.h" | 24 #include "content/public/browser/plugin_service.h" |
| 25 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 26 #include "ui/base/cursor/cursor.h" | 26 #include "ui/base/cursor/cursor.h" |
| 27 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
| 28 #include "ui/base/models/simple_menu_model.h" | 28 #include "ui/base/models/simple_menu_model.h" |
| 29 #include "ui/base/resource/resource_bundle.h" | 29 #include "ui/base/resource/resource_bundle.h" |
| 30 #include "ui/gfx/font_list.h" | 30 #include "ui/gfx/font_list.h" |
| 31 #include "ui/gfx/text_utils.h" | 31 #include "ui/gfx/text_utils.h" |
| 32 #include "ui/views/controls/button/label_button.h" | |
|
msw
2016/09/14 17:01:34
nit: This include is redundant
melandory
2016/09/14 19:30:12
Done.
| |
| 33 #include "ui/views/controls/button/md_text_button.h" | |
| 32 #include "ui/views/controls/button/menu_button.h" | 34 #include "ui/views/controls/button/menu_button.h" |
| 33 #include "ui/views/controls/button/radio_button.h" | 35 #include "ui/views/controls/button/radio_button.h" |
| 34 #include "ui/views/controls/combobox/combobox.h" | 36 #include "ui/views/controls/combobox/combobox.h" |
| 35 #include "ui/views/controls/image_view.h" | 37 #include "ui/views/controls/image_view.h" |
| 36 #include "ui/views/controls/label.h" | 38 #include "ui/views/controls/label.h" |
| 37 #include "ui/views/controls/link.h" | 39 #include "ui/views/controls/link.h" |
| 38 #include "ui/views/controls/menu/menu_config.h" | 40 #include "ui/views/controls/menu/menu_config.h" |
| 39 #include "ui/views/controls/menu/menu_runner.h" | 41 #include "ui/views/controls/menu/menu_runner.h" |
| 40 #include "ui/views/controls/separator.h" | 42 #include "ui/views/controls/separator.h" |
| 41 #include "ui/views/layout/grid_layout.h" | 43 #include "ui/views/layout/grid_layout.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 ContentSettingBubbleContents::ContentSettingBubbleContents( | 156 ContentSettingBubbleContents::ContentSettingBubbleContents( |
| 155 ContentSettingBubbleModel* content_setting_bubble_model, | 157 ContentSettingBubbleModel* content_setting_bubble_model, |
| 156 content::WebContents* web_contents, | 158 content::WebContents* web_contents, |
| 157 views::View* anchor_view, | 159 views::View* anchor_view, |
| 158 views::BubbleBorder::Arrow arrow) | 160 views::BubbleBorder::Arrow arrow) |
| 159 : content::WebContentsObserver(web_contents), | 161 : content::WebContentsObserver(web_contents), |
| 160 BubbleDialogDelegateView(anchor_view, arrow), | 162 BubbleDialogDelegateView(anchor_view, arrow), |
| 161 content_setting_bubble_model_(content_setting_bubble_model), | 163 content_setting_bubble_model_(content_setting_bubble_model), |
| 162 custom_link_(NULL), | 164 custom_link_(NULL), |
| 163 manage_link_(NULL), | 165 manage_link_(NULL), |
| 166 manage_button_(NULL), | |
|
msw
2016/09/14 17:01:34
nit: nullptr here and elsewhere
melandory
2016/09/14 19:30:12
Done.
| |
| 164 learn_more_link_(NULL) { | 167 learn_more_link_(NULL) { |
| 165 // Compensate for built-in vertical padding in the anchor view's image. | 168 // Compensate for built-in vertical padding in the anchor view's image. |
| 166 set_anchor_view_insets(gfx::Insets( | 169 set_anchor_view_insets(gfx::Insets( |
| 167 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); | 170 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); |
| 168 } | 171 } |
| 169 | 172 |
| 170 ContentSettingBubbleContents::~ContentSettingBubbleContents() { | 173 ContentSettingBubbleContents::~ContentSettingBubbleContents() { |
| 171 // Must remove the children here so the comboboxes get destroyed before | 174 // Must remove the children here so the comboboxes get destroyed before |
| 172 // their associated models. | 175 // their associated models. |
| 173 RemoveAllChildViews(true); | 176 RemoveAllChildViews(true); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 if (!bubble_content_empty) { | 377 if (!bubble_content_empty) { |
| 375 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 378 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 376 layout->StartRow(0, kSingleColumnSetId); | 379 layout->StartRow(0, kSingleColumnSetId); |
| 377 layout->AddView(new views::Separator(views::Separator::HORIZONTAL), 1, 1, | 380 layout->AddView(new views::Separator(views::Separator::HORIZONTAL), 1, 1, |
| 378 GridLayout::FILL, GridLayout::FILL); | 381 GridLayout::FILL, GridLayout::FILL); |
| 379 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 382 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 380 } | 383 } |
| 381 } | 384 } |
| 382 | 385 |
| 383 views::View* ContentSettingBubbleContents::CreateExtraView() { | 386 views::View* ContentSettingBubbleContents::CreateExtraView() { |
| 384 manage_link_ = new views::Link(base::UTF8ToUTF16( | 387 if (content_setting_bubble_model_->bubble_content().manage_link_as_button) { |
|
msw
2016/09/14 17:01:34
Why make this an option? Why not just always use a
melandory
2016/09/14 19:30:12
It was set as a requirement for our particular bub
msw
2016/09/14 19:50:24
Acknowledged.
| |
| 385 content_setting_bubble_model_->bubble_content().manage_link)); | 388 manage_button_ = views::MdTextButton::CreateSecondaryUiButton( |
| 386 manage_link_->set_listener(this); | 389 this, base::UTF8ToUTF16( |
| 387 return manage_link_; | 390 content_setting_bubble_model_->bubble_content().manage_link)); |
|
msw
2016/09/14 17:01:34
nit: rename |BubbleContent::manage_link| to |manag
melandory
2016/09/14 19:30:12
Done.
| |
| 391 return manage_button_; | |
| 392 } else { | |
| 393 manage_link_ = new views::Link(base::UTF8ToUTF16( | |
| 394 content_setting_bubble_model_->bubble_content().manage_link)); | |
| 395 manage_link_->set_listener(this); | |
| 396 return manage_link_; | |
| 397 } | |
| 388 } | 398 } |
| 389 | 399 |
| 390 bool ContentSettingBubbleContents::Accept() { | 400 bool ContentSettingBubbleContents::Accept() { |
| 391 content_setting_bubble_model_->OnDoneClicked(); | 401 content_setting_bubble_model_->OnDoneClicked(); |
| 392 return true; | 402 return true; |
| 393 } | 403 } |
| 394 | 404 |
| 395 bool ContentSettingBubbleContents::Close() { | 405 bool ContentSettingBubbleContents::Close() { |
| 396 return true; | 406 return true; |
| 397 } | 407 } |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 408 void ContentSettingBubbleContents::DidNavigateMainFrame( | 418 void ContentSettingBubbleContents::DidNavigateMainFrame( |
| 409 const content::LoadCommittedDetails& details, | 419 const content::LoadCommittedDetails& details, |
| 410 const content::FrameNavigateParams& params) { | 420 const content::FrameNavigateParams& params) { |
| 411 // Content settings are based on the main frame, so if it switches then | 421 // Content settings are based on the main frame, so if it switches then |
| 412 // close up shop. | 422 // close up shop. |
| 413 GetWidget()->Close(); | 423 GetWidget()->Close(); |
| 414 } | 424 } |
| 415 | 425 |
| 416 void ContentSettingBubbleContents::ButtonPressed(views::Button* sender, | 426 void ContentSettingBubbleContents::ButtonPressed(views::Button* sender, |
| 417 const ui::Event& event) { | 427 const ui::Event& event) { |
| 418 RadioGroup::const_iterator i( | 428 if (manage_button_ == sender) { |
| 419 std::find(radio_group_.begin(), radio_group_.end(), sender)); | 429 GetWidget()->Close(); |
| 420 DCHECK(i != radio_group_.end()); | 430 content_setting_bubble_model_->OnManageLinkClicked(); |
| 421 content_setting_bubble_model_->OnRadioClicked(i - radio_group_.begin()); | 431 } else { |
| 432 RadioGroup::const_iterator i( | |
| 433 std::find(radio_group_.begin(), radio_group_.end(), sender)); | |
| 434 DCHECK(i != radio_group_.end()); | |
| 435 content_setting_bubble_model_->OnRadioClicked(i - radio_group_.begin()); | |
| 436 } | |
| 422 } | 437 } |
| 423 | 438 |
| 424 void ContentSettingBubbleContents::LinkClicked(views::Link* source, | 439 void ContentSettingBubbleContents::LinkClicked(views::Link* source, |
| 425 int event_flags) { | 440 int event_flags) { |
| 426 if (source == learn_more_link_) { | 441 if (source == learn_more_link_) { |
| 427 content_setting_bubble_model_->OnLearnMoreLinkClicked(); | 442 content_setting_bubble_model_->OnLearnMoreLinkClicked(); |
| 428 GetWidget()->Close(); | 443 GetWidget()->Close(); |
| 429 return; | 444 return; |
| 430 } | 445 } |
| 431 if (source == custom_link_) { | 446 if (source == custom_link_) { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 445 DCHECK(i != list_item_links_.end()); | 460 DCHECK(i != list_item_links_.end()); |
| 446 content_setting_bubble_model_->OnListItemClicked(i->second); | 461 content_setting_bubble_model_->OnListItemClicked(i->second); |
| 447 } | 462 } |
| 448 | 463 |
| 449 void ContentSettingBubbleContents::OnPerformAction(views::Combobox* combobox) { | 464 void ContentSettingBubbleContents::OnPerformAction(views::Combobox* combobox) { |
| 450 MediaComboboxModel* model = | 465 MediaComboboxModel* model = |
| 451 static_cast<MediaComboboxModel*>(combobox->model()); | 466 static_cast<MediaComboboxModel*>(combobox->model()); |
| 452 content_setting_bubble_model_->OnMediaMenuClicked( | 467 content_setting_bubble_model_->OnMediaMenuClicked( |
| 453 model->type(), model->GetDevices()[combobox->selected_index()].id); | 468 model->type(), model->GetDevices()[combobox->selected_index()].id); |
| 454 } | 469 } |
| OLD | NEW |