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

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: Fixups. 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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 parent_->Close(); 270 parent_->Close();
271 } 271 }
272 272
273 void ManagePasswordsBubbleView::ManageView::LinkClicked(views::Link* source, 273 void ManagePasswordsBubbleView::ManageView::LinkClicked(views::Link* source,
274 int event_flags) { 274 int event_flags) {
275 DCHECK_EQ(source, manage_link_); 275 DCHECK_EQ(source, manage_link_);
276 parent_->model()->OnManageLinkClicked(); 276 parent_->model()->OnManageLinkClicked();
277 parent_->Close(); 277 parent_->Close();
278 } 278 }
279 279
280 // ManagePasswordsBubbleView::BlacklistedView ---------------------------------
281
282 ManagePasswordsBubbleView::BlacklistedView::BlacklistedView(
283 ManagePasswordsBubbleView* parent)
284 : parent_(parent) {
285 views::GridLayout* layout = new views::GridLayout(this);
286 SetLayoutManager(layout);
287
288 // Add the title.
289 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET);
290 AddTitleRow(layout, parent_->model());
291
292 // Add the "Hey! You blacklisted this site!" text.
293 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET);
294 views::Label* blacklisted = new views::Label(
295 l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_BLACKLISTED));
296 blacklisted->SetMultiLine(true);
297 layout->AddView(blacklisted);
298
299 // Then add the "enable password manager" and "Done" buttons.
300 unblacklist_button_ = new views::BlueButton(
301 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_UNBLACKLIST_BUTTON));
302 done_button_ =
303 new views::LabelButton(this, l10n_util::GetStringUTF16(IDS_DONE));
304 done_button_->SetStyle(views::Button::STYLE_BUTTON);
305
306 BuildColumnSet(layout, DOUBLE_BUTTON_COLUMN_SET);
307 layout->StartRowWithPadding(
308 0, DOUBLE_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing);
309 layout->AddView(unblacklist_button_);
310 layout->AddView(done_button_);
311
312 // Extra padding for visual awesomeness.
313 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
314 }
315
316 ManagePasswordsBubbleView::BlacklistedView::~BlacklistedView() {
317 }
318
319 void ManagePasswordsBubbleView::BlacklistedView::ButtonPressed(
320 views::Button* sender,
321 const ui::Event& event) {
322 if (sender == done_button_)
323 parent_->model()->OnDoneClicked();
324 else if (sender == unblacklist_button_)
325 parent_->model()->OnUnblacklistClicked();
326 else
327 NOTREACHED();
328 parent_->Close();
329 }
280 330
281 // ManagePasswordsBubbleView -------------------------------------------------- 331 // ManagePasswordsBubbleView --------------------------------------------------
282 332
283 // static 333 // static
284 ManagePasswordsBubbleView* ManagePasswordsBubbleView::manage_passwords_bubble_ = 334 ManagePasswordsBubbleView* ManagePasswordsBubbleView::manage_passwords_bubble_ =
285 NULL; 335 NULL;
286 336
287 // static 337 // static
288 void ManagePasswordsBubbleView::ShowBubble(content::WebContents* web_contents, 338 void ManagePasswordsBubbleView::ShowBubble(content::WebContents* web_contents,
289 DisplayReason reason) { 339 DisplayReason reason) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 GetWidget()->Close(); 419 GetWidget()->Close();
370 } 420 }
371 421
372 void ManagePasswordsBubbleView::Init() { 422 void ManagePasswordsBubbleView::Init() {
373 views::FillLayout* layout = new views::FillLayout(); 423 views::FillLayout* layout = new views::FillLayout();
374 SetLayoutManager(layout); 424 SetLayoutManager(layout);
375 SetFocusable(true); 425 SetFocusable(true);
376 426
377 if (model()->WaitingToSavePassword()) 427 if (model()->WaitingToSavePassword())
378 AddChildView(new PendingView(this)); 428 AddChildView(new PendingView(this));
429 else if (model()->NeverSavingPasswords())
430 AddChildView(new BlacklistedView(this));
379 else 431 else
380 AddChildView(new ManageView(this)); 432 AddChildView(new ManageView(this));
381 } 433 }
382 434
383 void ManagePasswordsBubbleView::WindowClosing() { 435 void ManagePasswordsBubbleView::WindowClosing() {
384 // Close() closes the window asynchronously, so by the time we reach here, 436 // Close() closes the window asynchronously, so by the time we reach here,
385 // |manage_passwords_bubble_| may have already been reset. 437 // |manage_passwords_bubble_| may have already been reset.
386 if (manage_passwords_bubble_ == this) 438 if (manage_passwords_bubble_ == this)
387 manage_passwords_bubble_ = NULL; 439 manage_passwords_bubble_ = NULL;
388 } 440 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698