summaryrefslogtreecommitdiffstats
path: root/webkit/glue/window_open_disposition.cc
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-16 06:36:28 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-16 06:36:28 +0000
commit4873c7de675554a357717ddedc1fcaca2820de19 (patch)
treecd6446547d3b9d57f634187aecb1853c5ecbc8fb /webkit/glue/window_open_disposition.cc
parent3b846396a90174835320be2ff50afe8dd4e31590 (diff)
downloadchromium_src-4873c7de675554a357717ddedc1fcaca2820de19.zip
chromium_src-4873c7de675554a357717ddedc1fcaca2820de19.tar.gz
chromium_src-4873c7de675554a357717ddedc1fcaca2820de19.tar.bz2
Reverting 20855.
Review URL: http://codereview.chromium.org/149744 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20859 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/window_open_disposition.cc')
-rw-r--r--webkit/glue/window_open_disposition.cc43
1 files changed, 43 insertions, 0 deletions
diff --git a/webkit/glue/window_open_disposition.cc b/webkit/glue/window_open_disposition.cc
new file mode 100644
index 0000000..417ab1a
--- /dev/null
+++ b/webkit/glue/window_open_disposition.cc
@@ -0,0 +1,43 @@
+// Copyright (c) 2009 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 "webkit/glue/window_open_disposition.h"
+
+#include "base/logging.h"
+
+// The macro dance here allows us to only express the mapping once.
+#define MAPPINGS(MAP) \
+ MAP(WebNavigationPolicyIgnore, IGNORE_ACTION) \
+ MAP(WebNavigationPolicyDownload, SAVE_TO_DISK) \
+ MAP(WebNavigationPolicyCurrentTab, CURRENT_TAB) \
+ MAP(WebNavigationPolicyNewBackgroundTab, NEW_BACKGROUND_TAB) \
+ MAP(WebNavigationPolicyNewForegroundTab, NEW_FOREGROUND_TAB) \
+ MAP(WebNavigationPolicyNewWindow, NEW_WINDOW) \
+ MAP(WebNavigationPolicyNewPopup, NEW_POPUP)
+
+#define POLICY_TO_DISPOSITION(policy, disposition) \
+ case WebKit::policy: return disposition;
+
+WindowOpenDisposition NavigationPolicyToDisposition(
+ WebKit::WebNavigationPolicy policy) {
+ switch (policy) {
+ MAPPINGS(POLICY_TO_DISPOSITION)
+ default:
+ NOTREACHED() << "Unexpected WebNavigationPolicy";
+ return IGNORE_ACTION;
+ }
+}
+
+#define DISPOSITION_TO_POLICY(policy, disposition) \
+ case disposition: return WebKit::policy;
+
+WebKit::WebNavigationPolicy DispositionToNavigationPolicy(
+ WindowOpenDisposition disposition) {
+ switch (disposition) {
+ MAPPINGS(DISPOSITION_TO_POLICY)
+ default:
+ NOTREACHED() << "Unexpected WindowOpenDisposition";
+ return WebKit::WebNavigationPolicyIgnore;
+ }
+}