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

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

Issue 10918275: [gtk] website settings bubble (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: slightly simpler drawing Created 8 years, 3 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/autofill/password_generator.h"
9 #include "chrome/browser/password_manager/password_manager.h" 9 #include "chrome/browser/password_manager/password_manager.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_finder.h" 11 #include "chrome/browser/ui/browser_finder.h"
12 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" 12 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h"
13 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" 13 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h"
14 #include "chrome/browser/ui/gtk/gtk_theme_service.h" 14 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
15 #include "chrome/browser/ui/gtk/gtk_util.h" 15 #include "chrome/browser/ui/gtk/gtk_util.h"
16 #include "chrome/browser/ui/tab_contents/tab_contents.h" 16 #include "chrome/browser/ui/tab_contents/tab_contents.h"
17 #include "chrome/common/autofill_messages.h" 17 #include "chrome/common/autofill_messages.h"
18 #include "chrome/common/url_constants.h" 18 #include "chrome/common/url_constants.h"
19 #include "content/public/browser/render_view_host.h" 19 #include "content/public/browser/render_view_host.h"
20 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
21 #include "grit/generated_resources.h" 21 #include "grit/generated_resources.h"
22 #include "grit/theme_resources.h" 22 #include "grit/theme_resources.h"
23 #include "ui/base/gtk/gtk_hig_constants.h" 23 #include "ui/base/gtk/gtk_hig_constants.h"
24 #include "ui/base/l10n/l10n_util.h" 24 #include "ui/base/l10n/l10n_util.h"
25 #include "ui/base/resource/resource_bundle.h" 25 #include "ui/base/resource/resource_bundle.h"
26 26
27 using content::RenderViewHost; 27 using content::RenderViewHost;
28 28
29 const int kContentBorder = 4;
30 const int kHorizontalSpacing = 4;
31
32 namespace { 29 namespace {
33 30
34 GdkPixbuf* GetImage(int resource_id) { 31 GdkPixbuf* GetImage(int resource_id) {
35 if (!resource_id) 32 if (!resource_id)
36 return NULL; 33 return NULL;
37 return ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed( 34 return ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(
38 resource_id, ui::ResourceBundle::RTL_ENABLED).ToGdkPixbuf(); 35 resource_id, ui::ResourceBundle::RTL_ENABLED).ToGdkPixbuf();
39 } 36 }
40 37
41 } // namespace 38 } // namespace
(...skipping 16 matching lines...) Expand all
58 gtk_box_pack_start(GTK_BOX(title_line), title, FALSE, FALSE, 0); 55 gtk_box_pack_start(GTK_BOX(title_line), title, FALSE, FALSE, 0);
59 GtkWidget* learn_more_link = gtk_chrome_link_button_new( 56 GtkWidget* learn_more_link = gtk_chrome_link_button_new(
60 l10n_util::GetStringUTF8(IDS_LEARN_MORE).c_str()); 57 l10n_util::GetStringUTF8(IDS_LEARN_MORE).c_str());
61 gtk_button_set_alignment(GTK_BUTTON(learn_more_link), 0.0, 0.5); 58 gtk_button_set_alignment(GTK_BUTTON(learn_more_link), 0.0, 0.5);
62 gtk_box_pack_start(GTK_BOX(title_line), 59 gtk_box_pack_start(GTK_BOX(title_line),
63 gtk_util::IndentWidget(learn_more_link), 60 gtk_util::IndentWidget(learn_more_link),
64 FALSE, FALSE, 0); 61 FALSE, FALSE, 0);
65 62
66 // The second contains the password in a text field, a regenerate button, and 63 // The second contains the password in a text field, a regenerate button, and
67 // an accept button. 64 // an accept button.
68 GtkWidget* password_line = gtk_hbox_new(FALSE, kHorizontalSpacing); 65 GtkWidget* password_line = gtk_hbox_new(FALSE, ui::kControlSpacing);
69 text_field_ = gtk_entry_new(); 66 text_field_ = gtk_entry_new();
70 gtk_entry_set_text(GTK_ENTRY(text_field_), 67 gtk_entry_set_text(GTK_ENTRY(text_field_),
71 password_generator_->Generate().c_str()); 68 password_generator_->Generate().c_str());
72 gtk_entry_set_max_length(GTK_ENTRY(text_field_), 15); 69 gtk_entry_set_max_length(GTK_ENTRY(text_field_), 15);
73 gtk_entry_set_icon_from_pixbuf( 70 gtk_entry_set_icon_from_pixbuf(
74 GTK_ENTRY(text_field_), GTK_ENTRY_ICON_SECONDARY, GetImage(IDR_RELOAD)); 71 GTK_ENTRY(text_field_), GTK_ENTRY_ICON_SECONDARY, GetImage(IDR_RELOAD));
75 gtk_entry_set_icon_tooltip_text( 72 gtk_entry_set_icon_tooltip_text(
76 GTK_ENTRY(text_field_), GTK_ENTRY_ICON_SECONDARY, "Regenerate"); 73 GTK_ENTRY(text_field_), GTK_ENTRY_ICON_SECONDARY, "Regenerate");
77 GtkWidget* accept_button = gtk_button_new_with_label("Try It"); 74 GtkWidget* accept_button = gtk_button_new_with_label("Try It");
78 gtk_box_pack_start(GTK_BOX(password_line), text_field_, TRUE, TRUE, 0); 75 gtk_box_pack_start(GTK_BOX(password_line), text_field_, TRUE, TRUE, 0);
79 gtk_box_pack_start(GTK_BOX(password_line), accept_button, TRUE, TRUE, 0); 76 gtk_box_pack_start(GTK_BOX(password_line), accept_button, TRUE, TRUE, 0);
80 77
81 gtk_container_set_border_width(GTK_CONTAINER(content), kContentBorder); 78 gtk_container_set_border_width(GTK_CONTAINER(content),
79 ui::kContentAreaBorder);
82 gtk_box_pack_start(GTK_BOX(content), title_line, TRUE, TRUE, 0); 80 gtk_box_pack_start(GTK_BOX(content), title_line, TRUE, TRUE, 0);
83 gtk_box_pack_start(GTK_BOX(content), password_line, TRUE, TRUE, 0); 81 gtk_box_pack_start(GTK_BOX(content), password_line, TRUE, TRUE, 0);
84 82
85 // Set initial focus to the text field containing the generated password. 83 // Set initial focus to the text field containing the generated password.
86 gtk_widget_grab_focus(text_field_); 84 gtk_widget_grab_focus(text_field_);
87 85
88 bubble_ = BubbleGtk::Show(tab->web_contents()->GetContentNativeView(), 86 bubble_ = BubbleGtk::Show(tab->web_contents()->GetContentNativeView(),
89 &anchor_rect, 87 &anchor_rect,
90 content, 88 content,
91 BubbleGtk::ARROW_LOCATION_TOP_LEFT, 89 BubbleGtk::ARROW_LOCATION_TOP_LEFT,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 144
147 void PasswordGenerationBubbleGtk::OnLearnMoreLinkClicked(GtkButton* button) { 145 void PasswordGenerationBubbleGtk::OnLearnMoreLinkClicked(GtkButton* button) {
148 actions_.learn_more_visited = true; 146 actions_.learn_more_visited = true;
149 Browser* browser = browser::FindBrowserWithWebContents(tab_->web_contents()); 147 Browser* browser = browser::FindBrowserWithWebContents(tab_->web_contents());
150 content::OpenURLParams params( 148 content::OpenURLParams params(
151 GURL(chrome::kAutoPasswordGenerationLearnMoreURL), content::Referrer(), 149 GURL(chrome::kAutoPasswordGenerationLearnMoreURL), content::Referrer(),
152 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false); 150 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false);
153 browser->OpenURL(params); 151 browser->OpenURL(params);
154 bubble_->Close(); 152 bubble_->Close();
155 } 153 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/one_click_signin_bubble_gtk.cc ('k') | chrome/browser/ui/gtk/website_settings/permission_selector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698