| 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/ui/webui/chromeos/drive_internals_ui.h" | 5 #include "chrome/browser/ui/webui/chromeos/drive_internals_ui.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/sys_info.h" | 13 #include "base/sys_info.h" |
| 14 #include "chrome/browser/chromeos/gdata/documents_service_interface.h" | 14 #include "chrome/browser/chromeos/gdata/drive_service_interface.h" |
| 15 #include "chrome/browser/chromeos/gdata/gdata.pb.h" | 15 #include "chrome/browser/chromeos/gdata/gdata.pb.h" |
| 16 #include "chrome/browser/chromeos/gdata/gdata_auth_service.h" | 16 #include "chrome/browser/chromeos/gdata/gdata_auth_service.h" |
| 17 #include "chrome/browser/chromeos/gdata/gdata_cache.h" | 17 #include "chrome/browser/chromeos/gdata/gdata_cache.h" |
| 18 #include "chrome/browser/chromeos/gdata/gdata_file_system_interface.h" | 18 #include "chrome/browser/chromeos/gdata/gdata_file_system_interface.h" |
| 19 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" | 19 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" |
| 20 #include "chrome/browser/chromeos/gdata/gdata_util.h" | 20 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" | 22 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" |
| 23 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
| 24 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 } | 215 } |
| 216 | 216 |
| 217 void DriveInternalsWebUIHandler::OnPageLoaded(const base::ListValue* args) { | 217 void DriveInternalsWebUIHandler::OnPageLoaded(const base::ListValue* args) { |
| 218 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 218 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 219 | 219 |
| 220 gdata::GDataSystemService* system_service = GetSystemService(); | 220 gdata::GDataSystemService* system_service = GetSystemService(); |
| 221 // |system_service| may be NULL in the guest/incognito mode. | 221 // |system_service| may be NULL in the guest/incognito mode. |
| 222 if (!system_service) | 222 if (!system_service) |
| 223 return; | 223 return; |
| 224 | 224 |
| 225 gdata::DocumentsServiceInterface* documents_service = | 225 gdata::DriveServiceInterface* drive_service = system_service->drive_service(); |
| 226 system_service->docs_service(); | 226 DCHECK(drive_service); |
| 227 DCHECK(documents_service); | |
| 228 | 227 |
| 229 // Update the auth status section. | 228 // Update the auth status section. |
| 230 base::DictionaryValue auth_status; | 229 base::DictionaryValue auth_status; |
| 231 auth_status.SetBoolean("has-refresh-token", | 230 auth_status.SetBoolean("has-refresh-token", |
| 232 documents_service->HasRefreshToken()); | 231 drive_service->HasRefreshToken()); |
| 233 auth_status.SetBoolean("has-access-token", | 232 auth_status.SetBoolean("has-access-token", |
| 234 documents_service->HasAccessToken()); | 233 drive_service->HasAccessToken()); |
| 235 web_ui()->CallJavascriptFunction("updateAuthStatus", auth_status); | 234 web_ui()->CallJavascriptFunction("updateAuthStatus", auth_status); |
| 236 | 235 |
| 237 // Start updating the GCache contents section. | 236 // Start updating the GCache contents section. |
| 238 Profile* profile = Profile::FromWebUI(web_ui()); | 237 Profile* profile = Profile::FromWebUI(web_ui()); |
| 239 const FilePath root_path = | 238 const FilePath root_path = |
| 240 gdata::GDataCache::GetCacheRootPath(profile); | 239 gdata::GDataCache::GetCacheRootPath(profile); |
| 241 base::ListValue* gcache_contents = new ListValue; | 240 base::ListValue* gcache_contents = new ListValue; |
| 242 base::DictionaryValue* gcache_summary = new DictionaryValue; | 241 base::DictionaryValue* gcache_summary = new DictionaryValue; |
| 243 BrowserThread::PostBlockingPoolTaskAndReply( | 242 BrowserThread::PostBlockingPoolTaskAndReply( |
| 244 FROM_HERE, | 243 FROM_HERE, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 270 base::ListValue* gcache_contents, | 269 base::ListValue* gcache_contents, |
| 271 base::DictionaryValue* gcache_summary) { | 270 base::DictionaryValue* gcache_summary) { |
| 272 DCHECK(gcache_contents); | 271 DCHECK(gcache_contents); |
| 273 DCHECK(gcache_summary); | 272 DCHECK(gcache_summary); |
| 274 web_ui()->CallJavascriptFunction("updateGCacheContents", | 273 web_ui()->CallJavascriptFunction("updateGCacheContents", |
| 275 *gcache_contents, | 274 *gcache_contents, |
| 276 *gcache_summary); | 275 *gcache_summary); |
| 277 | 276 |
| 278 // Start updating the file system tree section, if we have access token. | 277 // Start updating the file system tree section, if we have access token. |
| 279 gdata::GDataSystemService* system_service = GetSystemService(); | 278 gdata::GDataSystemService* system_service = GetSystemService(); |
| 280 if (!system_service->docs_service()->HasAccessToken()) | 279 if (!system_service->drive_service()->HasAccessToken()) |
| 281 return; | 280 return; |
| 282 | 281 |
| 283 // Start rendering the file system tree as text. | 282 // Start rendering the file system tree as text. |
| 284 const FilePath root_path = FilePath(gdata::kGDataRootDirectory); | 283 const FilePath root_path = FilePath(gdata::kGDataRootDirectory); |
| 285 ++num_pending_reads_; | 284 ++num_pending_reads_; |
| 286 system_service->file_system()->ReadDirectoryByPath( | 285 system_service->file_system()->ReadDirectoryByPath( |
| 287 root_path, | 286 root_path, |
| 288 base::Bind(&DriveInternalsWebUIHandler::OnReadDirectoryByPath, | 287 base::Bind(&DriveInternalsWebUIHandler::OnReadDirectoryByPath, |
| 289 weak_ptr_factory_.GetWeakPtr(), | 288 weak_ptr_factory_.GetWeakPtr(), |
| 290 root_path)); | 289 root_path)); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 new ChromeWebUIDataSource(chrome::kChromeUIDriveInternalsHost); | 386 new ChromeWebUIDataSource(chrome::kChromeUIDriveInternalsHost); |
| 388 source->add_resource_path("drive_internals.css", IDR_DRIVE_INTERNALS_CSS); | 387 source->add_resource_path("drive_internals.css", IDR_DRIVE_INTERNALS_CSS); |
| 389 source->add_resource_path("drive_internals.js", IDR_DRIVE_INTERNALS_JS); | 388 source->add_resource_path("drive_internals.js", IDR_DRIVE_INTERNALS_JS); |
| 390 source->set_default_resource(IDR_DRIVE_INTERNALS_HTML); | 389 source->set_default_resource(IDR_DRIVE_INTERNALS_HTML); |
| 391 | 390 |
| 392 Profile* profile = Profile::FromWebUI(web_ui); | 391 Profile* profile = Profile::FromWebUI(web_ui); |
| 393 ChromeURLDataManager::AddDataSource(profile, source); | 392 ChromeURLDataManager::AddDataSource(profile, source); |
| 394 } | 393 } |
| 395 | 394 |
| 396 } // namespace chromeos | 395 } // namespace chromeos |
| OLD | NEW |