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

Unified Diff: apps/app_restore_service.cc

Issue 12450014: Show an InfoBar when trying to start Packaged Apps from Metro mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add a 1 second delay, some nits Created 7 years, 9 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
Index: apps/app_restore_service.cc
diff --git a/apps/app_restore_service.cc b/apps/app_restore_service.cc
index f1b3fd3801998ef13600d1afa24fd36a67015d20..c669616eef7057df61b60419782eee15313fd5cc 100644
--- a/apps/app_restore_service.cc
+++ b/apps/app_restore_service.cc
@@ -4,6 +4,12 @@
#include "apps/app_restore_service.h"
+#include "apps/pref_names.h"
+#include "base/bind.h"
+#include "base/message_loop.h"
+#include "base/prefs/pref_service.h"
+#include "base/time.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/api/app_runtime/app_runtime_api.h"
#include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h"
#include "chrome/browser/extensions/event_router.h"
@@ -55,6 +61,8 @@ void AppRestoreService::HandleStartup(bool should_restore_apps) {
RestoreApp(*it, file_entries);
}
}
+
+ MaybeHandleMetroRelaunch(extension_service);
}
void AppRestoreService::Observe(int type,
@@ -107,4 +115,39 @@ void AppRestoreService::RestoreApp(
AppEventRouter::DispatchOnRestartedEvent(profile_, extension);
}
+void AppRestoreService::LaunchAppWithId(const std::string& extension_id) {
benwells 2013/03/15 00:39:04 I would prefer all this in a different PKS dedicat
tapted 2013/03/15 00:51:16 I'll try that out. Although I think the #if is st
+ ExtensionService* extension_service =
+ ExtensionSystem::Get(profile_)->extension_service();
+ const Extension* extension =
+ extension_service->GetExtensionById(extension_id, false);
+ // There is a possibility of the extension getting uninstalled.
+ if (!extension)
+ return;
+
+ extensions::AppEventRouter::DispatchOnLaunchedEvent(profile_, extension);
+}
+
+void AppRestoreService::MaybeHandleMetroRelaunch(
+ ExtensionService* extension_service) {
+#if defined(OS_WIN)
+ const int kRestartAppLaunchDelayMs = 1000;
+ PrefService* prefs = g_browser_process->local_state();
+ if (!prefs->HasPrefPath(prefs::kRestartFromMetroWithAppLaunch))
+ return;
+
+ std::string extension_id =
+ prefs->GetString(prefs::kRestartFromMetroWithAppLaunch);
+ if (extension_id.empty())
+ return;
+
+ prefs->ClearPref(prefs::kRestartFromMetroWithAppLaunch);
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&AppRestoreService::LaunchAppWithId,
+ base::Unretained(this),
+ extension_id),
+ base::TimeDelta::FromMilliseconds(kRestartAppLaunchDelayMs));
+#endif // defined(OS_WIN)
+}
+
} // namespace apps

Powered by Google App Engine
This is Rietveld 408576698