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

Side by Side Diff: chrome/browser/devtools/devtools_embedder_message_dispatcher.cc

Issue 137483007: [DevTools] Use special resizing strategy instead of insets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 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
OLDNEW
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,
pfeldman 2014/01/31 11:28:30 I'd rather define traits for Insets and Size
dgozman 2014/01/31 13:33:13 Done.
25 DevToolsContentsResizingStrategy& strategy) {
26 const base::DictionaryValue* dict;
27 if (!list.GetDictionary(pos, &dict))
28 return false;
29 const base::DictionaryValue* insets;
30 if (!dict->GetDictionary("insets", &insets))
31 return false;
32 int top = 0;
33 int left = 0;
34 int bottom = 0;
35 int right = 0;
36 if (!insets->GetInteger("top", &top) ||
37 !insets->GetInteger("left", &left) ||
38 !insets->GetInteger("bottom", &bottom) ||
39 !insets->GetInteger("right", &right))
40 return false;
41 strategy.insets.Set(top, left, bottom, right);
42 const base::DictionaryValue* min_size;
43 if (!dict->GetDictionary("min_size", &min_size))
44 return false;
45 int width = 0;
46 int height = 0;
47 if (!min_size->GetInteger("width", &width) ||
48 !min_size->GetInteger("height", &height))
49 return false;
50 strategy.min_size.SetSize(width, height);
51 return true;
52 }
53
24 template <typename T> 54 template <typename T>
25 struct StorageTraits { 55 struct StorageTraits {
26 typedef T StorageType; 56 typedef T StorageType;
27 }; 57 };
28 58
29 template <typename T> 59 template <typename T>
30 struct StorageTraits<const T&> { 60 struct StorageTraits<const T&> {
31 typedef T StorageType; 61 typedef T StorageType;
32 }; 62 };
33 63
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 Delegate* delegate) { 184 Delegate* delegate) {
155 RegisterHandler("bringToFront", 185 RegisterHandler("bringToFront",
156 BindToListParser(base::Bind(&Delegate::ActivateWindow, 186 BindToListParser(base::Bind(&Delegate::ActivateWindow,
157 base::Unretained(delegate)))); 187 base::Unretained(delegate))));
158 RegisterHandler("closeWindow", 188 RegisterHandler("closeWindow",
159 BindToListParser(base::Bind(&Delegate::CloseWindow, 189 BindToListParser(base::Bind(&Delegate::CloseWindow,
160 base::Unretained(delegate)))); 190 base::Unretained(delegate))));
161 RegisterHandler("setContentsInsets", 191 RegisterHandler("setContentsInsets",
162 BindToListParser(base::Bind(&Delegate::SetContentsInsets, 192 BindToListParser(base::Bind(&Delegate::SetContentsInsets,
163 base::Unretained(delegate)))); 193 base::Unretained(delegate))));
194 RegisterHandler("setContentsResizingStrategy",
195 BindToListParser(base::Bind(&Delegate::SetContentsResizingStrategy,
196 base::Unretained(delegate))));
164 RegisterHandler("moveWindowBy", 197 RegisterHandler("moveWindowBy",
165 BindToListParser(base::Bind(&Delegate::MoveWindow, 198 BindToListParser(base::Bind(&Delegate::MoveWindow,
166 base::Unretained(delegate)))); 199 base::Unretained(delegate))));
167 RegisterHandler("setIsDocked", 200 RegisterHandler("setIsDocked",
168 BindToListParser(base::Bind(&Delegate::SetIsDocked, 201 BindToListParser(base::Bind(&Delegate::SetIsDocked,
169 base::Unretained(delegate)))); 202 base::Unretained(delegate))));
170 RegisterHandler("openInNewTab", 203 RegisterHandler("openInNewTab",
171 BindToListParser(base::Bind(&Delegate::OpenInNewTab, 204 BindToListParser(base::Bind(&Delegate::OpenInNewTab,
172 base::Unretained(delegate)))); 205 base::Unretained(delegate))));
173 RegisterHandler("save", 206 RegisterHandler("save",
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 243
211 if (!it->second.Run(*params)) 244 if (!it->second.Run(*params))
212 return "Invalid frontend host message parameters: " + method; 245 return "Invalid frontend host message parameters: " + method;
213 return ""; 246 return "";
214 } 247 }
215 248
216 void DevToolsEmbedderMessageDispatcher::RegisterHandler( 249 void DevToolsEmbedderMessageDispatcher::RegisterHandler(
217 const std::string& method, const Handler& handler) { 250 const std::string& method, const Handler& handler) {
218 handlers_[method] = handler; 251 handlers_[method] = handler;
219 } 252 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698