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

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

Issue 11000016: Move forms/ out of webkit/. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Response to review Created 8 years, 2 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 (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/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 3397 matching lines...) Expand 10 before | Expand all | Expand 10 after
3408 import_settings_data_.browser = browser; 3408 import_settings_data_.browser = browser;
3409 import_settings_data_.reply_message = reply_message; 3409 import_settings_data_.reply_message = reply_message;
3410 3410
3411 importer_list_ = new ImporterList(NULL); 3411 importer_list_ = new ImporterList(NULL);
3412 importer_list_->DetectSourceProfiles(this); 3412 importer_list_->DetectSourceProfiles(this);
3413 } 3413 }
3414 3414
3415 namespace { 3415 namespace {
3416 3416
3417 // Translates a dictionary password to a PasswordForm struct. 3417 // Translates a dictionary password to a PasswordForm struct.
3418 webkit::forms::PasswordForm GetPasswordFormFromDict( 3418 content::PasswordForm GetPasswordFormFromDict(
3419 const DictionaryValue& password_dict) { 3419 const DictionaryValue& password_dict) {
3420 3420
3421 // If the time is specified, change time to the specified time. 3421 // If the time is specified, change time to the specified time.
3422 base::Time time = base::Time::Now(); 3422 base::Time time = base::Time::Now();
3423 int it; 3423 int it;
3424 double dt; 3424 double dt;
3425 if (password_dict.GetInteger("time", &it)) 3425 if (password_dict.GetInteger("time", &it))
3426 time = base::Time::FromTimeT(it); 3426 time = base::Time::FromTimeT(it);
3427 else if (password_dict.GetDouble("time", &dt)) 3427 else if (password_dict.GetDouble("time", &dt))
3428 time = base::Time::FromDoubleT(dt); 3428 time = base::Time::FromDoubleT(dt);
(...skipping 19 matching lines...) Expand all
3448 password_dict.GetString("username_element", &username_element); 3448 password_dict.GetString("username_element", &username_element);
3449 password_dict.GetString("password_element", &password_element); 3449 password_dict.GetString("password_element", &password_element);
3450 password_dict.GetString("submit_element", &submit_element); 3450 password_dict.GetString("submit_element", &submit_element);
3451 password_dict.GetString("action_target", &action_target_text); 3451 password_dict.GetString("action_target", &action_target_text);
3452 if (!password_dict.GetBoolean("blacklist", &blacklist)) 3452 if (!password_dict.GetBoolean("blacklist", &blacklist))
3453 blacklist = false; 3453 blacklist = false;
3454 3454
3455 GURL origin_gurl(origin_url_text); 3455 GURL origin_gurl(origin_url_text);
3456 GURL action_target(action_target_text); 3456 GURL action_target(action_target_text);
3457 3457
3458 webkit::forms::PasswordForm password_form; 3458 content::PasswordForm password_form;
3459 password_form.signon_realm = signon_realm; 3459 password_form.signon_realm = signon_realm;
3460 password_form.username_value = username_value; 3460 password_form.username_value = username_value;
3461 password_form.password_value = password_value; 3461 password_form.password_value = password_value;
3462 password_form.origin = origin_gurl; 3462 password_form.origin = origin_gurl;
3463 password_form.username_element = username_element; 3463 password_form.username_element = username_element;
3464 password_form.password_element = password_element; 3464 password_form.password_element = password_element;
3465 password_form.submit_element = submit_element; 3465 password_form.submit_element = submit_element;
3466 password_form.action = action_target; 3466 password_form.action = action_target;
3467 password_form.blacklisted_by_user = blacklist; 3467 password_form.blacklisted_by_user = blacklist;
3468 password_form.date_created = time; 3468 password_form.date_created = time;
(...skipping 18 matching lines...) Expand all
3487 } 3487 }
3488 3488
3489 // The "signon realm" is effectively the primary key and must be included. 3489 // The "signon realm" is effectively the primary key and must be included.
3490 // Check here before calling GetPasswordFormFromDict. 3490 // Check here before calling GetPasswordFormFromDict.
3491 if (!password_dict->HasKey("signon_realm")) { 3491 if (!password_dict->HasKey("signon_realm")) {
3492 AutomationJSONReply(this, reply_message).SendError( 3492 AutomationJSONReply(this, reply_message).SendError(
3493 "Password must include a value for 'signon_realm.'"); 3493 "Password must include a value for 'signon_realm.'");
3494 return; 3494 return;
3495 } 3495 }
3496 3496
3497 webkit::forms::PasswordForm new_password = 3497 content::PasswordForm new_password =
3498 GetPasswordFormFromDict(*password_dict); 3498 GetPasswordFormFromDict(*password_dict);
3499 3499
3500 // Use IMPLICIT_ACCESS since new passwords aren't added in incognito mode. 3500 // Use IMPLICIT_ACCESS since new passwords aren't added in incognito mode.
3501 PasswordStore* password_store = PasswordStoreFactory::GetForProfile( 3501 PasswordStore* password_store = PasswordStoreFactory::GetForProfile(
3502 browser->profile(), Profile::IMPLICIT_ACCESS); 3502 browser->profile(), Profile::IMPLICIT_ACCESS);
3503 3503
3504 // The password store does not exist for an incognito window. 3504 // The password store does not exist for an incognito window.
3505 if (password_store == NULL) { 3505 if (password_store == NULL) {
3506 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); 3506 scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
3507 return_value->SetBoolean("password_added", false); 3507 return_value->SetBoolean("password_added", false);
(...skipping 25 matching lines...) Expand all
3533 return; 3533 return;
3534 } 3534 }
3535 3535
3536 // The "signon realm" is effectively the primary key and must be included. 3536 // The "signon realm" is effectively the primary key and must be included.
3537 // Check here before calling GetPasswordFormFromDict. 3537 // Check here before calling GetPasswordFormFromDict.
3538 if (!password_dict->HasKey("signon_realm")) { 3538 if (!password_dict->HasKey("signon_realm")) {
3539 AutomationJSONReply(this, reply_message).SendError( 3539 AutomationJSONReply(this, reply_message).SendError(
3540 "Password must include a value for 'signon_realm.'"); 3540 "Password must include a value for 'signon_realm.'");
3541 return; 3541 return;
3542 } 3542 }
3543 webkit::forms::PasswordForm to_remove = 3543 content::PasswordForm to_remove =
3544 GetPasswordFormFromDict(*password_dict); 3544 GetPasswordFormFromDict(*password_dict);
3545 3545
3546 // Use EXPLICIT_ACCESS since passwords can be removed in incognito mode. 3546 // Use EXPLICIT_ACCESS since passwords can be removed in incognito mode.
3547 PasswordStore* password_store = PasswordStoreFactory::GetForProfile( 3547 PasswordStore* password_store = PasswordStoreFactory::GetForProfile(
3548 browser->profile(), Profile::EXPLICIT_ACCESS); 3548 browser->profile(), Profile::EXPLICIT_ACCESS);
3549 if (password_store == NULL) { 3549 if (password_store == NULL) {
3550 AutomationJSONReply(this, reply_message).SendError( 3550 AutomationJSONReply(this, reply_message).SendError(
3551 "Unable to get password store."); 3551 "Unable to get password store.");
3552 return; 3552 return;
3553 } 3553 }
(...skipping 2791 matching lines...) Expand 10 before | Expand all | Expand 10 after
6345 void TestingAutomationProvider::OnRemoveProvider() { 6345 void TestingAutomationProvider::OnRemoveProvider() {
6346 if (g_browser_process) 6346 if (g_browser_process)
6347 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); 6347 g_browser_process->GetAutomationProviderList()->RemoveProvider(this);
6348 } 6348 }
6349 6349
6350 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, 6350 void TestingAutomationProvider::EnsureTabSelected(Browser* browser,
6351 WebContents* tab) { 6351 WebContents* tab) {
6352 if (chrome::GetActiveWebContents(browser) != tab) 6352 if (chrome::GetActiveWebContents(browser) != tab)
6353 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); 6353 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true);
6354 } 6354 }
OLDNEW
« no previous file with comments | « chrome/browser/automation/automation_provider_observers.cc ('k') | chrome/browser/importer/external_process_importer_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698