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

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

Issue 10458018: This CL does the following: (1) Pass the max_length attribute to the password generator; (2) Update… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix a windows UI bug. Created 8 years, 6 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 (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/autofill/password_generator.h"
8 #include "chrome/browser/password_manager/password_manager.h" 9 #include "chrome/browser/password_manager/password_manager.h"
9 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_finder.h" 11 #include "chrome/browser/ui/browser_finder.h"
11 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" 12 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h"
12 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" 13 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h"
13 #include "chrome/browser/ui/gtk/gtk_theme_service.h" 14 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
14 #include "chrome/browser/ui/gtk/gtk_util.h" 15 #include "chrome/browser/ui/gtk/gtk_util.h"
15 #include "chrome/common/autofill_messages.h" 16 #include "chrome/common/autofill_messages.h"
16 #include "chrome/common/url_constants.h" 17 #include "chrome/common/url_constants.h"
17 #include "content/public/browser/render_view_host.h" 18 #include "content/public/browser/render_view_host.h"
18 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
19 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
20 #include "ui/base/gtk/gtk_hig_constants.h" 21 #include "ui/base/gtk/gtk_hig_constants.h"
21 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
22 23
23 const int kContentBorder = 4; 24 const int kContentBorder = 4;
24 const int kHorizontalSpacing = 4; 25 const int kHorizontalSpacing = 4;
25 26
26 PasswordGenerationBubbleGtk::PasswordGenerationBubbleGtk( 27 PasswordGenerationBubbleGtk::PasswordGenerationBubbleGtk(
27 const gfx::Rect& anchor_rect, 28 const gfx::Rect& anchor_rect,
28 const webkit::forms::PasswordForm& form, 29 const webkit::forms::PasswordForm& form,
29 GtkWidget* anchor_widget, 30 GtkWidget* anchor_widget,
30 Profile* profile, 31 Profile* profile,
31 content::RenderViewHost* render_view_host, 32 content::RenderViewHost* render_view_host,
33 autofill::PasswordGenerator* password_generator,
32 PasswordManager* password_manager) 34 PasswordManager* password_manager)
33 : profile_(profile), 35 : profile_(profile),
34 form_(form), 36 form_(form),
35 render_view_host_(render_view_host), 37 render_view_host_(render_view_host),
38 password_generator_(password_generator),
36 password_manager_(password_manager) { 39 password_manager_(password_manager) {
37 // TODO(gcasto): Localize text after we have finalized the UI. 40 // TODO(gcasto): Localize text after we have finalized the UI.
38 // crbug.com/118062 41 // crbug.com/118062
39 GtkWidget* content = gtk_vbox_new(FALSE, 5); 42 GtkWidget* content = gtk_vbox_new(FALSE, 5);
40 43
41 // We have two lines of content. The first is the title and learn more link. 44 // We have two lines of content. The first is the title and learn more link.
42 GtkWidget* title_line = gtk_hbox_new(FALSE, 0); 45 GtkWidget* title_line = gtk_hbox_new(FALSE, 0);
43 GtkWidget* title = gtk_label_new("Password Suggestion"); 46 GtkWidget* title = gtk_label_new("Password Suggestion");
44 gtk_box_pack_start(GTK_BOX(title_line), title, FALSE, FALSE, 0); 47 gtk_box_pack_start(GTK_BOX(title_line), title, FALSE, FALSE, 0);
45 GtkWidget* learn_more_link = gtk_chrome_link_button_new( 48 GtkWidget* learn_more_link = gtk_chrome_link_button_new(
46 l10n_util::GetStringUTF8(IDS_LEARN_MORE).c_str()); 49 l10n_util::GetStringUTF8(IDS_LEARN_MORE).c_str());
47 gtk_button_set_alignment(GTK_BUTTON(learn_more_link), 0.0, 0.5); 50 gtk_button_set_alignment(GTK_BUTTON(learn_more_link), 0.0, 0.5);
48 gtk_box_pack_start(GTK_BOX(title_line), 51 gtk_box_pack_start(GTK_BOX(title_line),
49 gtk_util::IndentWidget(learn_more_link), 52 gtk_util::IndentWidget(learn_more_link),
50 FALSE, FALSE, 0); 53 FALSE, FALSE, 0);
51 54
52 // The second contains the password in a text field and an accept button. 55 // The second contains the password in a text field and an accept button.
53 GtkWidget* password_line = gtk_hbox_new(FALSE, kHorizontalSpacing); 56 GtkWidget* password_line = gtk_hbox_new(FALSE, kHorizontalSpacing);
54 text_field_ = gtk_entry_new(); 57 text_field_ = gtk_entry_new();
55 gtk_entry_set_text(GTK_ENTRY(text_field_), 58 gtk_entry_set_text(GTK_ENTRY(text_field_),
56 password_generator_.Generate().c_str()); 59 password_generator_->Generate().c_str());
57 gtk_entry_set_max_length(GTK_ENTRY(text_field_), 15); 60 gtk_entry_set_max_length(GTK_ENTRY(text_field_), 15);
58 GtkWidget* accept_button = gtk_button_new_with_label("Try It"); 61 GtkWidget* accept_button = gtk_button_new_with_label("Try It");
59 gtk_box_pack_start(GTK_BOX(password_line), text_field_, TRUE, TRUE, 0); 62 gtk_box_pack_start(GTK_BOX(password_line), text_field_, TRUE, TRUE, 0);
60 gtk_box_pack_start(GTK_BOX(password_line), accept_button, TRUE, TRUE, 0); 63 gtk_box_pack_start(GTK_BOX(password_line), accept_button, TRUE, TRUE, 0);
61 64
62 gtk_container_set_border_width(GTK_CONTAINER(content), kContentBorder); 65 gtk_container_set_border_width(GTK_CONTAINER(content), kContentBorder);
63 gtk_box_pack_start(GTK_BOX(content), title_line, TRUE, TRUE, 0); 66 gtk_box_pack_start(GTK_BOX(content), title_line, TRUE, TRUE, 0);
64 gtk_box_pack_start(GTK_BOX(content), password_line, TRUE, TRUE, 0); 67 gtk_box_pack_start(GTK_BOX(content), password_line, TRUE, TRUE, 0);
65 68
66 bubble_ = BubbleGtk::Show(anchor_widget, 69 bubble_ = BubbleGtk::Show(anchor_widget,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 } 101 }
99 102
100 void PasswordGenerationBubbleGtk::OnLearnMoreLinkClicked(GtkButton* button) { 103 void PasswordGenerationBubbleGtk::OnLearnMoreLinkClicked(GtkButton* button) {
101 Browser* browser = browser::FindLastActiveWithProfile(profile_); 104 Browser* browser = browser::FindLastActiveWithProfile(profile_);
102 content::OpenURLParams params( 105 content::OpenURLParams params(
103 GURL(chrome::kAutoPasswordGenerationLearnMoreURL), content::Referrer(), 106 GURL(chrome::kAutoPasswordGenerationLearnMoreURL), content::Referrer(),
104 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false); 107 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false);
105 browser->OpenURL(params); 108 browser->OpenURL(params);
106 bubble_->Close(); 109 bubble_->Close();
107 } 110 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/password_generation_bubble_gtk.h ('k') | chrome/browser/ui/views/frame/browser_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698