| OLD | NEW |
| 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/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/browser_finder.h" | 10 #include "chrome/browser/ui/browser_finder.h" |
| 10 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" | 11 #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_chrome_link_button.h" |
| 12 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 13 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 13 #include "chrome/browser/ui/gtk/gtk_util.h" | 14 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 14 #include "chrome/common/autofill_messages.h" | 15 #include "chrome/common/autofill_messages.h" |
| 15 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
| 16 #include "content/public/browser/render_view_host.h" | 17 #include "content/public/browser/render_view_host.h" |
| 17 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 18 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
| 19 #include "ui/base/gtk/gtk_hig_constants.h" | 20 #include "ui/base/gtk/gtk_hig_constants.h" |
| 20 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
| 21 | 22 |
| 22 const int kContentBorder = 4; | 23 const int kContentBorder = 4; |
| 23 const int kHorizontalSpacing = 4; | 24 const int kHorizontalSpacing = 4; |
| 24 | 25 |
| 25 PasswordGenerationBubbleGtk::PasswordGenerationBubbleGtk( | 26 PasswordGenerationBubbleGtk::PasswordGenerationBubbleGtk( |
| 26 const gfx::Rect& anchor_rect, | 27 const gfx::Rect& anchor_rect, |
| 27 GtkWidget* anchor_widget, | 28 GtkWidget* anchor_widget, |
| 28 Profile* profile, | 29 Profile* profile, |
| 29 content::RenderViewHost* render_view_host) | 30 content::RenderViewHost* render_view_host, |
| 30 : profile_(profile), render_view_host_(render_view_host) { | 31 const autofill::PasswordGenerator& password_generator) |
| 32 : profile_(profile), |
| 33 render_view_host_(render_view_host), |
| 34 password_generator_(password_generator) { |
| 31 // TODO(gcasto): Localize text after we have finalized the UI. | 35 // TODO(gcasto): Localize text after we have finalized the UI. |
| 32 // crbug.com/118062 | 36 // crbug.com/118062 |
| 33 GtkWidget* content = gtk_vbox_new(FALSE, 5); | 37 GtkWidget* content = gtk_vbox_new(FALSE, 5); |
| 34 | 38 |
| 35 // We have two lines of content. The first is the title and learn more link. | 39 // We have two lines of content. The first is the title and learn more link. |
| 36 GtkWidget* title_line = gtk_hbox_new(FALSE, 0); | 40 GtkWidget* title_line = gtk_hbox_new(FALSE, 0); |
| 37 GtkWidget* title = gtk_label_new("Password Suggestion"); | 41 GtkWidget* title = gtk_label_new("Password Suggestion"); |
| 38 gtk_box_pack_start(GTK_BOX(title_line), title, FALSE, FALSE, 0); | 42 gtk_box_pack_start(GTK_BOX(title_line), title, FALSE, FALSE, 0); |
| 39 GtkWidget* learn_more_link = gtk_chrome_link_button_new( | 43 GtkWidget* learn_more_link = gtk_chrome_link_button_new( |
| 40 l10n_util::GetStringUTF8(IDS_LEARN_MORE).c_str()); | 44 l10n_util::GetStringUTF8(IDS_LEARN_MORE).c_str()); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 } | 95 } |
| 92 | 96 |
| 93 void PasswordGenerationBubbleGtk::OnLearnMoreLinkClicked(GtkButton* button) { | 97 void PasswordGenerationBubbleGtk::OnLearnMoreLinkClicked(GtkButton* button) { |
| 94 Browser* browser = browser::FindLastActiveWithProfile(profile_); | 98 Browser* browser = browser::FindLastActiveWithProfile(profile_); |
| 95 content::OpenURLParams params( | 99 content::OpenURLParams params( |
| 96 GURL(chrome::kAutoPasswordGenerationLearnMoreURL), content::Referrer(), | 100 GURL(chrome::kAutoPasswordGenerationLearnMoreURL), content::Referrer(), |
| 97 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false); | 101 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false); |
| 98 browser->OpenURL(params); | 102 browser->OpenURL(params); |
| 99 bubble_->Close(); | 103 bubble_->Close(); |
| 100 } | 104 } |
| OLD | NEW |