| 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 history::TopSites* top_sites = profile->GetTopSites(); | 284 history::TopSites* top_sites = profile->GetTopSites(); |
| 285 if (top_sites) { | 285 if (top_sites) { |
| 286 scoped_refptr<base::RefCountedMemory> data; | 286 scoped_refptr<base::RefCountedMemory> data; |
| 287 if (top_sites->GetPageThumbnail(url, false, &data)) | 287 if (top_sites->GetPageThumbnail(url, false, &data)) |
| 288 return std::string(reinterpret_cast<const char*>(data->front()), | 288 return std::string(reinterpret_cast<const char*>(data->front()), |
| 289 data->size()); | 289 data->size()); |
| 290 } | 290 } |
| 291 return ""; | 291 return ""; |
| 292 } | 292 } |
| 293 | 293 |
| 294 virtual scoped_ptr<content::DevToolsTarget> CreateNewTarget( | 294 virtual scoped_ptr<content::DevToolsTarget> CreateNewTarget() OVERRIDE { |
| 295 const GURL& url) OVERRIDE { | |
| 296 Profile* profile = | 295 Profile* profile = |
| 297 g_browser_process->profile_manager()->GetDefaultProfile(); | 296 g_browser_process->profile_manager()->GetDefaultProfile(); |
| 298 TabModel* tab_model = TabModelList::GetTabModelWithProfile(profile); | 297 TabModel* tab_model = TabModelList::GetTabModelWithProfile(profile); |
| 299 if (!tab_model) | 298 if (!tab_model) |
| 300 return scoped_ptr<content::DevToolsTarget>(); | 299 return scoped_ptr<content::DevToolsTarget>(); |
| 301 WebContents* web_contents = tab_model->CreateTabForTesting(url); | 300 WebContents* web_contents = |
| 301 tab_model->CreateTabForTesting(GURL(content::kAboutBlankURL)); |
| 302 if (!web_contents) | 302 if (!web_contents) |
| 303 return scoped_ptr<content::DevToolsTarget>(); | 303 return scoped_ptr<content::DevToolsTarget>(); |
| 304 | 304 |
| 305 for (int i = 0; i < tab_model->GetTabCount(); ++i) { | 305 for (int i = 0; i < tab_model->GetTabCount(); ++i) { |
| 306 if (web_contents != tab_model->GetWebContentsAt(i)) | 306 if (web_contents != tab_model->GetWebContentsAt(i)) |
| 307 continue; | 307 continue; |
| 308 TabAndroid* tab = tab_model->GetTabAt(i); | 308 TabAndroid* tab = tab_model->GetTabAt(i); |
| 309 return scoped_ptr<content::DevToolsTarget>( | 309 return scoped_ptr<content::DevToolsTarget>( |
| 310 TabTarget::CreateForWebContents(tab->GetAndroidId(), web_contents)); | 310 TabTarget::CreateForWebContents(tab->GetAndroidId(), web_contents)); |
| 311 } | 311 } |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 jobject obj, | 463 jobject obj, |
| 464 jint server, | 464 jint server, |
| 465 jboolean enabled) { | 465 jboolean enabled) { |
| 466 DevToolsServer* devtools_server = reinterpret_cast<DevToolsServer*>(server); | 466 DevToolsServer* devtools_server = reinterpret_cast<DevToolsServer*>(server); |
| 467 if (enabled) { | 467 if (enabled) { |
| 468 devtools_server->Start(); | 468 devtools_server->Start(); |
| 469 } else { | 469 } else { |
| 470 devtools_server->Stop(); | 470 devtools_server->Stop(); |
| 471 } | 471 } |
| 472 } | 472 } |
| OLD | NEW |