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

Side by Side Diff: chrome/browser/automation/testing_automation_provider.cc

Issue 23742004: Move PasswordForm from //content to //autofill. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_password_form_conversion_utils
Patch Set: Rebase Created 7 years, 3 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
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/automation/testing_automation_provider.h" 5 #include "chrome/browser/automation/testing_automation_provider.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 3156 matching lines...) Expand 10 before | Expand all | Expand 10 after
3167 } 3167 }
3168 // The observer will delete itself when done. 3168 // The observer will delete itself when done.
3169 new SavePackageNotificationObserver( 3169 new SavePackageNotificationObserver(
3170 BrowserContext::GetDownloadManager(browser->profile()), 3170 BrowserContext::GetDownloadManager(browser->profile()),
3171 this, reply_message); 3171 this, reply_message);
3172 } 3172 }
3173 3173
3174 namespace { 3174 namespace {
3175 3175
3176 // Translates a dictionary password to a PasswordForm struct. 3176 // Translates a dictionary password to a PasswordForm struct.
3177 content::PasswordForm GetPasswordFormFromDict( 3177 autofill::PasswordForm GetPasswordFormFromDict(
3178 const DictionaryValue& password_dict) { 3178 const DictionaryValue& password_dict) {
3179 3179
3180 // If the time is specified, change time to the specified time. 3180 // If the time is specified, change time to the specified time.
3181 base::Time time = base::Time::Now(); 3181 base::Time time = base::Time::Now();
3182 int it; 3182 int it;
3183 double dt; 3183 double dt;
3184 if (password_dict.GetInteger("time", &it)) 3184 if (password_dict.GetInteger("time", &it))
3185 time = base::Time::FromTimeT(it); 3185 time = base::Time::FromTimeT(it);
3186 else if (password_dict.GetDouble("time", &dt)) 3186 else if (password_dict.GetDouble("time", &dt))
3187 time = base::Time::FromDoubleT(dt); 3187 time = base::Time::FromDoubleT(dt);
(...skipping 19 matching lines...) Expand all
3207 password_dict.GetString("username_element", &username_element); 3207 password_dict.GetString("username_element", &username_element);
3208 password_dict.GetString("password_element", &password_element); 3208 password_dict.GetString("password_element", &password_element);
3209 password_dict.GetString("submit_element", &submit_element); 3209 password_dict.GetString("submit_element", &submit_element);
3210 password_dict.GetString("action_target", &action_target_text); 3210 password_dict.GetString("action_target", &action_target_text);
3211 if (!password_dict.GetBoolean("blacklist", &blacklist)) 3211 if (!password_dict.GetBoolean("blacklist", &blacklist))
3212 blacklist = false; 3212 blacklist = false;
3213 3213
3214 GURL origin_gurl(origin_url_text); 3214 GURL origin_gurl(origin_url_text);
3215 GURL action_target(action_target_text); 3215 GURL action_target(action_target_text);
3216 3216
3217 content::PasswordForm password_form; 3217 autofill::PasswordForm password_form;
3218 password_form.signon_realm = signon_realm; 3218 password_form.signon_realm = signon_realm;
3219 password_form.username_value = username_value; 3219 password_form.username_value = username_value;
3220 password_form.password_value = password_value; 3220 password_form.password_value = password_value;
3221 password_form.origin = origin_gurl; 3221 password_form.origin = origin_gurl;
3222 password_form.username_element = username_element; 3222 password_form.username_element = username_element;
3223 password_form.password_element = password_element; 3223 password_form.password_element = password_element;
3224 password_form.submit_element = submit_element; 3224 password_form.submit_element = submit_element;
3225 password_form.action = action_target; 3225 password_form.action = action_target;
3226 password_form.blacklisted_by_user = blacklist; 3226 password_form.blacklisted_by_user = blacklist;
3227 password_form.date_created = time; 3227 password_form.date_created = time;
(...skipping 18 matching lines...) Expand all
3246 } 3246 }
3247 3247
3248 // The "signon realm" is effectively the primary key and must be included. 3248 // The "signon realm" is effectively the primary key and must be included.
3249 // Check here before calling GetPasswordFormFromDict. 3249 // Check here before calling GetPasswordFormFromDict.
3250 if (!password_dict->HasKey("signon_realm")) { 3250 if (!password_dict->HasKey("signon_realm")) {
3251 AutomationJSONReply(this, reply_message).SendError( 3251 AutomationJSONReply(this, reply_message).SendError(
3252 "Password must include a value for 'signon_realm.'"); 3252 "Password must include a value for 'signon_realm.'");
3253 return; 3253 return;
3254 } 3254 }
3255 3255
3256 content::PasswordForm new_password = 3256 autofill::PasswordForm new_password =
3257 GetPasswordFormFromDict(*password_dict); 3257 GetPasswordFormFromDict(*password_dict);
3258 3258
3259 // Use IMPLICIT_ACCESS since new passwords aren't added in incognito mode. 3259 // Use IMPLICIT_ACCESS since new passwords aren't added in incognito mode.
3260 PasswordStore* password_store = PasswordStoreFactory::GetForProfile( 3260 PasswordStore* password_store = PasswordStoreFactory::GetForProfile(
3261 browser->profile(), Profile::IMPLICIT_ACCESS).get(); 3261 browser->profile(), Profile::IMPLICIT_ACCESS).get();
3262 3262
3263 // The password store does not exist for an incognito window. 3263 // The password store does not exist for an incognito window.
3264 if (password_store == NULL) { 3264 if (password_store == NULL) {
3265 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); 3265 scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
3266 return_value->SetBoolean("password_added", false); 3266 return_value->SetBoolean("password_added", false);
(...skipping 25 matching lines...) Expand all
3292 return; 3292 return;
3293 } 3293 }
3294 3294
3295 // The "signon realm" is effectively the primary key and must be included. 3295 // The "signon realm" is effectively the primary key and must be included.
3296 // Check here before calling GetPasswordFormFromDict. 3296 // Check here before calling GetPasswordFormFromDict.
3297 if (!password_dict->HasKey("signon_realm")) { 3297 if (!password_dict->HasKey("signon_realm")) {
3298 AutomationJSONReply(this, reply_message).SendError( 3298 AutomationJSONReply(this, reply_message).SendError(
3299 "Password must include a value for 'signon_realm.'"); 3299 "Password must include a value for 'signon_realm.'");
3300 return; 3300 return;
3301 } 3301 }
3302 content::PasswordForm to_remove = 3302 autofill::PasswordForm to_remove =
3303 GetPasswordFormFromDict(*password_dict); 3303 GetPasswordFormFromDict(*password_dict);
3304 3304
3305 // Use EXPLICIT_ACCESS since passwords can be removed in incognito mode. 3305 // Use EXPLICIT_ACCESS since passwords can be removed in incognito mode.
3306 PasswordStore* password_store = PasswordStoreFactory::GetForProfile( 3306 PasswordStore* password_store = PasswordStoreFactory::GetForProfile(
3307 browser->profile(), Profile::EXPLICIT_ACCESS).get(); 3307 browser->profile(), Profile::EXPLICIT_ACCESS).get();
3308 if (password_store == NULL) { 3308 if (password_store == NULL) {
3309 AutomationJSONReply(this, reply_message).SendError( 3309 AutomationJSONReply(this, reply_message).SendError(
3310 "Unable to get password store."); 3310 "Unable to get password store.");
3311 return; 3311 return;
3312 } 3312 }
(...skipping 2241 matching lines...) Expand 10 before | Expand all | Expand 10 after
5554 if (g_browser_process) 5554 if (g_browser_process)
5555 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); 5555 g_browser_process->GetAutomationProviderList()->RemoveProvider(this);
5556 } 5556 }
5557 5557
5558 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, 5558 void TestingAutomationProvider::EnsureTabSelected(Browser* browser,
5559 WebContents* tab) { 5559 WebContents* tab) {
5560 TabStripModel* tab_strip = browser->tab_strip_model(); 5560 TabStripModel* tab_strip = browser->tab_strip_model();
5561 if (tab_strip->GetActiveWebContents() != tab) 5561 if (tab_strip->GetActiveWebContents() != tab)
5562 tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(tab), true); 5562 tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(tab), true);
5563 } 5563 }
OLDNEW
« no previous file with comments | « chrome/browser/automation/automation_provider_observers.cc ('k') | chrome/browser/chrome_notification_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698