Chromium Code Reviews| 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 using base::Value; | |
| 15 using base::DictionaryValue; | |
| 16 using base::ListValue; | |
| 17 | |
| 18 namespace extensions { | |
| 19 namespace api { | |
| 20 namespace windows { | |
| 21 | |
| 22 // | |
| 23 // Types | |
| 24 // | |
| 25 | |
| 26 Window::Window() {} | |
| 27 Window::~Window() {} | |
| 28 | |
| 29 // static | |
| 30 bool Window::Populate(const Value& value, Window* out) { | |
| 31 if (!value.IsType(Value::TYPE_DICTIONARY)) | |
| 32 return false; | |
| 33 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); | |
| 34 | |
| 35 if (!json_schema_compiler::util::GetOptionalArrayFromDictionary(*dict, "tabs", &out->tabs)) | |
| 36 return false; | |
| 37 if (!dict->GetInteger("top", &out->top)) | |
| 38 return false; | |
| 39 if (!dict->GetInteger("height", &out->height)) | |
| 40 return false; | |
| 41 if (!dict->GetInteger("width", &out->width)) | |
| 42 return false; | |
| 43 if (!dict->GetString("state", &out->state)) | |
| 44 return false; | |
| 45 if (!dict->GetBoolean("focused", &out->focused)) | |
| 46 return false; | |
| 47 if (!dict->GetInteger("left", &out->left)) | |
| 48 return false; | |
| 49 if (!dict->GetString("type", &out->type)) | |
| 50 return false; | |
| 51 if (!dict->GetInteger("id", &out->id)) | |
| 52 return false; | |
| 53 if (!dict->GetBoolean("incognito", &out->incognito)) | |
| 54 return false; | |
| 55 return true; | |
| 56 } | |
| 57 | |
| 58 scoped_ptr<DictionaryValue> Window::ToValue() const { | |
| 59 scoped_ptr<DictionaryValue> value(new DictionaryValue()); | |
| 60 | |
| 61 if (tabs.get()) | |
| 62 json_schema_compiler::util::SetOptionalArrayToDictionary(tabs, "tabs", value .get()); | |
| 63 value->SetWithoutPathExpansion("top", Value::CreateIntegerValue(top)); | |
| 64 value->SetWithoutPathExpansion("height", Value::CreateIntegerValue(height)); | |
| 65 value->SetWithoutPathExpansion("width", Value::CreateIntegerValue(width)); | |
| 66 value->SetWithoutPathExpansion("state", Value::CreateStringValue(state)); | |
| 67 value->SetWithoutPathExpansion("focused", Value::CreateBooleanValue(focused)); | |
| 68 value->SetWithoutPathExpansion("left", Value::CreateIntegerValue(left)); | |
| 69 value->SetWithoutPathExpansion("type", Value::CreateStringValue(type)); | |
| 70 value->SetWithoutPathExpansion("id", Value::CreateIntegerValue(id)); | |
| 71 value->SetWithoutPathExpansion("incognito", Value::CreateBooleanValue(incognit o)); | |
| 72 | |
| 73 return value.Pass(); | |
| 74 } | |
| 75 | |
| 76 | |
| 77 // | |
| 78 // Functions | |
| 79 // | |
| 80 | |
| 81 Get::Params::GetInfo::GetInfo() {} | |
| 82 Get::Params::GetInfo::~GetInfo() {} | |
| 83 | |
| 84 // static | |
| 85 bool Get::Params::GetInfo::Populate(const Value& value, GetInfo* out) { | |
| 86 if (!value.IsType(Value::TYPE_DICTIONARY)) | |
| 87 return false; | |
| 88 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); | |
| 89 | |
| 90 { | |
| 91 bool populate_temp; | |
| 92 if (dict->GetBoolean("populate", &populate_temp)) | |
| 93 out->populate.reset(new bool(populate_temp)); | |
| 94 } | |
| 95 return true; | |
| 96 } | |
| 97 | |
| 98 | |
| 99 | |
| 100 Get::Params::Params() {} | |
| 101 Get::Params::~Params() {} | |
| 102 | |
| 103 // static | |
| 104 scoped_ptr<Get::Params> Get::Params::Create(const ListValue& args) { | |
| 105 if (args.GetSize() < 1 || args.GetSize() > 2) | |
| 106 return scoped_ptr<Params>(); | |
| 107 scoped_ptr<Params> params(new Params()); | |
| 108 | |
| 109 if (!args.GetInteger(0, ¶ms->window_id)) | |
| 110 return scoped_ptr<Params>(); | |
| 111 | |
| 112 DictionaryValue* get_info_param = NULL; | |
| 113 if (!args.GetDictionary(1, &get_info_param)) | |
| 114 return params.Pass(); | |
|
Yoyo Zhou
2012/02/10 01:49:33
So invalid optional arguments are treated as thoug
calamity
2012/02/10 03:52:50
Good catch. This is a big-ish change. I think it s
| |
| 115 params->get_info.reset(new GetInfo()); | |
| 116 if (!GetInfo::Populate(*get_info_param, params->get_info.get())) | |
| 117 return params.Pass(); | |
| 118 | |
| 119 return params.Pass(); | |
| 120 } | |
| 121 | |
| 122 Value* Get::Result::Create(const Window& window) { | |
| 123 return window.ToValue().release(); | |
| 124 } | |
| 125 | |
| 126 GetCurrent::Params::GetInfo::GetInfo() {} | |
| 127 GetCurrent::Params::GetInfo::~GetInfo() {} | |
| 128 | |
| 129 // static | |
| 130 bool GetCurrent::Params::GetInfo::Populate(const Value& value, GetInfo* out) { | |
| 131 if (!value.IsType(Value::TYPE_DICTIONARY)) | |
| 132 return false; | |
| 133 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); | |
| 134 | |
| 135 { | |
| 136 bool populate_temp; | |
| 137 if (dict->GetBoolean("populate", &populate_temp)) | |
| 138 out->populate.reset(new bool(populate_temp)); | |
| 139 } | |
| 140 return true; | |
| 141 } | |
| 142 | |
| 143 | |
| 144 | |
| 145 GetCurrent::Params::Params() {} | |
| 146 GetCurrent::Params::~Params() {} | |
| 147 | |
| 148 // static | |
| 149 scoped_ptr<GetCurrent::Params> GetCurrent::Params::Create(const ListValue& args) { | |
| 150 if (args.GetSize() > 1) | |
| 151 return scoped_ptr<Params>(); | |
| 152 scoped_ptr<Params> params(new Params()); | |
| 153 | |
| 154 DictionaryValue* get_info_param = NULL; | |
| 155 if (!args.GetDictionary(0, &get_info_param)) | |
| 156 return params.Pass(); | |
| 157 params->get_info.reset(new GetInfo()); | |
| 158 if (!GetInfo::Populate(*get_info_param, params->get_info.get())) | |
| 159 return params.Pass(); | |
| 160 | |
| 161 return params.Pass(); | |
| 162 } | |
| 163 | |
| 164 Value* GetCurrent::Result::Create(const Window& window) { | |
| 165 return window.ToValue().release(); | |
| 166 } | |
| 167 | |
| 168 Create::Params::CreateData::CreateData() {} | |
| 169 Create::Params::CreateData::~CreateData() {} | |
| 170 | |
| 171 // static | |
| 172 bool Create::Params::CreateData::Populate(const Value& value, CreateData* out) { | |
| 173 if (!value.IsType(Value::TYPE_DICTIONARY)) | |
| 174 return false; | |
| 175 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); | |
| 176 | |
| 177 { | |
| 178 int tab_id_temp; | |
| 179 if (dict->GetInteger("tabId", &tab_id_temp)) | |
| 180 out->tab_id.reset(new int(tab_id_temp)); | |
| 181 } | |
| 182 { | |
| 183 std::string url_temp; | |
| 184 if (dict->GetString("url", &url_temp)) | |
| 185 out->url.reset(new std::string(url_temp)); | |
| 186 } | |
| 187 { | |
| 188 int top_temp; | |
| 189 if (dict->GetInteger("top", &top_temp)) | |
| 190 out->top.reset(new int(top_temp)); | |
| 191 } | |
| 192 { | |
| 193 int height_temp; | |
| 194 if (dict->GetInteger("height", &height_temp)) | |
| 195 out->height.reset(new int(height_temp)); | |
| 196 } | |
| 197 { | |
| 198 int width_temp; | |
| 199 if (dict->GetInteger("width", &width_temp)) | |
| 200 out->width.reset(new int(width_temp)); | |
| 201 } | |
| 202 { | |
| 203 bool focused_temp; | |
| 204 if (dict->GetBoolean("focused", &focused_temp)) | |
| 205 out->focused.reset(new bool(focused_temp)); | |
| 206 } | |
| 207 { | |
| 208 int left_temp; | |
| 209 if (dict->GetInteger("left", &left_temp)) | |
| 210 out->left.reset(new int(left_temp)); | |
| 211 } | |
| 212 { | |
| 213 std::string type_temp; | |
| 214 if (dict->GetString("type", &type_temp)) | |
| 215 out->type.reset(new std::string(type_temp)); | |
| 216 } | |
| 217 { | |
| 218 bool incognito_temp; | |
| 219 if (dict->GetBoolean("incognito", &incognito_temp)) | |
| 220 out->incognito.reset(new bool(incognito_temp)); | |
| 221 } | |
| 222 return true; | |
| 223 } | |
| 224 | |
| 225 | |
| 226 | |
| 227 Create::Params::Params() {} | |
| 228 Create::Params::~Params() {} | |
| 229 | |
| 230 // static | |
| 231 scoped_ptr<Create::Params> Create::Params::Create(const ListValue& args) { | |
| 232 if (args.GetSize() > 1) | |
| 233 return scoped_ptr<Params>(); | |
| 234 scoped_ptr<Params> params(new Params()); | |
| 235 | |
| 236 DictionaryValue* create_data_param = NULL; | |
| 237 if (!args.GetDictionary(0, &create_data_param)) | |
| 238 return params.Pass(); | |
| 239 params->create_data.reset(new CreateData()); | |
| 240 if (!CreateData::Populate(*create_data_param, params->create_data.get())) | |
| 241 return params.Pass(); | |
| 242 | |
| 243 return params.Pass(); | |
| 244 } | |
| 245 | |
| 246 Value* Create::Result::Create(const scoped_ptr<Window>& window) { | |
| 247 return window->ToValue().release(); | |
| 248 } | |
| 249 | |
| 250 GetAll::Params::GetInfo::GetInfo() {} | |
| 251 GetAll::Params::GetInfo::~GetInfo() {} | |
| 252 | |
| 253 // static | |
| 254 bool GetAll::Params::GetInfo::Populate(const Value& value, GetInfo* out) { | |
| 255 if (!value.IsType(Value::TYPE_DICTIONARY)) | |
| 256 return false; | |
| 257 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); | |
| 258 | |
| 259 { | |
| 260 bool populate_temp; | |
| 261 if (dict->GetBoolean("populate", &populate_temp)) | |
| 262 out->populate.reset(new bool(populate_temp)); | |
| 263 } | |
| 264 return true; | |
| 265 } | |
| 266 | |
| 267 | |
| 268 | |
| 269 GetAll::Params::Params() {} | |
| 270 GetAll::Params::~Params() {} | |
| 271 | |
| 272 // static | |
| 273 scoped_ptr<GetAll::Params> GetAll::Params::Create(const ListValue& args) { | |
| 274 if (args.GetSize() > 1) | |
| 275 return scoped_ptr<Params>(); | |
| 276 scoped_ptr<Params> params(new Params()); | |
| 277 | |
| 278 DictionaryValue* get_info_param = NULL; | |
| 279 if (!args.GetDictionary(0, &get_info_param)) | |
| 280 return params.Pass(); | |
| 281 params->get_info.reset(new GetInfo()); | |
| 282 if (!GetInfo::Populate(*get_info_param, params->get_info.get())) | |
| 283 return params.Pass(); | |
| 284 | |
| 285 return params.Pass(); | |
| 286 } | |
| 287 | |
| 288 Value* GetAll::Result::Create(const std::vector<linked_ptr<Window> > windows) { | |
| 289 ListValue* value = new ListValue(); | |
| 290 json_schema_compiler::util::SetArrayToList(windows, value); | |
| 291 return value; | |
| 292 } | |
| 293 | |
| 294 Update::Params::UpdateInfo::UpdateInfo() {} | |
| 295 Update::Params::UpdateInfo::~UpdateInfo() {} | |
| 296 | |
| 297 // static | |
| 298 bool Update::Params::UpdateInfo::Populate(const Value& value, UpdateInfo* out) { | |
| 299 if (!value.IsType(Value::TYPE_DICTIONARY)) | |
| 300 return false; | |
| 301 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); | |
| 302 | |
| 303 { | |
| 304 int top_temp; | |
| 305 if (dict->GetInteger("top", &top_temp)) | |
| 306 out->top.reset(new int(top_temp)); | |
| 307 } | |
| 308 { | |
| 309 bool draw_attention_temp; | |
| 310 if (dict->GetBoolean("drawAttention", &draw_attention_temp)) | |
| 311 out->draw_attention.reset(new bool(draw_attention_temp)); | |
| 312 } | |
| 313 { | |
| 314 int height_temp; | |
| 315 if (dict->GetInteger("height", &height_temp)) | |
| 316 out->height.reset(new int(height_temp)); | |
| 317 } | |
| 318 { | |
| 319 int width_temp; | |
| 320 if (dict->GetInteger("width", &width_temp)) | |
| 321 out->width.reset(new int(width_temp)); | |
| 322 } | |
| 323 { | |
| 324 std::string state_temp; | |
| 325 if (dict->GetString("state", &state_temp)) | |
| 326 out->state.reset(new std::string(state_temp)); | |
| 327 } | |
| 328 { | |
| 329 bool focused_temp; | |
| 330 if (dict->GetBoolean("focused", &focused_temp)) | |
| 331 out->focused.reset(new bool(focused_temp)); | |
| 332 } | |
| 333 { | |
| 334 int left_temp; | |
| 335 if (dict->GetInteger("left", &left_temp)) | |
| 336 out->left.reset(new int(left_temp)); | |
| 337 } | |
| 338 return true; | |
| 339 } | |
| 340 | |
| 341 | |
| 342 | |
| 343 Update::Params::Params() {} | |
| 344 Update::Params::~Params() {} | |
| 345 | |
| 346 // static | |
| 347 scoped_ptr<Update::Params> Update::Params::Create(const ListValue& args) { | |
| 348 if (args.GetSize() != 2) | |
| 349 return scoped_ptr<Params>(); | |
| 350 scoped_ptr<Params> params(new Params()); | |
| 351 | |
| 352 if (!args.GetInteger(0, ¶ms->window_id)) | |
| 353 return scoped_ptr<Params>(); | |
| 354 | |
| 355 DictionaryValue* update_info_param = NULL; | |
| 356 if (!args.GetDictionary(1, &update_info_param)) | |
| 357 return scoped_ptr<Params>(); | |
| 358 if (!UpdateInfo::Populate(*update_info_param, ¶ms->update_info)) | |
| 359 return scoped_ptr<Params>(); | |
| 360 | |
| 361 return params.Pass(); | |
| 362 } | |
| 363 | |
| 364 Value* Update::Result::Create(const Window& window) { | |
| 365 return window.ToValue().release(); | |
| 366 } | |
| 367 | |
| 368 Remove::Params::Params() {} | |
| 369 Remove::Params::~Params() {} | |
| 370 | |
| 371 // static | |
| 372 scoped_ptr<Remove::Params> Remove::Params::Create(const ListValue& args) { | |
| 373 if (args.GetSize() != 1) | |
| 374 return scoped_ptr<Params>(); | |
| 375 scoped_ptr<Params> params(new Params()); | |
| 376 | |
| 377 if (!args.GetInteger(0, ¶ms->window_id)) | |
| 378 return scoped_ptr<Params>(); | |
| 379 | |
| 380 return params.Pass(); | |
| 381 } | |
| 382 | |
| 383 Value* Remove::Result::Create() { | |
| 384 return Value::CreateNullValue(); | |
| 385 } | |
| 386 | |
| 387 GetLastFocused::Params::GetInfo::GetInfo() {} | |
| 388 GetLastFocused::Params::GetInfo::~GetInfo() {} | |
| 389 | |
| 390 // static | |
| 391 bool GetLastFocused::Params::GetInfo::Populate(const Value& value, GetInfo* out) { | |
| 392 if (!value.IsType(Value::TYPE_DICTIONARY)) | |
| 393 return false; | |
| 394 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); | |
| 395 | |
| 396 { | |
| 397 bool populate_temp; | |
| 398 if (dict->GetBoolean("populate", &populate_temp)) | |
| 399 out->populate.reset(new bool(populate_temp)); | |
| 400 } | |
| 401 return true; | |
| 402 } | |
| 403 | |
| 404 | |
| 405 | |
| 406 GetLastFocused::Params::Params() {} | |
| 407 GetLastFocused::Params::~Params() {} | |
| 408 | |
| 409 // static | |
| 410 scoped_ptr<GetLastFocused::Params> GetLastFocused::Params::Create(const ListValu e& args) { | |
| 411 if (args.GetSize() > 1) | |
| 412 return scoped_ptr<Params>(); | |
| 413 scoped_ptr<Params> params(new Params()); | |
| 414 | |
| 415 DictionaryValue* get_info_param = NULL; | |
| 416 if (!args.GetDictionary(0, &get_info_param)) | |
| 417 return params.Pass(); | |
| 418 params->get_info.reset(new GetInfo()); | |
| 419 if (!GetInfo::Populate(*get_info_param, params->get_info.get())) | |
| 420 return params.Pass(); | |
| 421 | |
| 422 return params.Pass(); | |
| 423 } | |
| 424 | |
| 425 Value* GetLastFocused::Result::Create(const Window& window) { | |
| 426 return window.ToValue().release(); | |
| 427 } | |
| 428 | |
| 429 } // windows | |
| 430 } // api | |
| 431 } // extensions | |
| OLD | NEW |