| 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 <cstring> | 7 #include <cstring> |
| 8 #include <pwd.h> | 8 #include <pwd.h> |
| 9 | 9 |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 const char kSocketName[] = "chrome_devtools_remote"; | 34 const char kSocketName[] = "chrome_devtools_remote"; |
| 35 | 35 |
| 36 // Delegate implementation for the devtools http handler on android. A new | 36 // Delegate implementation for the devtools http handler on android. A new |
| 37 // instance of this gets created each time devtools is enabled. | 37 // instance of this gets created each time devtools is enabled. |
| 38 class DevToolsServerDelegate : public content::DevToolsHttpHandlerDelegate { | 38 class DevToolsServerDelegate : public content::DevToolsHttpHandlerDelegate { |
| 39 public: | 39 public: |
| 40 explicit DevToolsServerDelegate(bool use_bundled_frontend_resources) | 40 explicit DevToolsServerDelegate(bool use_bundled_frontend_resources) |
| 41 : use_bundled_frontend_resources_(use_bundled_frontend_resources) { | 41 : use_bundled_frontend_resources_(use_bundled_frontend_resources) { |
| 42 } | 42 } |
| 43 | 43 |
| 44 virtual std::string GetDiscoveryPageHTML() { | 44 virtual std::string GetDiscoveryPageHTML() OVERRIDE { |
| 45 // TopSites updates itself after a delay. Ask TopSites to update itself | 45 // TopSites updates itself after a delay. Ask TopSites to update itself |
| 46 // when we're about to show the remote debugging landing page. | 46 // when we're about to show the remote debugging landing page. |
| 47 content::BrowserThread::PostTask( | 47 content::BrowserThread::PostTask( |
| 48 content::BrowserThread::UI, | 48 content::BrowserThread::UI, |
| 49 FROM_HERE, | 49 FROM_HERE, |
| 50 base::Bind(&DevToolsServerDelegate::PopulatePageThumbnails)); | 50 base::Bind(&DevToolsServerDelegate::PopulatePageThumbnails)); |
| 51 return ResourceBundle::GetSharedInstance().GetRawDataResource( | 51 return ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 52 IDR_DEVTOOLS_DISCOVERY_PAGE_HTML).as_string(); | 52 IDR_DEVTOOLS_DISCOVERY_PAGE_HTML).as_string(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 virtual bool BundlesFrontendResources() { | 55 virtual bool BundlesFrontendResources() OVERRIDE { |
| 56 return use_bundled_frontend_resources_; | 56 return use_bundled_frontend_resources_; |
| 57 } | 57 } |
| 58 | 58 |
| 59 virtual base::FilePath GetDebugFrontendDir() { | 59 virtual base::FilePath GetDebugFrontendDir() OVERRIDE { |
| 60 return base::FilePath(); | 60 return base::FilePath(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 virtual std::string GetPageThumbnailData(const GURL& url) { | 63 virtual std::string GetPageThumbnailData(const GURL& url) OVERRIDE { |
| 64 Profile* profile = | 64 Profile* profile = |
| 65 ProfileManager::GetLastUsedProfile()->GetOriginalProfile(); | 65 ProfileManager::GetLastUsedProfile()->GetOriginalProfile(); |
| 66 history::TopSites* top_sites = profile->GetTopSites(); | 66 history::TopSites* top_sites = profile->GetTopSites(); |
| 67 if (top_sites) { | 67 if (top_sites) { |
| 68 scoped_refptr<base::RefCountedMemory> data; | 68 scoped_refptr<base::RefCountedMemory> data; |
| 69 if (top_sites->GetPageThumbnail(url, &data)) | 69 if (top_sites->GetPageThumbnail(url, &data)) |
| 70 return std::string(reinterpret_cast<const char*>(data->front()), | 70 return std::string(reinterpret_cast<const char*>(data->front()), |
| 71 data->size()); | 71 data->size()); |
| 72 } | 72 } |
| 73 return ""; | 73 return ""; |
| 74 } | 74 } |
| 75 | 75 |
| 76 content::RenderViewHost* CreateNewTarget() { | 76 virtual content::RenderViewHost* CreateNewTarget() OVERRIDE { |
| 77 return NULL; | 77 return NULL; |
| 78 } | 78 } |
| 79 | 79 |
| 80 TargetType GetTargetType(content::RenderViewHost*) { | 80 virtual TargetType GetTargetType(content::RenderViewHost*) OVERRIDE { |
| 81 return kTargetTypeTab; | 81 return kTargetTypeTab; |
| 82 } | 82 } |
| 83 | 83 |
| 84 virtual std::string GetViewDescription(content::RenderViewHost*) OVERRIDE { |
| 85 return ""; |
| 86 } |
| 87 |
| 84 private: | 88 private: |
| 85 static void PopulatePageThumbnails() { | 89 static void PopulatePageThumbnails() { |
| 86 Profile* profile = | 90 Profile* profile = |
| 87 ProfileManager::GetLastUsedProfile()->GetOriginalProfile(); | 91 ProfileManager::GetLastUsedProfile()->GetOriginalProfile(); |
| 88 history::TopSites* top_sites = profile->GetTopSites(); | 92 history::TopSites* top_sites = profile->GetTopSites(); |
| 89 if (top_sites) | 93 if (top_sites) |
| 90 top_sites->SyncWithHistory(); | 94 top_sites->SyncWithHistory(); |
| 91 } | 95 } |
| 92 | 96 |
| 93 bool use_bundled_frontend_resources_; | 97 bool use_bundled_frontend_resources_; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 jobject obj, | 174 jobject obj, |
| 171 jint server, | 175 jint server, |
| 172 jboolean enabled) { | 176 jboolean enabled) { |
| 173 DevToolsServer* devtools_server = reinterpret_cast<DevToolsServer*>(server); | 177 DevToolsServer* devtools_server = reinterpret_cast<DevToolsServer*>(server); |
| 174 if (enabled) { | 178 if (enabled) { |
| 175 devtools_server->Start(); | 179 devtools_server->Start(); |
| 176 } else { | 180 } else { |
| 177 devtools_server->Stop(); | 181 devtools_server->Stop(); |
| 178 } | 182 } |
| 179 } | 183 } |
| OLD | NEW |