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

Side by Side Diff: webkit/glue/window_open_disposition.cc

Issue 155637: Simplify window_open_disposition.cc since we only require conversion from... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/glue/window_open_disposition.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/glue/window_open_disposition.h" 5 #include "webkit/glue/window_open_disposition.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 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( 9 WindowOpenDisposition NavigationPolicyToDisposition(
23 WebKit::WebNavigationPolicy policy) { 10 WebKit::WebNavigationPolicy policy) {
24 switch (policy) { 11 switch (policy) {
25 MAPPINGS(POLICY_TO_DISPOSITION) 12 case WebKit::WebNavigationPolicyIgnore:
13 return IGNORE_ACTION;
14 case WebKit::WebNavigationPolicyDownload:
15 return SAVE_TO_DISK;
16 case WebKit::WebNavigationPolicyCurrentTab:
17 return CURRENT_TAB;
18 case WebKit::WebNavigationPolicyNewBackgroundTab:
19 return NEW_BACKGROUND_TAB;
20 case WebKit::WebNavigationPolicyNewForegroundTab:
21 return NEW_FOREGROUND_TAB;
22 case WebKit::WebNavigationPolicyNewWindow:
23 return NEW_WINDOW;
24 case WebKit::WebNavigationPolicyNewPopup:
25 return NEW_POPUP;
26 default: 26 default:
27 NOTREACHED() << "Unexpected WebNavigationPolicy"; 27 NOTREACHED() << "Unexpected WebNavigationPolicy";
28 return IGNORE_ACTION; 28 return IGNORE_ACTION;
29 } 29 }
30 } 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 }
OLDNEW
« no previous file with comments | « webkit/glue/window_open_disposition.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698