| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/sessions/base_session_service.h" | 5 #include "chrome/browser/sessions/base_session_service.h" |
| 6 | 6 |
| 7 #include "base/pickle.h" | 7 #include "base/pickle.h" |
| 8 #include "base/thread.h" | 8 #include "base/thread.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
| 11 #include "chrome/browser/sessions/session_backend.h" | 11 #include "chrome/browser/sessions/session_backend.h" |
| 12 #include "chrome/browser/sessions/session_types.h" | 12 #include "chrome/browser/sessions/session_types.h" |
| 13 #include "chrome/browser/tab_contents/navigation_entry.h" | 13 #include "chrome/browser/tab_contents/navigation_entry.h" |
| 14 #include "chrome/common/stl_util-inl.h" | 14 #include "chrome/common/stl_util-inl.h" |
| 15 #include "webkit/glue/webkit_glue.h" |
| 15 | 16 |
| 16 // InternalGetCommandsRequest ------------------------------------------------- | 17 // InternalGetCommandsRequest ------------------------------------------------- |
| 17 | 18 |
| 18 BaseSessionService::InternalGetCommandsRequest::~InternalGetCommandsRequest() { | 19 BaseSessionService::InternalGetCommandsRequest::~InternalGetCommandsRequest() { |
| 19 STLDeleteElements(&commands); | 20 STLDeleteElements(&commands); |
| 20 } | 21 } |
| 21 | 22 |
| 22 // BaseSessionService --------------------------------------------------------- | 23 // BaseSessionService --------------------------------------------------------- |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 std::numeric_limits<SessionCommand::size_type>::max() - 1024; | 154 std::numeric_limits<SessionCommand::size_type>::max() - 1024; |
| 154 | 155 |
| 155 int bytes_written = 0; | 156 int bytes_written = 0; |
| 156 | 157 |
| 157 WriteStringToPickle(pickle, &bytes_written, max_state_size, | 158 WriteStringToPickle(pickle, &bytes_written, max_state_size, |
| 158 entry.display_url().spec()); | 159 entry.display_url().spec()); |
| 159 | 160 |
| 160 WriteWStringToPickle(pickle, &bytes_written, max_state_size, | 161 WriteWStringToPickle(pickle, &bytes_written, max_state_size, |
| 161 UTF16ToWideHack(entry.title())); | 162 UTF16ToWideHack(entry.title())); |
| 162 | 163 |
| 163 WriteStringToPickle(pickle, &bytes_written, max_state_size, | 164 if (entry.has_post_data()) { |
| 164 entry.content_state()); | 165 // Remove the form data, it may contain sensitive information. |
| 166 WriteStringToPickle(pickle, &bytes_written, max_state_size, |
| 167 webkit_glue::RemoveFormDataFromHistoryState(entry.content_state())); |
| 168 } else { |
| 169 WriteStringToPickle(pickle, &bytes_written, max_state_size, |
| 170 entry.content_state()); |
| 171 } |
| 165 | 172 |
| 166 pickle.WriteInt(entry.transition_type()); | 173 pickle.WriteInt(entry.transition_type()); |
| 167 int type_mask = entry.has_post_data() ? TabNavigation::HAS_POST_DATA : 0; | 174 int type_mask = entry.has_post_data() ? TabNavigation::HAS_POST_DATA : 0; |
| 168 pickle.WriteInt(type_mask); | 175 pickle.WriteInt(type_mask); |
| 169 | 176 |
| 170 WriteStringToPickle(pickle, &bytes_written, max_state_size, | 177 WriteStringToPickle(pickle, &bytes_written, max_state_size, |
| 171 entry.referrer().is_valid() ? entry.referrer().spec() : std::string()); | 178 entry.referrer().is_valid() ? entry.referrer().spec() : std::string()); |
| 172 | 179 |
| 173 // Adding more data? Be sure and update TabRestoreService too. | 180 // Adding more data? Be sure and update TabRestoreService too. |
| 174 return new SessionCommand(command_id, pickle); | 181 return new SessionCommand(command_id, pickle); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 202 pickle->ReadString(&iterator, &referrer_spec); | 209 pickle->ReadString(&iterator, &referrer_spec); |
| 203 if (!referrer_spec.empty()) | 210 if (!referrer_spec.empty()) |
| 204 navigation->referrer_ = GURL(referrer_spec); | 211 navigation->referrer_ = GURL(referrer_spec); |
| 205 } | 212 } |
| 206 | 213 |
| 207 navigation->url_ = GURL(url_spec); | 214 navigation->url_ = GURL(url_spec); |
| 208 return true; | 215 return true; |
| 209 } | 216 } |
| 210 | 217 |
| 211 bool BaseSessionService::ShouldTrackEntry(const NavigationEntry& entry) { | 218 bool BaseSessionService::ShouldTrackEntry(const NavigationEntry& entry) { |
| 212 // Don't track entries that have post data. Post data may contain passwords | 219 return entry.display_url().is_valid(); |
| 213 // and other sensitive data users don't want stored to disk. | |
| 214 return entry.display_url().is_valid() && !entry.has_post_data(); | |
| 215 } | 220 } |
| 216 | 221 |
| 217 bool BaseSessionService::ShouldTrackEntry(const TabNavigation& navigation) { | 222 bool BaseSessionService::ShouldTrackEntry(const TabNavigation& navigation) { |
| 218 // Don't track entries that have post data. Post data may contain passwords | 223 return navigation.url().is_valid(); |
| 219 // and other sensitive data users don't want stored to disk. | |
| 220 return navigation.url().is_valid() && | |
| 221 (navigation.type_mask() & TabNavigation::HAS_POST_DATA) == 0; | |
| 222 } | 224 } |
| 223 | 225 |
| 224 BaseSessionService::Handle BaseSessionService::ScheduleGetLastSessionCommands( | 226 BaseSessionService::Handle BaseSessionService::ScheduleGetLastSessionCommands( |
| 225 InternalGetCommandsRequest* request, | 227 InternalGetCommandsRequest* request, |
| 226 CancelableRequestConsumerBase* consumer) { | 228 CancelableRequestConsumerBase* consumer) { |
| 227 scoped_refptr<InternalGetCommandsRequest> request_wrapper(request); | 229 scoped_refptr<InternalGetCommandsRequest> request_wrapper(request); |
| 228 AddRequest(request, consumer); | 230 AddRequest(request, consumer); |
| 229 if (backend_thread()) { | 231 if (backend_thread()) { |
| 230 backend_thread()->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 232 backend_thread()->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( |
| 231 backend(), &SessionBackend::ReadLastSessionCommands, request)); | 233 backend(), &SessionBackend::ReadLastSessionCommands, request)); |
| 232 } else { | 234 } else { |
| 233 backend()->ReadLastSessionCommands(request); | 235 backend()->ReadLastSessionCommands(request); |
| 234 } | 236 } |
| 235 return request->handle(); | 237 return request->handle(); |
| 236 } | 238 } |
| OLD | NEW |