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

Unified Diff: content/common/mouse_lock.h

Issue 10443045: Silent mouse lock after unlock by target (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Update for silent mouse relock Created 8 years, 7 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: content/common/mouse_lock.h
diff --git a/content/common/mouse_lock.h b/content/common/mouse_lock.h
new file mode 100644
index 0000000000000000000000000000000000000000..eb988094e3f71f7c75735d3435885ece359d6f19
--- /dev/null
+++ b/content/common/mouse_lock.h
@@ -0,0 +1,90 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
scheib 2012/05/30 16:41:21 2012
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_COMMON_MOUSE_LOCK_REQUEST_H_
+#define CONTENT_COMMON_MOUSE_LOCK_REQUEST_H_
+#pragma once
+
+#include "ipc/ipc_param_traits.h"
+#include "ipc/ipc_message_macros.h"
+#include "content/common/content_export.h"
+
+namespace content {
+
+// The source of a mouse lock request
scheib 2012/05/30 16:41:21 Punctuation: http://google-styleguide.googlecode.c
+enum MouseLockSource {
+ // Lock requested with a user gesture
+ USER_GESTURE,
scheib 2012/05/30 16:41:21 These enum names are too generic for the content n
+ // Lock requested not from a user gesture
+ NOT_USER_GESTURE
+};
+
+// The source of an unlock request
+enum MouseUnlockSource {
+ // The target requested the unlock
+ TARGET,
+ // User requested unlock by pressing ESC or initial state
+ NOT_TARGET
+};
+
+} // namespace content
+
+// param traits for serialization over IPC
scheib 2012/05/30 16:41:21 As you mention, the implementation should be place
+namespace IPC {
+template<>
+struct ParamTraits<content::MouseLockSource> {
+ typedef content::MouseLockSource param_type;
scheib 2012/05/30 16:41:21 IMHO the typedef param_type makes this code less r
+ static void Write(Message* m, const param_type& p) {
+ m->WriteInt(static_cast<int>(p));
+ }
+ static bool Read(const Message* m, PickleIterator* iter, param_type* p) {
+ int type;
+ if (!m->ReadInt(iter, &type))
+ return false;
+ *p = static_cast<param_type>(type);
+ return true;
+ }
+ static void Log(const param_type& p, std::string* l) {
+ std::string source;
+ switch (p) {
+ case content::USER_GESTURE:
+ source = "USER_GESTURE";
+ break;
+ case content::NOT_USER_GESTURE:
+ source = "NOT_USER_GESTURE";
+ break;
+ }
+ LogParam(source, l);
+ }
+};
+
+template<>
+struct ParamTraits<content::MouseUnlockSource> {
+ typedef content::MouseUnlockSource param_type;
+ static void Write(Message* m, const param_type& p) {
+ m->WriteInt(static_cast<int>(p));
+ }
+ static bool Read(const Message* m, PickleIterator* iter, param_type* p) {
+ int type;
+ if (!m->ReadInt(iter, &type))
+ return false;
+ *p = static_cast<param_type>(type);
+ return true;
+ }
+ static void Log(const param_type& p, std::string* l) {
+ std::string source;
+ switch (p) {
+ case content::TARGET:
+ source = "TARGET";
+ break;
+ case content::NOT_TARGET:
+ source = "NOT_TARGET";
+ break;
+ }
+ LogParam(source, l);
+ }
+};
+}
+
+#endif /* CONTENT_COMMON_MOUSE_LOCK_REQUEST_H_ */

Powered by Google App Engine
This is Rietveld 408576698