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" |
11 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" |
12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/sessions/session_backend.h" | 14 #include "chrome/browser/sessions/session_backend.h" |
15 #include "chrome/browser/sessions/session_types.h" | 15 #include "chrome/browser/sessions/session_types.h" |
16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 17 #include "chrome/common/url_constants.h" |
17 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
18 #include "content/public/browser/navigation_entry.h" | 19 #include "content/public/browser/navigation_entry.h" |
19 #include "content/public/common/referrer.h" | 20 #include "content/public/common/referrer.h" |
20 | 21 |
21 using content::BrowserThread; | 22 using content::BrowserThread; |
22 using content::NavigationEntry; | 23 using content::NavigationEntry; |
23 | 24 |
24 // BaseSessionService --------------------------------------------------------- | 25 // BaseSessionService --------------------------------------------------------- |
25 | 26 |
26 namespace { | 27 namespace { |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 scoped_ptr<Pickle> pickle(command.PayloadAsPickle()); | 258 scoped_ptr<Pickle> pickle(command.PayloadAsPickle()); |
258 if (!pickle.get()) | 259 if (!pickle.get()) |
259 return false; | 260 return false; |
260 | 261 |
261 PickleIterator iterator(*pickle); | 262 PickleIterator iterator(*pickle); |
262 return pickle->ReadInt(&iterator, window_id) && | 263 return pickle->ReadInt(&iterator, window_id) && |
263 pickle->ReadString(&iterator, app_name); | 264 pickle->ReadString(&iterator, app_name); |
264 } | 265 } |
265 | 266 |
266 bool BaseSessionService::ShouldTrackEntry(const GURL& url) { | 267 bool BaseSessionService::ShouldTrackEntry(const GURL& url) { |
267 return url.is_valid(); | 268 // Blacklist chrome://quit and chrome://restart to avoid quit or restart |
| 269 // loops. |
| 270 return url.is_valid() && !(url.SchemeIs(chrome::kChromeUIScheme) && |
| 271 (url.host() == chrome::kChromeUIQuitHost || |
| 272 url.host() == chrome::kChromeUIRestartHost)); |
268 } | 273 } |
269 | 274 |
270 CancelableTaskTracker::TaskId | 275 CancelableTaskTracker::TaskId |
271 BaseSessionService::ScheduleGetLastSessionCommands( | 276 BaseSessionService::ScheduleGetLastSessionCommands( |
272 const InternalGetCommandsCallback& callback, | 277 const InternalGetCommandsCallback& callback, |
273 CancelableTaskTracker* tracker) { | 278 CancelableTaskTracker* tracker) { |
274 CancelableTaskTracker::IsCanceledCallback is_canceled; | 279 CancelableTaskTracker::IsCanceledCallback is_canceled; |
275 CancelableTaskTracker::TaskId id = tracker->NewTrackedTaskId(&is_canceled); | 280 CancelableTaskTracker::TaskId id = tracker->NewTrackedTaskId(&is_canceled); |
276 | 281 |
277 InternalGetCommandsCallback run_if_not_canceled = | 282 InternalGetCommandsCallback run_if_not_canceled = |
(...skipping 20 matching lines...) Expand all Loading... |
298 from_here, | 303 from_here, |
299 task); | 304 task); |
300 } else { | 305 } else { |
301 // Fall back to executing on the main thread if the sequence | 306 // Fall back to executing on the main thread if the sequence |
302 // worker pool has been requested to shutdown (around shutdown | 307 // worker pool has been requested to shutdown (around shutdown |
303 // time). | 308 // time). |
304 task.Run(); | 309 task.Run(); |
305 return true; | 310 return true; |
306 } | 311 } |
307 } | 312 } |
OLD | NEW |