| 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/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" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 gtk_widget_grab_focus(text_field_); | 86 gtk_widget_grab_focus(text_field_); |
| 87 | 87 |
| 88 bubble_ = BubbleGtk::Show(tab->web_contents()->GetContentNativeView(), | 88 bubble_ = BubbleGtk::Show(tab->web_contents()->GetContentNativeView(), |
| 89 &anchor_rect, | 89 &anchor_rect, |
| 90 content, | 90 content, |
| 91 BubbleGtk::ARROW_LOCATION_TOP_LEFT, | 91 BubbleGtk::ARROW_LOCATION_TOP_LEFT, |
| 92 BubbleGtk::MATCH_SYSTEM_THEME | | 92 BubbleGtk::MATCH_SYSTEM_THEME | |
| 93 BubbleGtk::POPUP_WINDOW | | 93 BubbleGtk::POPUP_WINDOW | |
| 94 BubbleGtk::GRAB_INPUT, | 94 BubbleGtk::GRAB_INPUT, |
| 95 GtkThemeService::GetFrom(tab_->profile()), | 95 GtkThemeService::GetFrom(tab_->profile()), |
| 96 NULL); // delegate | 96 this); // delegate |
| 97 | 97 |
| 98 g_signal_connect(content, "destroy", | 98 g_signal_connect(content, "destroy", |
| 99 G_CALLBACK(&OnDestroyThunk), this); | 99 G_CALLBACK(&OnDestroyThunk), this); |
| 100 g_signal_connect(accept_button, "clicked", | 100 g_signal_connect(accept_button, "clicked", |
| 101 G_CALLBACK(&OnAcceptClickedThunk), this); | 101 G_CALLBACK(&OnAcceptClickedThunk), this); |
| 102 g_signal_connect(text_field_, "icon-press", | 102 g_signal_connect(text_field_, "icon-press", |
| 103 G_CALLBACK(&OnRegenerateClickedThunk), this); | 103 G_CALLBACK(&OnRegenerateClickedThunk), this); |
| 104 g_signal_connect(text_field_, "changed", |
| 105 G_CALLBACK(&OnPasswordEditedThunk), this); |
| 104 g_signal_connect(learn_more_link, "clicked", | 106 g_signal_connect(learn_more_link, "clicked", |
| 105 G_CALLBACK(OnLearnMoreLinkClickedThunk), this); | 107 G_CALLBACK(OnLearnMoreLinkClickedThunk), this); |
| 106 } | 108 } |
| 107 | 109 |
| 108 PasswordGenerationBubbleGtk::~PasswordGenerationBubbleGtk() {} | 110 PasswordGenerationBubbleGtk::~PasswordGenerationBubbleGtk() {} |
| 109 | 111 |
| 112 void PasswordGenerationBubbleGtk::BubbleClosing( |
| 113 BubbleGtk* bubble, |
| 114 bool closed_by_escape) { |
| 115 password_generation::LogUserActions(actions_); |
| 116 } |
| 117 |
| 110 void PasswordGenerationBubbleGtk::OnDestroy(GtkWidget* widget) { | 118 void PasswordGenerationBubbleGtk::OnDestroy(GtkWidget* widget) { |
| 111 // We are self deleting, we have a destroy signal setup to catch when we are | 119 // We are self deleting, we have a destroy signal setup to catch when we are |
| 112 // destroyed (via the BubbleGtk being destroyed), and delete ourself. | 120 // destroyed (via the BubbleGtk being destroyed), and delete ourself. |
| 113 delete this; | 121 delete this; |
| 114 } | 122 } |
| 115 | 123 |
| 116 void PasswordGenerationBubbleGtk::OnAcceptClicked(GtkWidget* widget) { | 124 void PasswordGenerationBubbleGtk::OnAcceptClicked(GtkWidget* widget) { |
| 125 actions_.password_accepted = true; |
| 117 RenderViewHost* render_view_host = tab_->web_contents()->GetRenderViewHost(); | 126 RenderViewHost* render_view_host = tab_->web_contents()->GetRenderViewHost(); |
| 118 render_view_host->Send(new AutofillMsg_GeneratedPasswordAccepted( | 127 render_view_host->Send(new AutofillMsg_GeneratedPasswordAccepted( |
| 119 render_view_host->GetRoutingID(), | 128 render_view_host->GetRoutingID(), |
| 120 UTF8ToUTF16(gtk_entry_get_text(GTK_ENTRY(text_field_))))); | 129 UTF8ToUTF16(gtk_entry_get_text(GTK_ENTRY(text_field_))))); |
| 121 tab_->password_manager()->SetFormHasGeneratedPassword(form_); | 130 tab_->password_manager()->SetFormHasGeneratedPassword(form_); |
| 122 bubble_->Close(); | 131 bubble_->Close(); |
| 123 } | 132 } |
| 124 | 133 |
| 125 void PasswordGenerationBubbleGtk::OnRegenerateClicked( | 134 void PasswordGenerationBubbleGtk::OnRegenerateClicked( |
| 126 GtkWidget* widget, | 135 GtkWidget* widget, |
| 127 GtkEntryIconPosition icon_pos, | 136 GtkEntryIconPosition icon_pos, |
| 128 GdkEvent* event) { | 137 GdkEvent* event) { |
| 129 gtk_entry_set_text(GTK_ENTRY(text_field_), | 138 gtk_entry_set_text(GTK_ENTRY(text_field_), |
| 130 password_generator_->Generate().c_str()); | 139 password_generator_->Generate().c_str()); |
| 140 actions_.password_regenerated = true; |
| 141 } |
| 142 |
| 143 void PasswordGenerationBubbleGtk::OnPasswordEdited(GtkWidget* widget) { |
| 144 actions_.password_edited = true; |
| 131 } | 145 } |
| 132 | 146 |
| 133 void PasswordGenerationBubbleGtk::OnLearnMoreLinkClicked(GtkButton* button) { | 147 void PasswordGenerationBubbleGtk::OnLearnMoreLinkClicked(GtkButton* button) { |
| 148 actions_.learn_more_visited = true; |
| 134 Browser* browser = browser::FindBrowserWithWebContents(tab_->web_contents()); | 149 Browser* browser = browser::FindBrowserWithWebContents(tab_->web_contents()); |
| 135 content::OpenURLParams params( | 150 content::OpenURLParams params( |
| 136 GURL(chrome::kAutoPasswordGenerationLearnMoreURL), content::Referrer(), | 151 GURL(chrome::kAutoPasswordGenerationLearnMoreURL), content::Referrer(), |
| 137 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false); | 152 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false); |
| 138 browser->OpenURL(params); | 153 browser->OpenURL(params); |
| 139 bubble_->Close(); | 154 bubble_->Close(); |
| 140 } | 155 } |
| OLD | NEW |