| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "webkit/glue/window_open_disposition.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 |
| 9 // The macro dance here allows us to only express the mapping once. |
| 10 #define MAPPINGS(MAP) \ |
| 11 MAP(WebNavigationPolicyIgnore, IGNORE_ACTION) \ |
| 12 MAP(WebNavigationPolicyDownload, SAVE_TO_DISK) \ |
| 13 MAP(WebNavigationPolicyCurrentTab, CURRENT_TAB) \ |
| 14 MAP(WebNavigationPolicyNewBackgroundTab, NEW_BACKGROUND_TAB) \ |
| 15 MAP(WebNavigationPolicyNewForegroundTab, NEW_FOREGROUND_TAB) \ |
| 16 MAP(WebNavigationPolicyNewWindow, NEW_WINDOW) \ |
| 17 MAP(WebNavigationPolicyNewPopup, NEW_POPUP) |
| 18 |
| 19 #define POLICY_TO_DISPOSITION(policy, disposition) \ |
| 20 case WebKit::policy: return disposition; |
| 21 |
| 22 WindowOpenDisposition NavigationPolicyToDisposition( |
| 23 WebKit::WebNavigationPolicy policy) { |
| 24 switch (policy) { |
| 25 MAPPINGS(POLICY_TO_DISPOSITION) |
| 26 default: |
| 27 NOTREACHED() << "Unexpected WebNavigationPolicy"; |
| 28 return IGNORE_ACTION; |
| 29 } |
| 30 } |
| 31 |
| 32 #define DISPOSITION_TO_POLICY(policy, disposition) \ |
| 33 case disposition: return WebKit::policy; |
| 34 |
| 35 WebKit::WebNavigationPolicy DispositionToNavigationPolicy( |
| 36 WindowOpenDisposition disposition) { |
| 37 switch (disposition) { |
| 38 MAPPINGS(DISPOSITION_TO_POLICY) |
| 39 default: |
| 40 NOTREACHED() << "Unexpected WindowOpenDisposition"; |
| 41 return WebKit::WebNavigationPolicyIgnore; |
| 42 } |
| 43 } |
| OLD | NEW |