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/files/file_enumerator.h" | 8 #include "base/files/file_enumerator.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "chrome/browser/drive/drive_service_interface.h" | 26 #include "chrome/browser/drive/drive_service_interface.h" |
27 #include "chrome/browser/drive/event_logger.h" | 27 #include "chrome/browser/drive/event_logger.h" |
28 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
29 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
30 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
31 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
32 #include "content/public/browser/web_ui.h" | 32 #include "content/public/browser/web_ui.h" |
33 #include "content/public/browser/web_ui_data_source.h" | 33 #include "content/public/browser/web_ui_data_source.h" |
34 #include "content/public/browser/web_ui_message_handler.h" | 34 #include "content/public/browser/web_ui_message_handler.h" |
35 #include "google_apis/drive/auth_service.h" | 35 #include "google_apis/drive/auth_service.h" |
| 36 #include "google_apis/drive/drive_api_error_codes.h" |
36 #include "google_apis/drive/drive_api_parser.h" | 37 #include "google_apis/drive/drive_api_parser.h" |
37 #include "google_apis/drive/gdata_errorcode.h" | |
38 #include "google_apis/drive/time_util.h" | 38 #include "google_apis/drive/time_util.h" |
39 #include "grit/browser_resources.h" | 39 #include "grit/browser_resources.h" |
40 | 40 |
41 using content::BrowserThread; | 41 using content::BrowserThread; |
42 | 42 |
43 namespace chromeos { | 43 namespace chromeos { |
44 | 44 |
45 namespace { | 45 namespace { |
46 | 46 |
47 // Gets metadata of all files and directories in |root_path| | 47 // Gets metadata of all files and directories in |root_path| |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 | 265 |
266 // Called as the iterator for DebugInfoCollector::IterateFileCache(). | 266 // Called as the iterator for DebugInfoCollector::IterateFileCache(). |
267 void UpdateCacheEntry(const std::string& local_id, | 267 void UpdateCacheEntry(const std::string& local_id, |
268 const drive::FileCacheEntry& cache_entry); | 268 const drive::FileCacheEntry& cache_entry); |
269 | 269 |
270 // Called when GetFreeDiskSpace() is complete. | 270 // Called when GetFreeDiskSpace() is complete. |
271 void OnGetFreeDiskSpace(base::DictionaryValue* local_storage_summary); | 271 void OnGetFreeDiskSpace(base::DictionaryValue* local_storage_summary); |
272 | 272 |
273 // Called when GetAboutResource() call to DriveService is complete. | 273 // Called when GetAboutResource() call to DriveService is complete. |
274 void OnGetAboutResource( | 274 void OnGetAboutResource( |
275 google_apis::GDataErrorCode status, | 275 google_apis::DriveApiErrorCode status, |
276 scoped_ptr<google_apis::AboutResource> about_resource); | 276 scoped_ptr<google_apis::AboutResource> about_resource); |
277 | 277 |
278 // Called when GetAppList() call to DriveService is complete. | 278 // Called when GetAppList() call to DriveService is complete. |
279 void OnGetAppList( | 279 void OnGetAppList( |
280 google_apis::GDataErrorCode status, | 280 google_apis::DriveApiErrorCode status, |
281 scoped_ptr<google_apis::AppList> app_list); | 281 scoped_ptr<google_apis::AppList> app_list); |
282 | 282 |
283 // Callback for DebugInfoCollector::GetMetadata for local update. | 283 // Callback for DebugInfoCollector::GetMetadata for local update. |
284 void OnGetFilesystemMetadataForLocal( | 284 void OnGetFilesystemMetadataForLocal( |
285 const drive::FileSystemMetadata& metadata); | 285 const drive::FileSystemMetadata& metadata); |
286 | 286 |
287 // Callback for DebugInfoCollector::GetMetadata for delta update. | 287 // Callback for DebugInfoCollector::GetMetadata for delta update. |
288 void OnGetFilesystemMetadataForDeltaUpdate( | 288 void OnGetFilesystemMetadataForDeltaUpdate( |
289 const drive::FileSystemMetadata& metadata); | 289 const drive::FileSystemMetadata& metadata); |
290 | 290 |
(...skipping 10 matching lines...) Expand all Loading... |
301 void ResetFinished(bool success); | 301 void ResetFinished(bool success); |
302 | 302 |
303 // The last event sent to the JavaScript side. | 303 // The last event sent to the JavaScript side. |
304 int last_sent_event_id_; | 304 int last_sent_event_id_; |
305 | 305 |
306 base::WeakPtrFactory<DriveInternalsWebUIHandler> weak_ptr_factory_; | 306 base::WeakPtrFactory<DriveInternalsWebUIHandler> weak_ptr_factory_; |
307 DISALLOW_COPY_AND_ASSIGN(DriveInternalsWebUIHandler); | 307 DISALLOW_COPY_AND_ASSIGN(DriveInternalsWebUIHandler); |
308 }; | 308 }; |
309 | 309 |
310 void DriveInternalsWebUIHandler::OnGetAboutResource( | 310 void DriveInternalsWebUIHandler::OnGetAboutResource( |
311 google_apis::GDataErrorCode status, | 311 google_apis::DriveApiErrorCode status, |
312 scoped_ptr<google_apis::AboutResource> parsed_about_resource) { | 312 scoped_ptr<google_apis::AboutResource> parsed_about_resource) { |
313 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 313 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
314 | 314 |
315 if (status != google_apis::HTTP_SUCCESS) { | 315 if (status != google_apis::HTTP_SUCCESS) { |
316 LOG(ERROR) << "Failed to get about resource"; | 316 LOG(ERROR) << "Failed to get about resource"; |
317 return; | 317 return; |
318 } | 318 } |
319 DCHECK(parsed_about_resource); | 319 DCHECK(parsed_about_resource); |
320 | 320 |
321 base::DictionaryValue about_resource; | 321 base::DictionaryValue about_resource; |
322 about_resource.SetDouble("account-quota-total", | 322 about_resource.SetDouble("account-quota-total", |
323 parsed_about_resource->quota_bytes_total()); | 323 parsed_about_resource->quota_bytes_total()); |
324 about_resource.SetDouble("account-quota-used", | 324 about_resource.SetDouble("account-quota-used", |
325 parsed_about_resource->quota_bytes_used()); | 325 parsed_about_resource->quota_bytes_used()); |
326 about_resource.SetDouble("account-largest-changestamp-remote", | 326 about_resource.SetDouble("account-largest-changestamp-remote", |
327 parsed_about_resource->largest_change_id()); | 327 parsed_about_resource->largest_change_id()); |
328 about_resource.SetString("root-resource-id", | 328 about_resource.SetString("root-resource-id", |
329 parsed_about_resource->root_folder_id()); | 329 parsed_about_resource->root_folder_id()); |
330 | 330 |
331 web_ui()->CallJavascriptFunction("updateAboutResource", about_resource); | 331 web_ui()->CallJavascriptFunction("updateAboutResource", about_resource); |
332 } | 332 } |
333 | 333 |
334 void DriveInternalsWebUIHandler::OnGetAppList( | 334 void DriveInternalsWebUIHandler::OnGetAppList( |
335 google_apis::GDataErrorCode status, | 335 google_apis::DriveApiErrorCode status, |
336 scoped_ptr<google_apis::AppList> parsed_app_list) { | 336 scoped_ptr<google_apis::AppList> parsed_app_list) { |
337 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 337 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
338 | 338 |
339 if (status != google_apis::HTTP_SUCCESS) { | 339 if (status != google_apis::HTTP_SUCCESS) { |
340 LOG(ERROR) << "Failed to get app list"; | 340 LOG(ERROR) << "Failed to get app list"; |
341 return; | 341 return; |
342 } | 342 } |
343 DCHECK(parsed_app_list); | 343 DCHECK(parsed_app_list); |
344 | 344 |
345 base::DictionaryValue app_list; | 345 base::DictionaryValue app_list; |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 content::WebUIDataSource::Create(chrome::kChromeUIDriveInternalsHost); | 893 content::WebUIDataSource::Create(chrome::kChromeUIDriveInternalsHost); |
894 source->AddResourcePath("drive_internals.css", IDR_DRIVE_INTERNALS_CSS); | 894 source->AddResourcePath("drive_internals.css", IDR_DRIVE_INTERNALS_CSS); |
895 source->AddResourcePath("drive_internals.js", IDR_DRIVE_INTERNALS_JS); | 895 source->AddResourcePath("drive_internals.js", IDR_DRIVE_INTERNALS_JS); |
896 source->SetDefaultResource(IDR_DRIVE_INTERNALS_HTML); | 896 source->SetDefaultResource(IDR_DRIVE_INTERNALS_HTML); |
897 | 897 |
898 Profile* profile = Profile::FromWebUI(web_ui); | 898 Profile* profile = Profile::FromWebUI(web_ui); |
899 content::WebUIDataSource::Add(profile, source); | 899 content::WebUIDataSource::Add(profile, source); |
900 } | 900 } |
901 | 901 |
902 } // namespace chromeos | 902 } // namespace chromeos |
OLD | NEW |