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

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

Issue 23537029: Save password functionality added to the save password bubble (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review 1 Created 7 years, 3 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 // ContentSettingBubbleContents ----------------------------------------------- 139 // ContentSettingBubbleContents -----------------------------------------------
140 140
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 cancel_button_(NULL),
150 save_button_(NULL),
149 custom_link_(NULL), 151 custom_link_(NULL),
150 manage_link_(NULL), 152 manage_link_(NULL),
151 close_button_(NULL), 153 close_button_(NULL) {
152 never_button_(NULL),
153 save_button_(NULL) {
154 // Compensate for built-in vertical padding in the anchor view's image. 154 // Compensate for built-in vertical padding in the anchor view's image.
155 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0)); 155 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0));
156 156
157 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, 157 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
158 content::Source<WebContents>(web_contents)); 158 content::Source<WebContents>(web_contents));
159 } 159 }
160 160
161 ContentSettingBubbleContents::~ContentSettingBubbleContents() { 161 ContentSettingBubbleContents::~ContentSettingBubbleContents() {
162 STLDeleteValues(&media_menus_); 162 STLDeleteValues(&media_menus_);
163 } 163 }
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 } 384 }
385 385
386 if (!bubble_content_empty) { 386 if (!bubble_content_empty) {
387 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 387 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
388 layout->StartRow(0, kSingleColumnSetId); 388 layout->StartRow(0, kSingleColumnSetId);
389 layout->AddView(new views::Separator(views::Separator::HORIZONTAL), 1, 1, 389 layout->AddView(new views::Separator(views::Separator::HORIZONTAL), 1, 1,
390 GridLayout::FILL, GridLayout::FILL); 390 GridLayout::FILL, GridLayout::FILL);
391 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 391 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
392 } 392 }
393 393
394 if (content_setting_bubble_model_->content_type() == 394 const int kDoubleColumnSetId = 1;
395 views::ColumnSet* double_column_set =
396 layout->AddColumnSet(kDoubleColumnSetId);
397 if (content_setting_bubble_model_->content_type() !=
Peter Kasting 2013/09/10 23:04:41 Tiny nit: I think the original ordering of "== SAV
npentrel 2013/09/11 09:10:42 Done.
395 CONTENT_SETTINGS_TYPE_SAVE_PASSWORD) { 398 CONTENT_SETTINGS_TYPE_SAVE_PASSWORD) {
396 const int kDoubleColumnSetId = 2; 399 double_column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1,
397 views::ColumnSet* double_column_set = 400 GridLayout::USE_PREF, 0, 0);
398 layout->AddColumnSet(kDoubleColumnSetId); 401 double_column_set->AddPaddingColumn(
402 0, views::kUnrelatedControlHorizontalSpacing);
403 double_column_set->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 0,
404 GridLayout::USE_PREF, 0, 0);
405
406 layout->StartRow(0, kDoubleColumnSetId);
407 manage_link_ = new views::Link(UTF8ToUTF16(bubble_content.manage_link));
408 manage_link_->set_listener(this);
409 layout->AddView(manage_link_);
410
411 close_button_ =
412 new views::LabelButton(this, l10n_util::GetStringUTF16(IDS_DONE));
413 close_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON);
414 layout->AddView(close_button_);
415 } else {
399 double_column_set->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 1, 416 double_column_set->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 1,
400 GridLayout::USE_PREF, 0, 0); 417 GridLayout::USE_PREF, 0, 0);
401 double_column_set->AddPaddingColumn( 418 double_column_set->AddPaddingColumn(
402 0, views::kRelatedControlSmallVerticalSpacing); 419 0, views::kRelatedControlSmallVerticalSpacing);
403 double_column_set->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 0, 420 double_column_set->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 0,
404 GridLayout::USE_PREF, 0, 0); 421 GridLayout::USE_PREF, 0, 0);
405 422
406 const int kSingleColumnRightSetId = 1; 423 const int kSingleColumnRightSetId = 2;
407 views::ColumnSet* right_column_set = 424 views::ColumnSet* right_column_set =
408 layout->AddColumnSet(kSingleColumnRightSetId); 425 layout->AddColumnSet(kSingleColumnRightSetId);
409 right_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, 426 right_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1,
410 GridLayout::USE_PREF, 0, 0); 427 GridLayout::USE_PREF, 0, 0);
411 428
412 never_button_ = new views::LabelButton( 429 cancel_button_ = new views::LabelButton(
413 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_BLACKLIST_BUTTON)); 430 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_BLACKLIST_BUTTON));
414 never_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); 431 cancel_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON);
415 save_button_ = new views::LabelButton( 432 save_button_ = new views::LabelButton(
416 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON)); 433 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON));
417 save_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); 434 save_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON);
418 manage_link_ = new views::Link(UTF8ToUTF16(bubble_content.manage_link)); 435 manage_link_ = new views::Link(UTF8ToUTF16(bubble_content.manage_link));
419 manage_link_->set_listener(this); 436 manage_link_->set_listener(this);
420 437
421 // Buttons row
422 layout->StartRow(0, kDoubleColumnSetId); 438 layout->StartRow(0, kDoubleColumnSetId);
423 layout->AddView(never_button_); 439 layout->AddView(cancel_button_);
424 layout->AddView(save_button_); 440 layout->AddView(save_button_);
425 441
426 // Manage link row
427 layout->StartRow(0, kSingleColumnRightSetId); 442 layout->StartRow(0, kSingleColumnRightSetId);
428 layout->AddView(manage_link_); 443 layout->AddView(manage_link_);
429 } else {
430 const int kDoubleColumnSetId = 1;
431 views::ColumnSet* double_column_set =
432 layout->AddColumnSet(kDoubleColumnSetId);
433 double_column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1,
434 GridLayout::USE_PREF, 0, 0);
435 double_column_set->AddPaddingColumn(
436 0, views::kUnrelatedControlHorizontalSpacing);
437 double_column_set->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 0,
438 GridLayout::USE_PREF, 0, 0);
439
440 layout->StartRow(0, kDoubleColumnSetId);
441 manage_link_ = new views::Link(UTF8ToUTF16(bubble_content.manage_link));
442 manage_link_->set_listener(this);
443 layout->AddView(manage_link_);
444
445 close_button_ =
446 new views::LabelButton(this, l10n_util::GetStringUTF16(IDS_DONE));
447 close_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON);
448 layout->AddView(close_button_);
449 } 444 }
450 } 445 }
451 446
452 void ContentSettingBubbleContents::ButtonPressed(views::Button* sender, 447 void ContentSettingBubbleContents::ButtonPressed(views::Button* sender,
453 const ui::Event& event) { 448 const ui::Event& event) {
454 if (sender == save_button_) { 449 RadioGroup::const_iterator i(
455 content_setting_bubble_model_->OnSaveClicked(); 450 std::find(radio_group_.begin(), radio_group_.end(), sender));
456 StartFade(false); 451 if (i != radio_group_.end()) {
457 return; 452 content_setting_bubble_model_->OnRadioClicked(i - radio_group_.begin());
458 }
459 if (sender == never_button_) {
460 content_setting_bubble_model_->OnCancelClicked();
461 StartFade(false);
462 return;
463 }
464 if (sender == close_button_) {
465 content_setting_bubble_model_->OnDoneClicked();
466 StartFade(false);
467 return; 453 return;
468 } 454 }
469 455
470 for (RadioGroup::const_iterator i(radio_group_.begin()); 456 if (sender == save_button_)
471 i != radio_group_.end(); ++i) { 457 content_setting_bubble_model_->OnSaveClicked();
472 if (sender == *i) { 458 else if (sender == cancel_button_)
473 content_setting_bubble_model_->OnRadioClicked(i - radio_group_.begin()); 459 content_setting_bubble_model_->OnCancelClicked();
474 return; 460 else if (sender == close_button_)
475 } 461 content_setting_bubble_model_->OnDoneClicked();
476 } 462 else
477 NOTREACHED() << "unknown radio"; 463 NOTREACHED() << "unknown radio";
Peter Kasting 2013/09/10 23:04:41 Nit: Remove this comment, which is not necessarily
npentrel 2013/09/11 09:10:42 Done.
464
Peter Kasting 2013/09/10 23:04:41 Tiny nit: I'd probably remove this blank line
npentrel 2013/09/11 09:10:42 Done.
465 StartFade(false);
478 } 466 }
479 467
480 void ContentSettingBubbleContents::LinkClicked(views::Link* source, 468 void ContentSettingBubbleContents::LinkClicked(views::Link* source,
481 int event_flags) { 469 int event_flags) {
482 if (source == custom_link_) { 470 if (source == custom_link_) {
483 content_setting_bubble_model_->OnCustomLinkClicked(); 471 content_setting_bubble_model_->OnCustomLinkClicked();
484 StartFade(false); 472 StartFade(false);
485 return; 473 return;
486 } 474 }
487 if (source == manage_link_) { 475 if (source == manage_link_) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 int width = button->GetPreferredSize().width(); 522 int width = button->GetPreferredSize().width();
535 for (int i = 0; i < menu_model->GetItemCount(); ++i) { 523 for (int i = 0; i < menu_model->GetItemCount(); ++i) {
536 button->SetText(menu_model->GetLabelAt(i)); 524 button->SetText(menu_model->GetLabelAt(i));
537 width = std::max(width, button->GetPreferredSize().width()); 525 width = std::max(width, button->GetPreferredSize().width());
538 } 526 }
539 527
540 // Recover the title for the menu button. 528 // Recover the title for the menu button.
541 button->SetText(title); 529 button->SetText(title);
542 return width; 530 return width;
543 } 531 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698