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/chromeos/extensions/file_browser_private_api.h" | 5 #include "chrome/browser/chromeos/extensions/file_browser_private_api.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 const std::string& extension_id, | 583 const std::string& extension_id, |
584 const std::string& action_id, | 584 const std::string& action_id, |
585 ExecuteTasksFileBrowserFunction* function) | 585 ExecuteTasksFileBrowserFunction* function) |
586 : FileTaskExecutor(profile, source_url, extension_id, action_id), | 586 : FileTaskExecutor(profile, source_url, extension_id, action_id), |
587 function_(function) | 587 function_(function) |
588 {} | 588 {} |
589 | 589 |
590 protected: | 590 protected: |
591 // FileTaskExecutor overrides. | 591 // FileTaskExecutor overrides. |
592 virtual Browser* browser() { return function_->GetCurrentBrowser(); } | 592 virtual Browser* browser() { return function_->GetCurrentBrowser(); } |
593 virtual void Done(bool success) { function_->SendResponse(success); } | 593 virtual void Done(bool success) { function_->OnTaskExecuted(success); } |
594 | 594 |
595 private: | 595 private: |
596 scoped_refptr<ExecuteTasksFileBrowserFunction> function_; | 596 scoped_refptr<ExecuteTasksFileBrowserFunction> function_; |
597 }; | 597 }; |
598 | 598 |
599 ExecuteTasksFileBrowserFunction::ExecuteTasksFileBrowserFunction() {} | 599 ExecuteTasksFileBrowserFunction::ExecuteTasksFileBrowserFunction() {} |
600 | 600 |
601 ExecuteTasksFileBrowserFunction::~ExecuteTasksFileBrowserFunction() {} | 601 ExecuteTasksFileBrowserFunction::~ExecuteTasksFileBrowserFunction() {} |
602 | 602 |
603 bool ExecuteTasksFileBrowserFunction::RunImpl() { | 603 bool ExecuteTasksFileBrowserFunction::RunImpl() { |
(...skipping 24 matching lines...) Expand all Loading... |
628 std::vector<GURL> file_urls; | 628 std::vector<GURL> file_urls; |
629 for (size_t i = 0; i < files_list->GetSize(); i++) { | 629 for (size_t i = 0; i < files_list->GetSize(); i++) { |
630 std::string origin_file_url; | 630 std::string origin_file_url; |
631 if (!files_list->GetString(i, &origin_file_url)) { | 631 if (!files_list->GetString(i, &origin_file_url)) { |
632 error_ = kInvalidFileUrl; | 632 error_ = kInvalidFileUrl; |
633 return false; | 633 return false; |
634 } | 634 } |
635 file_urls.push_back(GURL(origin_file_url)); | 635 file_urls.push_back(GURL(origin_file_url)); |
636 } | 636 } |
637 | 637 |
638 scoped_refptr<Executor> executor = | 638 executor_ = new Executor(profile(), source_url(), extension_id, action_id, |
639 new Executor(profile(), source_url(), extension_id, action_id, this); | 639 this); |
640 if (!executor->Execute(file_urls)) | 640 |
| 641 if (!executor_->Execute(file_urls)) { |
| 642 // Executor has our reference, so we have to unref it if we don't want to |
| 643 // leak. |
| 644 executor_ = NULL; |
641 return false; | 645 return false; |
| 646 } |
642 | 647 |
643 result_.reset(new base::FundamentalValue(true)); | 648 result_.reset(new base::FundamentalValue(true)); |
644 return true; | 649 return true; |
645 } | 650 } |
646 | 651 |
| 652 void ExecuteTasksFileBrowserFunction::OnTaskExecuted(bool success) { |
| 653 SendResponse(success); |
| 654 // Executor has our reference, so we have to unref it if we don't want to |
| 655 // leak. |
| 656 executor_ = NULL; |
| 657 } |
| 658 |
647 FileBrowserFunction::FileBrowserFunction() { | 659 FileBrowserFunction::FileBrowserFunction() { |
648 } | 660 } |
649 | 661 |
650 FileBrowserFunction::~FileBrowserFunction() { | 662 FileBrowserFunction::~FileBrowserFunction() { |
651 } | 663 } |
652 | 664 |
653 int32 FileBrowserFunction::GetTabId() const { | 665 int32 FileBrowserFunction::GetTabId() const { |
654 if (!dispatcher()) { | 666 if (!dispatcher()) { |
655 LOG(WARNING) << "No dispatcher"; | 667 LOG(WARNING) << "No dispatcher"; |
656 return 0; | 668 return 0; |
(...skipping 1315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1972 if (value->GetBoolean("cellularDisabled", &tmp)) { | 1984 if (value->GetBoolean("cellularDisabled", &tmp)) { |
1973 service->SetBoolean(prefs::kDisableGDataOverCellular, tmp); | 1985 service->SetBoolean(prefs::kDisableGDataOverCellular, tmp); |
1974 } | 1986 } |
1975 | 1987 |
1976 if (value->GetBoolean("hostedFilesDisabled", &tmp)) { | 1988 if (value->GetBoolean("hostedFilesDisabled", &tmp)) { |
1977 service->SetBoolean(prefs::kDisableGDataHostedFiles, tmp); | 1989 service->SetBoolean(prefs::kDisableGDataHostedFiles, tmp); |
1978 } | 1990 } |
1979 | 1991 |
1980 return true; | 1992 return true; |
1981 } | 1993 } |
OLD | NEW |