Chromium Code Reviews| 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/metrics/histogram.h" | |
| 7 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/autofill/password_generator.h" | 9 #include "chrome/browser/autofill/password_generator.h" |
| 9 #include "chrome/browser/password_manager/password_manager.h" | 10 #include "chrome/browser/password_manager/password_manager.h" |
| 10 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/browser_finder.h" | 12 #include "chrome/browser/ui/browser_finder.h" |
| 12 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" | 13 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" |
| 13 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" | 14 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" |
| 14 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 15 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 15 #include "chrome/browser/ui/gtk/gtk_util.h" | 16 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 16 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 17 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 | 88 |
| 88 bubble_ = BubbleGtk::Show(tab->web_contents()->GetContentNativeView(), | 89 bubble_ = BubbleGtk::Show(tab->web_contents()->GetContentNativeView(), |
| 89 &anchor_rect, | 90 &anchor_rect, |
| 90 content, | 91 content, |
| 91 BubbleGtk::ARROW_LOCATION_TOP_LEFT, | 92 BubbleGtk::ARROW_LOCATION_TOP_LEFT, |
| 92 BubbleGtk::MATCH_SYSTEM_THEME | | 93 BubbleGtk::MATCH_SYSTEM_THEME | |
| 93 BubbleGtk::POPUP_WINDOW | | 94 BubbleGtk::POPUP_WINDOW | |
| 94 BubbleGtk::GRAB_INPUT, | 95 BubbleGtk::GRAB_INPUT, |
| 95 GtkThemeService::GetFrom(tab_->profile()), | 96 GtkThemeService::GetFrom(tab_->profile()), |
| 96 NULL); // delegate | 97 NULL); // delegate |
| 98 UMA_HISTOGRAM_COUNTS( | |
| 99 "PasswordGeneration.PasswordGenerationBubbleShown_Linux", 1); | |
|
Garrett Casto
2012/07/16 22:32:39
You can break down UMA stats by OS so you don't ne
zysxqn
2012/07/18 01:01:00
Done.
| |
| 97 | 100 |
| 98 g_signal_connect(content, "destroy", | 101 g_signal_connect(content, "destroy", |
| 99 G_CALLBACK(&OnDestroyThunk), this); | 102 G_CALLBACK(&OnDestroyThunk), this); |
| 100 g_signal_connect(accept_button, "clicked", | 103 g_signal_connect(accept_button, "clicked", |
| 101 G_CALLBACK(&OnAcceptClickedThunk), this); | 104 G_CALLBACK(&OnAcceptClickedThunk), this); |
| 102 g_signal_connect(text_field_, "icon-press", | 105 g_signal_connect(text_field_, "icon-press", |
| 103 G_CALLBACK(&OnRegenerateClickedThunk), this); | 106 G_CALLBACK(&OnRegenerateClickedThunk), this); |
| 107 g_signal_connect(text_field_, "changed", | |
| 108 G_CALLBACK(&OnPasswordEditedThunk), this); | |
| 104 g_signal_connect(learn_more_link, "clicked", | 109 g_signal_connect(learn_more_link, "clicked", |
| 105 G_CALLBACK(OnLearnMoreLinkClickedThunk), this); | 110 G_CALLBACK(OnLearnMoreLinkClickedThunk), this); |
| 106 } | 111 } |
| 107 | 112 |
| 108 PasswordGenerationBubbleGtk::~PasswordGenerationBubbleGtk() {} | 113 PasswordGenerationBubbleGtk::~PasswordGenerationBubbleGtk() {} |
| 109 | 114 |
| 110 void PasswordGenerationBubbleGtk::OnDestroy(GtkWidget* widget) { | 115 void PasswordGenerationBubbleGtk::OnDestroy(GtkWidget* widget) { |
| 111 // We are self deleting, we have a destroy signal setup to catch when we are | 116 // 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. | 117 // destroyed (via the BubbleGtk being destroyed), and delete ourself. |
| 113 delete this; | 118 delete this; |
| 114 } | 119 } |
| 115 | 120 |
| 116 void PasswordGenerationBubbleGtk::OnAcceptClicked(GtkWidget* widget) { | 121 void PasswordGenerationBubbleGtk::OnAcceptClicked(GtkWidget* widget) { |
| 122 UMA_HISTOGRAM_COUNTS("PasswordGeneration.PasswordAccepted", 1); | |
| 117 RenderViewHost* render_view_host = tab_->web_contents()->GetRenderViewHost(); | 123 RenderViewHost* render_view_host = tab_->web_contents()->GetRenderViewHost(); |
| 118 render_view_host->Send(new AutofillMsg_GeneratedPasswordAccepted( | 124 render_view_host->Send(new AutofillMsg_GeneratedPasswordAccepted( |
| 119 render_view_host->GetRoutingID(), | 125 render_view_host->GetRoutingID(), |
| 120 UTF8ToUTF16(gtk_entry_get_text(GTK_ENTRY(text_field_))))); | 126 UTF8ToUTF16(gtk_entry_get_text(GTK_ENTRY(text_field_))))); |
| 121 tab_->password_manager()->SetFormHasGeneratedPassword(form_); | 127 tab_->password_manager()->SetFormHasGeneratedPassword(form_); |
| 122 bubble_->Close(); | 128 bubble_->Close(); |
| 123 } | 129 } |
| 124 | 130 |
| 125 void PasswordGenerationBubbleGtk::OnRegenerateClicked( | 131 void PasswordGenerationBubbleGtk::OnRegenerateClicked( |
| 126 GtkWidget* widget, | 132 GtkWidget* widget, |
| 127 GtkEntryIconPosition icon_pos, | 133 GtkEntryIconPosition icon_pos, |
| 128 GdkEvent* event) { | 134 GdkEvent* event) { |
| 135 UMA_HISTOGRAM_COUNTS("PasswordGeneration.RegenerationButtonClicked", 1); | |
| 129 gtk_entry_set_text(GTK_ENTRY(text_field_), | 136 gtk_entry_set_text(GTK_ENTRY(text_field_), |
| 130 password_generator_->Generate().c_str()); | 137 password_generator_->Generate().c_str()); |
| 131 } | 138 } |
| 132 | 139 |
| 140 void PasswordGenerationBubbleGtk::OnPasswordEdited(GtkWidget* widget) { | |
| 141 UMA_HISTOGRAM_COUNTS("PasswordGeneration.PasswordEditedByUsers", 1); | |
|
Garrett Casto
2012/07/16 22:32:39
I would think that we would want to know if the pa
zysxqn
2012/07/18 01:01:00
Done.
| |
| 142 } | |
| 143 | |
| 133 void PasswordGenerationBubbleGtk::OnLearnMoreLinkClicked(GtkButton* button) { | 144 void PasswordGenerationBubbleGtk::OnLearnMoreLinkClicked(GtkButton* button) { |
| 145 UMA_HISTOGRAM_COUNTS("PasswordGeneration.LearnMoreLinkClicked", 1); | |
| 134 Browser* browser = browser::FindBrowserWithWebContents(tab_->web_contents()); | 146 Browser* browser = browser::FindBrowserWithWebContents(tab_->web_contents()); |
| 135 content::OpenURLParams params( | 147 content::OpenURLParams params( |
| 136 GURL(chrome::kAutoPasswordGenerationLearnMoreURL), content::Referrer(), | 148 GURL(chrome::kAutoPasswordGenerationLearnMoreURL), content::Referrer(), |
| 137 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false); | 149 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false); |
| 138 browser->OpenURL(params); | 150 browser->OpenURL(params); |
| 139 bubble_->Close(); | 151 bubble_->Close(); |
| 140 } | 152 } |
| OLD | NEW |