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

Side by Side Diff: chrome/browser/ui/gtk/password_generation_bubble_gtk.cc

Issue 10226009: Add a learn more link to password generation bubble to point to a help page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make some changes according to review comments. Created 8 years, 8 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
« no previous file with comments | « chrome/browser/ui/gtk/password_generation_bubble_gtk.h ('k') | chrome/common/url_constants.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/gtk/password_generation_bubble_gtk.h" 5 #include "chrome/browser/ui/gtk/password_generation_bubble_gtk.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_list.h"
8 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" 10 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h"
11 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h"
12 #include "chrome/browser/ui/gtk/gtk_util.h"
9 #include "chrome/browser/ui/gtk/theme_service_gtk.h" 13 #include "chrome/browser/ui/gtk/theme_service_gtk.h"
10 #include "chrome/common/autofill_messages.h" 14 #include "chrome/common/autofill_messages.h"
15 #include "chrome/common/url_constants.h"
11 #include "content/public/browser/render_view_host.h" 16 #include "content/public/browser/render_view_host.h"
17 #include "content/public/browser/web_contents.h"
18 #include "grit/generated_resources.h"
12 #include "ui/base/gtk/gtk_hig_constants.h" 19 #include "ui/base/gtk/gtk_hig_constants.h"
20 #include "ui/base/l10n/l10n_util.h"
13 21
14 const int kContentBorder = 4; 22 const int kContentBorder = 4;
15 const int kHorizontalSpacing = 4; 23 const int kHorizontalSpacing = 4;
16 24
17 PasswordGenerationBubbleGtk::PasswordGenerationBubbleGtk( 25 PasswordGenerationBubbleGtk::PasswordGenerationBubbleGtk(
18 const gfx::Rect& anchor_rect, 26 const gfx::Rect& anchor_rect,
19 GtkWidget* anchor_widget, 27 GtkWidget* anchor_widget,
20 Profile* profile, 28 Profile* profile,
21 content::RenderViewHost* render_view_host) 29 content::RenderViewHost* render_view_host)
22 : render_view_host_(render_view_host) { 30 : profile_(profile), render_view_host_(render_view_host) {
23 // TODO(gcasto): Localize text after we have finalized the UI. 31 // TODO(gcasto): Localize text after we have finalized the UI.
24 // crbug.com/118062 32 // crbug.com/118062
25 GtkWidget* content = gtk_vbox_new(FALSE, 5); 33 GtkWidget* content = gtk_vbox_new(FALSE, 5);
26 34
27 // We have two lines of content. The first is just the title, 35 // We have two lines of content. The first is the title and learn more link.
28 GtkWidget* title_line = gtk_hbox_new(FALSE, 0); 36 GtkWidget* title_line = gtk_hbox_new(FALSE, 0);
29 GtkWidget* title = gtk_label_new("Password Suggestion"); 37 GtkWidget* title = gtk_label_new("Password Suggestion");
30 gtk_box_pack_start(GTK_BOX(title_line), title, FALSE, FALSE, 0); 38 gtk_box_pack_start(GTK_BOX(title_line), title, FALSE, FALSE, 0);
39 GtkWidget* learn_more_link = gtk_chrome_link_button_new(
40 l10n_util::GetStringUTF8(IDS_LEARN_MORE).c_str());
41 gtk_button_set_alignment(GTK_BUTTON(learn_more_link), 0.0, 0.5);
42 gtk_box_pack_start(GTK_BOX(title_line),
43 gtk_util::IndentWidget(learn_more_link),
44 FALSE, FALSE, 0);
31 45
32 // The second contains the password in a text field and an accept button. 46 // The second contains the password in a text field and an accept button.
33 GtkWidget* password_line = gtk_hbox_new(FALSE, kHorizontalSpacing); 47 GtkWidget* password_line = gtk_hbox_new(FALSE, kHorizontalSpacing);
34 text_field_ = gtk_entry_new(); 48 text_field_ = gtk_entry_new();
35 gtk_entry_set_text(GTK_ENTRY(text_field_), 49 gtk_entry_set_text(GTK_ENTRY(text_field_),
36 password_generator_.Generate().c_str()); 50 password_generator_.Generate().c_str());
37 gtk_entry_set_max_length(GTK_ENTRY(text_field_), 15); 51 gtk_entry_set_max_length(GTK_ENTRY(text_field_), 15);
38 GtkWidget* accept_button = gtk_button_new_with_label("Try It"); 52 GtkWidget* accept_button = gtk_button_new_with_label("Try It");
39 gtk_box_pack_start(GTK_BOX(password_line), text_field_, TRUE, TRUE, 0); 53 gtk_box_pack_start(GTK_BOX(password_line), text_field_, TRUE, TRUE, 0);
40 gtk_box_pack_start(GTK_BOX(password_line), accept_button, TRUE, TRUE, 0); 54 gtk_box_pack_start(GTK_BOX(password_line), accept_button, TRUE, TRUE, 0);
41 55
42 gtk_container_set_border_width(GTK_CONTAINER(content), kContentBorder); 56 gtk_container_set_border_width(GTK_CONTAINER(content), kContentBorder);
43 gtk_box_pack_start(GTK_BOX(content), title_line, TRUE, TRUE, 0); 57 gtk_box_pack_start(GTK_BOX(content), title_line, TRUE, TRUE, 0);
44 gtk_box_pack_start(GTK_BOX(content), password_line, TRUE, TRUE, 0); 58 gtk_box_pack_start(GTK_BOX(content), password_line, TRUE, TRUE, 0);
45 59
46 bubble_ = BubbleGtk::Show(anchor_widget, 60 bubble_ = BubbleGtk::Show(anchor_widget,
47 &anchor_rect, 61 &anchor_rect,
48 content, 62 content,
49 BubbleGtk::ARROW_LOCATION_TOP_LEFT, 63 BubbleGtk::ARROW_LOCATION_TOP_LEFT,
50 true, // match_system_theme 64 true, // match_system_theme
51 true, // grab_input 65 true, // grab_input
52 ThemeServiceGtk::GetFrom(profile), 66 ThemeServiceGtk::GetFrom(profile_),
53 NULL); // delegate 67 NULL); // delegate
54 68
55 g_signal_connect(content, "destroy", 69 g_signal_connect(content, "destroy",
56 G_CALLBACK(&OnDestroyThunk), this); 70 G_CALLBACK(&OnDestroyThunk), this);
57 g_signal_connect(accept_button, "clicked", 71 g_signal_connect(accept_button, "clicked",
58 G_CALLBACK(&OnAcceptClickedThunk), this); 72 G_CALLBACK(&OnAcceptClickedThunk), this);
73 g_signal_connect(learn_more_link, "clicked",
74 G_CALLBACK(OnLearnMoreLinkClickedThunk), this);
59 } 75 }
60 76
61 PasswordGenerationBubbleGtk::~PasswordGenerationBubbleGtk() {} 77 PasswordGenerationBubbleGtk::~PasswordGenerationBubbleGtk() {}
62 78
63 void PasswordGenerationBubbleGtk::OnDestroy(GtkWidget* widget) { 79 void PasswordGenerationBubbleGtk::OnDestroy(GtkWidget* widget) {
64 // We are self deleting, we have a destroy signal setup to catch when we are 80 // We are self deleting, we have a destroy signal setup to catch when we are
65 // destroyed (via the BubbleGtk being destroyed), and delete ourself. 81 // destroyed (via the BubbleGtk being destroyed), and delete ourself.
66 delete this; 82 delete this;
67 } 83 }
68 84
69 void PasswordGenerationBubbleGtk::OnAcceptClicked(GtkWidget* widget) { 85 void PasswordGenerationBubbleGtk::OnAcceptClicked(GtkWidget* widget) {
70 render_view_host_->Send(new AutofillMsg_GeneratedPasswordAccepted( 86 render_view_host_->Send(new AutofillMsg_GeneratedPasswordAccepted(
71 render_view_host_->GetRoutingID(), 87 render_view_host_->GetRoutingID(),
72 UTF8ToUTF16(gtk_entry_get_text(GTK_ENTRY(text_field_))))); 88 UTF8ToUTF16(gtk_entry_get_text(GTK_ENTRY(text_field_)))));
73 bubble_->Close(); 89 bubble_->Close();
74 } 90 }
91
92 void PasswordGenerationBubbleGtk::OnLearnMoreLinkClicked(GtkButton* button) {
93 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_);
94 content::OpenURLParams params(
95 GURL(chrome::kAutoPasswordGenerationLearnMoreURL), content::Referrer(),
96 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false);
97 browser->OpenURL(params);
98 bubble_->Close();
99 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/password_generation_bubble_gtk.h ('k') | chrome/common/url_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698