Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(681)

Side by Side Diff: chrome/browser/ui/webui/filebrowse_ui.cc

Issue 6674043: Rewritten MountLibrary to work with non-blocking mount API calls in libcros.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/filebrowse_ui.h" 5 #include "chrome/browser/ui/webui/filebrowse_ui.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // DirectoryLister::DirectoryListerDelegate methods: 115 // DirectoryLister::DirectoryListerDelegate methods:
116 virtual void OnListFile( 116 virtual void OnListFile(
117 const net::DirectoryLister::DirectoryListerData& data); 117 const net::DirectoryLister::DirectoryListerData& data);
118 virtual void OnListDone(int error); 118 virtual void OnListDone(int error);
119 119
120 // WebUIMessageHandler implementation. 120 // WebUIMessageHandler implementation.
121 virtual WebUIMessageHandler* Attach(WebUI* web_ui); 121 virtual WebUIMessageHandler* Attach(WebUI* web_ui);
122 virtual void RegisterMessages(); 122 virtual void RegisterMessages();
123 123
124 #if defined(OS_CHROMEOS) 124 #if defined(OS_CHROMEOS)
125 void MountChanged(chromeos::MountLibrary* obj, 125 // chromeos::MountLibrary::Observer interface
126 chromeos::MountEventType evt, 126 virtual void DiskChanged(chromeos::MountLibraryEventType event,
127 const std::string& path); 127 const chromeos::MountLibrary::Disk* disk);
128 virtual void DeviceChanged(chromeos::MountLibraryEventType event,
129 const std::string& device_path);
128 #endif 130 #endif
129 131
130 // DownloadItem::Observer interface 132 // DownloadItem::Observer interface
131 virtual void OnDownloadUpdated(DownloadItem* download); 133 virtual void OnDownloadUpdated(DownloadItem* download);
132 virtual void OnDownloadFileCompleted(DownloadItem* download); 134 virtual void OnDownloadFileCompleted(DownloadItem* download);
133 virtual void OnDownloadOpened(DownloadItem* download) { } 135 virtual void OnDownloadOpened(DownloadItem* download) { }
134 136
135 // DownloadManager::Observer interface 137 // DownloadManager::Observer interface
136 virtual void ModelChanged(); 138 virtual void ModelChanged();
137 139
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 std::string picture_url = kPicasawebBaseUrl; 548 std::string picture_url = kPicasawebBaseUrl;
547 picture_url += username; 549 picture_url += username;
548 picture_url += kPicasawebDropBox; 550 picture_url += kPicasawebDropBox;
549 info_value.SetString("url", picture_url); 551 info_value.SetString("url", picture_url);
550 info_value.SetInteger("status_code", upload_response_code_); 552 info_value.SetInteger("status_code", upload_response_code_);
551 web_ui_->CallJavascriptFunction("uploadComplete", info_value); 553 web_ui_->CallJavascriptFunction("uploadComplete", info_value);
552 #endif 554 #endif
553 } 555 }
554 556
555 #if defined(OS_CHROMEOS) 557 #if defined(OS_CHROMEOS)
556 void FilebrowseHandler::MountChanged(chromeos::MountLibrary* obj, 558 void FilebrowseHandler::DiskChanged(chromeos::MountLibraryEventType event,
557 chromeos::MountEventType evt, 559 const chromeos::MountLibrary::Disk* disk) {
558 const std::string& path) { 560 if (event == chromeos::MOUNT_DISK_REMOVED ||
559 if (evt == chromeos::DISK_REMOVED || 561 event == chromeos::MOUNT_DISK_CHANGED) {
560 evt == chromeos::DISK_CHANGED) {
561 web_ui_->CallJavascriptFunction("rootsChanged"); 562 web_ui_->CallJavascriptFunction("rootsChanged");
562 } 563 }
563 } 564 }
565
566 void FilebrowseHandler::DeviceChanged(chromeos::MountLibraryEventType event,
567 const std::string& device_path) {
568 }
564 #endif 569 #endif
565 570
566 void FilebrowseHandler::OnURLFetchComplete(const URLFetcher* source, 571 void FilebrowseHandler::OnURLFetchComplete(const URLFetcher* source,
567 const GURL& url, 572 const GURL& url,
568 const net::URLRequestStatus& status, 573 const net::URLRequestStatus& status,
569 int response_code, 574 int response_code,
570 const ResponseCookies& cookies, 575 const ResponseCookies& cookies,
571 const std::string& data) { 576 const std::string& data) {
572 upload_response_code_ = response_code; 577 upload_response_code_ = response_code;
573 VLOG(1) << "Response code: " << response_code; 578 VLOG(1) << "Response code: " << response_code;
574 VLOG(1) << "Request url: " << url; 579 VLOG(1) << "Request url: " << url;
575 if (StartsWithASCII(url.spec(), kPicasawebUserPrefix, true)) { 580 if (StartsWithASCII(url.spec(), kPicasawebUserPrefix, true)) {
576 BrowserThread::PostTask( 581 BrowserThread::PostTask(
577 BrowserThread::UI, FROM_HERE, 582 BrowserThread::UI, FROM_HERE,
578 NewRunnableMethod(current_task_, &TaskProxy::FireUploadCompleteProxy)); 583 NewRunnableMethod(current_task_, &TaskProxy::FireUploadCompleteProxy));
579 } 584 }
580 fetch_.reset(); 585 fetch_.reset();
581 } 586 }
582 587
583 void FilebrowseHandler::HandleGetRoots(const ListValue* args) { 588 void FilebrowseHandler::HandleGetRoots(const ListValue* args) {
584 ListValue results_value; 589 ListValue results_value;
585 DictionaryValue info_value; 590 DictionaryValue info_value;
586 // TODO(dhg): add other entries, make this more general 591 // TODO(dhg): add other entries, make this more general
587 #if defined(OS_CHROMEOS) 592 #if defined(OS_CHROMEOS)
588 chromeos::MountLibrary* lib = 593 chromeos::MountLibrary* lib = chromeos::CrosLibrary::Get()->GetMountLibrary();
589 chromeos::CrosLibrary::Get()->GetMountLibrary(); 594 for (chromeos::MountLibrary::DiskMap::const_iterator iter =
590 const chromeos::MountLibrary::DiskVector& disks = lib->disks(); 595 lib->disks().begin();
591 596 iter != lib->disks().end();
592 for (size_t i = 0; i < disks.size(); ++i) { 597 ++iter) {
593 if (!disks[i].mount_path.empty()) { 598 const chromeos::MountLibrary::Disk* disk = iter->second;
599 if (!disk->mount_path().empty()) {
594 DictionaryValue* page_value = new DictionaryValue(); 600 DictionaryValue* page_value = new DictionaryValue();
595 page_value->SetString(kPropertyPath, disks[i].mount_path); 601 page_value->SetString(kPropertyPath, disk->mount_path());
596 FilePath currentpath(disks[i].mount_path); 602 FilePath currentpath(disk->mount_path());
597 std::string filename; 603 std::string filename;
598 filename = currentpath.BaseName().value(); 604 filename = currentpath.BaseName().value();
599 page_value->SetString(kPropertyTitle, filename); 605 page_value->SetString(kPropertyTitle, filename);
600 page_value->SetBoolean(kPropertyDirectory, true); 606 page_value->SetBoolean(kPropertyDirectory, true);
601 results_value.Append(page_value); 607 results_value.Append(page_value);
602 } 608 }
603 } 609 }
604 #else 610 #else
605 DictionaryValue* page_value = new DictionaryValue(); 611 DictionaryValue* page_value = new DictionaryValue();
606 page_value->SetString(kPropertyPath, "/media"); 612 page_value->SetString(kPropertyPath, "/media");
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 } 1265 }
1260 } 1266 }
1261 1267
1262 return NULL; 1268 return NULL;
1263 } 1269 }
1264 1270
1265 const int FileBrowseUI::kPopupWidth = 250; 1271 const int FileBrowseUI::kPopupWidth = 250;
1266 const int FileBrowseUI::kPopupHeight = 300; 1272 const int FileBrowseUI::kPopupHeight = 300;
1267 const int FileBrowseUI::kSmallPopupWidth = 250; 1273 const int FileBrowseUI::kSmallPopupWidth = 250;
1268 const int FileBrowseUI::kSmallPopupHeight = 50; 1274 const int FileBrowseUI::kSmallPopupHeight = 50;
OLDNEW
« chrome/browser/sessions/session_restore.cc ('K') | « chrome/browser/ui/browser_init.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698