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

Unified Diff: chrome/browser/sessions/session_service_utils.cc

Issue 672083002: Refactoring of SessionService to get componentized. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added missing files. Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/sessions/session_service_utils.h ('k') | chrome/browser/sessions/session_types.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sessions/session_service_utils.cc
diff --git a/chrome/browser/sessions/session_service_utils.cc b/chrome/browser/sessions/session_service_utils.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3f9c1300656b2828b7788675fcb1ffcd34e58e72
--- /dev/null
+++ b/chrome/browser/sessions/session_service_utils.cc
@@ -0,0 +1,48 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/sessions/session_service_utils.h"
+
+bool ShouldRestoreWindowOfType(SessionWindow::WindowType window_type,
sky 2014/10/29 23:14:51 AFAICT the ShouldRestore/RemoveUnusedRestoreWindow
Mr4D (OOO till 08-26) 2014/10/29 23:47:44 Done.
+ AppType app_type) {
+#if defined(OS_CHROMEOS)
+ // Restore app popups for ChromeOS alone.
+ if (window_type == SessionWindow::TYPE_POPUP && app_type == TYPE_APP)
+ return true;
+#endif
+
+ return window_type == SessionWindow::TYPE_TABBED;
+}
+
+void RemoveUnusedRestoreWindows(std::vector<SessionWindow*>* window_list) {
+ std::vector<SessionWindow*>::iterator i = window_list->begin();
+ while (i != window_list->end()) {
+ SessionWindow* window = *i;
+ if (!ShouldRestoreWindowOfType(window->type,
+ window->app_name.empty() ? TYPE_NORMAL :
+ TYPE_APP)) {
+ window_list->erase(i);
sky 2014/10/29 23:14:51 This leaks.
Mr4D (OOO till 08-26) 2014/10/29 23:47:44 Done.
+ i = window_list->begin();
+ }
+ }
+}
+
+SessionWindow::WindowType WindowTypeForBrowserType(Browser::Type type) {
+ switch (type) {
+ case Browser::TYPE_POPUP:
+ return SessionWindow::TYPE_POPUP;
+ case Browser::TYPE_TABBED:
+ return SessionWindow::TYPE_TABBED;
+ }
+ NOTREACHED();
+}
+
+Browser::Type BrowserTypeForWindowType(SessionWindow::WindowType type) {
+ switch (type) {
+ case SessionWindow::TYPE_POPUP:
+ return Browser::TYPE_POPUP;
+ case SessionWindow::TYPE_TABBED:
+ return Browser::TYPE_TABBED;
+ }
+}
« no previous file with comments | « chrome/browser/sessions/session_service_utils.h ('k') | chrome/browser/sessions/session_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698