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

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

Issue 5168004: Revert 66646 - Add "open as window" menu item to NTP app menu.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 1 month 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
Index: chrome/browser/sessions/session_restore.cc
===================================================================
--- chrome/browser/sessions/session_restore.cc (revision 66663)
+++ chrome/browser/sessions/session_restore.cc (working copy)
@@ -272,7 +272,8 @@
synchronous_(synchronous),
clobber_existing_window_(clobber_existing_window),
always_create_tabbed_browser_(always_create_tabbed_browser),
- urls_to_open_(urls_to_open) {
+ urls_to_open_(urls_to_open),
+ waiting_for_extension_service_(false) {
}
void Restore() {
@@ -338,6 +339,19 @@
delete this;
return;
+ case NotificationType::EXTENSIONS_READY: {
+ if (!waiting_for_extension_service_)
+ return;
+
+ waiting_for_extension_service_ = false;
+ if (synchronous_) {
+ MessageLoop::current()->Quit();
+ return;
+ }
+ ProcessSessionWindows(&windows_);
+ return;
+ }
+
default:
NOTREACHED();
break;
@@ -382,6 +396,18 @@
void OnGotSession(SessionService::Handle handle,
std::vector<SessionWindow*>* windows) {
+ if (HasExtensionApps(*windows) && profile_->GetExtensionsService() &&
+ !profile_->GetExtensionsService()->is_ready()) {
+ // At least one tab is an app tab and the extension service hasn't
+ // finished loading. Wait to continue processing until the extensions
+ // service finishes loading.
+ registrar_.Add(this, NotificationType::EXTENSIONS_READY,
+ Source<Profile>(profile_));
+ windows_.swap(*windows);
+ waiting_for_extension_service_ = true;
+ return;
+ }
+
if (synchronous_) {
// See comment above windows_ as to why we don't process immediately.
windows_.swap(*windows);
@@ -392,6 +418,28 @@
ProcessSessionWindows(windows);
}
+ // Returns true if any tab in |windows| has an application extension id.
+ bool HasExtensionApps(const std::vector<SessionWindow*>& windows) {
+ for (std::vector<SessionWindow*>::const_iterator i = windows.begin();
+ i != windows.end(); ++i) {
+ if (HasExtensionApps((*i)->tabs))
+ return true;
+ }
+
+ return false;
+ }
+
+ // Returns true if any tab in |tabs| has an application extension id.
+ bool HasExtensionApps(const std::vector<SessionTab*>& tabs) {
+ for (std::vector<SessionTab*>::const_iterator i = tabs.begin();
+ i != tabs.end(); ++i) {
+ if (!(*i)->extension_app_id.empty())
+ return true;
+ }
+
+ return false;
+ }
+
void ProcessSessionWindows(std::vector<SessionWindow*>* windows) {
if (windows->empty()) {
// Restore was unsuccessful.
@@ -553,6 +601,10 @@
// windows when the nested message loop exits.
std::vector<SessionWindow*> windows_;
+ // If true, indicates at least one tab has an application extension id and
+ // we're waiting for the extension service to finish loading.
+ bool waiting_for_extension_service_;
+
NotificationRegistrar registrar_;
};
« no previous file with comments | « chrome/browser/resources/ntp/apps.js ('k') | chrome/browser/tab_contents/render_view_host_delegate_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698