| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #ifndef CHROME_RENDERER_NAVIGATION_STATE_H_ | 5 #ifndef CHROME_RENDERER_NAVIGATION_STATE_H_ |
| 6 #define CHROME_RENDERER_NAVIGATION_STATE_H_ | 6 #define CHROME_RENDERER_NAVIGATION_STATE_H_ |
| 7 | 7 |
| 8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "chrome/common/page_transition_types.h" | 10 #include "chrome/common/page_transition_types.h" |
| 11 #include "webkit/api/public/WebDataSource.h" | 11 #include "webkit/api/public/WebDataSource.h" |
| 12 #include "webkit/glue/alt_error_page_resource_fetcher.h" |
| 12 #include "webkit/glue/password_form.h" | 13 #include "webkit/glue/password_form.h" |
| 13 #include "webkit/glue/searchable_form_data.h" | 14 #include "webkit/glue/searchable_form_data.h" |
| 14 | 15 |
| 15 // The RenderView stores an instance of this class in the "extra data" of each | 16 // The RenderView stores an instance of this class in the "extra data" of each |
| 16 // WebDataSource (see RenderView::DidCreateDataSource). | 17 // WebDataSource (see RenderView::DidCreateDataSource). |
| 17 class NavigationState : public WebKit::WebDataSource::ExtraData { | 18 class NavigationState : public WebKit::WebDataSource::ExtraData { |
| 18 public: | 19 public: |
| 19 static NavigationState* CreateBrowserInitiated( | 20 static NavigationState* CreateBrowserInitiated( |
| 20 int32 pending_page_id, | 21 int32 pending_page_id, |
| 21 PageTransition::Type transition_type, | 22 PageTransition::Type transition_type, |
| 22 base::Time request_time) { | 23 base::Time request_time) { |
| 23 return new NavigationState(transition_type, request_time, false, | 24 return new NavigationState(transition_type, request_time, false, |
| 24 pending_page_id); | 25 pending_page_id); |
| 25 } | 26 } |
| 26 | 27 |
| 27 static NavigationState* CreateContentInitiated() { | 28 static NavigationState* CreateContentInitiated() { |
| 28 // We assume navigations initiated by content are link clicks. | 29 // We assume navigations initiated by content are link clicks. |
| 29 return new NavigationState(PageTransition::LINK, base::Time(), true, -1); | 30 return new NavigationState(PageTransition::LINK, base::Time(), true, -1); |
| 30 } | 31 } |
| 31 | 32 |
| 32 static NavigationState* FromDataSource(WebKit::WebDataSource* ds) { | 33 static NavigationState* FromDataSource(WebKit::WebDataSource* ds) { |
| 33 return static_cast<NavigationState*>(ds->extraData()); | 34 return static_cast<NavigationState*>(ds->extraData()); |
| 34 } | 35 } |
| 35 | 36 |
| 36 // Contains the page_id for this navigation or -1 if there is none yet. | 37 // Contains the page_id for this navigation or -1 if there is none yet. |
| 37 int32 pending_page_id() const { return pending_page_id_; } | 38 int32 pending_page_id() const { return pending_page_id_; } |
| 38 | 39 |
| 39 // Is this a new navigation? | |
| 40 bool is_new_navigation() const { return pending_page_id_ == -1; } | |
| 41 | |
| 42 // Contains the transition type that the browser specified when it | 40 // Contains the transition type that the browser specified when it |
| 43 // initiated the load. | 41 // initiated the load. |
| 44 PageTransition::Type transition_type() const { return transition_type_; } | 42 PageTransition::Type transition_type() const { return transition_type_; } |
| 45 void set_transition_type(PageTransition::Type type) { | 43 void set_transition_type(PageTransition::Type type) { |
| 46 transition_type_ = type; | 44 transition_type_ = type; |
| 47 } | 45 } |
| 48 | 46 |
| 49 // The time that this navigation was requested. | 47 // The time that this navigation was requested. |
| 50 const base::Time& request_time() const { | 48 const base::Time& request_time() const { |
| 51 return request_time_; | 49 return request_time_; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 searchable_form_data_.reset(data); | 123 searchable_form_data_.reset(data); |
| 126 } | 124 } |
| 127 | 125 |
| 128 webkit_glue::PasswordForm* password_form_data() const { | 126 webkit_glue::PasswordForm* password_form_data() const { |
| 129 return password_form_data_.get(); | 127 return password_form_data_.get(); |
| 130 } | 128 } |
| 131 void set_password_form_data(webkit_glue::PasswordForm* data) { | 129 void set_password_form_data(webkit_glue::PasswordForm* data) { |
| 132 password_form_data_.reset(data); | 130 password_form_data_.reset(data); |
| 133 } | 131 } |
| 134 | 132 |
| 133 webkit_glue::AltErrorPageResourceFetcher* alt_error_page_fetcher() const { |
| 134 return alt_error_page_fetcher_.get(); |
| 135 } |
| 136 void set_alt_error_page_fetcher(webkit_glue::AltErrorPageResourceFetcher* f) { |
| 137 alt_error_page_fetcher_.reset(f); |
| 138 } |
| 139 |
| 135 const std::string& security_info() const { | 140 const std::string& security_info() const { |
| 136 return security_info_; | 141 return security_info_; |
| 137 } | 142 } |
| 138 void set_security_info(const std::string& security_info) { | 143 void set_security_info(const std::string& security_info) { |
| 139 security_info_ = security_info; | 144 security_info_ = security_info; |
| 140 } | 145 } |
| 141 | 146 |
| 142 private: | 147 private: |
| 143 NavigationState(PageTransition::Type transition_type, | 148 NavigationState(PageTransition::Type transition_type, |
| 144 const base::Time& request_time, | 149 const base::Time& request_time, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 159 base::Time finish_document_load_time_; | 164 base::Time finish_document_load_time_; |
| 160 base::Time finish_load_time_; | 165 base::Time finish_load_time_; |
| 161 base::Time first_paint_time_; | 166 base::Time first_paint_time_; |
| 162 base::Time first_paint_after_load_time_; | 167 base::Time first_paint_after_load_time_; |
| 163 bool load_histograms_recorded_; | 168 bool load_histograms_recorded_; |
| 164 bool request_committed_; | 169 bool request_committed_; |
| 165 bool is_content_initiated_; | 170 bool is_content_initiated_; |
| 166 int32 pending_page_id_; | 171 int32 pending_page_id_; |
| 167 scoped_ptr<webkit_glue::SearchableFormData> searchable_form_data_; | 172 scoped_ptr<webkit_glue::SearchableFormData> searchable_form_data_; |
| 168 scoped_ptr<webkit_glue::PasswordForm> password_form_data_; | 173 scoped_ptr<webkit_glue::PasswordForm> password_form_data_; |
| 174 scoped_ptr<webkit_glue::AltErrorPageResourceFetcher> alt_error_page_fetcher_; |
| 169 std::string security_info_; | 175 std::string security_info_; |
| 170 | 176 |
| 171 DISALLOW_COPY_AND_ASSIGN(NavigationState); | 177 DISALLOW_COPY_AND_ASSIGN(NavigationState); |
| 172 }; | 178 }; |
| 173 | 179 |
| 174 #endif // CHROME_RENDERER_NAVIGATION_STATE_H_ | 180 #endif // CHROME_RENDERER_NAVIGATION_STATE_H_ |
| OLD | NEW |