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

Side by Side Diff: chrome/browser/ui/gtk/options/passwords_exceptions_page_gtk.cc

Issue 6609008: Change other usages of .size() to .empty() when applicable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Peter nits Created 9 years, 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/options/passwords_exceptions_page_gtk.h" 5 #include "chrome/browser/ui/gtk/options/passwords_exceptions_page_gtk.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/stl_util-inl.h" 9 #include "base/stl_util-inl.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages); 115 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages);
116 gtk_list_store_clear(exception_list_store_); 116 gtk_list_store_clear(exception_list_store_);
117 STLDeleteElements(&exception_list_); 117 STLDeleteElements(&exception_list_);
118 exception_list_ = result; 118 exception_list_ = result;
119 for (size_t i = 0; i < result.size(); ++i) { 119 for (size_t i = 0; i < result.size(); ++i) {
120 GtkTreeIter iter; 120 GtkTreeIter iter;
121 gtk_list_store_insert_with_values(exception_list_store_, &iter, (gint) i, 121 gtk_list_store_insert_with_values(exception_list_store_, &iter, (gint) i,
122 COL_SITE, 122 COL_SITE,
123 UTF16ToUTF8(net::FormatUrl(result[i]->origin, languages)).c_str(), -1); 123 UTF16ToUTF8(net::FormatUrl(result[i]->origin, languages)).c_str(), -1);
124 } 124 }
125 gtk_widget_set_sensitive(remove_all_button_, result.size() > 0); 125 gtk_widget_set_sensitive(remove_all_button_, !result.empty());
126 } 126 }
127 127
128 void PasswordsExceptionsPageGtk::OnRemoveButtonClicked(GtkWidget* widget) { 128 void PasswordsExceptionsPageGtk::OnRemoveButtonClicked(GtkWidget* widget) {
129 GtkTreeIter iter; 129 GtkTreeIter iter;
130 if (!gtk_tree_selection_get_selected(exception_selection_, 130 if (!gtk_tree_selection_get_selected(exception_selection_,
131 NULL, &iter)) { 131 NULL, &iter)) {
132 NOTREACHED(); 132 NOTREACHED();
133 return; 133 return;
134 } 134 }
135 135
136 GtkTreePath* path = gtk_tree_model_get_path( 136 GtkTreePath* path = gtk_tree_model_get_path(
137 GTK_TREE_MODEL(exception_list_sort_), &iter); 137 GTK_TREE_MODEL(exception_list_sort_), &iter);
138 gint index = gtk_tree::GetTreeSortChildRowNumForPath( 138 gint index = gtk_tree::GetTreeSortChildRowNumForPath(
139 exception_list_sort_, path); 139 exception_list_sort_, path);
140 gtk_tree_path_free(path); 140 gtk_tree_path_free(path);
141 141
142 GtkTreeIter child_iter; 142 GtkTreeIter child_iter;
143 gtk_tree_model_sort_convert_iter_to_child_iter( 143 gtk_tree_model_sort_convert_iter_to_child_iter(
144 GTK_TREE_MODEL_SORT(exception_list_sort_), &child_iter, &iter); 144 GTK_TREE_MODEL_SORT(exception_list_sort_), &child_iter, &iter);
145 145
146 // Remove from GTK list, DB, and vector. 146 // Remove from GTK list, DB, and vector.
147 gtk_list_store_remove(exception_list_store_, &child_iter); 147 gtk_list_store_remove(exception_list_store_, &child_iter);
148 GetPasswordStore()->RemoveLogin(*exception_list_[index]); 148 GetPasswordStore()->RemoveLogin(*exception_list_[index]);
149 delete exception_list_[index]; 149 delete exception_list_[index];
150 exception_list_.erase(exception_list_.begin() + index); 150 exception_list_.erase(exception_list_.begin() + index);
151 151
152 gtk_widget_set_sensitive(remove_all_button_, exception_list_.size() > 0); 152 gtk_widget_set_sensitive(remove_all_button_, !exception_list_.empty());
153 } 153 }
154 154
155 void PasswordsExceptionsPageGtk::OnRemoveAllButtonClicked(GtkWidget* widget) { 155 void PasswordsExceptionsPageGtk::OnRemoveAllButtonClicked(GtkWidget* widget) {
156 // Remove from GTK list, DB, and vector. 156 // Remove from GTK list, DB, and vector.
157 PasswordStore* store = GetPasswordStore(); 157 PasswordStore* store = GetPasswordStore();
158 gtk_list_store_clear(exception_list_store_); 158 gtk_list_store_clear(exception_list_store_);
159 for (size_t i = 0; i < exception_list_.size(); ++i) 159 for (size_t i = 0; i < exception_list_.size(); ++i)
160 store->RemoveLogin(*exception_list_[i]); 160 store->RemoveLogin(*exception_list_[i]);
161 STLDeleteElements(&exception_list_); 161 STLDeleteElements(&exception_list_);
162 gtk_widget_set_sensitive(remove_all_button_, FALSE); 162 gtk_widget_set_sensitive(remove_all_button_, FALSE);
(...skipping 30 matching lines...) Expand all
193 LOG(ERROR) << "No password store! Cannot display exceptions."; 193 LOG(ERROR) << "No password store! Cannot display exceptions.";
194 } 194 }
195 195
196 void 196 void
197 PasswordsExceptionsPageGtk::ExceptionListPopulater::OnPasswordStoreRequestDone( 197 PasswordsExceptionsPageGtk::ExceptionListPopulater::OnPasswordStoreRequestDone(
198 int handle, const std::vector<webkit_glue::PasswordForm*>& result) { 198 int handle, const std::vector<webkit_glue::PasswordForm*>& result) {
199 DCHECK_EQ(pending_login_query_, handle); 199 DCHECK_EQ(pending_login_query_, handle);
200 pending_login_query_ = 0; 200 pending_login_query_ = 0;
201 page_->SetExceptionList(result); 201 page_->SetExceptionList(result);
202 } 202 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/dialogs_gtk.cc ('k') | chrome/browser/ui/gtk/options/passwords_page_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698