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

Side by Side Diff: chrome/browser/ui/passwords/password_manager_presenter.cc

Issue 2771233002: Remove the wrapper functions content::RecordAction et al (Closed)
Patch Set: Rebased Created 3 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
« no previous file with comments | « chrome/browser/ui/page_info/page_info.cc ('k') | chrome/browser/ui/search/search_tab_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/passwords/password_manager_presenter.h" 5 #include "chrome/browser/ui/passwords/password_manager_presenter.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/metrics/user_metrics.h"
13 #include "base/metrics/user_metrics_action.h" 14 #include "base/metrics/user_metrics_action.h"
14 #include "base/strings/string_piece.h" 15 #include "base/strings/string_piece.h"
15 #include "base/strings/string_split.h" 16 #include "base/strings/string_split.h"
16 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
17 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
18 #include "base/time/time.h" 19 #include "base/time/time.h"
19 #include "base/values.h" 20 #include "base/values.h"
20 #include "build/build_config.h" 21 #include "build/build_config.h"
21 #include "chrome/browser/password_manager/password_store_factory.h" 22 #include "chrome/browser/password_manager/password_store_factory.h"
22 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/browser/signin/signin_manager_factory.h" 24 #include "chrome/browser/signin/signin_manager_factory.h"
24 #include "chrome/browser/sync/profile_sync_service_factory.h" 25 #include "chrome/browser/sync/profile_sync_service_factory.h"
25 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h" 26 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h"
26 #include "chrome/browser/ui/passwords/password_ui_view.h" 27 #include "chrome/browser/ui/passwords/password_ui_view.h"
27 #include "chrome/common/chrome_switches.h" 28 #include "chrome/common/chrome_switches.h"
28 #include "chrome/common/pref_names.h" 29 #include "chrome/common/pref_names.h"
29 #include "chrome/common/url_constants.h" 30 #include "chrome/common/url_constants.h"
30 #include "components/autofill/core/common/password_form.h" 31 #include "components/autofill/core/common/password_form.h"
31 #include "components/browser_sync/profile_sync_service.h" 32 #include "components/browser_sync/profile_sync_service.h"
32 #include "components/password_manager/core/browser/affiliation_utils.h" 33 #include "components/password_manager/core/browser/affiliation_utils.h"
33 #include "components/password_manager/core/browser/import/password_importer.h" 34 #include "components/password_manager/core/browser/import/password_importer.h"
34 #include "components/password_manager/core/browser/password_ui_utils.h" 35 #include "components/password_manager/core/browser/password_ui_utils.h"
35 #include "components/password_manager/core/common/password_manager_pref_names.h" 36 #include "components/password_manager/core/common/password_manager_pref_names.h"
36 #include "components/password_manager/sync/browser/password_sync_util.h" 37 #include "components/password_manager/sync/browser/password_sync_util.h"
37 #include "components/prefs/pref_service.h" 38 #include "components/prefs/pref_service.h"
38 #include "content/public/browser/browser_thread.h" 39 #include "content/public/browser/browser_thread.h"
39 #include "content/public/browser/user_metrics.h"
40 #include "content/public/browser/web_contents.h" 40 #include "content/public/browser/web_contents.h"
41 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 41 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
42 42
43 #if defined(OS_WIN) 43 #if defined(OS_WIN)
44 #include "chrome/browser/password_manager/password_manager_util_win.h" 44 #include "chrome/browser/password_manager/password_manager_util_win.h"
45 #elif defined(OS_MACOSX) 45 #elif defined(OS_MACOSX)
46 #include "chrome/browser/password_manager/password_manager_util_mac.h" 46 #include "chrome/browser/password_manager/password_manager_util_mac.h"
47 #endif 47 #endif
48 48
49 using base::StringPiece; 49 using base::StringPiece;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 // Don't let it crash the browser. 183 // Don't let it crash the browser.
184 return; 184 return;
185 } 185 }
186 PasswordStore* store = GetPasswordStore(); 186 PasswordStore* store = GetPasswordStore();
187 if (!store) 187 if (!store)
188 return; 188 return;
189 189
190 RemoveDuplicates(*password_list_[index], &password_duplicates_, store, 190 RemoveDuplicates(*password_list_[index], &password_duplicates_, store,
191 PasswordEntryType::SAVED); 191 PasswordEntryType::SAVED);
192 store->RemoveLogin(*password_list_[index]); 192 store->RemoveLogin(*password_list_[index]);
193 content::RecordAction( 193 base::RecordAction(
194 base::UserMetricsAction("PasswordManager_RemoveSavedPassword")); 194 base::UserMetricsAction("PasswordManager_RemoveSavedPassword"));
195 } 195 }
196 196
197 void PasswordManagerPresenter::RemovePasswordException(size_t index) { 197 void PasswordManagerPresenter::RemovePasswordException(size_t index) {
198 if (index >= password_exception_list_.size()) { 198 if (index >= password_exception_list_.size()) {
199 // |index| out of bounds might come from a compromised renderer 199 // |index| out of bounds might come from a compromised renderer
200 // (http://crbug.com/362054), or the user removed a password exception while 200 // (http://crbug.com/362054), or the user removed a password exception while
201 // a request to the store is in progress (i.e. |password_exception_list_| 201 // a request to the store is in progress (i.e. |password_exception_list_|
202 // is empty). Don't let it crash the browser. 202 // is empty). Don't let it crash the browser.
203 return; 203 return;
204 } 204 }
205 PasswordStore* store = GetPasswordStore(); 205 PasswordStore* store = GetPasswordStore();
206 if (!store) 206 if (!store)
207 return; 207 return;
208 RemoveDuplicates(*password_exception_list_[index], 208 RemoveDuplicates(*password_exception_list_[index],
209 &password_exception_duplicates_, store, 209 &password_exception_duplicates_, store,
210 PasswordEntryType::BLACKLISTED); 210 PasswordEntryType::BLACKLISTED);
211 store->RemoveLogin(*password_exception_list_[index]); 211 store->RemoveLogin(*password_exception_list_[index]);
212 content::RecordAction( 212 base::RecordAction(
213 base::UserMetricsAction("PasswordManager_RemovePasswordException")); 213 base::UserMetricsAction("PasswordManager_RemovePasswordException"));
214 } 214 }
215 215
216 void PasswordManagerPresenter::RequestShowPassword(size_t index) { 216 void PasswordManagerPresenter::RequestShowPassword(size_t index) {
217 #if !defined(OS_ANDROID) // This is never called on Android. 217 #if !defined(OS_ANDROID) // This is never called on Android.
218 if (index >= password_list_.size()) { 218 if (index >= password_list_.size()) {
219 // |index| out of bounds might come from a compromised renderer 219 // |index| out of bounds might come from a compromised renderer
220 // (http://crbug.com/362054), or the user requested to show a password while 220 // (http://crbug.com/362054), or the user requested to show a password while
221 // a request to the store is in progress (i.e. |password_list_| 221 // a request to the store is in progress (i.e. |password_list_|
222 // is empty). Don't let it crash the browser. 222 // is empty). Don't let it crash the browser.
223 return; 223 return;
224 } 224 }
225 225
226 if (!IsUserAuthenticated()) { 226 if (!IsUserAuthenticated()) {
227 return; 227 return;
228 } 228 }
229 229
230 syncer::SyncService* sync_service = nullptr; 230 syncer::SyncService* sync_service = nullptr;
231 if (ProfileSyncServiceFactory::HasProfileSyncService( 231 if (ProfileSyncServiceFactory::HasProfileSyncService(
232 password_view_->GetProfile())) { 232 password_view_->GetProfile())) {
233 sync_service = 233 sync_service =
234 ProfileSyncServiceFactory::GetForProfile(password_view_->GetProfile()); 234 ProfileSyncServiceFactory::GetForProfile(password_view_->GetProfile());
235 } 235 }
236 if (password_manager::sync_util::IsSyncAccountCredential( 236 if (password_manager::sync_util::IsSyncAccountCredential(
237 *password_list_[index], sync_service, 237 *password_list_[index], sync_service,
238 SigninManagerFactory::GetForProfile(password_view_->GetProfile()))) { 238 SigninManagerFactory::GetForProfile(password_view_->GetProfile()))) {
239 content::RecordAction( 239 base::RecordAction(
240 base::UserMetricsAction("PasswordManager_SyncCredentialShown")); 240 base::UserMetricsAction("PasswordManager_SyncCredentialShown"));
241 } 241 }
242 242
243 // Call back the front end to reveal the password. 243 // Call back the front end to reveal the password.
244 std::string origin_url = password_manager::GetHumanReadableOrigin( 244 std::string origin_url = password_manager::GetHumanReadableOrigin(
245 *password_list_[index]); 245 *password_list_[index]);
246 password_view_->ShowPassword( 246 password_view_->ShowPassword(
247 index, 247 index,
248 origin_url, 248 origin_url,
249 base::UTF16ToUTF8(password_list_[index]->username_value), 249 base::UTF16ToUTF8(password_list_[index]->username_value),
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 393
394 void PasswordManagerPresenter::PasswordExceptionListPopulater:: 394 void PasswordManagerPresenter::PasswordExceptionListPopulater::
395 OnGetPasswordStoreResults( 395 OnGetPasswordStoreResults(
396 std::vector<std::unique_ptr<autofill::PasswordForm>> results) { 396 std::vector<std::unique_ptr<autofill::PasswordForm>> results) {
397 page_->password_exception_list_ = std::move(results); 397 page_->password_exception_list_ = std::move(results);
398 page_->SortEntriesAndHideDuplicates(&page_->password_exception_list_, 398 page_->SortEntriesAndHideDuplicates(&page_->password_exception_list_,
399 &page_->password_exception_duplicates_, 399 &page_->password_exception_duplicates_,
400 PasswordEntryType::BLACKLISTED); 400 PasswordEntryType::BLACKLISTED);
401 page_->SetPasswordExceptionList(); 401 page_->SetPasswordExceptionList();
402 } 402 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/page_info/page_info.cc ('k') | chrome/browser/ui/search/search_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698