| OLD | NEW |
| 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/sessions/base_session_service.h" | 5 #include "chrome/browser/sessions/base_session_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 | 180 |
| 181 pickle.WriteInt(entry.GetTransitionType()); | 181 pickle.WriteInt(entry.GetTransitionType()); |
| 182 int type_mask = entry.GetHasPostData() ? TabNavigation::HAS_POST_DATA : 0; | 182 int type_mask = entry.GetHasPostData() ? TabNavigation::HAS_POST_DATA : 0; |
| 183 pickle.WriteInt(type_mask); | 183 pickle.WriteInt(type_mask); |
| 184 | 184 |
| 185 WriteStringToPickle(pickle, &bytes_written, max_state_size, | 185 WriteStringToPickle(pickle, &bytes_written, max_state_size, |
| 186 entry.GetReferrer().url.is_valid() ? | 186 entry.GetReferrer().url.is_valid() ? |
| 187 entry.GetReferrer().url.spec() : std::string()); | 187 entry.GetReferrer().url.spec() : std::string()); |
| 188 pickle.WriteInt(entry.GetReferrer().policy); | 188 pickle.WriteInt(entry.GetReferrer().policy); |
| 189 | 189 |
| 190 // Adding more data? Be sure and update TabRestoreService too. | 190 WriteStringToPickle(pickle, &bytes_written, max_state_size, |
| 191 entry.GetOriginalRequestURL().is_valid() ? |
| 192 entry.GetOriginalRequestURL().spec() : std::string()); |
| 193 |
| 191 return new SessionCommand(command_id, pickle); | 194 return new SessionCommand(command_id, pickle); |
| 192 } | 195 } |
| 193 | 196 |
| 194 SessionCommand* BaseSessionService::CreateSetTabExtensionAppIDCommand( | 197 SessionCommand* BaseSessionService::CreateSetTabExtensionAppIDCommand( |
| 195 SessionID::id_type command_id, | 198 SessionID::id_type command_id, |
| 196 SessionID::id_type tab_id, | 199 SessionID::id_type tab_id, |
| 197 const std::string& extension_id) { | 200 const std::string& extension_id) { |
| 198 // Use pickle to handle marshalling. | 201 // Use pickle to handle marshalling. |
| 199 Pickle pickle; | 202 Pickle pickle; |
| 200 pickle.WriteInt(tab_id); | 203 pickle.WriteInt(tab_id); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 // the default policy if the property is not present. | 262 // the default policy if the property is not present. |
| 260 int policy_int; | 263 int policy_int; |
| 261 WebReferrerPolicy policy; | 264 WebReferrerPolicy policy; |
| 262 if (pickle->ReadInt(&iterator, &policy_int)) | 265 if (pickle->ReadInt(&iterator, &policy_int)) |
| 263 policy = static_cast<WebReferrerPolicy>(policy_int); | 266 policy = static_cast<WebReferrerPolicy>(policy_int); |
| 264 else | 267 else |
| 265 policy = WebKit::WebReferrerPolicyDefault; | 268 policy = WebKit::WebReferrerPolicyDefault; |
| 266 navigation->referrer_ = content::Referrer( | 269 navigation->referrer_ = content::Referrer( |
| 267 referrer_spec.empty() ? GURL() : GURL(referrer_spec), | 270 referrer_spec.empty() ? GURL() : GURL(referrer_spec), |
| 268 policy); | 271 policy); |
| 272 |
| 273 // If the original URL can't be found, leave it empty. |
| 274 std::string url_spec; |
| 275 if (!pickle->ReadString(&iterator, &url_spec)) |
| 276 url_spec = std::string(); |
| 277 navigation->set_original_request_url(GURL(url_spec)); |
| 269 } | 278 } |
| 270 | 279 |
| 271 navigation->virtual_url_ = GURL(url_spec); | 280 navigation->virtual_url_ = GURL(url_spec); |
| 272 return true; | 281 return true; |
| 273 } | 282 } |
| 274 | 283 |
| 275 bool BaseSessionService::RestoreSetTabExtensionAppIDCommand( | 284 bool BaseSessionService::RestoreSetTabExtensionAppIDCommand( |
| 276 const SessionCommand& command, | 285 const SessionCommand& command, |
| 277 SessionID::id_type* tab_id, | 286 SessionID::id_type* tab_id, |
| 278 std::string* extension_app_id) { | 287 std::string* extension_app_id) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 if (profile_ && BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { | 331 if (profile_ && BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { |
| 323 return BrowserThread::PostTask(BrowserThread::FILE, from_here, task); | 332 return BrowserThread::PostTask(BrowserThread::FILE, from_here, task); |
| 324 } else { | 333 } else { |
| 325 // Fall back to executing on the main thread if the file thread | 334 // Fall back to executing on the main thread if the file thread |
| 326 // has gone away (around shutdown time) or if we're running as | 335 // has gone away (around shutdown time) or if we're running as |
| 327 // part of a unit test that does not set profile_. | 336 // part of a unit test that does not set profile_. |
| 328 task.Run(); | 337 task.Run(); |
| 329 return true; | 338 return true; |
| 330 } | 339 } |
| 331 } | 340 } |
| OLD | NEW |