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

Unified Diff: chrome/browser/modal_dialog_lock.h

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.h
diff --git a/chrome/browser/modal_dialog_lock.h b/chrome/browser/modal_dialog_lock.h
new file mode 100644
index 0000000000000000000000000000000000000000..f04756ff1f71fa6b22f73f7a9b7657c044f3b674
--- /dev/null
+++ b/chrome/browser/modal_dialog_lock.h
@@ -0,0 +1,52 @@
+// 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.
+
+#ifndef CHROME_BROWSER_MODAL_DIALOG_LOCK_H_
+#define CHROME_BROWSER_MODAL_DIALOG_LOCK_H_
+
+#include "base/basictypes.h"
+#include "chrome/browser/process_singleton.h"
+#include "ui/gfx/native_widget_types.h"
+
+class CommandLine;
+
+namespace base {
+class FilePath;
+}
+
+// Implements a ProcessSingleton::NotificationCallback that prevents
gab 2013/03/27 18:03:26 I don't like the use of "Implements" here since it
erikwright (departed) 2013/03/28 03:16:34 Changed to Provides.
+// command-line handling when a modal dialog is active.
+//
+// While a dialog is active, the ProcessSingleton notification
+// callback will handle but ignore notifications (i.e., neither this process
+// nor the invoking process will handle the command line) and the dialog is
+// brought to the foreground.
+//
+// Otherwise, the notification is forwarded to a wrapped NotificationCallback.
+class ModalDialogLock {
robertshield 2013/03/27 14:51:38 Minor nit, but would prefer naming this with "Proc
erikwright (departed) 2013/03/28 03:16:34 Done.
+ public:
+ explicit ModalDialogLock(
+ const ProcessSingleton::NotificationCallback& original_callback);
+ ~ModalDialogLock();
+
+ // Receives a handle to the active modal dialog, or NULL if the active dialog
+ // is dismissed.
+ void SetActiveModalDialog(gfx::NativeWindow active_dialog);
+
+ // Returns the callback that should be supplied to ProcessSingleton.
+ // The callback is only valid during the lifetime of the ModalDialogLock
+ // instance.
+ ProcessSingleton::NotificationCallback AsNotificationCallback();
+
+ private:
+ bool NotificationCallbackImpl(const CommandLine& command_line,
+ const base::FilePath& current_directory);
+
+ gfx::NativeWindow active_dialog_;
+ ProcessSingleton::NotificationCallback original_callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(ModalDialogLock);
+};
+
+#endif // CHROME_BROWSER_MODAL_DIALOG_LOCK_H_

Powered by Google App Engine
This is Rietveld 408576698