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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 base::Bind(&DevToolsServerDelegate::PopulatePageThumbnails)); | 98 base::Bind(&DevToolsServerDelegate::PopulatePageThumbnails)); |
99 return ResourceBundle::GetSharedInstance().GetRawDataResource( | 99 return ResourceBundle::GetSharedInstance().GetRawDataResource( |
100 IDR_DEVTOOLS_DISCOVERY_PAGE_HTML).as_string(); | 100 IDR_DEVTOOLS_DISCOVERY_PAGE_HTML).as_string(); |
101 } | 101 } |
102 | 102 |
103 std::string GetFrontendResource(const std::string& path) override { | 103 std::string GetFrontendResource(const std::string& path) override { |
104 return std::string(); | 104 return std::string(); |
105 } | 105 } |
106 | 106 |
107 std::string GetPageThumbnailData(const GURL& url) override { | 107 std::string GetPageThumbnailData(const GURL& url) override { |
108 Profile* profile = | 108 Profile* profile = g_browser_process->profile_manager() |
109 ProfileManager::GetLastUsedProfile()->GetOriginalProfile(); | 109 ->GetLastUsedProfile() |
| 110 ->GetOriginalProfile(); |
110 scoped_refptr<history::TopSites> top_sites = | 111 scoped_refptr<history::TopSites> top_sites = |
111 TopSitesFactory::GetForProfile(profile); | 112 TopSitesFactory::GetForProfile(profile); |
112 if (top_sites) { | 113 if (top_sites) { |
113 scoped_refptr<base::RefCountedMemory> data; | 114 scoped_refptr<base::RefCountedMemory> data; |
114 if (top_sites->GetPageThumbnail(url, false, &data)) | 115 if (top_sites->GetPageThumbnail(url, false, &data)) |
115 return std::string(data->front_as<char>(), data->size()); | 116 return std::string(data->front_as<char>(), data->size()); |
116 } | 117 } |
117 return std::string(); | 118 return std::string(); |
118 } | 119 } |
119 | 120 |
120 private: | 121 private: |
121 static void PopulatePageThumbnails() { | 122 static void PopulatePageThumbnails() { |
122 Profile* profile = | 123 Profile* profile = g_browser_process->profile_manager() |
123 ProfileManager::GetLastUsedProfile()->GetOriginalProfile(); | 124 ->GetLastUsedProfile() |
| 125 ->GetOriginalProfile(); |
124 scoped_refptr<history::TopSites> top_sites = | 126 scoped_refptr<history::TopSites> top_sites = |
125 TopSitesFactory::GetForProfile(profile); | 127 TopSitesFactory::GetForProfile(profile); |
126 if (top_sites) | 128 if (top_sites) |
127 top_sites->SyncWithHistory(); | 129 top_sites->SyncWithHistory(); |
128 } | 130 } |
129 | 131 |
130 DISALLOW_COPY_AND_ASSIGN(DevToolsServerDelegate); | 132 DISALLOW_COPY_AND_ASSIGN(DevToolsServerDelegate); |
131 }; | 133 }; |
132 | 134 |
133 // Factory for UnixDomainServerSocket. It tries a fallback socket when | 135 // Factory for UnixDomainServerSocket. It tries a fallback socket when |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 jlong server, | 257 jlong server, |
256 jboolean enabled, | 258 jboolean enabled, |
257 jboolean allow_debug_permission) { | 259 jboolean allow_debug_permission) { |
258 DevToolsServer* devtools_server = reinterpret_cast<DevToolsServer*>(server); | 260 DevToolsServer* devtools_server = reinterpret_cast<DevToolsServer*>(server); |
259 if (enabled) { | 261 if (enabled) { |
260 devtools_server->Start(allow_debug_permission); | 262 devtools_server->Start(allow_debug_permission); |
261 } else { | 263 } else { |
262 devtools_server->Stop(); | 264 devtools_server->Stop(); |
263 } | 265 } |
264 } | 266 } |
OLD | NEW |