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

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

Issue 22975006: Save password functionality added to the save password bubble (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor changes 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) {
152 // 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.
153 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0)); 155 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0));
154 156
155 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, 157 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
156 content::Source<WebContents>(web_contents)); 158 content::Source<WebContents>(web_contents));
157 } 159 }
158 160
159 ContentSettingBubbleContents::~ContentSettingBubbleContents() { 161 ContentSettingBubbleContents::~ContentSettingBubbleContents() {
160 STLDeleteValues(&media_menus_); 162 STLDeleteValues(&media_menus_);
161 } 163 }
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 393
392 const int kDoubleColumnSetId = 1; 394 const int kDoubleColumnSetId = 1;
393 views::ColumnSet* double_column_set = 395 views::ColumnSet* double_column_set =
394 layout->AddColumnSet(kDoubleColumnSetId); 396 layout->AddColumnSet(kDoubleColumnSetId);
395 double_column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1, 397 double_column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1,
396 GridLayout::USE_PREF, 0, 0); 398 GridLayout::USE_PREF, 0, 0);
397 double_column_set->AddPaddingColumn( 399 double_column_set->AddPaddingColumn(
398 0, views::kUnrelatedControlHorizontalSpacing); 400 0, views::kUnrelatedControlHorizontalSpacing);
399 double_column_set->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 0, 401 double_column_set->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 0,
400 GridLayout::USE_PREF, 0, 0); 402 GridLayout::USE_PREF, 0, 0);
401 403 if (content_setting_bubble_model_->content_type() ==
404 CONTENT_SETTINGS_TYPE_SAVE_PASSWORD) {
405 layout->StartRow(0, kDoubleColumnSetId);
406 never_button_ = new views::LabelButton(
407 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_BLACKLIST_BUTTON));
408 never_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON);
409 layout->AddView(never_button_);
410 save_button_ = new views::LabelButton(
411 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON));
412 save_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON);
413 layout->AddView(save_button_);
414 }
402 layout->StartRow(0, kDoubleColumnSetId); 415 layout->StartRow(0, kDoubleColumnSetId);
403 manage_link_ = new views::Link(UTF8ToUTF16(bubble_content.manage_link)); 416 manage_link_ = new views::Link(UTF8ToUTF16(bubble_content.manage_link));
404 manage_link_->set_listener(this); 417 manage_link_->set_listener(this);
405 layout->AddView(manage_link_); 418 layout->AddView(manage_link_);
406 if (content_setting_bubble_model_->content_type() != 419 if (content_setting_bubble_model_->content_type() !=
407 CONTENT_SETTINGS_TYPE_SAVE_PASSWORD) { 420 CONTENT_SETTINGS_TYPE_SAVE_PASSWORD) {
408 close_button_ = 421 close_button_ =
409 new views::LabelButton(this, l10n_util::GetStringUTF16(IDS_DONE)); 422 new views::LabelButton(this, l10n_util::GetStringUTF16(IDS_DONE));
410 close_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); 423 close_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON);
411 layout->AddView(close_button_); 424 layout->AddView(close_button_);
412 } 425 }
413 } 426 }
414 427
415 void ContentSettingBubbleContents::ButtonPressed(views::Button* sender, 428 void ContentSettingBubbleContents::ButtonPressed(views::Button* sender,
416 const ui::Event& event) { 429 const ui::Event& event) {
430 if (sender == save_button_) {
431 content_setting_bubble_model_->OnSaveClicked();
432 StartFade(false);
433 return;
434 }
435 if (sender == never_button_) {
436 content_setting_bubble_model_->OnCancelClicked();
437 StartFade(false);
438 return;
439 }
417 if (sender == close_button_) { 440 if (sender == close_button_) {
418 content_setting_bubble_model_->OnDoneClicked(); 441 content_setting_bubble_model_->OnDoneClicked();
419 StartFade(false); 442 StartFade(false);
420 return; 443 return;
421 } 444 }
422 445
423 for (RadioGroup::const_iterator i(radio_group_.begin()); 446 for (RadioGroup::const_iterator i(radio_group_.begin());
424 i != radio_group_.end(); ++i) { 447 i != radio_group_.end(); ++i) {
425 if (sender == *i) { 448 if (sender == *i) {
426 content_setting_bubble_model_->OnRadioClicked(i - radio_group_.begin()); 449 content_setting_bubble_model_->OnRadioClicked(i - radio_group_.begin());
427 return; 450 return;
428 } 451 }
429 } 452 }
430 NOTREACHED() << "unknown radio"; 453 NOTREACHED() << "unknown radio";
431 } 454 }
432 455
456 bool ContentSettingBubbleContents::Accept() {
457 return true;
458 }
459
460 bool ContentSettingBubbleContents::Cancel() {
461 return true;
462 }
463
433 void ContentSettingBubbleContents::LinkClicked(views::Link* source, 464 void ContentSettingBubbleContents::LinkClicked(views::Link* source,
434 int event_flags) { 465 int event_flags) {
435 if (source == custom_link_) { 466 if (source == custom_link_) {
436 content_setting_bubble_model_->OnCustomLinkClicked(); 467 content_setting_bubble_model_->OnCustomLinkClicked();
437 StartFade(false); 468 StartFade(false);
438 return; 469 return;
439 } 470 }
440 if (source == manage_link_) { 471 if (source == manage_link_) {
441 StartFade(false); 472 StartFade(false);
442 content_setting_bubble_model_->OnManageLinkClicked(); 473 content_setting_bubble_model_->OnManageLinkClicked();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 int width = button->GetPreferredSize().width(); 518 int width = button->GetPreferredSize().width();
488 for (int i = 0; i < menu_model->GetItemCount(); ++i) { 519 for (int i = 0; i < menu_model->GetItemCount(); ++i) {
489 button->SetText(menu_model->GetLabelAt(i)); 520 button->SetText(menu_model->GetLabelAt(i));
490 width = std::max(width, button->GetPreferredSize().width()); 521 width = std::max(width, button->GetPreferredSize().width());
491 } 522 }
492 523
493 // Recover the title for the menu button. 524 // Recover the title for the menu button.
494 button->SetText(title); 525 button->SetText(title);
495 return width; 526 return width;
496 } 527 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698