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

Unified Diff: chrome/browser/extensions/app_host_installer_win.cc

Issue 11054006: Make application shortcuts point to app_host.exe, install App Host during app installation. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 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
Index: chrome/browser/extensions/app_host_installer_win.cc
diff --git a/chrome/browser/extensions/app_host_installer_win.cc b/chrome/browser/extensions/app_host_installer_win.cc
new file mode 100755
index 0000000000000000000000000000000000000000..11afad10fcc9997712cdd9db6db0fad30b662161
--- /dev/null
+++ b/chrome/browser/extensions/app_host_installer_win.cc
@@ -0,0 +1,76 @@
+// Copyright (c) 2012 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/extensions/app_host_installer_win.h"
+
+#include <windows.h>
benwells 2012/10/03 05:08:43 Some of these includes are in the .h
huangs 2012/10/03 20:09:47 I thought a .cc file should not assume transitive
+#include "base/bind.h"
+#include "base/win/object_watcher.h"
+#include "chrome/installer/launcher_support/chrome_launcher_support.h"
+#include "content/public/browser/browser_thread.h"
+
+namespace extensions {
+
+namespace {
benwells 2012/10/03 05:08:43 Keep the anonymous namespace out of the extensions
huangs 2012/10/03 20:09:47 Done.
+
+class QuickEnableWatcher : public base::win::ObjectWatcher::Delegate {
+ public:
+ QuickEnableWatcher(bool* running, const base::Closure& on_success,
+ const base::Closure& on_failure)
+ : running_(running),
+ on_success_(on_success),
+ on_failure_(on_failure) {
+ }
+
+ // base::win::ObjectWatcher::Delegate implementation.
+ void OnObjectSignaled(HANDLE object) {
+ DWORD exit_code;
+ ::GetExitCodeProcess(object, &exit_code);
+ if (exit_code == 0)
+ on_success_.Run();
+ else
+ on_failure_.Run();
erikwright (departed) 2012/10/03 15:58:35 Use process_util::GetTerminationStatus instead of
huangs 2012/10/03 20:09:47 Done. I think TerminationStatus is sufficient; we
+ on_success_.Reset();
+ on_failure_.Reset();
+ *running_ = false;
+ }
+
+ private:
+ bool* running_;
+ base::Closure on_success_;
+ base::Closure on_failure_;
+
+ DISALLOW_COPY_AND_ASSIGN(QuickEnableWatcher);
+};
+} // namespace
benwells 2012/10/03 05:08:43 Nit: Blank line before end of namespace.
huangs 2012/10/03 20:09:47 Done.
+
+AppHostInstaller::AppHostInstaller()
+ : running_(false), process_(INVALID_HANDLE_VALUE), delegate_(NULL) {
erikwright (departed) 2012/10/03 15:58:35 process_ and delegate_ are objects whose default c
huangs 2012/10/03 20:09:47 Done.
+}
+
+void AppHostInstaller::EnsureAppHostPresentAndCall(
+ const base::Closure& on_success,
+ const base::Closure& on_failure) {
+ using content::BrowserThread;
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ DCHECK(!running_);
benwells 2012/10/03 05:08:43 Is running_ just for this DCHECK?
erikwright (departed) 2012/10/03 15:58:35 It could have been used to allow the AppHostInstal
huangs 2012/10/03 20:09:47 I'm worried about the case where user installs app
huangs 2012/10/03 20:09:47 Done.
+
+ // If installed.
+ if (chrome_launcher_support::IsAppHostPresent()) {
+ on_success.Run();
+ } else {
+ DCHECK(!process_.IsValid());
+ if (FAILED(chrome_launcher_support::LaunchQuickEnableAppHost(&process_))) {
+ on_failure.Run();
+ } else {
+ DCHECK(process_.IsValid());
+ running_ = true;
+ delegate_.reset(
+ new QuickEnableWatcher(&running_, on_success, on_failure));
+ watcher_.StartWatching(process_, delegate_.get());
+ }
+ }
+}
+
+} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698