Merge lp:~abreu-alexandre/oxide/add-devtools-support into lp:~oxide-developers/oxide/oxide.trunk
- add-devtools-support
- Merge into oxide.trunk
Proposed by
Alexandre Abreu
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 618 | ||||
Proposed branch: | lp:~abreu-alexandre/oxide/add-devtools-support | ||||
Merge into: | lp:~oxide-developers/oxide/oxide.trunk | ||||
Diff against target: |
1113 lines (+778/-6) 21 files modified
qt/core/api/oxideqwebpreferences.h (+1/-0) qt/core/glue/oxide_qt_web_context_adapter.cc (+31/-0) qt/core/glue/oxide_qt_web_context_adapter.h (+6/-0) qt/core/glue/oxide_qt_web_context_adapter_p.h (+2/-0) qt/core/glue/private/oxide_qt_web_context_adapter_p.cc (+10/-2) qt/quick/api/oxideqquickwebcontext.cc (+36/-0) qt/quick/api/oxideqquickwebcontext_p.h (+10/-0) shared/browser/oxide_browser_context.h (+14/-2) shared/browser/oxide_browser_context_impl.cc (+34/-1) shared/browser/oxide_browser_context_impl.h (+10/-0) shared/browser/oxide_devtools_http_handler_delegate.cc (+124/-0) shared/browser/oxide_devtools_http_handler_delegate.h (+71/-0) shared/browser/oxide_devtools_target.cc (+125/-0) shared/browser/oxide_devtools_target.h (+72/-0) shared/browser/oxide_off_the_record_browser_context_impl.cc (+9/-0) shared/browser/oxide_off_the_record_browser_context_impl.h (+3/-0) shared/browser/oxide_web_view.cc (+54/-1) shared/browser/oxide_web_view.h (+4/-0) shared/browser/resources/devtools_discovery_page.html (+155/-0) shared/oxide_resources.grd (+1/-0) shared/shared.gyp (+6/-0) |
||||
To merge this branch: | bzr merge lp:~abreu-alexandre/oxide/add-devtools-support | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Chris Coulson | Approve | ||
Review via email: mp+223239@code.launchpad.net |
Commit message
Add devtools support
Description of the change
Add devtools support
To post a comment you must log in.
- 614. By Alexandre Abreu
-
remove leftover clutter
- 615. By Alexandre Abreu
-
fixes
Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote : | # |
Thank you for the review,
I updated the MR,
Revision history for this message
Chris Coulson (chrisccoulson) wrote : | # |
Thanks! Almost there, I've just added a few minor comments
review:
Needs Fixing
- 616. By Alexandre Abreu
-
fixes
Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote : | # |
I updated the MR,
Revision history for this message
Chris Coulson (chrisccoulson) wrote : | # |
Thanks, this is good to merge now :)
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'qt/core/api/oxideqwebpreferences.h' |
2 | --- qt/core/api/oxideqwebpreferences.h 2014-05-26 22:12:33 +0000 |
3 | +++ qt/core/api/oxideqwebpreferences.h 2014-06-24 11:52:03 +0000 |
4 | @@ -139,6 +139,7 @@ |
5 | void setTouchEnabled(bool enabled); |
6 | |
7 | Q_SIGNALS: |
8 | + |
9 | void standardFontFamilyChanged(); |
10 | void fixedFontFamilyChanged(); |
11 | void serifFontFamilyChanged(); |
12 | |
13 | === modified file 'qt/core/glue/oxide_qt_web_context_adapter.cc' |
14 | --- qt/core/glue/oxide_qt_web_context_adapter.cc 2014-06-02 21:56:59 +0000 |
15 | +++ qt/core/glue/oxide_qt_web_context_adapter.cc 2014-06-24 11:52:03 +0000 |
16 | @@ -81,6 +81,37 @@ |
17 | } |
18 | } |
19 | |
20 | +bool WebContextAdapter::devtoolsEnabled() const { |
21 | + if (isInitialized()) { |
22 | + return priv->context_->GetDevtoolsEnabled(); |
23 | + } |
24 | + return priv->construct_props_->devtools_enabled; |
25 | +} |
26 | + |
27 | +void WebContextAdapter::setDevtoolsEnabled(bool enabled) { |
28 | + if (isInitialized()) { |
29 | + qWarning() << "Cannot change the devtools enabled after inititialization"; |
30 | + return; |
31 | + } |
32 | + priv->construct_props_->devtools_enabled = enabled; |
33 | +} |
34 | + |
35 | +int WebContextAdapter::devtoolsPort() const { |
36 | + if (isInitialized()) { |
37 | + return priv->context_->GetDevtoolsPort(); |
38 | + } |
39 | + |
40 | + return priv->construct_props_->devtools_port; |
41 | +} |
42 | + |
43 | +void WebContextAdapter::setDevtoolsPort(int port) { |
44 | + if (isInitialized()) { |
45 | + qWarning() << "Cannot change the devtools port after inititialization"; |
46 | + return; |
47 | + } |
48 | + priv->construct_props_->devtools_port = port; |
49 | +} |
50 | + |
51 | QUrl WebContextAdapter::dataPath() const { |
52 | base::FilePath path; |
53 | if (isInitialized()) { |
54 | |
55 | === modified file 'qt/core/glue/oxide_qt_web_context_adapter.h' |
56 | --- qt/core/glue/oxide_qt_web_context_adapter.h 2014-04-02 19:57:47 +0000 |
57 | +++ qt/core/glue/oxide_qt_web_context_adapter.h 2014-06-24 11:52:03 +0000 |
58 | @@ -105,6 +105,12 @@ |
59 | bool popupBlockerEnabled() const; |
60 | void setPopupBlockerEnabled(bool enabled); |
61 | |
62 | + bool devtoolsEnabled() const; |
63 | + void setDevtoolsEnabled(bool enabled); |
64 | + |
65 | + int devtoolsPort() const; |
66 | + void setDevtoolsPort(int port); |
67 | + |
68 | protected: |
69 | WebContextAdapter(QObject* q, |
70 | IOThreadDelegate* io_delegate, |
71 | |
72 | === modified file 'qt/core/glue/oxide_qt_web_context_adapter_p.h' |
73 | --- qt/core/glue/oxide_qt_web_context_adapter_p.h 2014-04-02 19:57:47 +0000 |
74 | +++ qt/core/glue/oxide_qt_web_context_adapter_p.h 2014-06-24 11:52:03 +0000 |
75 | @@ -69,6 +69,8 @@ |
76 | net::StaticCookiePolicy::Type cookie_policy; |
77 | content::CookieStoreConfig::SessionCookieMode session_cookie_mode; |
78 | bool popup_blocker_enabled; |
79 | + bool devtools_enabled; |
80 | + int devtools_port; |
81 | }; |
82 | |
83 | static WebContextAdapterPrivate* Create( |
84 | |
85 | === modified file 'qt/core/glue/private/oxide_qt_web_context_adapter_p.cc' |
86 | --- qt/core/glue/private/oxide_qt_web_context_adapter_p.cc 2014-04-02 19:57:47 +0000 |
87 | +++ qt/core/glue/private/oxide_qt_web_context_adapter_p.cc 2014-06-24 11:52:03 +0000 |
88 | @@ -38,13 +38,19 @@ |
89 | #include "../oxide_qt_user_script_adapter.h" |
90 | #include "../oxide_qt_user_script_adapter_p.h" |
91 | |
92 | +namespace { |
93 | +const unsigned kDefaultDevtoolsPort = 8484; |
94 | +} |
95 | + |
96 | namespace oxide { |
97 | namespace qt { |
98 | |
99 | WebContextAdapterPrivate::ConstructProperties::ConstructProperties() : |
100 | cookie_policy(net::StaticCookiePolicy::ALLOW_ALL_COOKIES), |
101 | session_cookie_mode(content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES), |
102 | - popup_blocker_enabled(true) {} |
103 | + popup_blocker_enabled(true), |
104 | + devtools_enabled(false), |
105 | + devtools_port(kDefaultDevtoolsPort) {} |
106 | |
107 | // static |
108 | WebContextAdapterPrivate* WebContextAdapterPrivate::Create( |
109 | @@ -204,7 +210,9 @@ |
110 | oxide::BrowserContext::Params params( |
111 | construct_props_->data_path, |
112 | construct_props_->cache_path, |
113 | - construct_props_->session_cookie_mode); |
114 | + construct_props_->session_cookie_mode, |
115 | + construct_props_->devtools_enabled, |
116 | + construct_props_->devtools_port); |
117 | context_ = oxide::BrowserContext::Create(params); |
118 | |
119 | if (!construct_props_->product.empty()) { |
120 | |
121 | === modified file 'qt/quick/api/oxideqquickwebcontext.cc' |
122 | --- qt/quick/api/oxideqquickwebcontext.cc 2014-06-05 09:51:42 +0000 |
123 | +++ qt/quick/api/oxideqquickwebcontext.cc 2014-06-24 11:52:03 +0000 |
124 | @@ -680,4 +680,40 @@ |
125 | } |
126 | } |
127 | |
128 | +bool OxideQQuickWebContext::devtoolsEnabled() const { |
129 | + Q_D(const OxideQQuickWebContext); |
130 | + |
131 | + return d->devtoolsEnabled(); |
132 | +} |
133 | + |
134 | +void OxideQQuickWebContext::setDevtoolsEnabled(bool enabled) { |
135 | + Q_D(OxideQQuickWebContext); |
136 | + |
137 | + if (d->devtoolsEnabled() == enabled) { |
138 | + return; |
139 | + } |
140 | + |
141 | + d->setDevtoolsEnabled(enabled); |
142 | + |
143 | + emit devtoolsEnabledChanged(); |
144 | +} |
145 | + |
146 | +int OxideQQuickWebContext::devtoolsPort() const { |
147 | + Q_D(const OxideQQuickWebContext); |
148 | + |
149 | + return d->devtoolsPort(); |
150 | +} |
151 | + |
152 | +void OxideQQuickWebContext::setDevtoolsPort(int port) { |
153 | + Q_D(OxideQQuickWebContext); |
154 | + |
155 | + if (d->devtoolsPort() == port) { |
156 | + return; |
157 | + } |
158 | + |
159 | + d->setDevtoolsPort(port); |
160 | + |
161 | + emit devtoolsPortChanged(); |
162 | +} |
163 | + |
164 | #include "moc_oxideqquickwebcontext_p.cpp" |
165 | |
166 | === modified file 'qt/quick/api/oxideqquickwebcontext_p.h' |
167 | --- qt/quick/api/oxideqquickwebcontext_p.h 2014-04-02 22:32:27 +0000 |
168 | +++ qt/quick/api/oxideqquickwebcontext_p.h 2014-06-24 11:52:03 +0000 |
169 | @@ -47,6 +47,8 @@ |
170 | Q_PROPERTY(OxideQQuickWebContextDelegateWorker* networkRequestDelegate READ networkRequestDelegate WRITE setNetworkRequestDelegate NOTIFY networkRequestDelegateChanged) |
171 | Q_PROPERTY(OxideQQuickWebContextDelegateWorker* storageAccessPermissionDelegate READ storageAccessPermissionDelegate WRITE setStorageAccessPermissionDelegate NOTIFY storageAccessPermissionDelegateChanged) |
172 | Q_PROPERTY(OxideQQuickWebContextDelegateWorker* userAgentOverrideDelegate READ userAgentOverrideDelegate WRITE setUserAgentOverrideDelegate NOTIFY userAgentOverrideDelegateChanged) |
173 | + Q_PROPERTY(bool devtoolsEnabled READ devtoolsEnabled WRITE setDevtoolsEnabled NOTIFY devtoolsEnabledChanged) |
174 | + Q_PROPERTY(int devtoolsPort READ devtoolsPort WRITE setDevtoolsPort NOTIFY devtoolsPortChanged) |
175 | |
176 | Q_ENUMS(CookiePolicy) |
177 | Q_ENUMS(SessionCookieMode) |
178 | @@ -115,6 +117,12 @@ |
179 | OxideQQuickWebContextDelegateWorker* userAgentOverrideDelegate() const; |
180 | void setUserAgentOverrideDelegate(OxideQQuickWebContextDelegateWorker* delegate); |
181 | |
182 | + bool devtoolsEnabled() const; |
183 | + void setDevtoolsEnabled(bool enabled); |
184 | + |
185 | + int devtoolsPort() const; |
186 | + void setDevtoolsPort(int port); |
187 | + |
188 | Q_SIGNALS: |
189 | void productChanged(); |
190 | void userAgentChanged(); |
191 | @@ -128,6 +136,8 @@ |
192 | void networkRequestDelegateChanged(); |
193 | void storageAccessPermissionDelegateChanged(); |
194 | void userAgentOverrideDelegateChanged(); |
195 | + void devtoolsEnabledChanged(); |
196 | + void devtoolsPortChanged(); |
197 | |
198 | private: |
199 | Q_PRIVATE_SLOT(d_func(), void userScriptUpdated()); |
200 | |
201 | === modified file 'shared/browser/oxide_browser_context.h' |
202 | --- shared/browser/oxide_browser_context.h 2014-06-19 17:41:21 +0000 |
203 | +++ shared/browser/oxide_browser_context.h 2014-06-24 11:52:03 +0000 |
204 | @@ -121,12 +121,20 @@ |
205 | struct Params { |
206 | Params(const base::FilePath& path, |
207 | const base::FilePath& cache_path, |
208 | - const content::CookieStoreConfig::SessionCookieMode session_cookie_mode) : |
209 | - path(path), cache_path(cache_path), session_cookie_mode(session_cookie_mode) {} |
210 | + const content::CookieStoreConfig::SessionCookieMode session_cookie_mode, |
211 | + bool devtools_enabled, |
212 | + int devtools_port) : |
213 | + path(path), |
214 | + cache_path(cache_path), |
215 | + session_cookie_mode(session_cookie_mode), |
216 | + devtools_enabled(devtools_enabled), |
217 | + devtools_port(devtools_port) {} |
218 | |
219 | base::FilePath path; |
220 | base::FilePath cache_path; |
221 | content::CookieStoreConfig::SessionCookieMode session_cookie_mode; |
222 | + bool devtools_enabled; |
223 | + int devtools_port; |
224 | }; |
225 | |
226 | virtual ~BrowserContext(); |
227 | @@ -180,6 +188,10 @@ |
228 | bool IsPopupBlockerEnabled() const; |
229 | virtual void SetIsPopupBlockerEnabled(bool enabled) = 0; |
230 | |
231 | + virtual bool GetDevtoolsEnabled() const = 0; |
232 | + |
233 | + virtual int GetDevtoolsPort() const = 0; |
234 | + |
235 | BrowserContextIOData* io_data() const { return io_data_handle_.io_data(); } |
236 | |
237 | virtual UserScriptMaster& UserScriptManager() = 0; |
238 | |
239 | === modified file 'shared/browser/oxide_browser_context_impl.cc' |
240 | --- shared/browser/oxide_browser_context_impl.cc 2014-06-02 15:06:30 +0000 |
241 | +++ shared/browser/oxide_browser_context_impl.cc 2014-06-24 11:52:03 +0000 |
242 | @@ -20,15 +20,25 @@ |
243 | #include "base/logging.h" |
244 | #include "base/strings/stringprintf.h" |
245 | #include "content/public/browser/browser_thread.h" |
246 | +#include "content/public/browser/devtools_http_handler.h" |
247 | #include "content/public/browser/render_process_host.h" |
248 | #include "content/public/common/user_agent.h" |
249 | +#include "net/socket/tcp_listen_socket.h" |
250 | |
251 | #include "shared/common/chrome_version.h" |
252 | #include "shared/common/oxide_content_client.h" |
253 | #include "shared/common/oxide_messages.h" |
254 | |
255 | + |
256 | +#include "oxide_devtools_http_handler_delegate.h" |
257 | #include "oxide_off_the_record_browser_context_impl.h" |
258 | |
259 | +namespace { |
260 | + |
261 | +const std::string kDevtoolsServerIp = "127.0.0.1"; |
262 | + |
263 | +} |
264 | + |
265 | namespace oxide { |
266 | |
267 | BrowserContextIODataImpl::BrowserContextIODataImpl( |
268 | @@ -39,7 +49,8 @@ |
269 | accept_langs_("en-us,en"), |
270 | cookie_policy_(net::StaticCookiePolicy::ALLOW_ALL_COOKIES), |
271 | session_cookie_mode_(params.session_cookie_mode), |
272 | - popup_blocker_enabled_(true) {} |
273 | + popup_blocker_enabled_(true) { |
274 | +} |
275 | |
276 | net::StaticCookiePolicy::Type BrowserContextIODataImpl::GetCookiePolicy() const { |
277 | base::AutoLock lock(lock_); |
278 | @@ -118,6 +129,19 @@ |
279 | default_user_agent_string_(true), |
280 | user_script_manager_(this) { |
281 | SetUserAgent(std::string()); |
282 | + |
283 | + if (params.devtools_enabled && |
284 | + params.devtools_port < 65535 && |
285 | + params.devtools_port > 1024) { |
286 | + std::string ip = kDevtoolsServerIp; |
287 | + unsigned port = params.devtools_port; |
288 | + devtools_http_handler_ = content::DevToolsHttpHandler::Start( |
289 | + new net::TCPListenSocketFactory(ip, port), |
290 | + std::string(), |
291 | + new DevtoolsHttpHandlerDelegate( |
292 | + ip, port, this), |
293 | + base::FilePath()); |
294 | + } |
295 | } |
296 | |
297 | BrowserContextImpl::~BrowserContextImpl() { |
298 | @@ -126,6 +150,7 @@ |
299 | CHECK(!otr_context_ || otr_context_->HasOneRef()) << |
300 | "Unexpected reference count for OTR BrowserContext. Did you use " |
301 | "scoped_refptr instead of ScopedBrowserContext?"; |
302 | + devtools_http_handler_->Stop(); |
303 | } |
304 | |
305 | BrowserContext* BrowserContextImpl::GetOffTheRecordContext() { |
306 | @@ -189,4 +214,12 @@ |
307 | return user_script_manager_; |
308 | } |
309 | |
310 | +bool BrowserContextImpl::GetDevtoolsEnabled() const FINAL { |
311 | + return devtools_enabled_; |
312 | +} |
313 | + |
314 | +int BrowserContextImpl::GetDevtoolsPort() const FINAL { |
315 | + return devtools_port_; |
316 | +} |
317 | + |
318 | } // namespace oxide |
319 | |
320 | === modified file 'shared/browser/oxide_browser_context_impl.h' |
321 | --- shared/browser/oxide_browser_context_impl.h 2014-05-22 08:09:28 +0000 |
322 | +++ shared/browser/oxide_browser_context_impl.h 2014-06-24 11:52:03 +0000 |
323 | @@ -27,6 +27,10 @@ |
324 | #include "oxide_browser_context.h" |
325 | #include "oxide_user_script_master.h" |
326 | |
327 | +namespace content { |
328 | +class DevToolsHttpHandler; |
329 | +} |
330 | + |
331 | namespace oxide { |
332 | |
333 | class OffTheRecordBrowserContextImpl; |
334 | @@ -85,6 +89,9 @@ |
335 | void SetCookiePolicy(net::StaticCookiePolicy::Type policy) FINAL; |
336 | void SetIsPopupBlockerEnabled(bool enabled) FINAL; |
337 | |
338 | + bool GetDevtoolsEnabled() const FINAL; |
339 | + int GetDevtoolsPort() const FINAL; |
340 | + |
341 | UserScriptMaster& UserScriptManager() FINAL; |
342 | |
343 | private: |
344 | @@ -96,6 +103,9 @@ |
345 | std::string product_; |
346 | bool default_user_agent_string_; |
347 | UserScriptMaster user_script_manager_; |
348 | + content::DevToolsHttpHandler* devtools_http_handler_; |
349 | + bool devtools_enabled_; |
350 | + int devtools_port_; |
351 | |
352 | DISALLOW_COPY_AND_ASSIGN(BrowserContextImpl); |
353 | }; |
354 | |
355 | === added file 'shared/browser/oxide_devtools_http_handler_delegate.cc' |
356 | --- shared/browser/oxide_devtools_http_handler_delegate.cc 1970-01-01 00:00:00 +0000 |
357 | +++ shared/browser/oxide_devtools_http_handler_delegate.cc 2014-06-24 11:52:03 +0000 |
358 | @@ -0,0 +1,124 @@ |
359 | +// vim:expandtab:shiftwidth=2:tabstop=2: |
360 | +// Copyright (C) 2013 Canonical Ltd. |
361 | + |
362 | +// This library is free software; you can redistribute it and/or |
363 | +// modify it under the terms of the GNU Lesser General Public |
364 | +// License as published by the Free Software Foundation; either |
365 | +// version 2.1 of the License, or (at your option) any later version. |
366 | + |
367 | +// This library is distributed in the hope that it will be useful, |
368 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
369 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
370 | +// Lesser General Public License for more details. |
371 | + |
372 | +// You should have received a copy of the GNU Lesser General Public |
373 | +// License along with this library; if not, write to the Free Software |
374 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
375 | + |
376 | +#include "oxide_devtools_http_handler_delegate.h" |
377 | + |
378 | +#include "base/logging.h" |
379 | +#include "base/path_service.h" |
380 | +#include "base/strings/string_number_conversions.h" |
381 | +#include "content/public/browser/web_contents.h" |
382 | +#include "content/public/browser/devtools_target.h" |
383 | +#include "content/public/browser/devtools_http_handler.h" |
384 | +#include "content/public/common/url_constants.h" |
385 | +#include "net/socket/tcp_listen_socket.h" |
386 | +#include "net/url_request/url_request_context_getter.h" |
387 | +#include "ui/base/resource/resource_bundle.h" |
388 | + |
389 | +#include "oxide_devtools_target.h" |
390 | +#include "oxide_io_thread.h" |
391 | +#include "oxide_web_view.h" |
392 | + |
393 | +#include "grit/oxide_resources.h" |
394 | + |
395 | +using content::DevToolsTarget; |
396 | +using content::RenderViewHost; |
397 | +using content::WebContents; |
398 | + |
399 | + |
400 | +namespace oxide { |
401 | + |
402 | +DevtoolsHttpHandlerDelegate::DevtoolsHttpHandlerDelegate( |
403 | + const std::string& ip, |
404 | + unsigned port, |
405 | + BrowserContext * attached_browser_context) |
406 | + : ip_(ip), |
407 | + port_(port), |
408 | + browser_context_(attached_browser_context) { |
409 | + LOG(INFO) << "DevTools instance running " |
410 | + << GetLocalDevToolsUrl(); |
411 | +} |
412 | + |
413 | +DevtoolsHttpHandlerDelegate::~DevtoolsHttpHandlerDelegate() { |
414 | +} |
415 | + |
416 | +std::string DevtoolsHttpHandlerDelegate::GetDiscoveryPageHTML() { |
417 | + return ui::ResourceBundle::GetSharedInstance().GetRawDataResource( |
418 | + IDR_OXIDE_DEVTOOLS_DISCOVERY_HTML_PAGE).as_string(); |
419 | +} |
420 | + |
421 | +std::string |
422 | +DevtoolsHttpHandlerDelegate::GetLocalDevToolsUrl() const { |
423 | + std::ostringstream oss; |
424 | + oss << "http://" |
425 | + << ip_ |
426 | + << ":" |
427 | + << port_; |
428 | + return oss.str(); |
429 | +} |
430 | + |
431 | +bool DevtoolsHttpHandlerDelegate::BundlesFrontendResources() { |
432 | + // We reuse the default chrome builtin webui from devtools_resources.pak |
433 | + return true; |
434 | +} |
435 | + |
436 | +base::FilePath DevtoolsHttpHandlerDelegate::GetDebugFrontendDir() { |
437 | + // We dont host the devtools resources & ui (see above). |
438 | + return base::FilePath(); |
439 | +} |
440 | + |
441 | +std::string DevtoolsHttpHandlerDelegate::GetPageThumbnailData( |
442 | + const GURL& url) { |
443 | + return std::string(); |
444 | +} |
445 | + |
446 | +scoped_ptr<DevToolsTarget> |
447 | +DevtoolsHttpHandlerDelegate::CreateNewTarget(const GURL& url) { |
448 | + // Not supported |
449 | + return scoped_ptr<DevToolsTarget>(); |
450 | +} |
451 | + |
452 | +void DevtoolsHttpHandlerDelegate::EnumerateTargets(TargetCallback callback) { |
453 | + TargetList targetList; |
454 | + std::set<WebView*> wvl = |
455 | + WebView::GetAllWebViewsFor(browser_context_); |
456 | + if (!wvl.empty()) { |
457 | + std::set<WebView*>::iterator it = wvl.begin(); |
458 | + for (; it != wvl.end(); ++it) { |
459 | + DCHECK(*it) << "Invalid WebView instance (NULL)"; |
460 | + |
461 | + content::WebContents * web_contents = |
462 | + (*it)->GetWebContents(); |
463 | + if (web_contents) { |
464 | + // The receiver of the target list is the owner of the content |
465 | + // See content/public/browser/devtools_http_handler_delegate.h |
466 | + targetList.push_back( |
467 | + DevtoolsTarget::CreateForWebContents(web_contents)); |
468 | + } |
469 | + } |
470 | + } |
471 | + callback.Run(targetList); |
472 | +} |
473 | + |
474 | +scoped_ptr<net::StreamListenSocket> |
475 | +DevtoolsHttpHandlerDelegate::CreateSocketForTethering( |
476 | + net::StreamListenSocket::Delegate* delegate, |
477 | + std::string* name) { |
478 | + // Not supported |
479 | + return scoped_ptr<net::StreamListenSocket>(); |
480 | +} |
481 | + |
482 | +} |
483 | |
484 | === added file 'shared/browser/oxide_devtools_http_handler_delegate.h' |
485 | --- shared/browser/oxide_devtools_http_handler_delegate.h 1970-01-01 00:00:00 +0000 |
486 | +++ shared/browser/oxide_devtools_http_handler_delegate.h 2014-06-24 11:52:03 +0000 |
487 | @@ -0,0 +1,71 @@ |
488 | +// vim:expandtab:shiftwidth=2:tabstop=2: |
489 | +// Copyright (C) 2014 Canonical Ltd. |
490 | + |
491 | +// This library is free software; you can redistribute it and/or |
492 | +// modify it under the terms of the GNU Lesser General Public |
493 | +// License as published by the Free Software Foundation; either |
494 | +// version 2.1 of the License, or (at your option) any later version. |
495 | + |
496 | +// This library is distributed in the hope that it will be useful, |
497 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
498 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
499 | +// Lesser General Public License for more details. |
500 | + |
501 | +// You should have received a copy of the GNU Lesser General Public |
502 | +// License along with this library; if not, write to the Free Software |
503 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
504 | + |
505 | +#ifndef _OXIDE_SHARED_BROWSER_DEVTOOLS_HTTP_HANDLER_DELEGATE_H_ |
506 | +#define _OXIDE_SHARED_BROWSER_DEVTOOLS_HTTP_HANDLER_DELEGATE_H_ |
507 | + |
508 | +#include <string> |
509 | + |
510 | +#include "base/basictypes.h" |
511 | +#include "base/compiler_specific.h" |
512 | +#include "content/public/browser/devtools_http_handler_delegate.h" |
513 | + |
514 | +namespace content { |
515 | +class DevToolsTarget; |
516 | +class DevToolsHttpHandler; |
517 | +} |
518 | + |
519 | +namespace oxide { |
520 | + |
521 | +class BrowserContext; |
522 | + |
523 | +class DevtoolsHttpHandlerDelegate |
524 | + : public content::DevToolsHttpHandlerDelegate { |
525 | + public: |
526 | + |
527 | + DevtoolsHttpHandlerDelegate( |
528 | + const std::string& ip, |
529 | + unsigned port, |
530 | + BrowserContext* attached_browser_context); |
531 | + virtual ~DevtoolsHttpHandlerDelegate(); |
532 | + |
533 | + // DevToolsHttpProtocolHandler::Delegate overrides. |
534 | + virtual std::string GetDiscoveryPageHTML() OVERRIDE; |
535 | + virtual bool BundlesFrontendResources() OVERRIDE; |
536 | + virtual base::FilePath GetDebugFrontendDir() OVERRIDE; |
537 | + virtual std::string GetPageThumbnailData(const GURL& url) OVERRIDE; |
538 | + virtual scoped_ptr<content::DevToolsTarget> CreateNewTarget( |
539 | + const GURL& url) OVERRIDE; |
540 | + virtual void EnumerateTargets(TargetCallback callback) OVERRIDE; |
541 | + virtual scoped_ptr<net::StreamListenSocket> CreateSocketForTethering( |
542 | + net::StreamListenSocket::Delegate* delegate, |
543 | + std::string* name) OVERRIDE; |
544 | + |
545 | + private: |
546 | + |
547 | + std::string GetLocalDevToolsUrl() const; |
548 | + |
549 | + std::string ip_; |
550 | + unsigned port_; |
551 | + BrowserContext* browser_context_; |
552 | + DISALLOW_COPY_AND_ASSIGN(DevtoolsHttpHandlerDelegate); |
553 | +}; |
554 | + |
555 | +} |
556 | + |
557 | +#endif // _OXIDE_SHARED_BROWSER_DEVTOOLS_HTTP_HANDLER_DELEGATE_H_ |
558 | + |
559 | |
560 | === added file 'shared/browser/oxide_devtools_target.cc' |
561 | --- shared/browser/oxide_devtools_target.cc 1970-01-01 00:00:00 +0000 |
562 | +++ shared/browser/oxide_devtools_target.cc 2014-06-24 11:52:03 +0000 |
563 | @@ -0,0 +1,125 @@ |
564 | +// vim:expandtab:shiftwidth=2:tabstop=2: |
565 | +// Copyright (C) 2014 Canonical Ltd. |
566 | + |
567 | +// This library is free software; you can redistribute it and/or |
568 | +// modify it under the terms of the GNU Lesser General Public |
569 | +// License as published by the Free Software Foundation; either |
570 | +// version 2.1 of the License, or (at your option) any later version. |
571 | + |
572 | +// This library is distributed in the hope that it will be useful, |
573 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
574 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
575 | +// Lesser General Public License for more details. |
576 | + |
577 | +// You should have received a copy of the GNU Lesser General Public |
578 | +// License along with this library; if not, write to the Free Software |
579 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
580 | + |
581 | +#include "oxide_devtools_target.h" |
582 | + |
583 | +#include "base/logging.h" |
584 | +#include "base/strings/utf_string_conversions.h" |
585 | +#include "content/public/browser/devtools_agent_host.h" |
586 | +#include "content/public/browser/devtools_target.h" |
587 | +#include "content/public/browser/devtools_http_handler.h" |
588 | +#include "content/public/browser/render_view_host.h" |
589 | +#include "content/public/browser/web_contents.h" |
590 | +#include "content/public/browser/web_contents_delegate.h" |
591 | +#include "content/public/common/url_constants.h" |
592 | + |
593 | +using content::DevToolsAgentHost; |
594 | +using content::DevToolsTarget; |
595 | +using content::RenderViewHost; |
596 | +using content::WebContents; |
597 | + |
598 | +namespace oxide { |
599 | + |
600 | +// static |
601 | +DevtoolsTarget* DevtoolsTarget::CreateForWebContents( |
602 | + content::WebContents * web_contents) { |
603 | + DCHECK(web_contents); |
604 | + return new DevtoolsTarget(web_contents); |
605 | +} |
606 | + |
607 | +DevtoolsTarget::DevtoolsTarget( |
608 | + content::WebContents * wc) |
609 | + : content::WebContentsObserver(wc) { |
610 | + DCHECK(wc); |
611 | + |
612 | + agent_host_ = DevToolsAgentHost::GetOrCreateFor(web_contents()); |
613 | +} |
614 | + |
615 | +DevtoolsTarget::~DevtoolsTarget() { |
616 | +} |
617 | + |
618 | +std::string DevtoolsTarget::GetId() const { |
619 | + return agent_host_ ? agent_host_->GetId() : std::string(); |
620 | +} |
621 | + |
622 | +std::string DevtoolsTarget::GetParentId() const { |
623 | + return std::string(); |
624 | +} |
625 | + |
626 | +std::string DevtoolsTarget::GetType() const { |
627 | + return std::string(); |
628 | +} |
629 | + |
630 | +std::string DevtoolsTarget::GetTitle() const { |
631 | + const content::WebContents* wc = web_contents(); |
632 | + if (!wc) { |
633 | + return std::string(); |
634 | + } |
635 | + |
636 | + return base::UTF16ToUTF8(wc->GetTitle()); |
637 | +} |
638 | + |
639 | +std::string DevtoolsTarget::GetDescription() const { |
640 | + return std::string(); |
641 | +} |
642 | + |
643 | +GURL DevtoolsTarget::GetURL() const { |
644 | + const content::WebContents* wc = web_contents(); |
645 | + if (!wc) { |
646 | + return GURL(); |
647 | + } |
648 | + |
649 | + return wc->GetVisibleURL(); |
650 | +} |
651 | + |
652 | +GURL DevtoolsTarget::GetFaviconURL() const { |
653 | + return GURL(); |
654 | +} |
655 | + |
656 | +base::TimeTicks DevtoolsTarget::GetLastActivityTime() const { |
657 | + const content::WebContents* wc = web_contents(); |
658 | + if (!wc) { |
659 | + return base::TimeTicks(); |
660 | + } |
661 | + |
662 | + return wc->GetLastActiveTime(); |
663 | +} |
664 | + |
665 | +bool DevtoolsTarget::IsAttached() const { |
666 | + return agent_host_->IsAttached(); |
667 | +} |
668 | + |
669 | +scoped_refptr<DevToolsAgentHost> DevtoolsTarget::GetAgentHost() const { |
670 | + return agent_host_; |
671 | +} |
672 | + |
673 | +bool DevtoolsTarget::Activate() const { |
674 | + content::WebContents* wc = web_contents(); |
675 | + if (!wc) { |
676 | + return false; |
677 | + } |
678 | + |
679 | + wc->GetDelegate()->ActivateContents(wc); |
680 | + return true; |
681 | +} |
682 | + |
683 | +bool DevtoolsTarget::Close() const { |
684 | + NOTIMPLEMENTED(); |
685 | + return false; |
686 | +} |
687 | + |
688 | +} |
689 | |
690 | === added file 'shared/browser/oxide_devtools_target.h' |
691 | --- shared/browser/oxide_devtools_target.h 1970-01-01 00:00:00 +0000 |
692 | +++ shared/browser/oxide_devtools_target.h 2014-06-24 11:52:03 +0000 |
693 | @@ -0,0 +1,72 @@ |
694 | +// vim:expandtab:shiftwidth=2:tabstop=2: |
695 | +// Copyright (C) 2014 Canonical Ltd. |
696 | + |
697 | +// This library is free software; you can redistribute it and/or |
698 | +// modify it under the terms of the GNU Lesser General Public |
699 | +// License as published by the Free Software Foundation; either |
700 | +// version 2.1 of the License, or (at your option) any later version. |
701 | + |
702 | +// This library is distributed in the hope that it will be useful, |
703 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
704 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
705 | +// Lesser General Public License for more details. |
706 | + |
707 | +// You should have received a copy of the GNU Lesser General Public |
708 | +// License along with this library; if not, write to the Free Software |
709 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
710 | + |
711 | +#ifndef _OXIDE_SHARED_BROWSER_DEVTOOLS_TARGET_H_ |
712 | +#define _OXIDE_SHARED_BROWSER_DEVTOOLS_TARGET_H_ |
713 | + |
714 | +#include <string> |
715 | + |
716 | +#include "base/basictypes.h" |
717 | +#include "base/compiler_specific.h" |
718 | +#include "content/public/browser/devtools_target.h" |
719 | +#include "content/public/browser/web_contents_observer.h" |
720 | + |
721 | +namespace content { |
722 | +class DevToolsTarget; |
723 | +class DevToolsAgentHost; |
724 | +class RenderViewHost; |
725 | +class WebContents; |
726 | +} |
727 | + |
728 | +namespace oxide { |
729 | + |
730 | +class DevtoolsTarget |
731 | + : public content::DevToolsTarget, |
732 | + public content::WebContentsObserver |
733 | +{ |
734 | + public: |
735 | + |
736 | + virtual ~DevtoolsTarget(); |
737 | + |
738 | + static DevtoolsTarget * CreateForWebContents(content::WebContents *); |
739 | + |
740 | + // DevToolsHttpProtocolHandler::Delegate overrides. |
741 | + virtual std::string GetId() const OVERRIDE; |
742 | + virtual std::string GetParentId() const OVERRIDE; |
743 | + virtual std::string GetType() const OVERRIDE; |
744 | + virtual std::string GetTitle() const OVERRIDE; |
745 | + virtual std::string GetDescription() const OVERRIDE; |
746 | + virtual GURL GetURL() const OVERRIDE; |
747 | + virtual GURL GetFaviconURL() const OVERRIDE; |
748 | + virtual base::TimeTicks GetLastActivityTime() const OVERRIDE; |
749 | + virtual bool IsAttached() const OVERRIDE; |
750 | + virtual scoped_refptr<content::DevToolsAgentHost> GetAgentHost() const OVERRIDE; |
751 | + virtual bool Activate() const OVERRIDE; |
752 | + virtual bool Close() const OVERRIDE; |
753 | + |
754 | + private: |
755 | + DevtoolsTarget(content::WebContents * web_contents); |
756 | + |
757 | + scoped_refptr<content::DevToolsAgentHost> agent_host_; |
758 | + |
759 | + DISALLOW_COPY_AND_ASSIGN(DevtoolsTarget); |
760 | +}; |
761 | + |
762 | +} |
763 | + |
764 | +#endif // _OXIDE_SHARED_BROWSER_DEVTOOLS_HTTP_HANDLER_DELEGATE_H_ |
765 | + |
766 | |
767 | === modified file 'shared/browser/oxide_off_the_record_browser_context_impl.cc' |
768 | --- shared/browser/oxide_off_the_record_browser_context_impl.cc 2014-05-22 08:09:28 +0000 |
769 | +++ shared/browser/oxide_off_the_record_browser_context_impl.cc 2014-06-24 11:52:03 +0000 |
770 | @@ -112,4 +112,13 @@ |
771 | return original_context_->UserScriptManager(); |
772 | } |
773 | |
774 | +bool OffTheRecordBrowserContextImpl::GetDevtoolsEnabled() const { |
775 | + return original_context_->GetDevtoolsEnabled(); |
776 | +} |
777 | + |
778 | +int OffTheRecordBrowserContextImpl::GetDevtoolsPort() const { |
779 | + return original_context_->GetDevtoolsPort(); |
780 | +} |
781 | + |
782 | + |
783 | } // namespace oxide |
784 | |
785 | === modified file 'shared/browser/oxide_off_the_record_browser_context_impl.h' |
786 | --- shared/browser/oxide_off_the_record_browser_context_impl.h 2014-05-22 08:09:28 +0000 |
787 | +++ shared/browser/oxide_off_the_record_browser_context_impl.h 2014-06-24 11:52:03 +0000 |
788 | @@ -66,6 +66,9 @@ |
789 | void SetCookiePolicy(net::StaticCookiePolicy::Type policy) FINAL; |
790 | void SetIsPopupBlockerEnabled(bool enabled) FINAL; |
791 | |
792 | + bool GetDevtoolsEnabled() const FINAL; |
793 | + int GetDevtoolsPort() const FINAL; |
794 | + |
795 | UserScriptMaster& UserScriptManager() FINAL; |
796 | |
797 | private: |
798 | |
799 | === modified file 'shared/browser/oxide_web_view.cc' |
800 | --- shared/browser/oxide_web_view.cc 2014-06-19 17:41:21 +0000 |
801 | +++ shared/browser/oxide_web_view.cc 2014-06-24 11:52:03 +0000 |
802 | @@ -19,6 +19,7 @@ |
803 | |
804 | #include <queue> |
805 | |
806 | +#include "base/lazy_instance.h" |
807 | #include "base/logging.h" |
808 | #include "base/strings/utf_string_conversions.h" |
809 | #include "base/supports_user_data.h" |
810 | @@ -113,6 +114,27 @@ |
811 | view->Init(¶ms); |
812 | } |
813 | |
814 | +typedef std::map<BrowserContext*, std::set<WebView*> > WebViewsPerContextMap; |
815 | +base::LazyInstance<WebViewsPerContextMap> g_web_view_per_context; |
816 | + |
817 | +} |
818 | + |
819 | +// static |
820 | +std::set<WebView*> |
821 | +WebView::GetAllWebViewsFor(BrowserContext * browser_context) { |
822 | + std::set<WebView*> webviews; |
823 | + if (!browser_context) { |
824 | + return webviews; |
825 | + } |
826 | + WebViewsPerContextMap::iterator it; |
827 | + for (it = g_web_view_per_context.Get().begin(); |
828 | + it != g_web_view_per_context.Get().end(); |
829 | + ++it) { |
830 | + if (browser_context->IsSameContext(it->first)) { |
831 | + return it->second; |
832 | + } |
833 | + } |
834 | + return webviews; |
835 | } |
836 | |
837 | void WebView::DispatchLoadFailed(const GURL& validated_url, |
838 | @@ -559,9 +581,25 @@ |
839 | : web_contents_helper_(NULL), |
840 | initial_preferences_(NULL), |
841 | root_frame_(NULL), |
842 | - is_fullscreen_(false) {} |
843 | + is_fullscreen_(false) { |
844 | +} |
845 | |
846 | WebView::~WebView() { |
847 | + BrowserContext* context = |
848 | + GetBrowserContext(); |
849 | + WebViewsPerContextMap::iterator it = |
850 | + g_web_view_per_context.Get().find(context); |
851 | + if (it != g_web_view_per_context.Get().end()) { |
852 | + std::set<WebView*>& wvl = it->second; |
853 | + if (wvl.find(this) != wvl.end()) { |
854 | + wvl.erase(this); |
855 | + g_web_view_per_context.Get()[context] = wvl; |
856 | + } |
857 | + if (g_web_view_per_context.Get()[context].empty()) { |
858 | + g_web_view_per_context.Get().erase(context); |
859 | + } |
860 | + } |
861 | + |
862 | if (root_frame_) { |
863 | root_frame_->Destroy(); |
864 | } |
865 | @@ -632,7 +670,22 @@ |
866 | SetURL(initial_url_); |
867 | initial_url_ = GURL(); |
868 | } |
869 | + |
870 | SetIsFullscreen(is_fullscreen_); |
871 | + |
872 | + { |
873 | + BrowserContext* context = |
874 | + GetBrowserContext()->GetOriginalContext(); |
875 | + WebViewsPerContextMap::iterator it = |
876 | + g_web_view_per_context.Get().find(context); |
877 | + if (it != g_web_view_per_context.Get().end()) { |
878 | + g_web_view_per_context.Get()[context].insert(this); |
879 | + } else { |
880 | + std::set<WebView*> wvl; |
881 | + wvl.insert(this); |
882 | + g_web_view_per_context.Get()[context] = wvl; |
883 | + } |
884 | + } |
885 | } |
886 | |
887 | // static |
888 | |
889 | === modified file 'shared/browser/oxide_web_view.h' |
890 | --- shared/browser/oxide_web_view.h 2014-06-19 17:41:21 +0000 |
891 | +++ shared/browser/oxide_web_view.h 2014-06-24 11:52:03 +0000 |
892 | @@ -20,6 +20,7 @@ |
893 | |
894 | #include <string> |
895 | #include <vector> |
896 | +#include <set> |
897 | |
898 | #include "base/basictypes.h" |
899 | #include "base/compiler_specific.h" |
900 | @@ -94,6 +95,9 @@ |
901 | static WebView* FromWebContents(const content::WebContents* web_contents); |
902 | static WebView* FromRenderViewHost(content::RenderViewHost* rvh); |
903 | |
904 | + static std::set<WebView*> GetAllWebViewsFor( |
905 | + BrowserContext * browser_context); |
906 | + |
907 | const GURL& GetURL() const; |
908 | void SetURL(const GURL& url); |
909 | |
910 | |
911 | === added directory 'shared/browser/resources' |
912 | === added file 'shared/browser/resources/devtools_discovery_page.html' |
913 | --- shared/browser/resources/devtools_discovery_page.html 1970-01-01 00:00:00 +0000 |
914 | +++ shared/browser/resources/devtools_discovery_page.html 2014-06-24 11:52:03 +0000 |
915 | @@ -0,0 +1,155 @@ |
916 | +<html> |
917 | +<head> |
918 | +<title>Inspectable pages</title> |
919 | +<style> |
920 | +body { |
921 | + background-color: rgb(245, 245, 245); |
922 | + font-family: Helvetica, Arial, sans-serif; |
923 | + text-shadow: rgba(255, 255, 255, 0.496094) 0px 1px 0px; |
924 | +} |
925 | + |
926 | +#caption { |
927 | + color: black; |
928 | + font-size: 16px; |
929 | + margin-top: 30px; |
930 | + margin-bottom: 0px; |
931 | + margin-left: 70px; |
932 | + height: 20px; |
933 | + text-align: left; |
934 | +} |
935 | + |
936 | +#items { |
937 | + display: -webkit-box; |
938 | + margin-left: 60px; |
939 | + margin-right: 60px; |
940 | + -webkit-box-orient: horizontal; |
941 | + -webkit-box-lines: multiple; |
942 | +} |
943 | + |
944 | +.frontend_ref { |
945 | + color: black; |
946 | + text-decoration: initial; |
947 | +} |
948 | + |
949 | +.thumbnail { |
950 | + background-attachment: scroll; |
951 | + background-origin: padding-box; |
952 | + background-repeat: no-repeat; |
953 | + border: 4px solid rgba(184, 184, 184, 1); |
954 | + border-radius: 5px; |
955 | + height: 132px; |
956 | + width: 212px; |
957 | + -webkit-transition-property: background-color, border-color; |
958 | + -webkit-transition: background-color 0.15s, 0.15s; |
959 | + -webkit-transition-delay: 0, 0; |
960 | +} |
961 | + |
962 | +.thumbnail:hover { |
963 | + background-color: rgba(242, 242, 242, 1); |
964 | + border-color: rgba(110, 116, 128, 1); |
965 | + color: black; |
966 | +} |
967 | + |
968 | +.thumbnail.connected { |
969 | + opacity: 0.5; |
970 | +} |
971 | + |
972 | +.thumbnail.connected:hover { |
973 | + border-color: rgba(184, 184, 184, 1); |
974 | + color: rgb(110, 116, 128); |
975 | +} |
976 | + |
977 | +.item { |
978 | + display: inline-block; |
979 | + margin: 5px; |
980 | + margin-top: 15px; |
981 | + height: 162px; |
982 | + vertical-align: top; |
983 | + width: 222px; |
984 | +} |
985 | + |
986 | +.text { |
987 | + background: no-repeat 0; |
988 | + background-size: 16px; |
989 | + font-size: 12px; |
990 | + margin: 4px 0px 0px 4px; |
991 | + overflow: hidden; |
992 | + padding: 2px 0px 0px 20px; |
993 | + text-align: left; |
994 | + text-overflow: ellipsis; |
995 | + white-space: nowrap; |
996 | +} |
997 | +</style> |
998 | + |
999 | +<script> |
1000 | + |
1001 | +function onLoad() { |
1002 | + var tabsListRequest = new XMLHttpRequest(); |
1003 | + tabsListRequest.open('GET', '/json/list', true); |
1004 | + tabsListRequest.onreadystatechange = onReady; |
1005 | + tabsListRequest.send(); |
1006 | +} |
1007 | + |
1008 | +function onReady() { |
1009 | + if(this.readyState == 4 && this.status == 200) { |
1010 | + if(this.response != null) |
1011 | + var responseJSON = JSON.parse(this.response); |
1012 | + for (var i = 0; i < responseJSON.length; ++i) |
1013 | + appendItem(responseJSON[i]); |
1014 | + } |
1015 | +} |
1016 | + |
1017 | +function overrideFrontendUrl(item) { |
1018 | + if (window.location.hash) { |
1019 | + var overridden_url = window.location.hash.substr(1); |
1020 | + var ws_suffix = item.webSocketDebuggerUrl.replace('ws://', 'ws='); |
1021 | + if (overridden_url.indexOf('?') == -1) |
1022 | + return overridden_url + '?' + ws_suffix; |
1023 | + else |
1024 | + return overridden_url + '&' + ws_suffix; |
1025 | + } |
1026 | + return item.devtoolsFrontendUrl; |
1027 | +} |
1028 | + |
1029 | +function appendItem(item_object) { |
1030 | + var frontend_ref; |
1031 | + if (item_object.devtoolsFrontendUrl) { |
1032 | + frontend_ref = document.createElement('a'); |
1033 | + frontend_ref.href = overrideFrontendUrl(item_object); |
1034 | + frontend_ref.title = item_object.title; |
1035 | + } else { |
1036 | + frontend_ref = document.createElement('div'); |
1037 | + frontend_ref.title = 'The tab already has an active debug session'; |
1038 | + } |
1039 | + frontend_ref.className = 'frontend_ref'; |
1040 | + |
1041 | + var thumbnail = document.createElement('div'); |
1042 | + thumbnail.className = item_object.devtoolsFrontendUrl ? |
1043 | + 'thumbnail' : 'thumbnail connected'; |
1044 | + thumbnail.style.cssText = 'background-image:url(' + |
1045 | + item_object.thumbnailUrl + |
1046 | + ')'; |
1047 | + frontend_ref.appendChild(thumbnail); |
1048 | + |
1049 | + var text = document.createElement('div'); |
1050 | + text.className = 'text'; |
1051 | + text.innerText = item_object.description || item_object.title; |
1052 | + text.style.cssText = 'background-image:url(' + |
1053 | + item_object.faviconUrl + ')'; |
1054 | + frontend_ref.appendChild(text); |
1055 | + |
1056 | + var item = document.createElement('p'); |
1057 | + item.className = 'item'; |
1058 | + item.appendChild(frontend_ref); |
1059 | + |
1060 | + document.getElementById('items').appendChild(item); |
1061 | +} |
1062 | +</script> |
1063 | +</head> |
1064 | +<body onload='onLoad()'> |
1065 | + <div id='caption'>Inspectable pages</div> |
1066 | + <div id='items'> |
1067 | + </div> |
1068 | + <hr> |
1069 | +</body> |
1070 | +</html> |
1071 | |
1072 | === modified file 'shared/oxide_resources.grd' |
1073 | --- shared/oxide_resources.grd 2014-02-28 12:53:41 +0000 |
1074 | +++ shared/oxide_resources.grd 2014-06-24 11:52:03 +0000 |
1075 | @@ -9,6 +9,7 @@ |
1076 | <release seq="1"> |
1077 | <includes> |
1078 | <include name="IDR_OXIDE_SCRIPT_MESSAGE_MANAGER_BINDINGS_JS" file="renderer/oxide_script_message_manager_bindings.js" type="BINDATA" /> |
1079 | + <include name="IDR_OXIDE_DEVTOOLS_DISCOVERY_HTML_PAGE" file="browser/resources/devtools_discovery_page.html" type="BINDATA" /> |
1080 | </includes> |
1081 | </release> |
1082 | </grit> |
1083 | |
1084 | === modified file 'shared/shared.gyp' |
1085 | --- shared/shared.gyp 2014-06-19 17:41:21 +0000 |
1086 | +++ shared/shared.gyp 2014-06-24 11:52:03 +0000 |
1087 | @@ -42,6 +42,7 @@ |
1088 | 'dependencies': [ |
1089 | 'oxide_extra_resources', |
1090 | '<(DEPTH)/content/content_resources.gyp:content_resources', |
1091 | + '<(DEPTH)/content/browser/devtools/devtools_resources.gyp:devtools_resources', |
1092 | '<(DEPTH)/net/net.gyp:net_resources', |
1093 | '<(DEPTH)/ui/resources/ui_resources.gyp:ui_resources', |
1094 | '<(DEPTH)/webkit/webkit_resources.gyp:webkit_resources', |
1095 | @@ -53,6 +54,7 @@ |
1096 | 'variables': { |
1097 | 'pak_inputs': [ |
1098 | '<(SHARED_INTERMEDIATE_DIR)/content/content_resources.pak', |
1099 | + '<(SHARED_INTERMEDIATE_DIR)/webkit/devtools_resources.pak', |
1100 | '<(SHARED_INTERMEDIATE_DIR)/net/net_resources.pak', |
1101 | '<(SHARED_INTERMEDIATE_DIR)/oxide/oxide_resources.pak', |
1102 | '<(SHARED_INTERMEDIATE_DIR)/webkit/blink_resources.pak', |
1103 | @@ -226,6 +228,10 @@ |
1104 | 'browser/oxide_content_browser_client.cc', |
1105 | 'browser/oxide_content_browser_client.h', |
1106 | 'browser/oxide_default_screen_info.h', |
1107 | + 'browser/oxide_devtools_http_handler_delegate.cc', |
1108 | + 'browser/oxide_devtools_http_handler_delegate.h', |
1109 | + 'browser/oxide_devtools_target.cc', |
1110 | + 'browser/oxide_devtools_target.h', |
1111 | 'browser/oxide_file_picker.cc', |
1112 | 'browser/oxide_file_picker.h', |
1113 | 'browser/oxide_form_factor.h', |
Left my comments inline :)