| 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 ContentSettingBubbleContents::ContentSettingBubbleContents( | 141 ContentSettingBubbleContents::ContentSettingBubbleContents( |
| 142 ContentSettingBubbleModel* content_setting_bubble_model, | 142 ContentSettingBubbleModel* content_setting_bubble_model, |
| 143 WebContents* web_contents, | 143 WebContents* web_contents, |
| 144 views::View* anchor_view, | 144 views::View* anchor_view, |
| 145 views::BubbleBorder::Arrow arrow) | 145 views::BubbleBorder::Arrow arrow) |
| 146 : BubbleDelegateView(anchor_view, arrow), | 146 : BubbleDelegateView(anchor_view, arrow), |
| 147 content_setting_bubble_model_(content_setting_bubble_model), | 147 content_setting_bubble_model_(content_setting_bubble_model), |
| 148 web_contents_(web_contents), | 148 web_contents_(web_contents), |
| 149 custom_link_(NULL), | 149 custom_link_(NULL), |
| 150 manage_link_(NULL), | 150 manage_link_(NULL), |
| 151 close_button_(NULL), | 151 close_button_(NULL) { |
| 152 never_button_(NULL), | |
| 153 save_button_(NULL) { | |
| 154 // Compensate for built-in vertical padding in the anchor view's image. | 152 // Compensate for built-in vertical padding in the anchor view's image. |
| 155 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0)); | 153 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0)); |
| 156 | 154 |
| 157 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 155 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| 158 content::Source<WebContents>(web_contents)); | 156 content::Source<WebContents>(web_contents)); |
| 159 } | 157 } |
| 160 | 158 |
| 161 ContentSettingBubbleContents::~ContentSettingBubbleContents() { | 159 ContentSettingBubbleContents::~ContentSettingBubbleContents() { |
| 162 STLDeleteValues(&media_menus_); | 160 STLDeleteValues(&media_menus_); |
| 163 } | 161 } |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 } | 382 } |
| 385 | 383 |
| 386 if (!bubble_content_empty) { | 384 if (!bubble_content_empty) { |
| 387 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 385 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 388 layout->StartRow(0, kSingleColumnSetId); | 386 layout->StartRow(0, kSingleColumnSetId); |
| 389 layout->AddView(new views::Separator(views::Separator::HORIZONTAL), 1, 1, | 387 layout->AddView(new views::Separator(views::Separator::HORIZONTAL), 1, 1, |
| 390 GridLayout::FILL, GridLayout::FILL); | 388 GridLayout::FILL, GridLayout::FILL); |
| 391 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 389 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 392 } | 390 } |
| 393 | 391 |
| 394 const int kDoubleColumnSetId = 2; | 392 const int kDoubleColumnSetId = 1; |
| 395 if (content_setting_bubble_model_->content_type() == | 393 views::ColumnSet* double_column_set = |
| 394 layout->AddColumnSet(kDoubleColumnSetId); |
| 395 double_column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1, |
| 396 GridLayout::USE_PREF, 0, 0); |
| 397 double_column_set->AddPaddingColumn( |
| 398 0, views::kUnrelatedControlHorizontalSpacing); |
| 399 double_column_set->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 0, |
| 400 GridLayout::USE_PREF, 0, 0); |
| 401 |
| 402 layout->StartRow(0, kDoubleColumnSetId); |
| 403 manage_link_ = new views::Link(UTF8ToUTF16(bubble_content.manage_link)); |
| 404 manage_link_->set_listener(this); |
| 405 layout->AddView(manage_link_); |
| 406 if (content_setting_bubble_model_->content_type() != |
| 396 CONTENT_SETTINGS_TYPE_SAVE_PASSWORD) { | 407 CONTENT_SETTINGS_TYPE_SAVE_PASSWORD) { |
| 397 views::ColumnSet* double_column_set = | |
| 398 layout->AddColumnSet(kDoubleColumnSetId); | |
| 399 double_column_set->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 1, | |
| 400 GridLayout::USE_PREF, 0, 0); | |
| 401 double_column_set->AddPaddingColumn( | |
| 402 0, views::kRelatedControlSmallVerticalSpacing); | |
| 403 double_column_set->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 0, | |
| 404 GridLayout::USE_PREF, 0, 0); | |
| 405 | |
| 406 const int kSingleColumnRightSetId = 1; | |
| 407 views::ColumnSet* right_column_set = | |
| 408 layout->AddColumnSet(kSingleColumnRightSetId); | |
| 409 right_column_set->AddColumn(GridLayout::TRAILING, GridLayout::FILL, 1, | |
| 410 GridLayout::USE_PREF, 0, 0); | |
| 411 | |
| 412 never_button_ = new views::LabelButton( | |
| 413 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_BLACKLIST_BUTTON)); | |
| 414 never_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | |
| 415 save_button_ = new views::LabelButton( | |
| 416 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON)); | |
| 417 save_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | |
| 418 manage_link_ = new views::Link(UTF8ToUTF16(bubble_content.manage_link)); | |
| 419 manage_link_->set_listener(this); | |
| 420 | |
| 421 // Buttons row | |
| 422 layout->StartRow(0, kDoubleColumnSetId); | |
| 423 layout->AddView(never_button_); | |
| 424 layout->AddView(save_button_); | |
| 425 | |
| 426 // Manage link row | |
| 427 layout->StartRow(0, kSingleColumnRightSetId); | |
| 428 layout->AddView(manage_link_); | |
| 429 } else { | |
| 430 views::ColumnSet* double_column_set = | |
| 431 layout->AddColumnSet(kDoubleColumnSetId); | |
| 432 double_column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1, | |
| 433 GridLayout::USE_PREF, 0, 0); | |
| 434 double_column_set->AddPaddingColumn( | |
| 435 0, views::kUnrelatedControlHorizontalSpacing); | |
| 436 double_column_set->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 0, | |
| 437 GridLayout::USE_PREF, 0, 0); | |
| 438 | |
| 439 layout->StartRow(0, kDoubleColumnSetId); | |
| 440 manage_link_ = new views::Link(UTF8ToUTF16(bubble_content.manage_link)); | |
| 441 manage_link_->set_listener(this); | |
| 442 layout->AddView(manage_link_); | |
| 443 | |
| 444 close_button_ = | 408 close_button_ = |
| 445 new views::LabelButton(this, l10n_util::GetStringUTF16(IDS_DONE)); | 409 new views::LabelButton(this, l10n_util::GetStringUTF16(IDS_DONE)); |
| 446 close_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | 410 close_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); |
| 447 layout->AddView(close_button_); | 411 layout->AddView(close_button_); |
| 448 } | 412 } |
| 449 } | 413 } |
| 450 | 414 |
| 451 void ContentSettingBubbleContents::ButtonPressed(views::Button* sender, | 415 void ContentSettingBubbleContents::ButtonPressed(views::Button* sender, |
| 452 const ui::Event& event) { | 416 const ui::Event& event) { |
| 453 if (sender == save_button_) { | |
| 454 content_setting_bubble_model_->OnSaveClicked(); | |
| 455 StartFade(false); | |
| 456 return; | |
| 457 } | |
| 458 if (sender == never_button_) { | |
| 459 content_setting_bubble_model_->OnCancelClicked(); | |
| 460 StartFade(false); | |
| 461 return; | |
| 462 } | |
| 463 if (sender == close_button_) { | 417 if (sender == close_button_) { |
| 464 content_setting_bubble_model_->OnDoneClicked(); | 418 content_setting_bubble_model_->OnDoneClicked(); |
| 465 StartFade(false); | 419 StartFade(false); |
| 466 return; | 420 return; |
| 467 } | 421 } |
| 468 | 422 |
| 469 for (RadioGroup::const_iterator i(radio_group_.begin()); | 423 for (RadioGroup::const_iterator i(radio_group_.begin()); |
| 470 i != radio_group_.end(); ++i) { | 424 i != radio_group_.end(); ++i) { |
| 471 if (sender == *i) { | 425 if (sender == *i) { |
| 472 content_setting_bubble_model_->OnRadioClicked(i - radio_group_.begin()); | 426 content_setting_bubble_model_->OnRadioClicked(i - radio_group_.begin()); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 int width = button->GetPreferredSize().width(); | 487 int width = button->GetPreferredSize().width(); |
| 534 for (int i = 0; i < menu_model->GetItemCount(); ++i) { | 488 for (int i = 0; i < menu_model->GetItemCount(); ++i) { |
| 535 button->SetText(menu_model->GetLabelAt(i)); | 489 button->SetText(menu_model->GetLabelAt(i)); |
| 536 width = std::max(width, button->GetPreferredSize().width()); | 490 width = std::max(width, button->GetPreferredSize().width()); |
| 537 } | 491 } |
| 538 | 492 |
| 539 // Recover the title for the menu button. | 493 // Recover the title for the menu button. |
| 540 button->SetText(title); | 494 button->SetText(title); |
| 541 return width; | 495 return width; |
| 542 } | 496 } |
| OLD | NEW |