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

Side by Side Diff: chrome/browser/sessions/base_session_service.cc

Issue 10855022: Remove the effects of --disable-restore-session-state. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Test update. Created 8 years, 4 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 | Annotate | Revision Log
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/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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 68
69 // static 69 // static
70 const int BaseSessionService::max_persist_navigation_count = 6; 70 const int BaseSessionService::max_persist_navigation_count = 6;
71 71
72 BaseSessionService::BaseSessionService(SessionType type, 72 BaseSessionService::BaseSessionService(SessionType type,
73 Profile* profile, 73 Profile* profile,
74 const FilePath& path) 74 const FilePath& path)
75 : profile_(profile), 75 : profile_(profile),
76 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), 76 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
77 pending_reset_(false), 77 pending_reset_(false),
78 commands_since_reset_(0), 78 commands_since_reset_(0) {
79 save_post_data_(false) {
80 if (profile) { 79 if (profile) {
81 // We should never be created when incognito. 80 // We should never be created when incognito.
82 DCHECK(!profile->IsOffTheRecord()); 81 DCHECK(!profile->IsOffTheRecord());
83 const CommandLine* command_line = CommandLine::ForCurrentProcess();
84 save_post_data_ =
85 !command_line->HasSwitch(switches::kDisableRestoreSessionState);
86 } 82 }
87 backend_ = new SessionBackend(type, profile_ ? profile_->GetPath() : path); 83 backend_ = new SessionBackend(type, profile_ ? profile_->GetPath() : path);
88 DCHECK(backend_.get()); 84 DCHECK(backend_.get());
89 85
90 // SessionBackend::Init() cannot be scheduled to be called here. There are 86 // SessionBackend::Init() cannot be scheduled to be called here. There are
91 // service processes which create the BaseSessionService, but they should not 87 // service processes which create the BaseSessionService, but they should not
92 // initialize the backend. If they do, the backend will cycle the session 88 // initialize the backend. If they do, the backend will cycle the session
93 // restore files. That in turn prevents the session restore from working when 89 // restore files. That in turn prevents the session restore from working when
94 // the normal chromium process is launched. Normally, the backend will be 90 // the normal chromium process is launched. Normally, the backend will be
95 // initialized before it's actually used. However, if we're running as a part 91 // initialized before it's actually used. However, if we're running as a part
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 int bytes_written = 0; 164 int bytes_written = 0;
169 165
170 WriteStringToPickle(pickle, &bytes_written, max_state_size, 166 WriteStringToPickle(pickle, &bytes_written, max_state_size,
171 entry.GetVirtualURL().spec()); 167 entry.GetVirtualURL().spec());
172 168
173 WriteString16ToPickle(pickle, &bytes_written, max_state_size, 169 WriteString16ToPickle(pickle, &bytes_written, max_state_size,
174 entry.GetTitle()); 170 entry.GetTitle());
175 171
176 std::string content_state = entry.GetContentState(); 172 std::string content_state = entry.GetContentState();
177 if (entry.GetHasPostData()) { 173 if (entry.GetHasPostData()) {
178 if (save_post_data_) { 174 content_state =
179 content_state = 175 webkit_glue::RemovePasswordDataFromHistoryState(content_state);
180 webkit_glue::RemovePasswordDataFromHistoryState(content_state);
181 } else {
182 content_state =
183 webkit_glue::RemoveFormDataFromHistoryState(content_state);
184 }
185 } 176 }
186 WriteStringToPickle(pickle, &bytes_written, max_state_size, content_state); 177 WriteStringToPickle(pickle, &bytes_written, max_state_size, content_state);
187 178
188 pickle.WriteInt(entry.GetTransitionType()); 179 pickle.WriteInt(entry.GetTransitionType());
189 int type_mask = entry.GetHasPostData() ? TabNavigation::HAS_POST_DATA : 0; 180 int type_mask = entry.GetHasPostData() ? TabNavigation::HAS_POST_DATA : 0;
190 pickle.WriteInt(type_mask); 181 pickle.WriteInt(type_mask);
191 182
192 WriteStringToPickle(pickle, &bytes_written, max_state_size, 183 WriteStringToPickle(pickle, &bytes_written, max_state_size,
193 entry.GetReferrer().url.is_valid() ? 184 entry.GetReferrer().url.is_valid() ?
194 entry.GetReferrer().url.spec() : std::string()); 185 entry.GetReferrer().url.spec() : std::string());
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 // has gone away (around shutdown time) or if we're running as 375 // has gone away (around shutdown time) or if we're running as
385 // part of a unit test that does not set profile_. 376 // part of a unit test that does not set profile_.
386 task.Run(); 377 task.Run();
387 return true; 378 return true;
388 } 379 }
389 } 380 }
390 381
391 bool BaseSessionService::RunningInProduction() const { 382 bool BaseSessionService::RunningInProduction() const {
392 return profile_ && BrowserThread::IsMessageLoopValid(BrowserThread::FILE); 383 return profile_ && BrowserThread::IsMessageLoopValid(BrowserThread::FILE);
393 } 384 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/base_session_service.h ('k') | chrome/browser/sessions/session_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698