OLD | NEW |
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/downloads_dom_handler.h" | 5 #include "chrome/browser/ui/webui/downloads_dom_handler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 // If this is an incognito downloader, clear All should clear main download | 350 // If this is an incognito downloader, clear All should clear main download |
351 // manager as well. | 351 // manager as well. |
352 if (profile->GetOriginalProfile() != profile) | 352 if (profile->GetOriginalProfile() != profile) |
353 DownloadServiceFactory::GetForProfile( | 353 DownloadServiceFactory::GetForProfile( |
354 profile->GetOriginalProfile())-> | 354 profile->GetOriginalProfile())-> |
355 GetDownloadManager()->RemoveAllDownloads(); | 355 GetDownloadManager()->RemoveAllDownloads(); |
356 } | 356 } |
357 | 357 |
358 void DownloadsDOMHandler::HandleOpenDownloadsFolder(const ListValue* args) { | 358 void DownloadsDOMHandler::HandleOpenDownloadsFolder(const ListValue* args) { |
359 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_OPEN_FOLDER); | 359 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_OPEN_FOLDER); |
360 FilePath path = DownloadPrefs::FromDownloadManager(download_manager_)-> | 360 platform_util::OpenItem( |
361 download_path(); | 361 DownloadPrefs::FromDownloadManager(download_manager_)->download_path()); |
362 | |
363 #if defined(OS_MACOSX) | |
364 // Must be called from the UI thread on Mac. | |
365 platform_util::OpenItem(path); | |
366 #elif defined(OS_CHROMEOS) | |
367 FileManagerUtil::ShowFullTabUrl( | |
368 Profile::FromBrowserContext(download_manager_->browser_context()), | |
369 path); | |
370 #else | |
371 BrowserThread::PostTask( | |
372 BrowserThread::FILE, FROM_HERE, | |
373 base::Bind(&platform_util::OpenItem, path)); | |
374 #endif | |
375 } | 362 } |
376 | 363 |
377 // DownloadsDOMHandler, private: ---------------------------------------------- | 364 // DownloadsDOMHandler, private: ---------------------------------------------- |
378 | 365 |
379 void DownloadsDOMHandler::SendCurrentDownloads() { | 366 void DownloadsDOMHandler::SendCurrentDownloads() { |
380 ListValue results_value; | 367 ListValue results_value; |
381 for (OrderedDownloads::iterator it = download_items_.begin(); | 368 for (OrderedDownloads::iterator it = download_items_.begin(); |
382 it != download_items_.end(); ++it) { | 369 it != download_items_.end(); ++it) { |
383 int index = static_cast<int>(it - download_items_.begin()); | 370 int index = static_cast<int>(it - download_items_.begin()); |
384 if (index > kMaxDownloads) | 371 if (index > kMaxDownloads) |
(...skipping 28 matching lines...) Expand all Loading... |
413 return NULL; | 400 return NULL; |
414 } | 401 } |
415 | 402 |
416 DownloadItem* DownloadsDOMHandler::GetDownloadByValue(const ListValue* args) { | 403 DownloadItem* DownloadsDOMHandler::GetDownloadByValue(const ListValue* args) { |
417 int id; | 404 int id; |
418 if (ExtractIntegerValue(args, &id)) { | 405 if (ExtractIntegerValue(args, &id)) { |
419 return GetDownloadById(id); | 406 return GetDownloadById(id); |
420 } | 407 } |
421 return NULL; | 408 return NULL; |
422 } | 409 } |
OLD | NEW |