Chromium Code Reviews| 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/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.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/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
|
Haruki Sato
2012/10/15 07:10:29
If we don't use Int64ToString in this file,
can we
satorux1
2012/10/16 05:02:56
Done. good catch!
| |
| 14 #include "base/stringprintf.h" | 14 #include "base/stringprintf.h" |
| 15 #include "base/sys_info.h" | 15 #include "base/sys_info.h" |
| 16 #include "chrome/browser/chromeos/drive/drive.pb.h" | 16 #include "chrome/browser/chromeos/drive/drive.pb.h" |
| 17 #include "chrome/browser/chromeos/drive/drive_cache.h" | 17 #include "chrome/browser/chromeos/drive/drive_cache.h" |
| 18 #include "chrome/browser/chromeos/drive/drive_file_system_interface.h" | 18 #include "chrome/browser/chromeos/drive/drive_file_system_interface.h" |
| 19 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h" | |
| 19 #include "chrome/browser/chromeos/drive/drive_service_interface.h" | 20 #include "chrome/browser/chromeos/drive/drive_service_interface.h" |
| 20 #include "chrome/browser/chromeos/drive/drive_system_service.h" | 21 #include "chrome/browser/chromeos/drive/drive_system_service.h" |
| 21 #include "chrome/browser/google_apis/auth_service.h" | 22 #include "chrome/browser/google_apis/auth_service.h" |
| 22 #include "chrome/browser/google_apis/drive_api_parser.h" | 23 #include "chrome/browser/google_apis/drive_api_parser.h" |
| 23 #include "chrome/browser/google_apis/gdata_errorcode.h" | 24 #include "chrome/browser/google_apis/gdata_errorcode.h" |
| 24 #include "chrome/browser/google_apis/gdata_util.h" | 25 #include "chrome/browser/google_apis/gdata_util.h" |
| 25 #include "chrome/browser/google_apis/gdata_wapi_parser.h" | 26 #include "chrome/browser/google_apis/gdata_wapi_parser.h" |
| 26 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
| 27 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" | 28 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" |
| 28 #include "chrome/common/url_constants.h" | 29 #include "chrome/common/url_constants.h" |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 230 base::DictionaryValue account_metadata; | 231 base::DictionaryValue account_metadata; |
| 231 | 232 |
| 232 if (gdata::util::IsDriveV2ApiEnabled()) { | 233 if (gdata::util::IsDriveV2ApiEnabled()) { |
| 233 scoped_ptr<gdata::AboutResource> about_resource; | 234 scoped_ptr<gdata::AboutResource> about_resource; |
| 234 about_resource = gdata::AboutResource::CreateFrom(*data); | 235 about_resource = gdata::AboutResource::CreateFrom(*data); |
| 235 | 236 |
| 236 account_metadata.SetDouble("account-quota-total", | 237 account_metadata.SetDouble("account-quota-total", |
| 237 about_resource->quota_bytes_total()); | 238 about_resource->quota_bytes_total()); |
| 238 account_metadata.SetDouble("account-quota-used", | 239 account_metadata.SetDouble("account-quota-used", |
| 239 about_resource->quota_bytes_used()); | 240 about_resource->quota_bytes_used()); |
| 240 account_metadata.SetString( | 241 account_metadata.SetDouble("account-largest-changestamp-remote", |
|
Haruki Sato
2012/10/15 07:10:29
I personally like string here as they are consider
satorux1
2012/10/16 05:02:56
These are not IDs. These are monotonically increas
| |
| 241 "account-largest-changestamp", | 242 about_resource->largest_change_id()); |
| 242 base::Int64ToString(about_resource->largest_change_id())); | |
| 243 | 243 |
| 244 // TODO(haruki): Fill installed Drive apps for Drive API. | 244 // TODO(haruki): Fill installed Drive apps for Drive API. |
| 245 // http://crbug.com/154241 | 245 // http://crbug.com/154241 |
| 246 return; | 246 return; |
| 247 } else { | 247 } else { |
| 248 scoped_ptr<gdata::AccountMetadataFeed> feed; | 248 scoped_ptr<gdata::AccountMetadataFeed> feed; |
| 249 feed = gdata::AccountMetadataFeed::CreateFrom(*data); | 249 feed = gdata::AccountMetadataFeed::CreateFrom(*data); |
| 250 | 250 |
| 251 account_metadata.SetDouble("account-quota-total", | 251 account_metadata.SetDouble("account-quota-total", |
| 252 feed->quota_bytes_total()); | 252 feed->quota_bytes_total()); |
| 253 account_metadata.SetDouble("account-quota-used", feed->quota_bytes_used()); | 253 account_metadata.SetDouble("account-quota-used", feed->quota_bytes_used()); |
| 254 account_metadata.SetString( | 254 account_metadata.SetDouble("account-largest-changestamp-remote", |
| 255 "account-largest-changestamp", | 255 feed->largest_changestamp()); |
| 256 base::Int64ToString(feed->largest_changestamp())); | |
| 257 | 256 |
| 258 base::ListValue* installed_apps = new base::ListValue(); | 257 base::ListValue* installed_apps = new base::ListValue(); |
| 259 for (size_t i = 0; i < feed->installed_apps().size(); ++i) { | 258 for (size_t i = 0; i < feed->installed_apps().size(); ++i) { |
| 260 const gdata::InstalledApp* app = feed->installed_apps()[i]; | 259 const gdata::InstalledApp* app = feed->installed_apps()[i]; |
| 261 base::DictionaryValue* app_data = new base::DictionaryValue(); | 260 base::DictionaryValue* app_data = new base::DictionaryValue(); |
| 262 app_data->SetString("app_name", app->app_name()); | 261 app_data->SetString("app_name", app->app_name()); |
| 263 app_data->SetString("app_id", app->app_id()); | 262 app_data->SetString("app_id", app->app_id()); |
| 264 app_data->SetString("object_type", app->object_type()); | 263 app_data->SetString("object_type", app->object_type()); |
| 265 app_data->SetBoolean("supports_create", app->supports_create()); | 264 app_data->SetBoolean("supports_create", app->supports_create()); |
| 266 | 265 |
| 267 installed_apps->Append(app_data); | 266 installed_apps->Append(app_data); |
| 268 } | 267 } |
| 269 account_metadata.Set("installed-apps", installed_apps); | 268 account_metadata.Set("installed-apps", installed_apps); |
| 270 } | 269 } |
| 271 | 270 |
| 271 // Add the local largest chargestamp. | |
| 272 const drive::DriveResourceMetadata* resource_metadata = | |
| 273 GetSystemService()->file_system()->GetResourceMetadata(); | |
| 274 const int64 largest_changestamp = resource_metadata->largest_changestamp(); | |
| 275 account_metadata.SetDouble("account-largest-changestamp-local", | |
| 276 largest_changestamp); | |
| 277 | |
| 272 web_ui()->CallJavascriptFunction("updateAccountMetadata", account_metadata); | 278 web_ui()->CallJavascriptFunction("updateAccountMetadata", account_metadata); |
| 273 } | 279 } |
| 274 | 280 |
| 275 void DriveInternalsWebUIHandler::RegisterMessages() { | 281 void DriveInternalsWebUIHandler::RegisterMessages() { |
| 276 web_ui()->RegisterMessageCallback( | 282 web_ui()->RegisterMessageCallback( |
| 277 "pageLoaded", | 283 "pageLoaded", |
| 278 base::Bind(&DriveInternalsWebUIHandler::OnPageLoaded, | 284 base::Bind(&DriveInternalsWebUIHandler::OnPageLoaded, |
| 279 weak_ptr_factory_.GetWeakPtr())); | 285 weak_ptr_factory_.GetWeakPtr())); |
| 280 web_ui()->RegisterMessageCallback( | 286 web_ui()->RegisterMessageCallback( |
| 281 "periodicUpdate", | 287 "periodicUpdate", |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 508 new ChromeWebUIDataSource(chrome::kChromeUIDriveInternalsHost); | 514 new ChromeWebUIDataSource(chrome::kChromeUIDriveInternalsHost); |
| 509 source->add_resource_path("drive_internals.css", IDR_DRIVE_INTERNALS_CSS); | 515 source->add_resource_path("drive_internals.css", IDR_DRIVE_INTERNALS_CSS); |
| 510 source->add_resource_path("drive_internals.js", IDR_DRIVE_INTERNALS_JS); | 516 source->add_resource_path("drive_internals.js", IDR_DRIVE_INTERNALS_JS); |
| 511 source->set_default_resource(IDR_DRIVE_INTERNALS_HTML); | 517 source->set_default_resource(IDR_DRIVE_INTERNALS_HTML); |
| 512 | 518 |
| 513 Profile* profile = Profile::FromWebUI(web_ui); | 519 Profile* profile = Profile::FromWebUI(web_ui); |
| 514 ChromeURLDataManager::AddDataSource(profile, source); | 520 ChromeURLDataManager::AddDataSource(profile, source); |
| 515 } | 521 } |
| 516 | 522 |
| 517 } // namespace chromeos | 523 } // namespace chromeos |
| OLD | NEW |