Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(759)

Side by Side Diff: chrome/browser/ui/views/content_setting_bubble_contents.cc

Issue 2793413002: [subresource_filter] Update the desktop UI according to mocks (Closed)
Patch Set: Not as part of the extra view Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 ContentSettingBubbleModel* content_setting_bubble_model, 165 ContentSettingBubbleModel* content_setting_bubble_model,
166 content::WebContents* web_contents, 166 content::WebContents* web_contents,
167 views::View* anchor_view, 167 views::View* anchor_view,
168 views::BubbleBorder::Arrow arrow) 168 views::BubbleBorder::Arrow arrow)
169 : content::WebContentsObserver(web_contents), 169 : content::WebContentsObserver(web_contents),
170 BubbleDialogDelegateView(anchor_view, arrow), 170 BubbleDialogDelegateView(anchor_view, arrow),
171 content_setting_bubble_model_(content_setting_bubble_model), 171 content_setting_bubble_model_(content_setting_bubble_model),
172 custom_link_(nullptr), 172 custom_link_(nullptr),
173 manage_link_(nullptr), 173 manage_link_(nullptr),
174 manage_button_(nullptr), 174 manage_button_(nullptr),
175 manage_checkbox_(nullptr),
175 learn_more_link_(nullptr) { 176 learn_more_link_(nullptr) {
176 // Compensate for built-in vertical padding in the anchor view's image. 177 // Compensate for built-in vertical padding in the anchor view's image.
177 set_anchor_view_insets(gfx::Insets( 178 set_anchor_view_insets(gfx::Insets(
178 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); 179 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0));
179 } 180 }
180 181
181 ContentSettingBubbleContents::~ContentSettingBubbleContents() { 182 ContentSettingBubbleContents::~ContentSettingBubbleContents() {
182 // Must remove the children here so the comboboxes get destroyed before 183 // Must remove the children here so the comboboxes get destroyed before
183 // their associated models. 184 // their associated models.
184 RemoveAllChildViews(true); 185 RemoveAllChildViews(true);
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 new views::Link(base::UTF8ToUTF16(bubble_content.custom_link)); 410 new views::Link(base::UTF8ToUTF16(bubble_content.custom_link));
410 custom_link_->SetEnabled(bubble_content.custom_link_enabled); 411 custom_link_->SetEnabled(bubble_content.custom_link_enabled);
411 custom_link_->set_listener(this); 412 custom_link_->set_listener(this);
412 if (!bubble_content_empty) 413 if (!bubble_content_empty)
413 layout->AddPaddingRow(0, related_control_vertical_spacing); 414 layout->AddPaddingRow(0, related_control_vertical_spacing);
414 layout->StartRow(0, kSingleColumnSetId); 415 layout->StartRow(0, kSingleColumnSetId);
415 layout->AddView(custom_link_); 416 layout->AddView(custom_link_);
416 bubble_content_empty = false; 417 bubble_content_empty = false;
417 } 418 }
418 419
420 if (content_setting_bubble_model_->bubble_content()
msw 2017/04/05 22:08:34 Use |bubble_content| here and below.
Charlie Harrison 2017/04/05 22:35:32 Done.
421 .show_manage_text_as_checkbox) {
422 manage_checkbox_ = new views::Checkbox(base::UTF8ToUTF16(
423 content_setting_bubble_model_->bubble_content().manage_text));
424 manage_checkbox_->set_listener(this);
425 layout->AddPaddingRow(0, related_control_vertical_spacing);
426 layout->StartRow(0, indented_kSingleColumnSetId);
427 layout->AddView(manage_checkbox_);
428 }
429
419 if (!bubble_content_empty) { 430 if (!bubble_content_empty) {
420 if (!layout_delegate->IsHarmonyMode()) { 431 if (!layout_delegate->IsHarmonyMode()) {
421 layout->AddPaddingRow(0, related_control_vertical_spacing); 432 layout->AddPaddingRow(0, related_control_vertical_spacing);
422 layout->StartRow(0, kSingleColumnSetId); 433 layout->StartRow(0, kSingleColumnSetId);
423 layout->AddView(new views::Separator(), 1, 1, GridLayout::FILL, 434 layout->AddView(new views::Separator(), 1, 1, GridLayout::FILL,
424 GridLayout::FILL); 435 GridLayout::FILL);
425 } 436 }
426 layout->AddPaddingRow(0, related_control_vertical_spacing); 437 layout->AddPaddingRow(0, related_control_vertical_spacing);
427 } 438 }
428 } 439 }
429 440
430 views::View* ContentSettingBubbleContents::CreateExtraView() { 441 views::View* ContentSettingBubbleContents::CreateExtraView() {
431 if (content_setting_bubble_model_->bubble_content() 442 if (content_setting_bubble_model_->bubble_content()
msw 2017/04/05 22:08:34 optional nit: make and use a local |bubble_content
Charlie Harrison 2017/04/05 22:35:32 Done.
432 .show_manage_text_as_button) { 443 .show_manage_text_as_button) {
433 manage_button_ = views::MdTextButton::CreateSecondaryUiButton( 444 manage_button_ = views::MdTextButton::CreateSecondaryUiButton(
434 this, base::UTF8ToUTF16( 445 this, base::UTF8ToUTF16(
435 content_setting_bubble_model_->bubble_content().manage_text)); 446 content_setting_bubble_model_->bubble_content().manage_text));
436 return manage_button_; 447 return manage_button_;
448 } else if (content_setting_bubble_model_->bubble_content()
msw 2017/04/05 22:08:34 No else after return here and below
Charlie Harrison 2017/04/05 22:35:32 Done.
449 .show_manage_text_as_checkbox) {
450 // Added as part of the primary view.
451 return nullptr;
437 } else { 452 } else {
438 manage_link_ = new views::Link(base::UTF8ToUTF16( 453 manage_link_ = new views::Link(base::UTF8ToUTF16(
439 content_setting_bubble_model_->bubble_content().manage_text)); 454 content_setting_bubble_model_->bubble_content().manage_text));
440 manage_link_->set_listener(this); 455 manage_link_->set_listener(this);
441 return manage_link_; 456 return manage_link_;
442 } 457 }
443 } 458 }
444 459
445 bool ContentSettingBubbleContents::Accept() { 460 bool ContentSettingBubbleContents::Accept() {
446 content_setting_bubble_model_->OnDoneClicked(); 461 content_setting_bubble_model_->OnDoneClicked();
447 return true; 462 return true;
448 } 463 }
449 464
450 bool ContentSettingBubbleContents::Close() { 465 bool ContentSettingBubbleContents::Close() {
451 return true; 466 return true;
452 } 467 }
453 468
454 int ContentSettingBubbleContents::GetDialogButtons() const { 469 int ContentSettingBubbleContents::GetDialogButtons() const {
455 return ui::DIALOG_BUTTON_OK; 470 return ui::DIALOG_BUTTON_OK;
456 } 471 }
457 472
458 base::string16 ContentSettingBubbleContents::GetDialogButtonLabel( 473 base::string16 ContentSettingBubbleContents::GetDialogButtonLabel(
459 ui::DialogButton button) const { 474 ui::DialogButton button) const {
475 base::string16 done_text =
msw 2017/04/05 22:08:34 const &
Charlie Harrison 2017/04/05 22:35:32 Done.
476 content_setting_bubble_model_->bubble_content().done_text;
477 if (!done_text.empty())
478 return done_text;
460 return l10n_util::GetStringUTF16(IDS_DONE); 479 return l10n_util::GetStringUTF16(IDS_DONE);
461 } 480 }
462 481
463 void ContentSettingBubbleContents::DidFinishNavigation( 482 void ContentSettingBubbleContents::DidFinishNavigation(
464 content::NavigationHandle* navigation_handle) { 483 content::NavigationHandle* navigation_handle) {
465 if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted()) 484 if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted())
466 return; 485 return;
467 486
468 // Content settings are based on the main frame, so if it switches then 487 // Content settings are based on the main frame, so if it switches then
469 // close up shop. 488 // close up shop.
470 GetWidget()->Close(); 489 GetWidget()->Close();
471 } 490 }
472 491
473 void ContentSettingBubbleContents::ButtonPressed(views::Button* sender, 492 void ContentSettingBubbleContents::ButtonPressed(views::Button* sender,
474 const ui::Event& event) { 493 const ui::Event& event) {
475 if (manage_button_ == sender) { 494 if (manage_button_ == sender) {
476 GetWidget()->Close(); 495 GetWidget()->Close();
477 content_setting_bubble_model_->OnManageLinkClicked(); 496 content_setting_bubble_model_->OnManageLinkClicked();
497 } else if (manage_checkbox_ == sender) {
498 content_setting_bubble_model_->OnChecked(manage_checkbox_->checked());
478 } else { 499 } else {
479 RadioGroup::const_iterator i( 500 RadioGroup::const_iterator i(
480 std::find(radio_group_.begin(), radio_group_.end(), sender)); 501 std::find(radio_group_.begin(), radio_group_.end(), sender));
481 DCHECK(i != radio_group_.end()); 502 DCHECK(i != radio_group_.end());
482 content_setting_bubble_model_->OnRadioClicked(i - radio_group_.begin()); 503 content_setting_bubble_model_->OnRadioClicked(i - radio_group_.begin());
483 } 504 }
484 } 505 }
485 506
486 void ContentSettingBubbleContents::LinkClicked(views::Link* source, 507 void ContentSettingBubbleContents::LinkClicked(views::Link* source,
487 int event_flags) { 508 int event_flags) {
(...skipping 19 matching lines...) Expand all
507 DCHECK(i != list_item_links_.end()); 528 DCHECK(i != list_item_links_.end());
508 content_setting_bubble_model_->OnListItemClicked(i->second); 529 content_setting_bubble_model_->OnListItemClicked(i->second);
509 } 530 }
510 531
511 void ContentSettingBubbleContents::OnPerformAction(views::Combobox* combobox) { 532 void ContentSettingBubbleContents::OnPerformAction(views::Combobox* combobox) {
512 MediaComboboxModel* model = 533 MediaComboboxModel* model =
513 static_cast<MediaComboboxModel*>(combobox->model()); 534 static_cast<MediaComboboxModel*>(combobox->model());
514 content_setting_bubble_model_->OnMediaMenuClicked( 535 content_setting_bubble_model_->OnMediaMenuClicked(
515 model->type(), model->GetDevices()[combobox->selected_index()].id); 536 model->type(), model->GetDevices()[combobox->selected_index()].id);
516 } 537 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698