Skip to content

Commit

Permalink
Add a regenerate button to regenerate the password in Windows.
Browse files Browse the repository at this point in the history
BUG=120480
TEST=Not tested.


Review URL: https://chromiumcodereview.appspot.com/10642009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144071 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
zysxqn@google.com committed Jun 26, 2012
1 parent 2be6abf commit 5eff57e
Show file tree
Hide file tree
Showing 55 changed files with 34 additions and 6,986 deletions.
5 changes: 4 additions & 1 deletion chrome/browser/ui/views/frame/browser_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2487,6 +2487,8 @@ void BrowserView::ShowPasswordGenerationBubble(
const gfx::Rect& rect,
autofill::PasswordGenerator* password_generator,
const webkit::forms::PasswordForm& form) {
ui::ThemeProvider* theme_provider = GetWidget()->GetThemeProvider();

// Create a rect in the content bounds that the bubble will point to.
gfx::Point origin(rect.origin());
views::View::ConvertPointToScreen(GetTabContentsContainerView(), &origin);
Expand All @@ -2505,7 +2507,8 @@ void BrowserView::ShowPasswordGenerationBubble(
tab_contents->web_contents()->GetRenderViewHost(),
password_generator,
browser_.get(),
tab_contents->password_manager());
tab_contents->password_manager(),
theme_provider);

views::BubbleDelegateView::CreateBubble(bubble);
bubble->SetAlignment(views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR);
Expand Down
25 changes: 23 additions & 2 deletions chrome/browser/ui/views/password_generation_bubble_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
#include "content/public/browser/render_view_host.h"
#include "googleurl/src/gurl.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources_standard.h"
#include "ui/base/theme_provider.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/button/text_button.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/link.h"
Expand All @@ -33,16 +36,19 @@ PasswordGenerationBubbleView::PasswordGenerationBubbleView(
content::RenderViewHost* render_view_host,
autofill::PasswordGenerator* password_generator,
content::PageNavigator* navigator,
PasswordManager* password_manager)
PasswordManager* password_manager,
ui::ThemeProvider* theme_provider)
: BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT),
accept_button_(NULL),
regenerate_button_(NULL),
text_field_(NULL),
anchor_rect_(anchor_rect),
form_(form),
render_view_host_(render_view_host),
password_generator_(password_generator),
navigator_(navigator),
password_manager_(password_manager) {}
password_manager_(password_manager),
theme_provider_(theme_provider) {}

PasswordGenerationBubbleView::~PasswordGenerationBubbleView() {}

Expand All @@ -52,6 +58,15 @@ void PasswordGenerationBubbleView::Init() {
accept_button_ = new views::NativeTextButton(this,
ASCIIToUTF16("Try It"));

regenerate_button_ = new views::ImageButton(this);
regenerate_button_->SetImage(views::CustomButton::BS_NORMAL,
theme_provider_->GetImageSkiaNamed(IDR_RELOAD));
regenerate_button_->SetImage(views::CustomButton::BS_HOT,
theme_provider_->GetImageSkiaNamed(IDR_RELOAD_H));
regenerate_button_->SetImage(views::CustomButton::BS_PUSHED,
theme_provider_->GetImageSkiaNamed(IDR_RELOAD_P));
regenerate_button_->SetTooltipText(ASCIIToUTF16("Regenerate"));

text_field_ = new views::Textfield();
text_field_->SetText(
ASCIIToUTF16(password_generator_->Generate()));
Expand Down Expand Up @@ -79,6 +94,8 @@ void PasswordGenerationBubbleView::Init() {
cs = layout->AddColumnSet(1);
cs->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0,
GridLayout::USE_PREF, 0, 100);
cs->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0, GridLayout::FIXED,
regenerate_button_->GetPreferredSize().width(), 100);
cs->AddPaddingColumn(1, views::kRelatedControlHorizontalSpacing);
cs->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 0,
GridLayout::USE_PREF, 0, 0);
Expand All @@ -89,6 +106,7 @@ void PasswordGenerationBubbleView::Init() {

layout->StartRow(0, 1);
layout->AddView(text_field_);
layout->AddView(regenerate_button_);
layout->AddView(accept_button_);
}

Expand All @@ -103,6 +121,9 @@ void PasswordGenerationBubbleView::ButtonPressed(views::Button* sender,
render_view_host_->GetRoutingID(), text_field_->text()));
password_manager_->SetFormHasGeneratedPassword(form_);
StartFade(false);
} else if (sender == regenerate_button_) {
text_field_->SetText(
ASCIIToUTF16(password_generator_->Generate()));
}
}

Expand Down
8 changes: 7 additions & 1 deletion chrome/browser/ui/views/password_generation_bubble_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class RenderViewHost;
}

namespace views {
class ImageButton;
class TextButton;
class Textfield;
}
Expand All @@ -44,7 +45,8 @@ class PasswordGenerationBubbleView : public views::BubbleDelegateView,
content::RenderViewHost* render_view_host,
autofill::PasswordGenerator* password_generator,
content::PageNavigator* navigator,
PasswordManager* password_manager);
PasswordManager* password_manager,
ui::ThemeProvider* theme_provider);
virtual ~PasswordGenerationBubbleView();

private:
Expand All @@ -64,6 +66,7 @@ class PasswordGenerationBubbleView : public views::BubbleDelegateView,

// Subviews
views::TextButton* accept_button_;
views::ImageButton* regenerate_button_;
views::Textfield* text_field_;

// Location that the bubble points to
Expand All @@ -85,6 +88,9 @@ class PasswordGenerationBubbleView : public views::BubbleDelegateView,
// PasswordManager associated with this tab.
PasswordManager* password_manager_;

// Theme provider used to draw the regenerate button.
ui::ThemeProvider* theme_provider_;

DISALLOW_COPY_AND_ASSIGN(PasswordGenerationBubbleView);
};

Expand Down
70 changes: 0 additions & 70 deletions rlz/DEPS

This file was deleted.

4 changes: 0 additions & 4 deletions rlz/OWNERS

This file was deleted.

15 changes: 0 additions & 15 deletions rlz/lib/assert.cc

This file was deleted.

53 changes: 0 additions & 53 deletions rlz/lib/assert.h

This file was deleted.

17 changes: 0 additions & 17 deletions rlz/lib/crc32.h

This file was deleted.

52 changes: 0 additions & 52 deletions rlz/lib/crc32_unittest.cc

This file was deleted.

36 changes: 0 additions & 36 deletions rlz/lib/crc32_wrapper.cc

This file was deleted.

Loading

0 comments on commit 5eff57e

Please sign in to comment.