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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 const char kTargetTypeOther[] = "other"; | 70 const char kTargetTypeOther[] = "other"; |
71 | 71 |
72 static GURL GetFaviconURLForContents(WebContents* web_contents) { | 72 static GURL GetFaviconURLForContents(WebContents* web_contents) { |
73 content::NavigationController& controller = web_contents->GetController(); | 73 content::NavigationController& controller = web_contents->GetController(); |
74 content::NavigationEntry* entry = controller.GetActiveEntry(); | 74 content::NavigationEntry* entry = controller.GetActiveEntry(); |
75 if (entry != NULL && entry->GetURL().is_valid()) | 75 if (entry != NULL && entry->GetURL().is_valid()) |
76 return entry->GetFavicon().url; | 76 return entry->GetFavicon().url; |
77 return GURL(); | 77 return GURL(); |
78 } | 78 } |
79 | 79 |
80 bool AuthenticateSocketAccess(pid_t pid, uid_t uid, gid_t gid) { | |
81 JNIEnv* env = base::android::AttachCurrentThread(); | |
82 return Java_DevToolsServer_checkPermission(env, pid, uid) || | |
83 content::CanUserConnectToDevTools(pid, uid, gid); | |
byungchul
2014/08/01 16:45:16
wrong indentation, 4 whitespaces.
SeRya
2014/08/04 10:47:03
Done.
| |
84 } | |
85 | |
80 class TargetBase : public content::DevToolsTarget { | 86 class TargetBase : public content::DevToolsTarget { |
81 public: | 87 public: |
82 // content::DevToolsTarget implementation: | 88 // content::DevToolsTarget implementation: |
83 virtual std::string GetParentId() const OVERRIDE { return std::string(); } | 89 virtual std::string GetParentId() const OVERRIDE { return std::string(); } |
84 | 90 |
85 virtual std::string GetTitle() const OVERRIDE { return title_; } | 91 virtual std::string GetTitle() const OVERRIDE { return title_; } |
86 | 92 |
87 virtual std::string GetDescription() const OVERRIDE { return std::string(); } | 93 virtual std::string GetDescription() const OVERRIDE { return std::string(); } |
88 | 94 |
89 virtual GURL GetURL() const OVERRIDE { return url_; } | 95 virtual GURL GetURL() const OVERRIDE { return url_; } |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
364 virtual scoped_ptr<net::StreamListenSocket> CreateSocketForTethering( | 370 virtual scoped_ptr<net::StreamListenSocket> CreateSocketForTethering( |
365 net::StreamListenSocket::Delegate* delegate, | 371 net::StreamListenSocket::Delegate* delegate, |
366 std::string* name) OVERRIDE { | 372 std::string* name) OVERRIDE { |
367 *name = base::StringPrintf( | 373 *name = base::StringPrintf( |
368 kTetheringSocketName, getpid(), ++last_tethering_socket_); | 374 kTetheringSocketName, getpid(), ++last_tethering_socket_); |
369 return net::deprecated::UnixDomainListenSocket:: | 375 return net::deprecated::UnixDomainListenSocket:: |
370 CreateAndListenWithAbstractNamespace( | 376 CreateAndListenWithAbstractNamespace( |
371 *name, | 377 *name, |
372 "", | 378 "", |
373 delegate, | 379 delegate, |
374 base::Bind(&content::CanUserConnectToDevTools)) | 380 base::Bind(&AuthenticateSocketAccess)) |
375 .PassAs<net::StreamListenSocket>(); | 381 .PassAs<net::StreamListenSocket>(); |
376 } | 382 } |
377 | 383 |
378 private: | 384 private: |
379 static void PopulatePageThumbnails() { | 385 static void PopulatePageThumbnails() { |
380 Profile* profile = | 386 Profile* profile = |
381 ProfileManager::GetLastUsedProfile()->GetOriginalProfile(); | 387 ProfileManager::GetLastUsedProfile()->GetOriginalProfile(); |
382 history::TopSites* top_sites = profile->GetTopSites(); | 388 history::TopSites* top_sites = profile->GetTopSites(); |
383 if (top_sites) | 389 if (top_sites) |
384 top_sites->SyncWithHistory(); | 390 top_sites->SyncWithHistory(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
420 } | 426 } |
421 | 427 |
422 void DevToolsServer::Start() { | 428 void DevToolsServer::Start() { |
423 if (protocol_handler_) | 429 if (protocol_handler_) |
424 return; | 430 return; |
425 | 431 |
426 protocol_handler_ = content::DevToolsHttpHandler::Start( | 432 protocol_handler_ = content::DevToolsHttpHandler::Start( |
427 new net::deprecated::UnixDomainListenSocketWithAbstractNamespaceFactory( | 433 new net::deprecated::UnixDomainListenSocketWithAbstractNamespaceFactory( |
428 socket_name_, | 434 socket_name_, |
429 base::StringPrintf("%s_%d", socket_name_.c_str(), getpid()), | 435 base::StringPrintf("%s_%d", socket_name_.c_str(), getpid()), |
430 base::Bind(&content::CanUserConnectToDevTools)), | 436 base::Bind(&AuthenticateSocketAccess)), |
431 base::StringPrintf(kFrontEndURL, content::GetWebKitRevision().c_str()), | 437 base::StringPrintf(kFrontEndURL, content::GetWebKitRevision().c_str()), |
432 new DevToolsServerDelegate(), | 438 new DevToolsServerDelegate(), |
433 base::FilePath()); | 439 base::FilePath()); |
434 } | 440 } |
435 | 441 |
436 void DevToolsServer::Stop() { | 442 void DevToolsServer::Stop() { |
437 if (!protocol_handler_) | 443 if (!protocol_handler_) |
438 return; | 444 return; |
439 // Note that the call to Stop() below takes care of |protocol_handler_| | 445 // Note that the call to Stop() below takes care of |protocol_handler_| |
440 // deletion. | 446 // deletion. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
472 jobject obj, | 478 jobject obj, |
473 jlong server, | 479 jlong server, |
474 jboolean enabled) { | 480 jboolean enabled) { |
475 DevToolsServer* devtools_server = reinterpret_cast<DevToolsServer*>(server); | 481 DevToolsServer* devtools_server = reinterpret_cast<DevToolsServer*>(server); |
476 if (enabled) { | 482 if (enabled) { |
477 devtools_server->Start(); | 483 devtools_server->Start(); |
478 } else { | 484 } else { |
479 devtools_server->Stop(); | 485 devtools_server->Stop(); |
480 } | 486 } |
481 } | 487 } |
OLD | NEW |