OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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 // GENERATED FROM THE API DEFINITION IN |
| 6 // chrome/common/extensions/api/windows.json |
| 7 // DO NOT EDIT. |
| 8 |
| 9 #include "tools/json_schema_compiler/util.h" |
| 10 #include "chrome/common/extensions/api/windows.h" |
| 11 #include "chrome/common/extensions/api/tabs.h" |
| 12 |
| 13 |
| 14 namespace extensions { |
| 15 namespace api { |
| 16 namespace windows { |
| 17 |
| 18 // |
| 19 // Types |
| 20 // |
| 21 |
| 22 Window::Window() {} |
| 23 Window::~Window() {} |
| 24 |
| 25 // static |
| 26 bool Window::Populate(const Value& value, Window* out) { |
| 27 if (!value.IsType(Value::TYPE_DICTIONARY)) |
| 28 return false; |
| 29 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); |
| 30 |
| 31 if (!json_schema_compiler::util::GetOptionalArrayFromDictionary(*dict, "tabs",
&out->tabs)) |
| 32 return false; |
| 33 if (!dict->GetInteger("top", &out->top)) |
| 34 return false; |
| 35 if (!dict->GetInteger("height", &out->height)) |
| 36 return false; |
| 37 if (!dict->GetInteger("width", &out->width)) |
| 38 return false; |
| 39 if (!dict->GetString("state", &out->state)) |
| 40 return false; |
| 41 if (!dict->GetBoolean("focused", &out->focused)) |
| 42 return false; |
| 43 if (!dict->GetInteger("left", &out->left)) |
| 44 return false; |
| 45 if (!dict->GetString("type", &out->type)) |
| 46 return false; |
| 47 if (!dict->GetInteger("id", &out->id)) |
| 48 return false; |
| 49 if (!dict->GetBoolean("incognito", &out->incognito)) |
| 50 return false; |
| 51 return true; |
| 52 } |
| 53 |
| 54 DictionaryValue* Window::ToValue() const { |
| 55 DictionaryValue* value = new DictionaryValue(); |
| 56 |
| 57 if (tabs.get()) |
| 58 json_schema_compiler::util::SetOptionalArrayToDictionary(tabs, "tabs", value
); |
| 59 value->SetWithoutPathExpansion("top", Value::CreateIntegerValue(top)); |
| 60 value->SetWithoutPathExpansion("height", Value::CreateIntegerValue(height)); |
| 61 value->SetWithoutPathExpansion("width", Value::CreateIntegerValue(width)); |
| 62 value->SetWithoutPathExpansion("state", Value::CreateStringValue(state)); |
| 63 value->SetWithoutPathExpansion("focused", Value::CreateBooleanValue(focused)); |
| 64 value->SetWithoutPathExpansion("left", Value::CreateIntegerValue(left)); |
| 65 value->SetWithoutPathExpansion("type", Value::CreateStringValue(type)); |
| 66 value->SetWithoutPathExpansion("id", Value::CreateIntegerValue(id)); |
| 67 value->SetWithoutPathExpansion("incognito", Value::CreateBooleanValue(incognit
o)); |
| 68 |
| 69 return value; |
| 70 } |
| 71 |
| 72 |
| 73 // |
| 74 // Functions |
| 75 // |
| 76 |
| 77 Get::Params::GetInfo::GetInfo() {} |
| 78 Get::Params::GetInfo::~GetInfo() {} |
| 79 |
| 80 // static |
| 81 bool Get::Params::GetInfo::Populate(const Value& value, GetInfo* out) { |
| 82 if (!value.IsType(Value::TYPE_DICTIONARY)) |
| 83 return false; |
| 84 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); |
| 85 |
| 86 { |
| 87 bool populate_temp; |
| 88 if (dict->GetBoolean("populate", &populate_temp)) |
| 89 out->populate.reset(new bool(populate_temp)); |
| 90 } |
| 91 return true; |
| 92 } |
| 93 |
| 94 |
| 95 |
| 96 Get::Params::Params() {} |
| 97 Get::Params::~Params() {} |
| 98 |
| 99 // static |
| 100 scoped_ptr<Get::Params> Get::Params::Create(const ListValue& args) { |
| 101 if (args.GetSize() < 1 && args.GetSize() > 2) |
| 102 return scoped_ptr<Params>(); |
| 103 scoped_ptr<Params> params(new Params()); |
| 104 |
| 105 if (!args.GetInteger(0, ¶ms->window_id)) |
| 106 return scoped_ptr<Params>(); |
| 107 |
| 108 DictionaryValue* get_info_param = NULL; |
| 109 if (!args.GetDictionary(1, &get_info_param)) |
| 110 return params.Pass(); |
| 111 params->get_info.reset(new GetInfo()); |
| 112 if (!GetInfo::Populate(*get_info_param, params->get_info.get())) |
| 113 return params.Pass(); |
| 114 |
| 115 return params.Pass(); |
| 116 } |
| 117 |
| 118 // static |
| 119 Value* Get::Result::Create(const Window& window) { |
| 120 return window.ToValue(); |
| 121 } |
| 122 |
| 123 GetCurrent::Params::GetInfo::GetInfo() {} |
| 124 GetCurrent::Params::GetInfo::~GetInfo() {} |
| 125 |
| 126 // static |
| 127 bool GetCurrent::Params::GetInfo::Populate(const Value& value, GetInfo* out) { |
| 128 if (!value.IsType(Value::TYPE_DICTIONARY)) |
| 129 return false; |
| 130 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); |
| 131 |
| 132 { |
| 133 bool populate_temp; |
| 134 if (dict->GetBoolean("populate", &populate_temp)) |
| 135 out->populate.reset(new bool(populate_temp)); |
| 136 } |
| 137 return true; |
| 138 } |
| 139 |
| 140 |
| 141 |
| 142 GetCurrent::Params::Params() {} |
| 143 GetCurrent::Params::~Params() {} |
| 144 |
| 145 // static |
| 146 scoped_ptr<GetCurrent::Params> GetCurrent::Params::Create(const ListValue& args)
{ |
| 147 if (args.GetSize() > 1) |
| 148 return scoped_ptr<Params>(); |
| 149 scoped_ptr<Params> params(new Params()); |
| 150 |
| 151 DictionaryValue* get_info_param = NULL; |
| 152 if (!args.GetDictionary(0, &get_info_param)) |
| 153 return params.Pass(); |
| 154 params->get_info.reset(new GetInfo()); |
| 155 if (!GetInfo::Populate(*get_info_param, params->get_info.get())) |
| 156 return params.Pass(); |
| 157 |
| 158 return params.Pass(); |
| 159 } |
| 160 |
| 161 // static |
| 162 Value* GetCurrent::Result::Create(const Window& window) { |
| 163 return window.ToValue(); |
| 164 } |
| 165 |
| 166 GetAll::Params::GetInfo::GetInfo() {} |
| 167 GetAll::Params::GetInfo::~GetInfo() {} |
| 168 |
| 169 // static |
| 170 bool GetAll::Params::GetInfo::Populate(const Value& value, GetInfo* out) { |
| 171 if (!value.IsType(Value::TYPE_DICTIONARY)) |
| 172 return false; |
| 173 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); |
| 174 |
| 175 { |
| 176 bool populate_temp; |
| 177 if (dict->GetBoolean("populate", &populate_temp)) |
| 178 out->populate.reset(new bool(populate_temp)); |
| 179 } |
| 180 return true; |
| 181 } |
| 182 |
| 183 |
| 184 |
| 185 GetAll::Params::Params() {} |
| 186 GetAll::Params::~Params() {} |
| 187 |
| 188 // static |
| 189 scoped_ptr<GetAll::Params> GetAll::Params::Create(const ListValue& args) { |
| 190 if (args.GetSize() > 1) |
| 191 return scoped_ptr<Params>(); |
| 192 scoped_ptr<Params> params(new Params()); |
| 193 |
| 194 DictionaryValue* get_info_param = NULL; |
| 195 if (!args.GetDictionary(0, &get_info_param)) |
| 196 return params.Pass(); |
| 197 params->get_info.reset(new GetInfo()); |
| 198 if (!GetInfo::Populate(*get_info_param, params->get_info.get())) |
| 199 return params.Pass(); |
| 200 |
| 201 return params.Pass(); |
| 202 } |
| 203 |
| 204 // static |
| 205 Value* GetAll::Result::Create(const std::vector<linked_ptr<Window> > windows) { |
| 206 ListValue* value = new ListValue(); |
| 207 json_schema_compiler::util::SetArrayToList(windows, value); |
| 208 return value; |
| 209 } |
| 210 |
| 211 Update::Params::UpdateInfo::UpdateInfo() {} |
| 212 Update::Params::UpdateInfo::~UpdateInfo() {} |
| 213 |
| 214 // static |
| 215 bool Update::Params::UpdateInfo::Populate(const Value& value, UpdateInfo* out) { |
| 216 if (!value.IsType(Value::TYPE_DICTIONARY)) |
| 217 return false; |
| 218 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); |
| 219 |
| 220 { |
| 221 int top_temp; |
| 222 if (dict->GetInteger("top", &top_temp)) |
| 223 out->top.reset(new int(top_temp)); |
| 224 } |
| 225 { |
| 226 bool draw_attention_temp; |
| 227 if (dict->GetBoolean("drawAttention", &draw_attention_temp)) |
| 228 out->draw_attention.reset(new bool(draw_attention_temp)); |
| 229 } |
| 230 { |
| 231 int height_temp; |
| 232 if (dict->GetInteger("height", &height_temp)) |
| 233 out->height.reset(new int(height_temp)); |
| 234 } |
| 235 { |
| 236 int width_temp; |
| 237 if (dict->GetInteger("width", &width_temp)) |
| 238 out->width.reset(new int(width_temp)); |
| 239 } |
| 240 { |
| 241 std::string state_temp; |
| 242 if (dict->GetString("state", &state_temp)) |
| 243 out->state.reset(new std::string(state_temp)); |
| 244 } |
| 245 { |
| 246 bool focused_temp; |
| 247 if (dict->GetBoolean("focused", &focused_temp)) |
| 248 out->focused.reset(new bool(focused_temp)); |
| 249 } |
| 250 { |
| 251 int left_temp; |
| 252 if (dict->GetInteger("left", &left_temp)) |
| 253 out->left.reset(new int(left_temp)); |
| 254 } |
| 255 return true; |
| 256 } |
| 257 |
| 258 |
| 259 |
| 260 Update::Params::Params() {} |
| 261 Update::Params::~Params() {} |
| 262 |
| 263 // static |
| 264 scoped_ptr<Update::Params> Update::Params::Create(const ListValue& args) { |
| 265 if (args.GetSize() != 2) |
| 266 return scoped_ptr<Params>(); |
| 267 scoped_ptr<Params> params(new Params()); |
| 268 |
| 269 if (!args.GetInteger(0, ¶ms->window_id)) |
| 270 return scoped_ptr<Params>(); |
| 271 |
| 272 DictionaryValue* update_info_param = NULL; |
| 273 if (!args.GetDictionary(1, &update_info_param)) |
| 274 return scoped_ptr<Params>(); |
| 275 if (!UpdateInfo::Populate(*update_info_param, ¶ms->update_info)) |
| 276 return scoped_ptr<Params>(); |
| 277 |
| 278 return params.Pass(); |
| 279 } |
| 280 |
| 281 // static |
| 282 Value* Update::Result::Create(const Window& window) { |
| 283 return window.ToValue(); |
| 284 } |
| 285 |
| 286 Remove::Params::Params() {} |
| 287 Remove::Params::~Params() {} |
| 288 |
| 289 // static |
| 290 scoped_ptr<Remove::Params> Remove::Params::Create(const ListValue& args) { |
| 291 if (args.GetSize() != 1) |
| 292 return scoped_ptr<Params>(); |
| 293 scoped_ptr<Params> params(new Params()); |
| 294 |
| 295 if (!args.GetInteger(0, ¶ms->window_id)) |
| 296 return scoped_ptr<Params>(); |
| 297 |
| 298 return params.Pass(); |
| 299 } |
| 300 |
| 301 // static |
| 302 Value* Remove::Result::Create() { |
| 303 return Value::CreateNullValue(); |
| 304 } |
| 305 |
| 306 GetLastFocused::Params::GetInfo::GetInfo() {} |
| 307 GetLastFocused::Params::GetInfo::~GetInfo() {} |
| 308 |
| 309 // static |
| 310 bool GetLastFocused::Params::GetInfo::Populate(const Value& value, GetInfo* out)
{ |
| 311 if (!value.IsType(Value::TYPE_DICTIONARY)) |
| 312 return false; |
| 313 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); |
| 314 |
| 315 { |
| 316 bool populate_temp; |
| 317 if (dict->GetBoolean("populate", &populate_temp)) |
| 318 out->populate.reset(new bool(populate_temp)); |
| 319 } |
| 320 return true; |
| 321 } |
| 322 |
| 323 |
| 324 |
| 325 GetLastFocused::Params::Params() {} |
| 326 GetLastFocused::Params::~Params() {} |
| 327 |
| 328 // static |
| 329 scoped_ptr<GetLastFocused::Params> GetLastFocused::Params::Create(const ListValu
e& args) { |
| 330 if (args.GetSize() > 1) |
| 331 return scoped_ptr<Params>(); |
| 332 scoped_ptr<Params> params(new Params()); |
| 333 |
| 334 DictionaryValue* get_info_param = NULL; |
| 335 if (!args.GetDictionary(0, &get_info_param)) |
| 336 return params.Pass(); |
| 337 params->get_info.reset(new GetInfo()); |
| 338 if (!GetInfo::Populate(*get_info_param, params->get_info.get())) |
| 339 return params.Pass(); |
| 340 |
| 341 return params.Pass(); |
| 342 } |
| 343 |
| 344 // static |
| 345 Value* GetLastFocused::Result::Create(const Window& window) { |
| 346 return window.ToValue(); |
| 347 } |
| 348 |
| 349 } // windows |
| 350 } // api |
| 351 } // extensions |
OLD | NEW |