diff options
-rw-r--r-- | chrome/app/policy/policy_templates.grd | 11 | ||||
-rw-r--r-- | chrome/app/policy/policy_templates.json | 7 | ||||
-rw-r--r-- | chrome/browser/gtk/options/passwords_page_gtk.cc | 53 | ||||
-rw-r--r-- | chrome/browser/gtk/options/passwords_page_gtk.h | 16 | ||||
-rw-r--r-- | chrome/browser/password_manager/password_manager.cc | 1 | ||||
-rw-r--r-- | chrome/browser/policy/configuration_policy_pref_store.cc | 2 | ||||
-rw-r--r-- | chrome/browser/policy/configuration_policy_provider.cc | 2 | ||||
-rw-r--r-- | chrome/browser/policy/configuration_policy_store.h | 1 | ||||
-rw-r--r-- | chrome/browser/views/options/passwords_page_view.cc | 32 | ||||
-rw-r--r-- | chrome/browser/views/options/passwords_page_view.h | 10 | ||||
-rw-r--r-- | chrome/common/policy_constants.cc | 2 | ||||
-rw-r--r-- | chrome/common/policy_constants.h | 1 | ||||
-rw-r--r-- | chrome/common/pref_names.cc | 5 | ||||
-rw-r--r-- | chrome/common/pref_names.h | 1 |
14 files changed, 130 insertions, 14 deletions
diff --git a/chrome/app/policy/policy_templates.grd b/chrome/app/policy/policy_templates.grd index 3b5df8f..8c2adcc 100644 --- a/chrome/app/policy/policy_templates.grd +++ b/chrome/app/policy/policy_templates.grd @@ -374,6 +374,17 @@ templates and will be translated for each locale. --> If you enable or disable this setting, users cannot change or override this setting in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>. </message> + <message name="IDS_POLICY_GROUP_PASSWORDMANAGERALLOWSHOWPASSWORDS_CAPTION" desc="Caption of the 'allow show passwords in password manager' policy settings page."> + Allow to show passwords in Password Manager + </message> + <message name="IDS_POLICY_GROUP_PASSWORDMANAGERALLOWSHOWPASSWORDS_DESC" desc="Description of the 'allow show passwords in password manager' policy settings page."> + Controls whether the user may show passwords in clear text in the password manager. + + If you disable this setting, the password manager does not allow showing stored passwords in clear text in the password manager window. + + If you enable or do not configure this setting, users can view their passwords in clear text in the password manager. + </message> + <message name="IDS_POLICY_GROUP_DISABLEDPLUGINS_CAPTION" desc="Caption of the 'disable plugins' policy settings page."> Specify a list of plugins that are disabled </message> diff --git a/chrome/app/policy/policy_templates.json b/chrome/app/policy/policy_templates.json index 852cc5a..fe84664 100644 --- a/chrome/app/policy/policy_templates.json +++ b/chrome/app/policy/policy_templates.json @@ -143,6 +143,13 @@ }] }, { + 'name': 'PasswordManagerAllowShowPasswords', + 'policies': [{ + 'name': 'PasswordManagerAllowShowPasswords', + 'type': 'main', + }] + }, + { 'name' : 'AutoFillEnabled', 'policies': [{ 'name': 'AutoFillEnabled', diff --git a/chrome/browser/gtk/options/passwords_page_gtk.cc b/chrome/browser/gtk/options/passwords_page_gtk.cc index 19f8c2a..af4d846 100644 --- a/chrome/browser/gtk/options/passwords_page_gtk.cc +++ b/chrome/browser/gtk/options/passwords_page_gtk.cc @@ -13,6 +13,8 @@ #include "chrome/browser/gtk/gtk_tree.h" #include "chrome/browser/gtk/gtk_util.h" #include "chrome/browser/prefs/pref_service.h" +#include "chrome/common/notification_details.h" +#include "chrome/common/notification_type.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" #include "gfx/gtk_util.h" @@ -40,6 +42,9 @@ enum { PasswordsPageGtk::PasswordsPageGtk(Profile* profile) : populater(this), password_showing_(false), profile_(profile) { + allow_show_passwords_.Init(prefs::kPasswordManagerAllowShowPasswords, + profile->GetPrefs(), + this); remove_button_ = gtk_button_new_with_label( l10n_util::GetStringUTF8(IDS_PASSWORDS_PAGE_VIEW_REMOVE_BUTTON).c_str()); @@ -55,6 +60,7 @@ PasswordsPageGtk::PasswordsPageGtk(Profile* profile) // We start with the "hide password" text but change it in the realize event. show_password_button_ = gtk_button_new_with_label( l10n_util::GetStringUTF8(IDS_PASSWORDS_PAGE_VIEW_HIDE_BUTTON).c_str()); + gtk_widget_set_no_show_all(show_password_button_, true); gtk_widget_set_sensitive(show_password_button_, FALSE); g_signal_connect(show_password_button_, "clicked", G_CALLBACK(OnShowPasswordButtonClickedThunk), this); @@ -62,6 +68,7 @@ PasswordsPageGtk::PasswordsPageGtk(Profile* profile) G_CALLBACK(OnShowPasswordButtonRealizedThunk), this); password_ = gtk_label_new(""); + gtk_widget_set_no_show_all(password_, true); GtkWidget* buttons = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); gtk_box_pack_start(GTK_BOX(buttons), remove_button_, FALSE, FALSE, 0); @@ -84,6 +91,9 @@ PasswordsPageGtk::PasswordsPageGtk(Profile* profile) gtk_util::kContentAreaBorder); gtk_box_pack_end(GTK_BOX(page_), buttons, FALSE, FALSE, 0); gtk_box_pack_end(GTK_BOX(page_), scroll_window, TRUE, TRUE, 0); + + // Initialize UI state based on current preference values. + OnPrefChanged(prefs::kPasswordManagerAllowShowPasswords); } PasswordsPageGtk::~PasswordsPageGtk() { @@ -157,6 +167,36 @@ void PasswordsPageGtk::SetPasswordList( gtk_widget_set_sensitive(remove_all_button_, result.size() > 0); } +void PasswordsPageGtk::HidePassword() { + password_showing_ = false; + gtk_label_set_text(GTK_LABEL(password_), ""); + gtk_button_set_label(GTK_BUTTON(show_password_button_), + l10n_util::GetStringUTF8(IDS_PASSWORDS_PAGE_VIEW_SHOW_BUTTON).c_str()); +} + +void PasswordsPageGtk::Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) { + DCHECK_EQ(NotificationType::PREF_CHANGED, type.value); + const std::string* pref_name = Details<std::string>(details).ptr(); + OnPrefChanged(*pref_name); +} + +void PasswordsPageGtk::OnPrefChanged(const std::string& pref_name) { + if (pref_name == prefs::kPasswordManagerAllowShowPasswords) { + if (allow_show_passwords_.GetValue()) { + gtk_widget_show(show_password_button_); + gtk_widget_show(password_); + } else { + HidePassword(); + gtk_widget_hide(show_password_button_); + gtk_widget_hide(password_); + } + } else { + NOTREACHED(); + } +} + void PasswordsPageGtk::OnRemoveButtonClicked(GtkWidget* widget) { GtkTreeIter iter; if (!gtk_tree_selection_get_selected(password_selection_, @@ -227,15 +267,13 @@ void PasswordsPageGtk::OnRemoveAllConfirmResponse(GtkWidget* confirm, } void PasswordsPageGtk::OnShowPasswordButtonClicked(GtkWidget* widget) { - password_showing_ = !password_showing_; - if (!password_showing_) { + if (password_showing_ || !allow_show_passwords_.GetValue()) { // Hide the password. - gtk_label_set_text(GTK_LABEL(password_), ""); - gtk_button_set_label(GTK_BUTTON(show_password_button_), - l10n_util::GetStringUTF8(IDS_PASSWORDS_PAGE_VIEW_SHOW_BUTTON).c_str()); + HidePassword(); return; } // Show the password. + password_showing_ = true; GtkTreeIter iter; if (!gtk_tree_selection_get_selected(password_selection_, NULL, &iter)) { @@ -277,10 +315,7 @@ void PasswordsPageGtk::OnShowPasswordButtonRealized(GtkWidget* widget) { void PasswordsPageGtk::OnPasswordSelectionChanged(GtkTreeSelection* selection) { // No matter how the selection changed, we want to hide the old password. - gtk_label_set_text(GTK_LABEL(password_), ""); - gtk_button_set_label(GTK_BUTTON(show_password_button_), - l10n_util::GetStringUTF8(IDS_PASSWORDS_PAGE_VIEW_SHOW_BUTTON).c_str()); - password_showing_ = false; + HidePassword(); GtkTreeIter iter; if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) { diff --git a/chrome/browser/gtk/options/passwords_page_gtk.h b/chrome/browser/gtk/options/passwords_page_gtk.h index 3b7dc25..8d81689c 100644 --- a/chrome/browser/gtk/options/passwords_page_gtk.h +++ b/chrome/browser/gtk/options/passwords_page_gtk.h @@ -12,9 +12,11 @@ #include "app/gtk_signal.h" #include "chrome/browser/password_manager/password_store.h" +#include "chrome/browser/prefs/pref_member.h" #include "chrome/browser/profile.h" +#include "chrome/common/notification_observer.h" -class PasswordsPageGtk { +class PasswordsPageGtk : public NotificationObserver { public: explicit PasswordsPageGtk(Profile* profile); virtual ~PasswordsPageGtk(); @@ -32,6 +34,17 @@ class PasswordsPageGtk { // the PasswordForms in the vector. void SetPasswordList(const std::vector<webkit_glue::PasswordForm*>& result); + // Helper that hides the password. + void HidePassword(); + + // NotificationObserver implementation. + void Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details); + + // Handles changes to the observed preferences and updates the UI. + void OnPrefChanged(const std::string& pref_name); + CHROMEGTK_CALLBACK_0(PasswordsPageGtk, void, OnRemoveButtonClicked); CHROMEGTK_CALLBACK_0(PasswordsPageGtk, void, OnRemoveAllButtonClicked); CHROMEGTK_CALLBACK_1(PasswordsPageGtk, void, OnRemoveAllConfirmResponse, int); @@ -91,6 +104,7 @@ class PasswordsPageGtk { GtkWidget* page_; Profile* profile_; + BooleanPrefMember allow_show_passwords_; std::vector<webkit_glue::PasswordForm*> password_list_; DISALLOW_COPY_AND_ASSIGN(PasswordsPageGtk); diff --git a/chrome/browser/password_manager/password_manager.cc b/chrome/browser/password_manager/password_manager.cc index 723615e..d1041cb 100644 --- a/chrome/browser/password_manager/password_manager.cc +++ b/chrome/browser/password_manager/password_manager.cc @@ -25,6 +25,7 @@ using webkit_glue::PasswordFormMap; // static void PasswordManager::RegisterUserPrefs(PrefService* prefs) { prefs->RegisterBooleanPref(prefs::kPasswordManagerEnabled, true); + prefs->RegisterBooleanPref(prefs::kPasswordManagerAllowShowPasswords, true); } // This routine is called when PasswordManagers are constructed. diff --git a/chrome/browser/policy/configuration_policy_pref_store.cc b/chrome/browser/policy/configuration_policy_pref_store.cc index 0561afc..12ec818 100644 --- a/chrome/browser/policy/configuration_policy_pref_store.cc +++ b/chrome/browser/policy/configuration_policy_pref_store.cc @@ -105,6 +105,8 @@ const ConfigurationPolicyPrefStore::PolicyToPreferenceMapEntry prefs::kSafeBrowsingEnabled }, { Value::TYPE_BOOLEAN, kPolicyPasswordManagerEnabled, prefs::kPasswordManagerEnabled }, + { Value::TYPE_BOOLEAN, kPolicyPasswordManagerAllowShowPasswords, + prefs::kPasswordManagerAllowShowPasswords }, { Value::TYPE_BOOLEAN, kPolicyMetricsReportingEnabled, prefs::kMetricsReportingEnabled }, { Value::TYPE_STRING, kPolicyApplicationLocale, diff --git a/chrome/browser/policy/configuration_policy_provider.cc b/chrome/browser/policy/configuration_policy_provider.cc index 5427884..9a41b72 100644 --- a/chrome/browser/policy/configuration_policy_provider.cc +++ b/chrome/browser/policy/configuration_policy_provider.cc @@ -48,6 +48,8 @@ const InternalPolicyValueMapEntry kPolicyValueMap[] = { Value::TYPE_BOOLEAN, policy::key::kMetricsReportingEnabled }, { ConfigurationPolicyStore::kPolicyPasswordManagerEnabled, Value::TYPE_BOOLEAN, policy::key::kPasswordManagerEnabled }, + { ConfigurationPolicyStore::kPolicyPasswordManagerAllowShowPasswords, + Value::TYPE_BOOLEAN, policy::key::kPasswordManagerAllowShowPasswords }, { ConfigurationPolicyStore::kPolicyAutoFillEnabled, Value::TYPE_BOOLEAN, policy::key::kAutoFillEnabled }, { ConfigurationPolicyStore::kPolicyDisabledPlugins, diff --git a/chrome/browser/policy/configuration_policy_store.h b/chrome/browser/policy/configuration_policy_store.h index b591f6a..5fef8d5 100644 --- a/chrome/browser/policy/configuration_policy_store.h +++ b/chrome/browser/policy/configuration_policy_store.h @@ -32,6 +32,7 @@ class ConfigurationPolicyStore { kPolicySafeBrowsingEnabled, kPolicyMetricsReportingEnabled, kPolicyPasswordManagerEnabled, + kPolicyPasswordManagerAllowShowPasswords, kPolicyAutoFillEnabled, kPolicySyncDisabled, kPolicyApplicationLocale, diff --git a/chrome/browser/views/options/passwords_page_view.cc b/chrome/browser/views/options/passwords_page_view.cc index 600ae20..6d22d5e 100644 --- a/chrome/browser/views/options/passwords_page_view.cc +++ b/chrome/browser/views/options/passwords_page_view.cc @@ -33,6 +33,9 @@ MultiLabelButtons::MultiLabelButtons(views::ButtonListener* listener, } gfx::Size MultiLabelButtons::GetPreferredSize() { + if (!IsVisible()) + return gfx::Size(); + if (pref_size_.IsEmpty()) { // Let's compute our preferred size. std::wstring current_label = label(); @@ -185,6 +188,9 @@ PasswordsPageView::PasswordsPageView(Profile* profile) table_model_(profile), table_view_(NULL), current_selected_password_(NULL) { + allow_show_passwords_.Init(prefs::kPasswordManagerAllowShowPasswords, + profile->GetPrefs(), + this); } PasswordsPageView::~PasswordsPageView() { @@ -238,14 +244,13 @@ void PasswordsPageView::ButtonPressed( if (sender == &remove_button_) { table_model_.ForgetAndRemoveSignon(row); } else if (sender == &show_button_) { - if (password_label_.GetText().length() == 0) { + if (password_label_.GetText().length() == 0 && + allow_show_passwords_.GetValue()) { password_label_.SetText(selected->password_value); show_button_.SetLabel( l10n_util::GetString(IDS_PASSWORDS_PAGE_VIEW_HIDE_BUTTON)); } else { - password_label_.SetText(L""); - show_button_.SetLabel( - l10n_util::GetString(IDS_PASSWORDS_PAGE_VIEW_SHOW_BUTTON)); + HidePassword(); } } else { NOTREACHED() << "Invalid button."; @@ -341,3 +346,22 @@ void PasswordsPageView::SetupTable() { table_view_->SetSortDescriptors(sort); table_view_->SetObserver(this); } + +void PasswordsPageView::HidePassword() { + password_label_.SetText(L""); + show_button_.SetLabel( + l10n_util::GetString(IDS_PASSWORDS_PAGE_VIEW_SHOW_BUTTON)); +} + +void PasswordsPageView::NotifyPrefChanged(const std::string* pref_name) { + if (!pref_name || *pref_name == prefs::kPasswordManagerAllowShowPasswords) { + bool show = allow_show_passwords_.GetValue(); + if (!show) + HidePassword(); + show_button_.SetVisible(show); + password_label_.SetVisible(show); + // Update the layout (it may depend on the button size). + show_button_.InvalidateLayout(); + Layout(); + } +} diff --git a/chrome/browser/views/options/passwords_page_view.h b/chrome/browser/views/options/passwords_page_view.h index 357b02b..418fcbe 100644 --- a/chrome/browser/views/options/passwords_page_view.h +++ b/chrome/browser/views/options/passwords_page_view.h @@ -14,6 +14,7 @@ #include "base/stl_util-inl.h" #include "chrome/browser/password_manager/password_store.h" #include "chrome/browser/profile.h" +#include "chrome/browser/prefs/pref_member.h" #include "chrome/browser/views/confirm_message_box_dialog.h" #include "chrome/browser/views/options/options_page_view.h" #include "views/controls/button/native_button.h" @@ -174,6 +175,12 @@ class PasswordsPageView : public OptionsPageView, // Helper to configure our table view. void SetupTable(); + // Helper that hides the password. + void HidePassword(); + + // Handles changes to the observed preferences and updates the UI. + void NotifyPrefChanged(const std::string* pref_name); + PasswordsTableModel table_model_; views::TableView* table_view_; @@ -184,6 +191,9 @@ class PasswordsPageView : public OptionsPageView, views::Label password_label_; webkit_glue::PasswordForm* current_selected_password_; + // Tracks the preference that controls whether showing passwords is allowed. + BooleanPrefMember allow_show_passwords_; + DISALLOW_COPY_AND_ASSIGN(PasswordsPageView); }; diff --git a/chrome/common/policy_constants.cc b/chrome/common/policy_constants.cc index f3d4714..fb1be24 100644 --- a/chrome/common/policy_constants.cc +++ b/chrome/common/policy_constants.cc @@ -30,6 +30,8 @@ const char kDnsPrefetchingEnabled[] = "DnsPrefetchingEnabled"; const char kSafeBrowsingEnabled[] = "SafeBrowsingEnabled"; const char kMetricsReportingEnabled[] = "MetricsReportingEnabled"; const char kPasswordManagerEnabled[] = "PasswordManagerEnabled"; +const char kPasswordManagerAllowShowPasswords[] = + "PasswordManagerAllowShowPasswords"; const char kDisabledPlugins[] = "DisabledPlugins"; const char kAutoFillEnabled[] = "AutoFillEnabled"; const char kApplicationLocaleValue[] = "ApplicationLocaleValue"; diff --git a/chrome/common/policy_constants.h b/chrome/common/policy_constants.h index 79a205b..d9d4e9d 100644 --- a/chrome/common/policy_constants.h +++ b/chrome/common/policy_constants.h @@ -32,6 +32,7 @@ extern const char kDnsPrefetchingEnabled[]; extern const char kSafeBrowsingEnabled[]; extern const char kMetricsReportingEnabled[]; extern const char kPasswordManagerEnabled[]; +extern const char kPasswordManagerAllowShowPasswords[]; extern const char kDisabledPlugins[]; extern const char kAutoFillEnabled[]; extern const char kApplicationLocaleValue[]; diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index c62378a..2cd8b84 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -98,6 +98,11 @@ const char kShowBookmarkBar[] = "bookmark_bar.show_on_all_tabs"; // passwords and fill in known passwords). const char kPasswordManagerEnabled[] = "profile.password_manager_enabled"; +// Boolean controlling whether the password manager allows to retrieve passwords +// in clear text. +const char kPasswordManagerAllowShowPasswords[] = + "profile.password_manager_allow_show_passwords"; + // OBSOLETE. Boolean that is true if the form AutoFill is on (will record // values entered in text inputs in forms and shows them in a popup when user // type in a text input with the same name later on). This has been superseded diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index 322e718..6321c6a 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -47,6 +47,7 @@ extern const char kWebKitTextAreasAreResizable[]; extern const char kWebKitJavaEnabled[]; extern const char kWebkitTabsToLinks[]; extern const char kPasswordManagerEnabled[]; +extern const char kPasswordManagerAllowShowPasswords[]; extern const char kFormAutofillEnabled[]; // OBSOLETE extern const char kSafeBrowsingEnabled[]; extern const char kSearchSuggestEnabled[]; |