summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/ui')
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc5
-rw-r--r--chrome/browser/ui/views/password_generation_bubble_view.cc25
-rw-r--r--chrome/browser/ui/views/password_generation_bubble_view.h8
3 files changed, 34 insertions, 4 deletions
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index 615f495..09f410f 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -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);
@@ -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);
diff --git a/chrome/browser/ui/views/password_generation_bubble_view.cc b/chrome/browser/ui/views/password_generation_bubble_view.cc
index 1e82e3a..6800a99 100644
--- a/chrome/browser/ui/views/password_generation_bubble_view.cc
+++ b/chrome/browser/ui/views/password_generation_bubble_view.cc
@@ -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"
@@ -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() {}
@@ -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()));
@@ -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);
@@ -89,6 +106,7 @@ void PasswordGenerationBubbleView::Init() {
layout->StartRow(0, 1);
layout->AddView(text_field_);
+ layout->AddView(regenerate_button_);
layout->AddView(accept_button_);
}
@@ -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()));
}
}
diff --git a/chrome/browser/ui/views/password_generation_bubble_view.h b/chrome/browser/ui/views/password_generation_bubble_view.h
index 9fe5c7a6..7fbf214 100644
--- a/chrome/browser/ui/views/password_generation_bubble_view.h
+++ b/chrome/browser/ui/views/password_generation_bubble_view.h
@@ -24,6 +24,7 @@ class RenderViewHost;
}
namespace views {
+class ImageButton;
class TextButton;
class Textfield;
}
@@ -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:
@@ -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
@@ -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);
};