| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/devtools/devtools_embedder_message_dispatcher.h" | 5 #include "chrome/browser/devtools/devtools_embedder_message_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| 11 | 11 |
| 12 bool GetValue(const base::ListValue& list, int pos, std::string& value) { | 12 bool GetValue(const base::ListValue& list, int pos, std::string& value) { |
| 13 return list.GetString(pos, &value); | 13 return list.GetString(pos, &value); |
| 14 } | 14 } |
| 15 | 15 |
| 16 bool GetValue(const base::ListValue& list, int pos, int& value) { | 16 bool GetValue(const base::ListValue& list, int pos, int& value) { |
| 17 return list.GetInteger(pos, &value); | 17 return list.GetInteger(pos, &value); |
| 18 } | 18 } |
| 19 | 19 |
| 20 bool GetValue(const base::ListValue& list, int pos, bool& value) { | 20 bool GetValue(const base::ListValue& list, int pos, bool& value) { |
| 21 return list.GetBoolean(pos, &value); | 21 return list.GetBoolean(pos, &value); |
| 22 } | 22 } |
| 23 | 23 |
| 24 bool GetValue(const base::ListValue& list, int pos, gfx::Insets& insets) { | |
| 25 const base::DictionaryValue* dict; | |
| 26 if (!list.GetDictionary(pos, &dict)) | |
| 27 return false; | |
| 28 int top = 0; | |
| 29 int left = 0; | |
| 30 int bottom = 0; | |
| 31 int right = 0; | |
| 32 if (!dict->GetInteger("top", &top) || | |
| 33 !dict->GetInteger("left", &left) || | |
| 34 !dict->GetInteger("bottom", &bottom) || | |
| 35 !dict->GetInteger("right", &right)) | |
| 36 return false; | |
| 37 insets.Set(top, left, bottom, right); | |
| 38 return true; | |
| 39 } | |
| 40 | |
| 41 bool GetValue(const base::ListValue& list, int pos, gfx::Size& size) { | |
| 42 const base::DictionaryValue* dict; | |
| 43 if (!list.GetDictionary(pos, &dict)) | |
| 44 return false; | |
| 45 int width = 0; | |
| 46 int height = 0; | |
| 47 if (!dict->GetInteger("width", &width) || | |
| 48 !dict->GetInteger("height", &height)) | |
| 49 return false; | |
| 50 size.SetSize(width, height); | |
| 51 return true; | |
| 52 } | |
| 53 | |
| 54 bool GetValue(const base::ListValue& list, int pos, gfx::Rect& rect) { | 24 bool GetValue(const base::ListValue& list, int pos, gfx::Rect& rect) { |
| 55 const base::DictionaryValue* dict; | 25 const base::DictionaryValue* dict; |
| 56 if (!list.GetDictionary(pos, &dict)) | 26 if (!list.GetDictionary(pos, &dict)) |
| 57 return false; | 27 return false; |
| 58 int x = 0; | 28 int x = 0; |
| 59 int y = 0; | 29 int y = 0; |
| 60 int width = 0; | 30 int width = 0; |
| 61 int height = 0; | 31 int height = 0; |
| 62 if (!dict->GetInteger("x", &x) || | 32 if (!dict->GetInteger("x", &x) || |
| 63 !dict->GetInteger("y", &y) || | 33 !dict->GetInteger("y", &y) || |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 221 |
| 252 DevToolsEmbedderMessageDispatcher* | 222 DevToolsEmbedderMessageDispatcher* |
| 253 DevToolsEmbedderMessageDispatcher::createForDevToolsFrontend( | 223 DevToolsEmbedderMessageDispatcher::createForDevToolsFrontend( |
| 254 Delegate* delegate) { | 224 Delegate* delegate) { |
| 255 DispatcherImpl* d = new DispatcherImpl(); | 225 DispatcherImpl* d = new DispatcherImpl(); |
| 256 | 226 |
| 257 d->RegisterHandler("bringToFront", &Delegate::ActivateWindow, delegate); | 227 d->RegisterHandler("bringToFront", &Delegate::ActivateWindow, delegate); |
| 258 d->RegisterHandler("closeWindow", &Delegate::CloseWindow, delegate); | 228 d->RegisterHandler("closeWindow", &Delegate::CloseWindow, delegate); |
| 259 d->RegisterHandler("setInspectedPageBounds", | 229 d->RegisterHandler("setInspectedPageBounds", |
| 260 &Delegate::SetInspectedPageBounds, delegate); | 230 &Delegate::SetInspectedPageBounds, delegate); |
| 261 d->RegisterHandler("setContentsResizingStrategy", | |
| 262 &Delegate::SetContentsResizingStrategy, delegate); | |
| 263 d->RegisterHandler("inspectElementCompleted", | 231 d->RegisterHandler("inspectElementCompleted", |
| 264 &Delegate::InspectElementCompleted, delegate); | 232 &Delegate::InspectElementCompleted, delegate); |
| 265 d->RegisterHandler("inspectedURLChanged", | 233 d->RegisterHandler("inspectedURLChanged", |
| 266 &Delegate::InspectedURLChanged, delegate); | 234 &Delegate::InspectedURLChanged, delegate); |
| 267 d->RegisterHandler("moveWindowBy", &Delegate::MoveWindow, delegate); | 235 d->RegisterHandler("moveWindowBy", &Delegate::MoveWindow, delegate); |
| 268 d->RegisterHandler("setIsDocked", &Delegate::SetIsDocked, delegate); | 236 d->RegisterHandler("setIsDocked", &Delegate::SetIsDocked, delegate); |
| 269 d->RegisterHandler("openInNewTab", &Delegate::OpenInNewTab, delegate); | 237 d->RegisterHandler("openInNewTab", &Delegate::OpenInNewTab, delegate); |
| 270 d->RegisterHandler("save", &Delegate::SaveToFile, delegate); | 238 d->RegisterHandler("save", &Delegate::SaveToFile, delegate); |
| 271 d->RegisterHandler("append", &Delegate::AppendToFile, delegate); | 239 d->RegisterHandler("append", &Delegate::AppendToFile, delegate); |
| 272 d->RegisterHandler("requestFileSystems", | 240 d->RegisterHandler("requestFileSystems", |
| (...skipping 13 matching lines...) Expand all Loading... |
| 286 d->RegisterHandler("openUrlOnRemoteDeviceAndInspect", | 254 d->RegisterHandler("openUrlOnRemoteDeviceAndInspect", |
| 287 &Delegate::OpenUrlOnRemoteDeviceAndInspect, delegate); | 255 &Delegate::OpenUrlOnRemoteDeviceAndInspect, delegate); |
| 288 d->RegisterHandler("setDeviceCountUpdatesEnabled", | 256 d->RegisterHandler("setDeviceCountUpdatesEnabled", |
| 289 &Delegate::SetDeviceCountUpdatesEnabled, delegate); | 257 &Delegate::SetDeviceCountUpdatesEnabled, delegate); |
| 290 d->RegisterHandler("setDevicesUpdatesEnabled", | 258 d->RegisterHandler("setDevicesUpdatesEnabled", |
| 291 &Delegate::SetDevicesUpdatesEnabled, delegate); | 259 &Delegate::SetDevicesUpdatesEnabled, delegate); |
| 292 d->RegisterHandler("sendMessageToBrowser", | 260 d->RegisterHandler("sendMessageToBrowser", |
| 293 &Delegate::SendMessageToBrowser, delegate); | 261 &Delegate::SendMessageToBrowser, delegate); |
| 294 return d; | 262 return d; |
| 295 } | 263 } |
| OLD | NEW |