OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/android/dev_tools_server.h" | 5 #include "chrome/browser/android/dev_tools_server.h" |
6 | 6 |
7 #include <pwd.h> | 7 #include <pwd.h> |
8 #include <cstring> | 8 #include <cstring> |
9 | 9 |
10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "content/public/browser/devtools_http_handler.h" | 30 #include "content/public/browser/devtools_http_handler.h" |
31 #include "content/public/browser/devtools_http_handler_delegate.h" | 31 #include "content/public/browser/devtools_http_handler_delegate.h" |
32 #include "content/public/browser/devtools_target.h" | 32 #include "content/public/browser/devtools_target.h" |
33 #include "content/public/browser/favicon_status.h" | 33 #include "content/public/browser/favicon_status.h" |
34 #include "content/public/browser/navigation_entry.h" | 34 #include "content/public/browser/navigation_entry.h" |
35 #include "content/public/browser/render_view_host.h" | 35 #include "content/public/browser/render_view_host.h" |
36 #include "content/public/browser/web_contents.h" | 36 #include "content/public/browser/web_contents.h" |
37 #include "content/public/browser/web_contents_delegate.h" | 37 #include "content/public/browser/web_contents_delegate.h" |
38 #include "content/public/common/content_switches.h" | 38 #include "content/public/common/content_switches.h" |
39 #include "content/public/common/url_constants.h" | 39 #include "content/public/common/url_constants.h" |
| 40 #include "content/public/common/user_agent.h" |
40 #include "grit/browser_resources.h" | 41 #include "grit/browser_resources.h" |
41 #include "jni/DevToolsServer_jni.h" | 42 #include "jni/DevToolsServer_jni.h" |
42 #include "net/socket/unix_domain_socket_posix.h" | 43 #include "net/socket/unix_domain_socket_posix.h" |
43 #include "net/url_request/url_request_context_getter.h" | 44 #include "net/url_request/url_request_context_getter.h" |
44 #include "ui/base/resource/resource_bundle.h" | 45 #include "ui/base/resource/resource_bundle.h" |
45 #include "webkit/common/user_agent/user_agent_util.h" | |
46 | 46 |
47 using content::DevToolsAgentHost; | 47 using content::DevToolsAgentHost; |
48 using content::RenderViewHost; | 48 using content::RenderViewHost; |
49 using content::WebContents; | 49 using content::WebContents; |
50 | 50 |
51 namespace { | 51 namespace { |
52 | 52 |
53 const char kFrontEndURL[] = | 53 const char kFrontEndURL[] = |
54 "http://chrome-devtools-frontend.appspot.com/serve_rev/%s/devtools.html"; | 54 "http://chrome-devtools-frontend.appspot.com/serve_rev/%s/devtools.html"; |
55 const char kDefaultSocketNamePrefix[] = "chrome"; | 55 const char kDefaultSocketNamePrefix[] = "chrome"; |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 | 407 |
408 void DevToolsServer::Start() { | 408 void DevToolsServer::Start() { |
409 if (protocol_handler_) | 409 if (protocol_handler_) |
410 return; | 410 return; |
411 | 411 |
412 protocol_handler_ = content::DevToolsHttpHandler::Start( | 412 protocol_handler_ = content::DevToolsHttpHandler::Start( |
413 new net::UnixDomainSocketWithAbstractNamespaceFactory( | 413 new net::UnixDomainSocketWithAbstractNamespaceFactory( |
414 socket_name_, | 414 socket_name_, |
415 base::StringPrintf("%s_%d", socket_name_.c_str(), getpid()), | 415 base::StringPrintf("%s_%d", socket_name_.c_str(), getpid()), |
416 base::Bind(&content::CanUserConnectToDevTools)), | 416 base::Bind(&content::CanUserConnectToDevTools)), |
417 base::StringPrintf(kFrontEndURL, | 417 base::StringPrintf(kFrontEndURL, content::GetWebKitRevision().c_str()), |
418 webkit_glue::GetWebKitRevision().c_str()), | |
419 new DevToolsServerDelegate()); | 418 new DevToolsServerDelegate()); |
420 } | 419 } |
421 | 420 |
422 void DevToolsServer::Stop() { | 421 void DevToolsServer::Stop() { |
423 if (!protocol_handler_) | 422 if (!protocol_handler_) |
424 return; | 423 return; |
425 // Note that the call to Stop() below takes care of |protocol_handler_| | 424 // Note that the call to Stop() below takes care of |protocol_handler_| |
426 // deletion. | 425 // deletion. |
427 protocol_handler_->Stop(); | 426 protocol_handler_->Stop(); |
428 protocol_handler_ = NULL; | 427 protocol_handler_ = NULL; |
(...skipping 29 matching lines...) Expand all Loading... |
458 jobject obj, | 457 jobject obj, |
459 jlong server, | 458 jlong server, |
460 jboolean enabled) { | 459 jboolean enabled) { |
461 DevToolsServer* devtools_server = reinterpret_cast<DevToolsServer*>(server); | 460 DevToolsServer* devtools_server = reinterpret_cast<DevToolsServer*>(server); |
462 if (enabled) { | 461 if (enabled) { |
463 devtools_server->Start(); | 462 devtools_server->Start(); |
464 } else { | 463 } else { |
465 devtools_server->Stop(); | 464 devtools_server->Stop(); |
466 } | 465 } |
467 } | 466 } |
OLD | NEW |