diff options
56 files changed, 342 insertions, 305 deletions
diff --git a/chrome/browser/importer/firefox2_importer.cc b/chrome/browser/importer/firefox2_importer.cc index 95f7587d..5885773 100644 --- a/chrome/browser/importer/firefox2_importer.cc +++ b/chrome/browser/importer/firefox2_importer.cc @@ -20,6 +20,7 @@ #include "net/base/data_url.h" using base::Time; +using webkit_glue::PasswordForm; // Firefox2Importer. diff --git a/chrome/browser/importer/firefox3_importer.cc b/chrome/browser/importer/firefox3_importer.cc index 60be97c..0c6571d 100644 --- a/chrome/browser/importer/firefox3_importer.cc +++ b/chrome/browser/importer/firefox3_importer.cc @@ -16,6 +16,7 @@ #include "grit/generated_resources.h" using base::Time; +using webkit_glue::PasswordForm; // Wraps the function sqlite3_close() in a class that is // used in scoped_ptr_malloc. diff --git a/chrome/browser/importer/firefox_importer_utils.cc b/chrome/browser/importer/firefox_importer_utils.cc index 8380290..47816c8 100644 --- a/chrome/browser/importer/firefox_importer_utils.cc +++ b/chrome/browser/importer/firefox_importer_utils.cc @@ -21,6 +21,7 @@ #include "googleurl/src/gurl.h" #include "net/base/base64.h" +using webkit_glue::PasswordForm; namespace { diff --git a/chrome/browser/importer/firefox_importer_utils.h b/chrome/browser/importer/firefox_importer_utils.h index 14c0c7a..cb44b1c 100644 --- a/chrome/browser/importer/firefox_importer_utils.h +++ b/chrome/browser/importer/firefox_importer_utils.h @@ -190,7 +190,7 @@ class NSSDecryptor { // username/password and reads other related information. // The result will be stored in |forms|. void ParseSignons(const std::string& content, - std::vector<PasswordForm>* forms); + std::vector<webkit_glue::PasswordForm>* forms); private: // Methods in Firefox security components. diff --git a/chrome/browser/importer/ie_importer.cc b/chrome/browser/importer/ie_importer.cc index 4ccfdf8..3862437 100644 --- a/chrome/browser/importer/ie_importer.cc +++ b/chrome/browser/importer/ie_importer.cc @@ -28,6 +28,7 @@ #include "grit/generated_resources.h" using base::Time; +using webkit_glue::PasswordForm; namespace { diff --git a/chrome/browser/importer/importer.cc b/chrome/browser/importer/importer.cc index b3a36a3..1046cfd 100644 --- a/chrome/browser/importer/importer.cc +++ b/chrome/browser/importer/importer.cc @@ -47,6 +47,8 @@ #include "chrome/browser/gtk/import_lock_dialog_gtk.h" #endif +using webkit_glue::PasswordForm; + // ProfileWriter. bool ProfileWriter::BookmarkModelIsLoaded() const { diff --git a/chrome/browser/importer/importer.h b/chrome/browser/importer/importer.h index b42bc20..bce26ee 100644 --- a/chrome/browser/importer/importer.h +++ b/chrome/browser/importer/importer.h @@ -94,7 +94,7 @@ class ProfileWriter : public base::RefCounted<ProfileWriter> { }; // Helper methods for adding data to local stores. - virtual void AddPasswordForm(const PasswordForm& form); + virtual void AddPasswordForm(const webkit_glue::PasswordForm& form); #if defined(OS_WIN) virtual void AddIE7PasswordInfo(const IE7PasswordInfo& info); #endif diff --git a/chrome/browser/importer/importer_unittest.cc b/chrome/browser/importer/importer_unittest.cc index e732365..d6ab67a 100644 --- a/chrome/browser/importer/importer_unittest.cc +++ b/chrome/browser/importer/importer_unittest.cc @@ -22,6 +22,8 @@ #include "chrome/browser/profile.h" #include "chrome/common/chrome_paths.h" +using webkit_glue::PasswordForm; + class ImporterTest : public testing::Test { public: protected: diff --git a/chrome/browser/login_prompt.cc b/chrome/browser/login_prompt.cc index 002e017..dbed8aa 100644 --- a/chrome/browser/login_prompt.cc +++ b/chrome/browser/login_prompt.cc @@ -26,6 +26,7 @@ using namespace std; using views::LoginView; +using webkit_glue::PasswordForm; class LoginHandlerImpl; diff --git a/chrome/browser/password_manager/login_database.cc b/chrome/browser/password_manager/login_database.cc index a8eebab..d455300 100644 --- a/chrome/browser/password_manager/login_database.cc +++ b/chrome/browser/password_manager/login_database.cc @@ -10,6 +10,8 @@ #include "base/time.h" #include "chrome/common/sqlite_utils.h" +using webkit_glue::PasswordForm; + static const int kCurrentVersionNumber = 1; static const int kCompatibleVersionNumber = 1; diff --git a/chrome/browser/password_manager/login_database.h b/chrome/browser/password_manager/login_database.h index bc067dd..ce53993 100644 --- a/chrome/browser/password_manager/login_database.h +++ b/chrome/browser/password_manager/login_database.h @@ -28,13 +28,13 @@ class LoginDatabase { bool Init(const std::string& db_name); // Adds |form| to the list of remembered password forms. - bool AddLogin(const PasswordForm& form); + bool AddLogin(const webkit_glue::PasswordForm& form); // Updates remembered password form. - bool UpdateLogin(const PasswordForm& form); + bool UpdateLogin(const webkit_glue::PasswordForm& form); // Removes |form| from the list of remembered password forms. - bool RemoveLogin(const PasswordForm& form); + bool RemoveLogin(const webkit_glue::PasswordForm& form); // Removes all logins created from |delete_begin| onwards (inclusive) and // before |delete_end|. You may use a null Time value to do an unbounded @@ -45,14 +45,14 @@ class LoginDatabase { // Loads a list of matching password forms into the specified vector |forms|. // The list will contain all possibly relevant entries to the observed |form|, // including blacklisted matches. - bool GetLogins(const PasswordForm& form, - std::vector<PasswordForm*>* forms) const; + bool GetLogins(const webkit_glue::PasswordForm& form, + std::vector<webkit_glue::PasswordForm*>* forms) const; // Loads the complete list of password forms into the specified vector |forms| // if include_blacklisted is true, otherwise only loads those which are // actually autofillable; i.e haven't been blacklisted by the user selecting // the 'Never for this site' button. - bool GetAllLogins(std::vector<PasswordForm*>* forms, + bool GetAllLogins(std::vector<webkit_glue::PasswordForm*>* forms, bool include_blacklisted) const; protected: @@ -69,7 +69,7 @@ class LoginDatabase { private: // Fills |form| from the values in the given statement (which is assumed to // be of the form used by GetLogins/GetAllLogins). - void InitPasswordFormFromStatement(PasswordForm* form, + void InitPasswordFormFromStatement(webkit_glue::PasswordForm* form, SQLStatement* s) const; sqlite3* db_; diff --git a/chrome/browser/password_manager/login_database_unittest.cc b/chrome/browser/password_manager/login_database_unittest.cc index 9e8be84..6c6322f 100644 --- a/chrome/browser/password_manager/login_database_unittest.cc +++ b/chrome/browser/password_manager/login_database_unittest.cc @@ -16,6 +16,8 @@ #include "chrome/common/chrome_paths.h" #include "webkit/glue/password_form.h" +using webkit_glue::PasswordForm; + class LoginDatabaseTest : public testing::Test { protected: virtual void SetUp() { diff --git a/chrome/browser/password_manager/password_form_manager.cc b/chrome/browser/password_manager/password_form_manager.cc index 8122f28..94d0c93 100644 --- a/chrome/browser/password_manager/password_form_manager.cc +++ b/chrome/browser/password_manager/password_form_manager.cc @@ -12,6 +12,8 @@ #include "webkit/glue/password_form_dom_manager.h" using base::Time; +using webkit_glue::PasswordForm; +using webkit_glue::PasswordFormMap; PasswordFormManager::PasswordFormManager(Profile* profile, PasswordManager* password_manager, diff --git a/chrome/browser/password_manager/password_form_manager.h b/chrome/browser/password_manager/password_form_manager.h index 90ffc86..78229de 100644 --- a/chrome/browser/password_manager/password_form_manager.h +++ b/chrome/browser/password_manager/password_form_manager.h @@ -26,12 +26,12 @@ class PasswordFormManager : public PasswordStoreConsumer { // used to filter login results from database. PasswordFormManager(Profile* profile, PasswordManager* password_manager, - const PasswordForm& observed_form, + const webkit_glue::PasswordForm& observed_form, bool ssl_valid); virtual ~PasswordFormManager(); // Compare basic data of observed_form_ with argument. - bool DoesManage(const PasswordForm& form) const; + bool DoesManage(const webkit_glue::PasswordForm& form) const; // Retrieves potential matching logins from the database. void FetchMatchingLoginsFromWebDatabase(); @@ -59,11 +59,12 @@ class PasswordFormManager : public PasswordStoreConsumer { bool IsNewLogin(); // Determines if we need to autofill given the results of the query. - void OnRequestDone(int handle, const std::vector<PasswordForm*>& result); + void OnRequestDone( + int handle, const std::vector<webkit_glue::PasswordForm*>& result); // PasswordStoreConsumer implementation. virtual void OnPasswordStoreRequestDone( - int handle, const std::vector<PasswordForm*>& result); + int handle, const std::vector<webkit_glue::PasswordForm*>& result); // A user opted to 'never remember' passwords for this form. // Blacklist it so that from now on when it is seen we ignore it. @@ -72,7 +73,7 @@ class PasswordFormManager : public PasswordStoreConsumer { // If the user has submitted observed_form_, provisionally hold on to // the submitted credentials until we are told by PasswordManager whether // or not the login was successful. - void ProvisionallySave(const PasswordForm& credentials); + void ProvisionallySave(const webkit_glue::PasswordForm& credentials); // Handles save-as-new or update of the form managed by this manager. // Note the basic data of updated_credentials must match that of @@ -87,7 +88,7 @@ class PasswordFormManager : public PasswordStoreConsumer { // Helper for OnWebDataServiceRequestDone to determine whether or not // the given result form is worth scoring. - bool IgnoreResult(const PasswordForm& form) const; + bool IgnoreResult(const webkit_glue::PasswordForm& form) const; // Helper for Save in the case that best_matches.size() == 0, meaning // we have no prior record of this form/username/password and the user @@ -96,7 +97,7 @@ class PasswordFormManager : public PasswordStoreConsumer { // Helper for OnWebDataServiceRequestDone to score an individual result // against the observed_form_. - int ScoreResult(const PasswordForm& form) const; + int ScoreResult(const webkit_glue::PasswordForm& form) const; // Helper for Save in the case that best_matches.size() > 0, meaning // we have at least one match for this form/username/password. This @@ -108,13 +109,13 @@ class PasswordFormManager : public PasswordStoreConsumer { // Set of PasswordForms from the DB that best match the form // being managed by this. Use a map instead of vector, because we most // frequently require lookups by username value in IsNewLogin. - PasswordFormMap best_matches_; + webkit_glue::PasswordFormMap best_matches_; // Cleans up when best_matches_ goes out of scope. - STLValueDeleter<PasswordFormMap> best_matches_deleter_; + STLValueDeleter<webkit_glue::PasswordFormMap> best_matches_deleter_; // The PasswordForm from the page or dialog managed by this. - PasswordForm observed_form_; + webkit_glue::PasswordForm observed_form_; // The origin url path of observed_form_ tokenized, for convenience when // scoring. @@ -122,7 +123,7 @@ class PasswordFormManager : public PasswordStoreConsumer { // Stores updated credentials when the form was submitted but success is // still unknown. - PasswordForm pending_credentials_; + webkit_glue::PasswordForm pending_credentials_; // Whether pending_credentials_ stores a new login or is an update // to an existing one. @@ -138,7 +139,7 @@ class PasswordFormManager : public PasswordStoreConsumer { // as preferred. This is only allowed to be null if there are no best matches // at all, since there will always be one preferred login when there are // multiple matches (when first saved, a login is marked preferred). - const PasswordForm* preferred_match_; + const webkit_glue::PasswordForm* preferred_match_; typedef enum { PRE_MATCHING_PHASE, // Have not yet invoked a GetLogins query to find diff --git a/chrome/browser/password_manager/password_form_manager_unittest.cc b/chrome/browser/password_manager/password_form_manager_unittest.cc index 092cfd9..30c4faa 100644 --- a/chrome/browser/password_manager/password_form_manager_unittest.cc +++ b/chrome/browser/password_manager/password_form_manager_unittest.cc @@ -10,6 +10,8 @@ #include "chrome/test/testing_profile.h" #include "webkit/glue/password_form.h" +using webkit_glue::PasswordForm; + class PasswordFormManagerTest : public testing::Test { public: PasswordFormManagerTest() { diff --git a/chrome/browser/password_manager/password_manager.cc b/chrome/browser/password_manager/password_manager.cc index 5566e99..58c4afd 100644 --- a/chrome/browser/password_manager/password_manager.cc +++ b/chrome/browser/password_manager/password_manager.cc @@ -19,6 +19,9 @@ #include "grit/generated_resources.h" #include "grit/theme_resources.h" +using webkit_glue::PasswordForm; +using webkit_glue::PasswordFormMap; + // After a successful *new* login attempt, we take the PasswordFormManager in // provisional_save_manager_ and move it to a SavePasswordInfoBarDelegate while // the user makes up their mind with the "save password" infobar. Note if the diff --git a/chrome/browser/password_manager/password_manager.h b/chrome/browser/password_manager/password_manager.h index 175e4cd..5487da3 100644 --- a/chrome/browser/password_manager/password_manager.h +++ b/chrome/browser/password_manager/password_manager.h @@ -30,9 +30,9 @@ class PasswordManager : public views::LoginModel { // Called by a PasswordFormManager when it decides a form can be autofilled // on the page. - void Autofill(const PasswordForm& form_for_autofill, - const PasswordFormMap& best_matches, - const PasswordForm* const preferred_match) const; + void Autofill(const webkit_glue::PasswordForm& form_for_autofill, + const webkit_glue::PasswordFormMap& best_matches, + const webkit_glue::PasswordForm* const preferred_match) const; // Notification that the user navigated away from the current page. // Unless this is a password form submission, for our purposes this @@ -44,12 +44,12 @@ class PasswordManager : public views::LoginModel { void DidStopLoading(); // Notifies the password manager that password forms were parsed on the page. - void PasswordFormsSeen(const std::vector<PasswordForm>& forms); + void PasswordFormsSeen(const std::vector<webkit_glue::PasswordForm>& forms); // When a form is submitted, we prepare to save the password but wait // until we decide the user has successfully logged in. This is step 1 // of 2 (see SavePassword). - void ProvisionallySavePassword(PasswordForm form); + void ProvisionallySavePassword(webkit_glue::PasswordForm form); // Clear any pending saves void ClearProvisionalSave(); diff --git a/chrome/browser/password_manager/password_store.cc b/chrome/browser/password_manager/password_store.cc index d84b788..ba258bf 100644 --- a/chrome/browser/password_manager/password_store.cc +++ b/chrome/browser/password_manager/password_store.cc @@ -8,6 +8,7 @@ #include "base/task.h" using std::vector; +using webkit_glue::PasswordForm; PasswordStore::PasswordStore() : handle_(0) { } diff --git a/chrome/browser/password_manager/password_store.h b/chrome/browser/password_manager/password_store.h index 1850e48..d63f099 100644 --- a/chrome/browser/password_manager/password_store.h +++ b/chrome/browser/password_manager/password_store.h @@ -22,7 +22,7 @@ class PasswordStoreConsumer { // Call this when the request is finished. If there are no results, call it // anyway with an empty vector. virtual void OnPasswordStoreRequestDone( - int handle, const std::vector<PasswordForm*>& result) = 0; + int handle, const std::vector<webkit_glue::PasswordForm*>& result) = 0; }; // Interface for storing form passwords in a platform-specific secure way. @@ -39,15 +39,15 @@ class PasswordStore : public base::RefCountedThreadSafe<PasswordStore> { // password_store_default; once that is fixed, they can become non-virtual. // Adds the given PasswordForm to the secure password store asynchronously. - virtual void AddLogin(const PasswordForm& form); + virtual void AddLogin(const webkit_glue::PasswordForm& form); // Updates the matching PasswordForm in the secure password store (async). - virtual void UpdateLogin(const PasswordForm& form); + virtual void UpdateLogin(const webkit_glue::PasswordForm& form); // Removes the matching PasswordForm from the secure password store (async). - virtual void RemoveLogin(const PasswordForm& form); + virtual void RemoveLogin(const webkit_glue::PasswordForm& form); // Searches for a matching PasswordForm and returns a handle so the async // request can be tracked. Implement the PasswordStoreConsumer interface to // be notified on completion. - virtual int GetLogins(const PasswordForm& form, + virtual int GetLogins(const webkit_glue::PasswordForm& form, PasswordStoreConsumer* consumer); // Cancels a previous GetLogins query (async) @@ -57,12 +57,12 @@ class PasswordStore : public base::RefCountedThreadSafe<PasswordStore> { // Simple container class that represents a GetLogins request. // Created in GetLogins and passed to GetLoginsImpl. struct GetLoginsRequest { - GetLoginsRequest(const PasswordForm& f, + GetLoginsRequest(const webkit_glue::PasswordForm& f, PasswordStoreConsumer* c, int handle); // The query form that was originally passed to GetLogins - PasswordForm form; + webkit_glue::PasswordForm form; // The consumer to notify when this GetLogins request is complete PasswordStoreConsumer* consumer; // A unique handle for the request @@ -79,11 +79,11 @@ class PasswordStore : public base::RefCountedThreadSafe<PasswordStore> { // These will be run in PasswordStore's own thread. // Synchronous implementation to add the given login. - virtual void AddLoginImpl(const PasswordForm& form) = 0; + virtual void AddLoginImpl(const webkit_glue::PasswordForm& form) = 0; // Synchronous implementation to update the given login. - virtual void UpdateLoginImpl(const PasswordForm& form) = 0; + virtual void UpdateLoginImpl(const webkit_glue::PasswordForm& form) = 0; // Synchronous implementation to remove the given login. - virtual void RemoveLoginImpl(const PasswordForm& form) = 0; + virtual void RemoveLoginImpl(const webkit_glue::PasswordForm& form) = 0; // Should find all PasswordForms with the same signon_realm. The results // will then be scored by the PasswordFormManager. Once they are found // (or not), the consumer should be notified. @@ -91,7 +91,7 @@ class PasswordStore : public base::RefCountedThreadSafe<PasswordStore> { // Notifies the consumer that GetLoginsImpl() is complete. void NotifyConsumer(GetLoginsRequest* request, - const std::vector<PasswordForm*> forms); + const std::vector<webkit_glue::PasswordForm*> forms); // Next handle to return from GetLogins() to allow callers to track // their request. @@ -106,7 +106,7 @@ class PasswordStore : public base::RefCountedThreadSafe<PasswordStore> { // that PasswordStoreConsumer doesn't have to be reference counted (we assume // consumers will cancel their requests before they are destroyed). void NotifyConsumerImpl(PasswordStoreConsumer* consumer, int handle, - const std::vector<PasswordForm*> forms); + const std::vector<webkit_glue::PasswordForm*> forms); // List of pending request handles. Handles are removed from the set when // they finish or are canceled. diff --git a/chrome/browser/password_manager/password_store_default.cc b/chrome/browser/password_manager/password_store_default.cc index 33895b5..050fe46 100644 --- a/chrome/browser/password_manager/password_store_default.cc +++ b/chrome/browser/password_manager/password_store_default.cc @@ -9,6 +9,8 @@ #include "base/logging.h" #include "base/task.h" +using webkit_glue::PasswordForm; + PasswordStoreDefault::PasswordStoreDefault(WebDataService* web_data_service) : web_data_service_(web_data_service) { } diff --git a/chrome/browser/password_manager/password_store_default.h b/chrome/browser/password_manager/password_store_default.h index 5529502..2434900 100644 --- a/chrome/browser/password_manager/password_store_default.h +++ b/chrome/browser/password_manager/password_store_default.h @@ -29,18 +29,18 @@ class PasswordStoreDefault : public PasswordStore, // Overridden to bypass the threading logic in PasswordStore, since // WebDataService's API is not threadsafe. - virtual void AddLogin(const PasswordForm& form); - virtual void UpdateLogin(const PasswordForm& form); - virtual void RemoveLogin(const PasswordForm& form); - virtual int GetLogins(const PasswordForm& form, + virtual void AddLogin(const webkit_glue::PasswordForm& form); + virtual void UpdateLogin(const webkit_glue::PasswordForm& form); + virtual void RemoveLogin(const webkit_glue::PasswordForm& form); + virtual int GetLogins(const webkit_glue::PasswordForm& form, PasswordStoreConsumer* consumer); virtual void CancelLoginsQuery(int handle); protected: // Implements PasswordStore interface. - void AddLoginImpl(const PasswordForm& form); - void UpdateLoginImpl(const PasswordForm& form); - void RemoveLoginImpl(const PasswordForm& form); + void AddLoginImpl(const webkit_glue::PasswordForm& form); + void UpdateLoginImpl(const webkit_glue::PasswordForm& form); + void RemoveLoginImpl(const webkit_glue::PasswordForm& form); void GetLoginsImpl(GetLoginsRequest* request); // Called when a WebDataService method finishes. diff --git a/chrome/browser/password_manager/password_store_mac.cc b/chrome/browser/password_manager/password_store_mac.cc index 760e5dc5..07032de 100644 --- a/chrome/browser/password_manager/password_store_mac.cc +++ b/chrome/browser/password_manager/password_store_mac.cc @@ -14,6 +14,8 @@ #include "base/time.h" #include "chrome/browser/keychain_mac.h" +using webkit_glue::PasswordForm; + namespace internal_keychain_helpers { // Utility class to handle the details of constructing and running a keychain diff --git a/chrome/browser/password_manager/password_store_mac.h b/chrome/browser/password_manager/password_store_mac.h index 61bce2d..425081f 100644 --- a/chrome/browser/password_manager/password_store_mac.h +++ b/chrome/browser/password_manager/password_store_mac.h @@ -17,9 +17,9 @@ class PasswordStoreMac : public PasswordStore { virtual ~PasswordStoreMac() {} private: - void AddLoginImpl(const PasswordForm& form); - void UpdateLoginImpl(const PasswordForm& form); - void RemoveLoginImpl(const PasswordForm& form); + void AddLoginImpl(const webkit_glue::PasswordForm& form); + void UpdateLoginImpl(const webkit_glue::PasswordForm& form); + void RemoveLoginImpl(const webkit_glue::PasswordForm& form); void GetLoginsImpl(GetLoginsRequest* request); scoped_ptr<MacKeychain> keychain_; diff --git a/chrome/browser/password_manager/password_store_mac_internal.h b/chrome/browser/password_manager/password_store_mac_internal.h index 53113d4..09da925 100644 --- a/chrome/browser/password_manager/password_store_mac_internal.h +++ b/chrome/browser/password_manager/password_store_mac_internal.h @@ -38,24 +38,26 @@ bool TimeFromKeychainTimeString(const char* time_string_bytes, base::Time* time); // Returns the Keychain SecAuthenticationType type corresponding to |scheme|. -SecAuthenticationType AuthTypeForScheme(PasswordForm::Scheme scheme); +SecAuthenticationType AuthTypeForScheme( + webkit_glue::PasswordForm::Scheme scheme); // Returns the PasswordForm Scheme corresponding to |auth_type|. -PasswordForm::Scheme SchemeForAuthType(SecAuthenticationType auth_type); +webkit_glue::PasswordForm::Scheme SchemeForAuthType( + SecAuthenticationType auth_type); // Searches |keychain| for all items usable for the given signon_realm, and // puts them in |items|. The caller is responsible for calling keychain->Free // on each of them when it is finished with them. void FindMatchingKeychainItems(const MacKeychain& keychain, const std::string& signon_realm, - PasswordForm::Scheme scheme, + webkit_glue::PasswordForm::Scheme scheme, std::vector<SecKeychainItemRef>* items); // Searches |keychain| for the specific keychain entry matching the given form. // If no match is found, |match| will be NULL on return. // The caller is responsible for calling keychain->Free on |match|. void FindMatchingKeychainItem(const MacKeychain& keychain, - const PasswordForm& form, + const webkit_glue::PasswordForm& form, SecKeychainItemRef* match); // Sets the fields of |form| based on the keychain data from |keychain_item|. @@ -71,7 +73,7 @@ void FindMatchingKeychainItem(const MacKeychain& keychain, // require authorization). bool FillPasswordFormFromKeychainItem(const MacKeychain& keychain, const SecKeychainItemRef& keychain_item, - PasswordForm* form); + webkit_glue::PasswordForm* form); } // internal_keychain_helpers diff --git a/chrome/browser/password_manager/password_store_mac_unittest.cc b/chrome/browser/password_manager/password_store_mac_unittest.cc index 1c352fe..f7ce02d 100644 --- a/chrome/browser/password_manager/password_store_mac_unittest.cc +++ b/chrome/browser/password_manager/password_store_mac_unittest.cc @@ -8,6 +8,8 @@ #include "chrome/browser/password_manager/password_store_mac.h" #include "chrome/browser/password_manager/password_store_mac_internal.h" +using webkit_glue::PasswordForm; + #pragma mark Mock Keychain // TODO(stuartmorgan): Replace this with gMock. You know, once we have it. diff --git a/chrome/browser/password_manager/password_store_win.cc b/chrome/browser/password_manager/password_store_win.cc index fa5e4ab..c8bd867 100644 --- a/chrome/browser/password_manager/password_store_win.cc +++ b/chrome/browser/password_manager/password_store_win.cc @@ -12,6 +12,7 @@ using std::map; using std::vector; +using webkit_glue::PasswordForm; PasswordStoreWin::PasswordStoreWin(WebDataService* web_data_service) : PasswordStoreDefault(web_data_service) { diff --git a/chrome/browser/password_manager/password_store_win.h b/chrome/browser/password_manager/password_store_win.h index a56b416..ad59d8a 100644 --- a/chrome/browser/password_manager/password_store_win.h +++ b/chrome/browser/password_manager/password_store_win.h @@ -30,8 +30,9 @@ class PasswordStoreWin : public PasswordStoreDefault { // Gets logins from IE7 if no others are found. Also copies them into // Chrome's WebDatabase so we don't need to look next time. - PasswordForm* GetIE7Result(const WDTypedResult* result, - const PasswordForm& form); + webkit_glue::PasswordForm* GetIE7Result( + const WDTypedResult* result, + const webkit_glue::PasswordForm& form); DISALLOW_COPY_AND_ASSIGN(PasswordStoreWin); }; diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index 9aa1d0a..d6d1767 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -1218,7 +1218,7 @@ void RenderViewHost::OnMsgShowModalHTMLDialog( } void RenderViewHost::OnMsgPasswordFormsSeen( - const std::vector<PasswordForm>& forms) { + const std::vector<webkit_glue::PasswordForm>& forms) { delegate_->PasswordFormsSeen(forms); } diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h index 92b05b8..67d8347 100644 --- a/chrome/browser/renderer_host/render_view_host.h +++ b/chrome/browser/renderer_host/render_view_host.h @@ -517,7 +517,8 @@ class RenderViewHost : public RenderWidgetHost { void OnMsgShowModalHTMLDialog(const GURL& url, int width, int height, const std::string& json_arguments, IPC::Message* reply_msg); - void OnMsgPasswordFormsSeen(const std::vector<PasswordForm>& forms); + void OnMsgPasswordFormsSeen( + const std::vector<webkit_glue::PasswordForm>& forms); void OnMsgAutofillFormSubmitted(const webkit_glue::AutofillForm& forms); void OnMsgStartDragging(const WebDropData& drop_data); void OnUpdateDragCursor(bool is_drop_target); diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h index fb41a9c..dbf29eb 100644 --- a/chrome/browser/renderer_host/render_view_host_delegate.h +++ b/chrome/browser/renderer_host/render_view_host_delegate.h @@ -322,7 +322,8 @@ class RenderViewHostDelegate { IPC::Message* reply_msg) { } // Password forms have been detected in the page. - virtual void PasswordFormsSeen(const std::vector<PasswordForm>& forms) { } + virtual void PasswordFormsSeen( + const std::vector<webkit_glue::PasswordForm>& forms) { } // Forms fillable by autofill have been detected in the page. virtual void AutofillFormSubmitted(const webkit_glue::AutofillForm& form) { } diff --git a/chrome/browser/renderer_host/test_render_view_host.cc b/chrome/browser/renderer_host/test_render_view_host.cc index 44001fd..65dd323 100644 --- a/chrome/browser/renderer_host/test_render_view_host.cc +++ b/chrome/browser/renderer_host/test_render_view_host.cc @@ -8,6 +8,8 @@ #include "chrome/browser/tab_contents/test_web_contents.h" #include "chrome/common/render_messages.h" +using webkit_glue::PasswordForm; + TestRenderViewHost::TestRenderViewHost(SiteInstance* instance, RenderViewHostDelegate* delegate, int routing_id, diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc index 7f6390c..7e70e08 100644 --- a/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc +++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc @@ -8,6 +8,8 @@ #include "chrome/browser/tab_contents/navigation_entry.h" #include "chrome/common/render_messages.h" +using webkit_glue::PasswordForm; + static const char* kGoogleURL = "http://www.google.com/"; static const char* kGoodURL = "http://www.goodguys.com/"; static const char* kBadURL = "http://www.badguys.com/"; diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index 8965085..0380c2b 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -1925,7 +1925,7 @@ void TabContents::ShowModalHTMLDialog(const GURL& url, int width, int height, } void TabContents::PasswordFormsSeen( - const std::vector<PasswordForm>& forms) { + const std::vector<webkit_glue::PasswordForm>& forms) { GetPasswordManager()->PasswordFormsSeen(forms); } diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h index f32bfb7..c344a8a 100644 --- a/chrome/browser/tab_contents/tab_contents.h +++ b/chrome/browser/tab_contents/tab_contents.h @@ -803,7 +803,8 @@ class TabContents : public PageNavigator, virtual void ShowModalHTMLDialog(const GURL& url, int width, int height, const std::string& json_arguments, IPC::Message* reply_msg); - virtual void PasswordFormsSeen(const std::vector<PasswordForm>& forms); + virtual void PasswordFormsSeen( + const std::vector<webkit_glue::PasswordForm>& forms); virtual void AutofillFormSubmitted(const webkit_glue::AutofillForm& form); virtual void GetAutofillSuggestions(const std::wstring& field_name, const std::wstring& user_text, int64 node_id, int request_id); diff --git a/chrome/browser/tab_contents/web_contents_unittest.cc b/chrome/browser/tab_contents/web_contents_unittest.cc index 5a228ac..c391fd1 100644 --- a/chrome/browser/tab_contents/web_contents_unittest.cc +++ b/chrome/browser/tab_contents/web_contents_unittest.cc @@ -17,6 +17,8 @@ #include "chrome/test/testing_profile.h" #include "testing/gtest/include/gtest/gtest.h" +using webkit_glue::PasswordForm; + static void InitNavigateParams(ViewHostMsg_FrameNavigate_Params* params, int page_id, const GURL& url) { diff --git a/chrome/browser/views/options/exceptions_page_view.cc b/chrome/browser/views/options/exceptions_page_view.cc index 1718484..f9d77c9 100644 --- a/chrome/browser/views/options/exceptions_page_view.cc +++ b/chrome/browser/views/options/exceptions_page_view.cc @@ -17,6 +17,7 @@ using views::ColumnSet; using views::GridLayout; +using webkit_glue::PasswordForm; /////////////////////////////////////////////////////////////////////////////// // ExceptionsTableModel diff --git a/chrome/browser/views/options/passwords_page_view.cc b/chrome/browser/views/options/passwords_page_view.cc index 64da35b..bc73703 100644 --- a/chrome/browser/views/options/passwords_page_view.cc +++ b/chrome/browser/views/options/passwords_page_view.cc @@ -17,6 +17,7 @@ using views::ColumnSet; using views::GridLayout; +using webkit_glue::PasswordForm; /////////////////////////////////////////////////////////////////////////////// // MultiLabelButtons diff --git a/chrome/browser/views/options/passwords_page_view.h b/chrome/browser/views/options/passwords_page_view.h index 35cb31e..907ffb4 100644 --- a/chrome/browser/views/options/passwords_page_view.h +++ b/chrome/browser/views/options/passwords_page_view.h @@ -87,7 +87,7 @@ class PasswordsTableModel : public views::TableModel, void GetAllSavedLoginsForProfile(); // Return the PasswordForm at the specified index. - PasswordForm* GetPasswordFormAt(int row); + webkit_glue::PasswordForm* GetPasswordFormAt(int row); // Set the observer who concerns about how many rows are in the table. void set_row_count_observer(PasswordsTableModelObserver* observer) { @@ -98,7 +98,8 @@ class PasswordsTableModel : public views::TableModel, // Wraps the PasswordForm from the database and caches the display URL for // quick sorting. struct PasswordRow { - PasswordRow(const gfx::SortedDisplayURL& url, PasswordForm* password_form) + PasswordRow(const gfx::SortedDisplayURL& url, + webkit_glue::PasswordForm* password_form) : display_url(url), form(password_form) { } @@ -106,7 +107,7 @@ class PasswordsTableModel : public views::TableModel, gfx::SortedDisplayURL display_url; // The underlying PasswordForm. We own this. - scoped_ptr<PasswordForm> form; + scoped_ptr<webkit_glue::PasswordForm> form; }; // The web data service associated with the currently active profile. diff --git a/chrome/browser/webdata/web_data_service.cc b/chrome/browser/webdata/web_data_service.cc index 7dbf1eb..b93ae6d 100644 --- a/chrome/browser/webdata/web_data_service.cc +++ b/chrome/browser/webdata/web_data_service.cc @@ -20,6 +20,7 @@ using base::Time; using webkit_glue::AutofillForm; +using webkit_glue::PasswordForm; WebDataService::WebDataService() : thread_(NULL), db_(NULL), diff --git a/chrome/browser/webdata/web_data_service.h b/chrome/browser/webdata/web_data_service.h index 212e958..05b997b 100644 --- a/chrome/browser/webdata/web_data_service.h +++ b/chrome/browser/webdata/web_data_service.h @@ -19,12 +19,15 @@ #if defined(OS_WIN) struct IE7PasswordInfo; #endif -struct PasswordForm; class FilePath; class GURL; class ShutdownTask; class TemplateURL; +namespace webkit_glue { +struct PasswordForm; +} + //////////////////////////////////////////////////////////////////////////////// // // WebDataService is a generic data repository for meta data associated with @@ -307,13 +310,13 @@ class WebDataService : public base::RefCountedThreadSafe<WebDataService> { ////////////////////////////////////////////////////////////////////////////// // Updates the remembered password form. - void UpdateLogin(const PasswordForm& form); + void UpdateLogin(const webkit_glue::PasswordForm& form); // Adds |form| to the list of remembered password forms. - void AddLogin(const PasswordForm& form); + void AddLogin(const webkit_glue::PasswordForm& form); // Removes |form| from the list of remembered password forms. - void RemoveLogin(const PasswordForm& form); + void RemoveLogin(const webkit_glue::PasswordForm& form); // Removes all logins created in the specified daterange void RemoveLoginsCreatedBetween(const base::Time delete_begin, @@ -326,7 +329,8 @@ class WebDataService : public base::RefCountedThreadSafe<WebDataService> { // |consumer| will be notified when the request is done. The result is of // type WDResult<std::vector<PasswordForm*>>. // The result will be null on failure. The |consumer| owns all PasswordForm's. - Handle GetLogins(const PasswordForm& form, WebDataServiceConsumer* consumer); + Handle GetLogins(const webkit_glue::PasswordForm& form, + WebDataServiceConsumer* consumer); // Gets the complete list of password forms that have not been blacklisted and // are thus auto-fillable. @@ -437,12 +441,12 @@ class WebDataService : public base::RefCountedThreadSafe<WebDataService> { // Password manager. // ////////////////////////////////////////////////////////////////////////////// - void AddLoginImpl(GenericRequest<PasswordForm>* request); - void UpdateLoginImpl(GenericRequest<PasswordForm>* request); - void RemoveLoginImpl(GenericRequest<PasswordForm>* request); + void AddLoginImpl(GenericRequest<webkit_glue::PasswordForm>* request); + void UpdateLoginImpl(GenericRequest<webkit_glue::PasswordForm>* request); + void RemoveLoginImpl(GenericRequest<webkit_glue::PasswordForm>* request); void RemoveLoginsCreatedBetweenImpl( GenericRequest2<base::Time, base::Time>* request); - void GetLoginsImpl(GenericRequest<PasswordForm>* request); + void GetLoginsImpl(GenericRequest<webkit_glue::PasswordForm>* request); void GetAllAutofillableLoginsImpl(WebDataRequest* request); void GetAllLoginsImpl(WebDataRequest* request); #if defined(OS_WIN) diff --git a/chrome/browser/webdata/web_database.cc b/chrome/browser/webdata/web_database.cc index 8914906..c21aa74 100644 --- a/chrome/browser/webdata/web_database.cc +++ b/chrome/browser/webdata/web_database.cc @@ -24,6 +24,8 @@ // http://code.google.com/p/chromium/issues/detail?id=8205 (Linux) #include "chrome/browser/password_manager/encryptor.h" +using webkit_glue::PasswordForm; + //////////////////////////////////////////////////////////////////////////////// // // Schema diff --git a/chrome/browser/webdata/web_database.h b/chrome/browser/webdata/web_database.h index c4d0d23..7ef4f03 100644 --- a/chrome/browser/webdata/web_database.h +++ b/chrome/browser/webdata/web_database.h @@ -17,9 +17,13 @@ #include "webkit/glue/autofill_form.h" namespace base { - class Time; +class Time; } + +namespace webkit_glue { struct PasswordForm; +} + #if defined(OS_WIN) struct IE7PasswordInfo; #endif @@ -80,7 +84,7 @@ class WebDatabase { ////////////////////////////////////////////////////////////////////////////// // Adds |form| to the list of remembered password forms. - bool AddLogin(const PasswordForm& form); + bool AddLogin(const webkit_glue::PasswordForm& form); #if defined(OS_WIN) // Adds |info| to the list of imported passwords from ie7/ie8. @@ -94,10 +98,10 @@ class WebDatabase { #endif // Updates remembered password form. - bool UpdateLogin(const PasswordForm& form); + bool UpdateLogin(const webkit_glue::PasswordForm& form); // Removes |form| from the list of remembered password forms. - bool RemoveLogin(const PasswordForm& form); + bool RemoveLogin(const webkit_glue::PasswordForm& form); // Removes all logins created from |delete_begin| onwards (inclusive) and // before |delete_end|. You may use a null Time value to do an unbounded @@ -108,14 +112,14 @@ class WebDatabase { // Loads a list of matching password forms into the specified vector |forms|. // The list will contain all possibly relevant entries to the observed |form|, // including blacklisted matches. - bool GetLogins(const PasswordForm& form, - std::vector<PasswordForm*>* forms) const; + bool GetLogins(const webkit_glue::PasswordForm& form, + std::vector<webkit_glue::PasswordForm*>* forms) const; // Loads the complete list of password forms into the specified vector |forms| // if include_blacklisted is true, otherwise only loads those which are // actually autofillable; i.e haven't been blacklisted by the user selecting // the 'Never for this site' button. - bool GetAllLogins(std::vector<PasswordForm*>* forms, + bool GetAllLogins(std::vector<webkit_glue::PasswordForm*>* forms, bool include_blacklisted) const; ////////////////////////////////////////////////////////////////////////////// diff --git a/chrome/browser/webdata/web_database_unittest.cc b/chrome/browser/webdata/web_database_unittest.cc index a456f91..5076fc2 100644 --- a/chrome/browser/webdata/web_database_unittest.cc +++ b/chrome/browser/webdata/web_database_unittest.cc @@ -19,6 +19,7 @@ using base::Time; using base::TimeDelta; using webkit_glue::AutofillForm; +using webkit_glue::PasswordForm; class WebDatabaseTest : public testing::Test { protected: diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index c08e5a9..a36f0a3 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -2169,6 +2169,7 @@ 'renderer/js_only_v8_extensions.h', 'renderer/localized_error.cc', 'renderer/localized_error.h', + 'renderer/navigation_state.h', 'renderer/plugin_channel_host.cc', 'renderer/plugin_channel_host.h', 'renderer/print_web_view_helper.cc', diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index 9ccce61..fd3e5eb 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -115,7 +115,7 @@ struct ViewHostMsg_FrameNavigate_Params { std::string searchable_form_encoding; // See password_form.h. - PasswordForm password_form; + webkit_glue::PasswordForm password_form; // Information regarding the security of the connection (empty if the // connection was not secure). @@ -664,8 +664,8 @@ struct ParamTraits<ViewMsg_Navigate_Params> { // Traits for PasswordForm_Params structure to pack/unpack. template <> -struct ParamTraits<PasswordForm> { - typedef PasswordForm param_type; +struct ParamTraits<webkit_glue::PasswordForm> { + typedef webkit_glue::PasswordForm param_type; static void Write(Message* m, const param_type& p) { WriteParam(m, p.signon_realm); WriteParam(m, p.origin); diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index abd7b7b..9904bd0 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -981,7 +981,7 @@ IPC_BEGIN_MESSAGES(ViewHost) // Notification that password forms have been seen that are candidates for // filling/submitting by the password manager IPC_MESSAGE_ROUTED1(ViewHostMsg_PasswordFormsSeen, - std::vector<PasswordForm> /* forms */) + std::vector<webkit_glue::PasswordForm> /* forms */) // Notification that a form has been submitted. The user hit the button. IPC_MESSAGE_ROUTED1(ViewHostMsg_AutofillFormSubmitted, diff --git a/chrome/renderer/loadtimes_extension_bindings.cc b/chrome/renderer/loadtimes_extension_bindings.cc index 6acbbe6..d3ed834 100644 --- a/chrome/renderer/loadtimes_extension_bindings.cc +++ b/chrome/renderer/loadtimes_extension_bindings.cc @@ -6,6 +6,7 @@ #include "base/time.h" #include "v8/include/v8.h" +#include "chrome/renderer/navigation_state.h" #include "webkit/glue/webframe.h" #include "webkit/glue/webdatasource.h" @@ -55,27 +56,29 @@ class LoadTimesExtensionWrapper : public v8::Extension { } static v8::Handle<v8::Value> GetLoadTimes(const v8::Arguments& args) { - WebFrame* win_frame = WebFrame::RetrieveFrameForEnteredContext(); - if (win_frame) { - WebDataSource* data_source = win_frame->GetDataSource(); + WebFrame* frame = WebFrame::RetrieveFrameForEnteredContext(); + if (frame) { + WebDataSource* data_source = frame->GetDataSource(); + NavigationState* navigation_state = + NavigationState::FromDataSource(data_source); if (data_source) { v8::Local<v8::Object> load_times = v8::Object::New(); load_times->Set( v8::String::New("requestTime"), - v8::Number::New(data_source->GetRequestTime().ToDoubleT())); + v8::Number::New(navigation_state->request_time().ToDoubleT())); load_times->Set( v8::String::New("startLoadTime"), - v8::Number::New(data_source->GetStartLoadTime().ToDoubleT())); + v8::Number::New(navigation_state->start_load_time().ToDoubleT())); load_times->Set( v8::String::New("finishDocumentLoadTime"), v8::Number::New( - data_source->GetFinishDocumentLoadTime().ToDoubleT())); + navigation_state->finish_document_load_time().ToDoubleT())); load_times->Set( v8::String::New("finishLoadTime"), - v8::Number::New(data_source->GetFinishLoadTime().ToDoubleT())); + v8::Number::New(navigation_state->finish_load_time().ToDoubleT())); load_times->Set( v8::String::New("firstLayoutTime"), - v8::Number::New(data_source->GetFirstLayoutTime().ToDoubleT())); + v8::Number::New(navigation_state->first_layout_time().ToDoubleT())); load_times->Set( v8::String::New("navigationType"), v8::String::New( diff --git a/chrome/renderer/navigation_state.h b/chrome/renderer/navigation_state.h new file mode 100644 index 0000000..eabe25f6 --- /dev/null +++ b/chrome/renderer/navigation_state.h @@ -0,0 +1,138 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_RENDERER_NAVIGATION_STATE_H_ +#define CHROME_RENDERER_NAVIGATION_STATE_H_ + +#include "base/scoped_ptr.h" +#include "base/time.h" +#include "chrome/common/page_transition_types.h" +#include "webkit/glue/password_form.h" +#include "webkit/glue/searchable_form_data.h" +#include "webkit/glue/webdatasource.h" + +// The RenderView stores an instance of this class in the "extra data" of each +// WebDataSource (see RenderView::DidCreateDataSource). +class NavigationState : public WebDataSource::ExtraData { + public: + static NavigationState* CreateBrowserInitiated( + int32 pending_page_id, + PageTransition::Type transition_type, + base::Time request_time) { + return new NavigationState(transition_type, request_time, false, + pending_page_id); + } + + static NavigationState* CreateContentInitiated() { + // We assume navigations initiated by content are link clicks. + return new NavigationState(PageTransition::LINK, base::Time(), true, -1); + } + + static NavigationState* FromDataSource(WebDataSource* ds) { + return static_cast<NavigationState*>(ds->GetExtraData()); + } + + // Contains the page_id for this navigation or -1 if there is none yet. + int32 pending_page_id() const { return pending_page_id_; } + + // Is this a new navigation? + bool is_new_navigation() const { return pending_page_id_ == -1; } + + // Contains the transition type that the browser specified when it + // initiated the load. + PageTransition::Type transition_type() const { return transition_type_; } + void set_transition_type(PageTransition::Type type) { + transition_type_ = type; + } + + // The time that this navigation was requested. + const base::Time& request_time() const { + return request_time_; + } + void set_request_time(const base::Time& value) { + request_time_ = value; + } + + // The time that this navigation actually started. + const base::Time& start_load_time() const { + return start_load_time_; + } + void set_start_load_time(const base::Time& value) { + start_load_time_ = value; + } + + // The time that the document finished loading. + const base::Time& finish_document_load_time() const { + return finish_document_load_time_; + } + void set_finish_document_load_time(const base::Time& value) { + finish_document_load_time_ = value; + } + + // The time that the document and all subresources finished loading. + const base::Time& finish_load_time() const { + return finish_load_time_; + } + void set_finish_load_time(const base::Time& value) { + finish_load_time_ = value; + } + + // The time that layout first ran after a new navigation. + const base::Time& first_layout_time() const { + return first_layout_time_; + } + void set_first_layout_time(const base::Time& value) { + first_layout_time_ = value; + } + + // True if we have already processed the "DidCommitLoad" event for this + // request. Used by session history. + bool request_committed() const { return request_committed_; } + void set_request_committed(bool value) { request_committed_ = value; } + + // True if this navigation was not initiated via WebFrame::LoadRequest. + bool is_content_initiated() const { return is_content_initiated_; } + + webkit_glue::SearchableFormData* searchable_form_data() const { + return searchable_form_data_.get(); + } + void set_searchable_form_data(webkit_glue::SearchableFormData* data) { + searchable_form_data_.reset(data); + } + + webkit_glue::PasswordForm* password_form_data() const { + return password_form_data_.get(); + } + void set_password_form_data(webkit_glue::PasswordForm* data) { + password_form_data_.reset(data); + } + + private: + NavigationState(PageTransition::Type transition_type, + const base::Time& request_time, + bool is_content_initiated, + int32 pending_page_id) + : transition_type_(transition_type), + request_time_(request_time), + request_committed_(false), + is_content_initiated_(is_content_initiated), + pending_page_id_(pending_page_id) { + } + + PageTransition::Type transition_type_; + base::Time request_time_; + base::Time start_load_time_; + base::Time finish_document_load_time_; + base::Time finish_load_time_; + base::Time first_layout_time_; + bool request_committed_; + bool is_content_initiated_; + int32 pending_page_id_; + scoped_ptr<webkit_glue::SearchableFormData> searchable_form_data_; + scoped_ptr<webkit_glue::PasswordForm> password_form_data_; + + DISALLOW_COPY_AND_ASSIGN(NavigationState); +}; + +#endif // CHROME_RENDERER_NAVIGATION_STATE_H_ diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 7c2bbf1..b6d29a2 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -39,6 +39,7 @@ #include "chrome/renderer/localized_error.h" #include "chrome/renderer/media/audio_renderer_impl.h" #include "chrome/renderer/media/buffered_data_source.h" +#include "chrome/renderer/navigation_state.h" #include "chrome/renderer/print_web_view_helper.h" #include "chrome/renderer/render_process.h" #include "chrome/renderer/renderer_logging.h" @@ -90,6 +91,7 @@ using base::Time; using base::TimeDelta; using webkit_glue::AutofillForm; +using webkit_glue::PasswordForm; using webkit_glue::PasswordFormDomManager; using webkit_glue::SearchableFormData; using WebKit::WebConsoleMessage; @@ -141,87 +143,6 @@ static const char* const kUnreachableWebDataURL = static const char* const kBackForwardNavigationScheme = "history"; -// Associated with browser-initiated navigations to hold tracking data. -class RenderView::NavigationState : public WebDataSource::ExtraData { - public: - static NavigationState* CreateBrowserInitiated( - int32 pending_page_id, - PageTransition::Type transition_type, - Time request_time) { - return new NavigationState(transition_type, request_time, false, - pending_page_id); - } - - static NavigationState* CreateContentInitiated() { - // We assume navigations initiated by content are link clicks. - return new NavigationState(PageTransition::LINK, Time(), true, -1); - } - - static NavigationState* FromDataSource(WebDataSource* ds) { - return static_cast<NavigationState*>(ds->GetExtraData()); - } - - // Contains the page_id for this navigation or -1 if there is none yet. - int32 pending_page_id() const { return pending_page_id_; } - - // Is this a new navigation? - bool is_new_navigation() const { return pending_page_id_ == -1; } - - // Contains the transition type that the browser specified when it - // initiated the load. - PageTransition::Type transition_type() const { return transition_type_; } - void set_transition_type(PageTransition::Type type) { - transition_type_ = type; - } - - // The time that this navigation was requested. - const Time& request_time() const { return request_time_; } - - // True if we have already processed the "DidCommitLoad" event for this - // request. Used by session history. - bool request_committed() const { return request_committed_; } - void set_request_committed(bool value) { request_committed_ = value; } - - // True if this navigation was not initiated via WebFrame::LoadRequest. - bool is_content_initiated() const { return is_content_initiated_; } - - SearchableFormData* searchable_form_data() const { - return searchable_form_data_.get(); - } - void set_searchable_form_data(SearchableFormData* data) { - searchable_form_data_.reset(data); - } - - PasswordForm* password_form_data() const { - return password_form_data_.get(); - } - void set_password_form_data(PasswordForm* data) { - password_form_data_.reset(data); - } - - private: - NavigationState(PageTransition::Type transition_type, - const Time& request_time, - bool is_content_initiated, - int32 pending_page_id) - : transition_type_(transition_type), - request_time_(request_time), - request_committed_(false), - is_content_initiated_(is_content_initiated), - pending_page_id_(pending_page_id) { - } - - PageTransition::Type transition_type_; - Time request_time_; - bool request_committed_; - bool is_content_initiated_; - int32 pending_page_id_; - scoped_ptr<SearchableFormData> searchable_form_data_; - scoped_ptr<PasswordForm> password_form_data_; - - DISALLOW_COPY_AND_ASSIGN(NavigationState); -}; - /////////////////////////////////////////////////////////////////////////////// RenderView::RenderView(RenderThreadBase* render_thread) @@ -1119,24 +1040,28 @@ void RenderView::DidStartProvisionalLoadForFrame( WebView* webview, WebFrame* frame, NavigationGesture gesture) { - if (webview->GetMainFrame() == frame) { + WebDataSource* ds = frame->GetProvisionalDataSource(); + NavigationState* navigation_state = NavigationState::FromDataSource(ds); + + navigation_state->set_start_load_time(Time::Now()); + + // Update the request time if WebKit has better knowledge of it. + if (navigation_state->request_time().is_null()) { + double event_time = ds->GetTriggeringEventTime(); + if (event_time != 0.0) + navigation_state->set_request_time(Time::FromDoubleT(event_time)); + } + + bool is_top_most = !frame->GetParent(); + if (is_top_most) { navigation_gesture_ = gesture; // Make sure redirect tracking state is clear for the new load. completed_client_redirect_src_ = GURL(); } - // We may have better knowledge of when this navigation was requested. - WebDataSource* ds = frame->GetProvisionalDataSource(); - if (ds) { - NavigationState* navigation_state = NavigationState::FromDataSource(ds); - if (!navigation_state->request_time().is_null()) - ds->SetRequestTime(navigation_state->request_time()); - } - Send(new ViewHostMsg_DidStartProvisionalLoadForFrame( - routing_id_, webview->GetMainFrame() == frame, - frame->GetProvisionalDataSource()->GetRequest().GetURL())); + routing_id_, is_top_most, ds->GetRequest().GetURL())); } bool RenderView::DidLoadResourceFromMemoryCache(WebView* webview, @@ -2834,12 +2759,16 @@ void RenderView::OnExtensionResponse(int request_id, // so firstLayout can be 0. void RenderView::DumpLoadHistograms() const { WebFrame* main_frame = webview()->GetMainFrame(); - WebDataSource* ds = main_frame->GetDataSource(); - Time request_time = ds->GetRequestTime(); - Time start_load_time = ds->GetStartLoadTime(); - Time finish_document_load_time = ds->GetFinishDocumentLoadTime(); - Time finish_load_time = ds->GetFinishLoadTime(); - Time first_layout_time = ds->GetFirstLayoutTime(); + NavigationState* navigation_state = + NavigationState::FromDataSource(main_frame->GetDataSource()); + + Time request_time = navigation_state->request_time(); + Time start_load_time = navigation_state->start_load_time(); + Time finish_document_load_time = + navigation_state->finish_document_load_time(); + Time finish_load_time = navigation_state->finish_load_time(); + Time first_layout_time = navigation_state->first_layout_time(); + TimeDelta request_to_start = start_load_time - request_time; TimeDelta start_to_finish_doc = finish_document_load_time - start_load_time; TimeDelta finish_doc_to_finish = @@ -2854,8 +2783,8 @@ void RenderView::DumpLoadHistograms() const { UMA_HISTOGRAM_MEDIUM_TIMES("Renderer2.RequestToStart", request_to_start); UMA_HISTOGRAM_CLIPPED_TIMES( FieldTrial::MakeName("Renderer2.RequestToFinish_L", "DnsImpact").data(), - request_to_finish, base::TimeDelta::FromMilliseconds(10), - base::TimeDelta::FromMinutes(10), 100); + request_to_finish, TimeDelta::FromMilliseconds(10), + TimeDelta::FromMinutes(10), 100); if (request_to_first_layout.ToInternalValue() >= 0) { UMA_HISTOGRAM_MEDIUM_TIMES("Renderer2.RequestToFirstLayout", request_to_first_layout); diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index f1108eb..3a710d7 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -47,8 +47,9 @@ class DebugMessageHandler; class DevToolsAgent; class DevToolsClient; class FilePath; -class PrintWebViewHelper; class GURL; +class NavigationState; +class PrintWebViewHelper; class RenderThread; class ResourceDispatcher; class WebError; @@ -788,7 +789,6 @@ class RenderView : public RenderWidget, // the WebDataSource::ExtraData attribute. We use pending_navigation_state_ // as a temporary holder for the state until the WebDataSource corresponding // to the new navigation is created. See DidCreateDataSource. - class NavigationState; scoped_ptr<NavigationState> pending_navigation_state_; // Need for printing diff --git a/webkit/glue/password_form.h b/webkit/glue/password_form.h index 2d88343..df41be8 100644 --- a/webkit/glue/password_form.h +++ b/webkit/glue/password_form.h @@ -11,6 +11,8 @@ #include "base/time.h" #include "googleurl/src/gurl.h" +namespace webkit_glue { + // The PasswordForm struct encapsulates information about a login form, // which can be an HTML form or a dialog with username/password text fields. // @@ -143,4 +145,6 @@ struct PasswordForm { // Map username to PasswordForm* for convenience. See password_form_manager.h. typedef std::map<std::wstring, PasswordForm*> PasswordFormMap; +} // namespace webkit_glue + #endif // WEBKIT_GLUE_PASSWORD_FORM_H__ diff --git a/webkit/glue/webdatasource.h b/webkit/glue/webdatasource.h index 5885db7..4625508 100644 --- a/webkit/glue/webdatasource.h +++ b/webkit/glue/webdatasource.h @@ -18,8 +18,6 @@ namespace base { class Time; } -struct PasswordForm; - enum WebNavigationType { WebNavigationTypeLinkClicked, WebNavigationTypeFormSubmitted, @@ -84,29 +82,9 @@ class WebDataSource { // Returns the page title. virtual string16 GetPageTitle() const = 0; - // Returns the time the document was request by the user. - virtual base::Time GetRequestTime() const = 0; - - // Sets the request time. This is used to override the default behavior - // if the client knows more about the origination of the request than the - // underlying mechanism could. - virtual void SetRequestTime(base::Time time) = 0; - - // Returns the time we started loading the page. This corresponds to - // the DidStartProvisionalLoadForFrame delegate notification. - virtual base::Time GetStartLoadTime() const = 0; - - // Returns the time the document itself was finished loading. This corresponds - // to the DidFinishDocumentLoadForFrame delegate notification. - virtual base::Time GetFinishDocumentLoadTime() const = 0; - - // Returns the time all dependent resources have been loaded and onload() - // has been called. This corresponds to the DidFinishLoadForFrame delegate - // notification. - virtual base::Time GetFinishLoadTime() const = 0; - - // Returns the first time a layout was performed - virtual base::Time GetFirstLayoutTime() const = 0; + // The time in seconds (since the epoch) of the event if any that triggered + // this navigation. Returns 0 if unknown. + virtual double GetTriggeringEventTime() const = 0; // Returns the reason the document was loaded. virtual WebNavigationType GetNavigationType() const = 0; diff --git a/webkit/glue/webdatasource_impl.cc b/webkit/glue/webdatasource_impl.cc index c0ace9b..01e174b 100644 --- a/webkit/glue/webdatasource_impl.cc +++ b/webkit/glue/webdatasource_impl.cc @@ -11,8 +11,6 @@ #include "ResourceRequest.h" #undef LOG -#include "base/histogram.h" -#include "base/string_util.h" #include "webkit/glue/glue_util.h" #include "webkit/glue/password_form.h" #include "webkit/glue/webdatasource_impl.h" @@ -20,9 +18,6 @@ #include "webkit/glue/weburlrequest_impl.h" #include "webkit/glue/webview_delegate.h" -using base::TimeDelta; -using base::Time; - // static PassRefPtr<WebDataSourceImpl> WebDataSourceImpl::Create( const WebCore::ResourceRequest& request, @@ -82,28 +77,12 @@ string16 WebDataSourceImpl::GetPageTitle() const { return webkit_glue::StringToString16(title()); } -base::Time WebDataSourceImpl::GetRequestTime() const { - return request_time_; -} - -void WebDataSourceImpl::SetRequestTime(base::Time time) { - request_time_ = time; -} - -base::Time WebDataSourceImpl::GetStartLoadTime() const { - return start_load_time_; -} - -base::Time WebDataSourceImpl::GetFinishDocumentLoadTime() const { - return finish_document_load_time_; -} - -base::Time WebDataSourceImpl::GetFinishLoadTime() const { - return finish_load_time_; -} +double WebDataSourceImpl::GetTriggeringEventTime() const { + if (!triggeringAction().event()) + return 0.0; -base::Time WebDataSourceImpl::GetFirstLayoutTime() const { - return first_layout_time_; + // DOMTimeStamp uses units of milliseconds. + return triggeringAction().event()->timeStamp() / 1000.0; } WebNavigationType WebDataSourceImpl::GetNavigationType() const { diff --git a/webkit/glue/webdatasource_impl.h b/webkit/glue/webdatasource_impl.h index d2e98bf..deecf64 100644 --- a/webkit/glue/webdatasource_impl.h +++ b/webkit/glue/webdatasource_impl.h @@ -7,8 +7,6 @@ #include "DocumentLoader.h" -#include "base/scoped_ptr.h" -#include "base/time.h" #include "webkit/glue/webdatasource.h" #include "webkit/glue/webresponse_impl.h" #include "webkit/glue/weburlrequest_impl.h" @@ -33,12 +31,7 @@ class WebDataSourceImpl : public WebCore::DocumentLoader, public WebDataSource { virtual bool HasUnreachableURL() const; virtual const std::vector<GURL>& GetRedirectChain() const; virtual string16 GetPageTitle() const; - virtual base::Time GetRequestTime() const; - virtual void SetRequestTime(base::Time time); - virtual base::Time GetStartLoadTime() const; - virtual base::Time GetFinishDocumentLoadTime() const; - virtual base::Time GetFinishLoadTime() const; - virtual base::Time GetFirstLayoutTime() const; + virtual double GetTriggeringEventTime() const; virtual WebNavigationType GetNavigationType() const; virtual ExtraData* GetExtraData() const; virtual void SetExtraData(ExtraData*); @@ -49,26 +42,6 @@ class WebDataSourceImpl : public WebCore::DocumentLoader, public WebDataSource { void ClearRedirectChain(); void AppendRedirect(const GURL& url); - void set_request_time(base::Time request_time) { - request_time_ = request_time; - } - - void set_start_load_time(base::Time start_load_time) { - start_load_time_ = start_load_time; - } - - void set_finish_document_load_time(base::Time finish_document_load_time) { - finish_document_load_time_ = finish_document_load_time; - } - - void set_finish_load_time(base::Time finish_load_time) { - finish_load_time_ = finish_load_time; - } - - void set_first_layout_time(base::Time first_layout_time) { - first_layout_time_ = first_layout_time; - } - private: WebDataSourceImpl(const WebCore::ResourceRequest&, const WebCore::SubstituteData&); @@ -88,13 +61,6 @@ class WebDataSourceImpl : public WebCore::DocumentLoader, public WebDataSource { OwnPtr<ExtraData> extra_data_; - // See webdatasource.h for a description of these time stamps. - base::Time request_time_; - base::Time start_load_time_; - base::Time finish_document_load_time_; - base::Time finish_load_time_; - base::Time first_layout_time_; - DISALLOW_COPY_AND_ASSIGN(WebDataSourceImpl); }; diff --git a/webkit/glue/webframeloaderclient_impl.cc b/webkit/glue/webframeloaderclient_impl.cc index a4a77a9..5a31352 100644 --- a/webkit/glue/webframeloaderclient_impl.cc +++ b/webkit/glue/webframeloaderclient_impl.cc @@ -379,7 +379,6 @@ void WebFrameLoaderClient::dispatchDidFinishDocumentLoad() { if (d) d->DidFinishDocumentLoadForFrame(webview, webframe_); - data_source->set_finish_document_load_time(base::Time::Now()); } bool WebFrameLoaderClient::dispatchDidLoadResourceFromMemoryCache( @@ -683,21 +682,6 @@ void WebFrameLoaderClient::dispatchDidStartProvisionalLoad() { // about the client redirect the load is responsible for completing. d->DidStartProvisionalLoadForFrame(webview, webframe_, NavigationGestureForLastLoad()); - DocumentLoader* documentLoader = - webframe_->frame()->loader()->activeDocumentLoader(); - WebDataSourceImpl* dataSource = - WebDataSourceImpl::FromLoader(documentLoader); - if (dataSource->GetRequestTime().ToInternalValue() == 0) { - const Event *event = documentLoader->triggeringAction().event(); - if (event) { - // If the request was generated by a click, we have to use the time - // from the event. Unfortunately this isn't tracked all the way from - // the platform event, but it will have to do - double eventTime = event->timeStamp() / 1000.0; - dataSource->set_request_time(Time::FromDoubleT(eventTime)); - } - } - dataSource->set_start_load_time(base::Time::Now()); if (completing_client_redirect) d->DidCompleteClientRedirect(webview, webframe_, expected_client_redirect_src_); @@ -767,7 +751,6 @@ void WebFrameLoaderClient::dispatchDidFinishLoad() { WebDataSourceImpl::FromLoader(documentLoader); WebViewImpl* webview = webframe_->GetWebViewImpl(); WebViewDelegate* d = webview->delegate(); - dataSource->set_finish_load_time(base::Time::Now()); if (d) d->DidFinishLoadForFrame(webview, webframe_); WebPluginDelegate* plg_delegate = webframe_->plugin_delegate(); @@ -780,15 +763,10 @@ void WebFrameLoaderClient::dispatchDidFinishLoad() { } void WebFrameLoaderClient::dispatchDidFirstLayout() { - // FIXME: called when webkit finished layout of page. - // All resources have not necessarily finished loading. - DocumentLoader* document_loader = - webframe_->frame()->loader()->documentLoader(); - WebDataSourceImpl* ds = - WebDataSourceImpl::FromLoader(document_loader); - if (ds->GetFirstLayoutTime().ToInternalValue() == 0) { - ds->set_first_layout_time(base::Time::Now()); - } + WebViewImpl* webview = webframe_->GetWebViewImpl(); + WebViewDelegate* d = webview->delegate(); + if (d) + d->DidFirstLayout(webview, webframe_); } void WebFrameLoaderClient::dispatchDidFirstVisuallyNonEmptyLayout() { diff --git a/webkit/glue/webview_delegate.h b/webkit/glue/webview_delegate.h index 7002c57..2736103 100644 --- a/webkit/glue/webview_delegate.h +++ b/webkit/glue/webview_delegate.h @@ -350,6 +350,11 @@ class WebViewDelegate : virtual public WebWidgetDelegate { virtual void DidFinishDocumentLoadForFrame(WebView* webview, WebFrame* frame) { } + // Called after layout runs for the first time after a new document is loaded + // into a frame. All resources have not necessarily finished loading. + virtual void DidFirstLayout(WebView* webview, WebFrame* frame) { + } + // This method is called when we load a resource from an in-memory cache. // A return value of |false| indicates the load should proceed, but WebCore // appears to largely ignore the return value. |