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

Unified Diff: chrome/browser/modal_dialog_lock.cc

Issue 12096114: Extract locking behaviour from ProcessSingleton. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: missed merge. 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: chrome/browser/modal_dialog_lock.cc
diff --git a/chrome/browser/modal_dialog_lock.cc b/chrome/browser/modal_dialog_lock.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c341fee96428b25454dfd79fda18cf8e579c9560
--- /dev/null
+++ b/chrome/browser/modal_dialog_lock.cc
@@ -0,0 +1,54 @@
+// Copyright (c) 2013 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/modal_dialog_lock.h"
+
+#if defined(OS_WIN)
+#include <Windows.h>
+#endif
+
+#include "base/bind.h"
+#include "base/command_line.h"
+#include "base/files/file_path.h"
+#include "base/logging.h"
+
+ModalDialogLock::ModalDialogLock(
+ const ProcessSingleton::NotificationCallback& original_callback)
+ : active_dialog_(NULL),
+ original_callback_(original_callback) {}
+
+ModalDialogLock::~ModalDialogLock() {}
+
+void ModalDialogLock::SetActiveModalDialog(gfx::NativeWindow active_dialog) {
+#if !defined(OS_WIN) || defined(USE_AURA)
gab 2013/03/27 18:03:26 If this is only meant to be used on Windows, why n
gab 2013/03/27 18:03:26 Why is this a NOTREACHED() on win-Aura?
erikwright (departed) 2013/03/28 03:16:34 I didn't want to force too may #ifdef's in the cli
erikwright (departed) 2013/03/28 03:16:34 It was never actually called and eventually we wou
+ NOTREACHED();
gab 2013/03/27 18:03:26 nit: indent two less spaces.
erikwright (departed) 2013/03/28 03:16:34 n/a.
+#else
+ active_dialog_ = active_dialog;
+#endif
+}
+
+ProcessSingleton::NotificationCallback
+ModalDialogLock::AsNotificationCallback() {
+#if !defined(OS_WIN) || defined(USE_AURA)
+ return original_callback_;
+#else
+ return base::Bind(&ModalDialogLock::NotificationCallbackImpl,
+ base::Unretained(this));
+#endif
+}
+
+bool ModalDialogLock::NotificationCallbackImpl(
+ const CommandLine& command_line,
+ const base::FilePath& current_directory) {
+ if (active_dialog_ != NULL) {
+#if !defined(OS_WIN) || defined(USE_AURA)
+ NOTREACHED();
+#else
+ ::SetForegroundWindow(active_dialog_);
+#endif
+ return true;
+ } else {
+ return original_callback_.Run(command_line, current_directory);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698