Commit eb06def3 authored by zysxqn@google.com's avatar zysxqn@google.com

Add a learn more link to password generation bubble to point to a help page.


BUG=120798
TEST=not tested


Review URL: http://codereview.chromium.org/10226009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134766 0039d316-1c4b-4281-b951-d872f2087c98
parent 6ecb0d97
......@@ -5,11 +5,19 @@
#include "chrome/browser/ui/gtk/password_generation_bubble_gtk.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/gtk/bubble/bubble_gtk.h"
#include "chrome/browser/ui/gtk/gtk_chrome_link_button.h"
#include "chrome/browser/ui/gtk/gtk_util.h"
#include "chrome/browser/ui/gtk/theme_service_gtk.h"
#include "chrome/common/autofill_messages.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "grit/generated_resources.h"
#include "ui/base/gtk/gtk_hig_constants.h"
#include "ui/base/l10n/l10n_util.h"
const int kContentBorder = 4;
const int kHorizontalSpacing = 4;
......@@ -19,15 +27,21 @@ PasswordGenerationBubbleGtk::PasswordGenerationBubbleGtk(
GtkWidget* anchor_widget,
Profile* profile,
content::RenderViewHost* render_view_host)
: render_view_host_(render_view_host) {
: profile_(profile), render_view_host_(render_view_host) {
// TODO(gcasto): Localize text after we have finalized the UI.
// crbug.com/118062
GtkWidget* content = gtk_vbox_new(FALSE, 5);
// We have two lines of content. The first is just the title,
// We have two lines of content. The first is the title and learn more link.
GtkWidget* title_line = gtk_hbox_new(FALSE, 0);
GtkWidget* title = gtk_label_new("Password Suggestion");
gtk_box_pack_start(GTK_BOX(title_line), title, FALSE, FALSE, 0);
GtkWidget* learn_more_link = gtk_chrome_link_button_new(
l10n_util::GetStringUTF8(IDS_LEARN_MORE).c_str());
gtk_button_set_alignment(GTK_BUTTON(learn_more_link), 0.0, 0.5);
gtk_box_pack_start(GTK_BOX(title_line),
gtk_util::IndentWidget(learn_more_link),
FALSE, FALSE, 0);
// The second contains the password in a text field and an accept button.
GtkWidget* password_line = gtk_hbox_new(FALSE, kHorizontalSpacing);
......@@ -49,13 +63,15 @@ PasswordGenerationBubbleGtk::PasswordGenerationBubbleGtk(
BubbleGtk::ARROW_LOCATION_TOP_LEFT,
true, // match_system_theme
true, // grab_input
ThemeServiceGtk::GetFrom(profile),
ThemeServiceGtk::GetFrom(profile_),
NULL); // delegate
g_signal_connect(content, "destroy",
G_CALLBACK(&OnDestroyThunk), this);
g_signal_connect(accept_button, "clicked",
G_CALLBACK(&OnAcceptClickedThunk), this);
g_signal_connect(learn_more_link, "clicked",
G_CALLBACK(OnLearnMoreLinkClickedThunk), this);
}
PasswordGenerationBubbleGtk::~PasswordGenerationBubbleGtk() {}
......@@ -72,3 +88,12 @@ void PasswordGenerationBubbleGtk::OnAcceptClicked(GtkWidget* widget) {
UTF8ToUTF16(gtk_entry_get_text(GTK_ENTRY(text_field_)))));
bubble_->Close();
}
void PasswordGenerationBubbleGtk::OnLearnMoreLinkClicked(GtkButton* button) {
Browser* browser = BrowserList::GetLastActiveWithProfile(profile_);
content::OpenURLParams params(
GURL(chrome::kAutoPasswordGenerationLearnMoreURL), content::Referrer(),
NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false);
browser->OpenURL(params);
bubble_->Close();
}
......@@ -34,9 +34,12 @@ class PasswordGenerationBubbleGtk {
private:
CHROMEGTK_CALLBACK_0(PasswordGenerationBubbleGtk, void, OnDestroy);
CHROMEGTK_CALLBACK_0(PasswordGenerationBubbleGtk, void, OnAcceptClicked);
CHROMEG_CALLBACK_0(
PasswordGenerationBubbleGtk, void, OnLearnMoreLinkClicked, GtkButton*);
BubbleGtk* bubble_;
GtkWidget* text_field_;
Profile* profile_;
// RenderViewHost associated with the button that spawned this bubble.
content::RenderViewHost* render_view_host_;
......
......@@ -264,6 +264,10 @@ const char kBluetoothAddDeviceSubPage[] = "bluetooth";
const char kSyncGoogleDashboardURL[] = "https://www.google.com/dashboard/";
const char kAutoPasswordGenerationLearnMoreURL[] =
"https://support.google.com/chrome/?hl=en&p=ui_generate_password";
const char kPasswordManagerLearnMoreURL[] =
#if defined(OS_CHROMEOS)
"https://support.google.com/chromeos/?p=settings_password";
......
......@@ -259,6 +259,9 @@ extern const char kBluetoothAddDeviceSubPage[];
extern const char kSyncGoogleDashboardURL[];
// "Learn more" URL for the auto password generation.
extern const char kAutoPasswordGenerationLearnMoreURL[];
extern const char kPasswordManagerLearnMoreURL[];
// General help link for Chrome.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment