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

Side by Side Diff: chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc

Issue 259153004: Password bubble: Give users the option of unblacklisting a site. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/passwords/manage_passwords_bubble_view.h" 5 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "chrome/browser/chrome_notification_types.h" 8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_finder.h" 10 #include "chrome/browser/ui/browser_finder.h"
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 parent_->Close(); 296 parent_->Close();
297 } 297 }
298 298
299 void ManagePasswordsBubbleView::ManageView::LinkClicked(views::Link* source, 299 void ManagePasswordsBubbleView::ManageView::LinkClicked(views::Link* source,
300 int event_flags) { 300 int event_flags) {
301 DCHECK_EQ(source, manage_link_); 301 DCHECK_EQ(source, manage_link_);
302 parent_->model()->OnManageLinkClicked(); 302 parent_->model()->OnManageLinkClicked();
303 parent_->Close(); 303 parent_->Close();
304 } 304 }
305 305
306 // ManagePasswordsBubbleView::BlacklistedView ---------------------------------
307
308 ManagePasswordsBubbleView::BlacklistedView::BlacklistedView(
309 ManagePasswordsBubbleView* parent)
310 : parent_(parent) {
311 views::GridLayout* layout = new views::GridLayout(this);
312 SetLayoutManager(layout);
313
314 // Add the title.
315 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET);
316 AddTitleRow(layout, parent_->model());
317
318 // Add the "Hey! You blacklisted this site!" text.
319 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET);
320 views::Label* blacklisted = new views::Label(
321 l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_BLACKLISTED));
322 blacklisted->SetMultiLine(true);
323 layout->AddView(blacklisted);
324
325 // Then add the "enable password manager" and "Done" buttons.
326 unblacklist_button_ = new views::BlueButton(
327 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_UNBLACKLIST_BUTTON));
328 done_button_ =
329 new views::LabelButton(this, l10n_util::GetStringUTF16(IDS_DONE));
330 done_button_->SetStyle(views::Button::STYLE_BUTTON);
331
332 BuildColumnSet(layout, DOUBLE_BUTTON_COLUMN_SET);
333 layout->StartRowWithPadding(
334 0, DOUBLE_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing);
335 layout->AddView(unblacklist_button_);
336 layout->AddView(done_button_);
337
338 // Extra padding for visual awesomeness.
339 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
340 }
341
342 ManagePasswordsBubbleView::BlacklistedView::~BlacklistedView() {
343 }
344
345 void ManagePasswordsBubbleView::BlacklistedView::ButtonPressed(
346 views::Button* sender,
347 const ui::Event& event) {
348 if (sender == done_button_)
349 parent_->model()->OnDoneClicked();
350 else if (sender == unblacklist_button_)
351 parent_->model()->OnUnblacklistClicked();
352 else
353 NOTREACHED();
354 parent_->Close();
355 }
306 356
307 // ManagePasswordsBubbleView -------------------------------------------------- 357 // ManagePasswordsBubbleView --------------------------------------------------
308 358
309 // static 359 // static
310 ManagePasswordsBubbleView* ManagePasswordsBubbleView::manage_passwords_bubble_ = 360 ManagePasswordsBubbleView* ManagePasswordsBubbleView::manage_passwords_bubble_ =
311 NULL; 361 NULL;
312 362
313 // static 363 // static
314 void ManagePasswordsBubbleView::ShowBubble(content::WebContents* web_contents, 364 void ManagePasswordsBubbleView::ShowBubble(content::WebContents* web_contents,
315 DisplayReason reason) { 365 DisplayReason reason) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 GetWidget()->Close(); 445 GetWidget()->Close();
396 } 446 }
397 447
398 void ManagePasswordsBubbleView::Init() { 448 void ManagePasswordsBubbleView::Init() {
399 views::FillLayout* layout = new views::FillLayout(); 449 views::FillLayout* layout = new views::FillLayout();
400 SetLayoutManager(layout); 450 SetLayoutManager(layout);
401 SetFocusable(true); 451 SetFocusable(true);
402 452
403 if (model()->WaitingToSavePassword()) 453 if (model()->WaitingToSavePassword())
404 AddChildView(new PendingView(this)); 454 AddChildView(new PendingView(this));
455 else if (model()->NeverSavingPasswords())
456 AddChildView(new BlacklistedView(this));
405 else 457 else
406 AddChildView(new ManageView(this)); 458 AddChildView(new ManageView(this));
407 } 459 }
408 460
409 void ManagePasswordsBubbleView::WindowClosing() { 461 void ManagePasswordsBubbleView::WindowClosing() {
410 // Close() closes the window asynchronously, so by the time we reach here, 462 // Close() closes the window asynchronously, so by the time we reach here,
411 // |manage_passwords_bubble_| may have already been reset. 463 // |manage_passwords_bubble_| may have already been reset.
412 if (manage_passwords_bubble_ == this) 464 if (manage_passwords_bubble_ == this)
413 manage_passwords_bubble_ = NULL; 465 manage_passwords_bubble_ = NULL;
414 } 466 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698