OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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 #ifndef CHROME_COMMON_RENDER_MESSAGES_PARAMS_H_ | |
6 #define CHROME_COMMON_RENDER_MESSAGES_PARAMS_H_ | |
7 #pragma once | |
8 | |
9 #include <string> | |
10 | |
11 #include "ipc/ipc_param_traits.h" | |
12 | |
13 // The type of OSDD that the renderer is giving to the browser. | |
14 struct ViewHostMsg_PageHasOSDD_Type { | |
15 enum Type { | |
16 // The Open Search Description URL was detected automatically. | |
17 AUTODETECTED_PROVIDER, | |
18 | |
19 // The Open Search Description URL was given by Javascript. | |
20 EXPLICIT_PROVIDER, | |
21 | |
22 // The Open Search Description URL was given by Javascript to be the new | |
23 // default search engine. | |
24 EXPLICIT_DEFAULT_PROVIDER | |
25 }; | |
26 | |
27 Type type; | |
28 | |
29 ViewHostMsg_PageHasOSDD_Type() : type(AUTODETECTED_PROVIDER) { | |
30 } | |
31 | |
32 explicit ViewHostMsg_PageHasOSDD_Type(Type t) | |
33 : type(t) { | |
34 } | |
35 | |
36 static ViewHostMsg_PageHasOSDD_Type Autodetected() { | |
37 return ViewHostMsg_PageHasOSDD_Type(AUTODETECTED_PROVIDER); | |
38 } | |
39 | |
40 static ViewHostMsg_PageHasOSDD_Type Explicit() { | |
41 return ViewHostMsg_PageHasOSDD_Type(EXPLICIT_PROVIDER); | |
42 } | |
43 | |
44 static ViewHostMsg_PageHasOSDD_Type ExplicitDefault() { | |
45 return ViewHostMsg_PageHasOSDD_Type(EXPLICIT_DEFAULT_PROVIDER); | |
46 } | |
47 }; | |
48 | |
49 // The install state of the search provider (not installed, installed, default). | |
50 struct ViewHostMsg_GetSearchProviderInstallState_Params { | |
51 enum State { | |
52 // Equates to an access denied error. | |
53 DENIED = -1, | |
54 | |
55 // DON'T CHANGE THE VALUES BELOW. | |
56 // All of the following values are manidated by the | |
57 // spec for window.external.IsSearchProviderInstalled. | |
58 | |
59 // The search provider is not installed. | |
60 NOT_INSTALLED = 0, | |
61 | |
62 // The search provider is in the user's set but is not | |
63 INSTALLED_BUT_NOT_DEFAULT = 1, | |
64 | |
65 // The search provider is set as the user's default. | |
66 INSTALLED_AS_DEFAULT = 2 | |
67 }; | |
68 State state; | |
69 | |
70 ViewHostMsg_GetSearchProviderInstallState_Params() | |
71 : state(DENIED) { | |
72 } | |
73 | |
74 explicit ViewHostMsg_GetSearchProviderInstallState_Params(State s) | |
75 : state(s) { | |
76 } | |
77 | |
78 static ViewHostMsg_GetSearchProviderInstallState_Params Denied() { | |
79 return ViewHostMsg_GetSearchProviderInstallState_Params(DENIED); | |
80 } | |
81 | |
82 static ViewHostMsg_GetSearchProviderInstallState_Params NotInstalled() { | |
83 return ViewHostMsg_GetSearchProviderInstallState_Params(NOT_INSTALLED); | |
84 } | |
85 | |
86 static ViewHostMsg_GetSearchProviderInstallState_Params | |
87 InstallButNotDefault() { | |
88 return ViewHostMsg_GetSearchProviderInstallState_Params( | |
89 INSTALLED_BUT_NOT_DEFAULT); | |
90 } | |
91 | |
92 static ViewHostMsg_GetSearchProviderInstallState_Params InstalledAsDefault() { | |
93 return ViewHostMsg_GetSearchProviderInstallState_Params( | |
94 INSTALLED_AS_DEFAULT); | |
95 } | |
96 }; | |
97 | |
98 namespace IPC { | |
99 | |
100 class Message; | |
101 | |
102 template <> | |
103 struct ParamTraits<ViewHostMsg_PageHasOSDD_Type> { | |
104 typedef ViewHostMsg_PageHasOSDD_Type param_type; | |
105 static void Write(Message* m, const param_type& p); | |
106 static bool Read(const Message* m, void** iter, param_type* p); | |
107 static void Log(const param_type& p, std::string* l); | |
108 }; | |
109 | |
110 template <> | |
111 struct ParamTraits<ViewHostMsg_GetSearchProviderInstallState_Params> { | |
112 typedef ViewHostMsg_GetSearchProviderInstallState_Params param_type; | |
113 static void Write(Message* m, const param_type& p); | |
114 static bool Read(const Message* m, void** iter, param_type* p); | |
115 static void Log(const param_type& p, std::string* l); | |
116 }; | |
117 | |
118 } // namespace IPC | |
119 | |
120 #endif // CHROME_COMMON_RENDER_MESSAGES_PARAMS_H_ | |
OLD | NEW |