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

Side by Side Diff: chrome/browser/chromeos/extensions/file_browser_private_api.cc

Issue 10067021: Postpone setting up file handler's file permissions if handler is running lazy background page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 8 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) 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 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 task->SetString("iconUrl", icon.spec()); 569 task->SetString("iconUrl", icon.spec());
570 result_list->Append(task); 570 result_list->Append(task);
571 } 571 }
572 572
573 // TODO(zelidrag, serya): Add intent content tasks to result_list once we 573 // TODO(zelidrag, serya): Add intent content tasks to result_list once we
574 // implement that API. 574 // implement that API.
575 SendResponse(true); 575 SendResponse(true);
576 return true; 576 return true;
577 } 577 }
578 578
579 class ExecuteTasksFileBrowserFunction::Executor: public FileTaskExecutor { 579 class ExecuteTasksFileBrowserFunction::Executor : public FileTaskExecutor {
580 public: 580 public:
581 Executor(Profile* profile, 581 Executor(Profile* profile,
582 const GURL& source_url, 582 const GURL& source_url,
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
590 virtual ~Executor() OVERRIDE {
591 if (function_)
592 function_->OnTaskExecuted(false);
593 }
589 594
590 protected: 595 protected:
591 // FileTaskExecutor overrides. 596 // FileTaskExecutor overrides.
592 virtual Browser* browser() { return function_->GetCurrentBrowser(); } 597 virtual Browser* browser() { return function_->GetCurrentBrowser(); }
593 virtual void Done(bool success) { function_->SendResponse(success); } 598 virtual void Done(bool success) {
599 function_->OnTaskExecuted(success);
600 // Let's make sure |function_| gets notified only once.
601 function_ = NULL;
602 }
594 603
595 private: 604 private:
596 scoped_refptr<ExecuteTasksFileBrowserFunction> function_; 605 scoped_refptr<ExecuteTasksFileBrowserFunction> function_;
597 }; 606 };
598 607
599 ExecuteTasksFileBrowserFunction::ExecuteTasksFileBrowserFunction() {} 608 ExecuteTasksFileBrowserFunction::ExecuteTasksFileBrowserFunction() {}
600 609
601 ExecuteTasksFileBrowserFunction::~ExecuteTasksFileBrowserFunction() {} 610 ExecuteTasksFileBrowserFunction::~ExecuteTasksFileBrowserFunction() {}
602 611
603 bool ExecuteTasksFileBrowserFunction::RunImpl() { 612 bool ExecuteTasksFileBrowserFunction::RunImpl() {
(...skipping 26 matching lines...) Expand all
630 std::string origin_file_url; 639 std::string origin_file_url;
631 if (!files_list->GetString(i, &origin_file_url)) { 640 if (!files_list->GetString(i, &origin_file_url)) {
632 error_ = kInvalidFileUrl; 641 error_ = kInvalidFileUrl;
633 return false; 642 return false;
634 } 643 }
635 file_urls.push_back(GURL(origin_file_url)); 644 file_urls.push_back(GURL(origin_file_url));
636 } 645 }
637 646
638 scoped_refptr<Executor> executor = 647 scoped_refptr<Executor> executor =
639 new Executor(profile(), source_url(), extension_id, action_id, this); 648 new Executor(profile(), source_url(), extension_id, action_id, this);
649
640 if (!executor->Execute(file_urls)) 650 if (!executor->Execute(file_urls))
641 return false; 651 return false;
642 652
643 result_.reset(new base::FundamentalValue(true)); 653 result_.reset(new base::FundamentalValue(true));
644 return true; 654 return true;
645 } 655 }
646 656
657 void ExecuteTasksFileBrowserFunction::OnTaskExecuted(bool success) {
658 SendResponse(success);
659 }
660
647 FileBrowserFunction::FileBrowserFunction() { 661 FileBrowserFunction::FileBrowserFunction() {
648 } 662 }
649 663
650 FileBrowserFunction::~FileBrowserFunction() { 664 FileBrowserFunction::~FileBrowserFunction() {
651 } 665 }
652 666
653 int32 FileBrowserFunction::GetTabId() const { 667 int32 FileBrowserFunction::GetTabId() const {
654 if (!dispatcher()) { 668 if (!dispatcher()) {
655 LOG(WARNING) << "No dispatcher"; 669 LOG(WARNING) << "No dispatcher";
656 return 0; 670 return 0;
(...skipping 1315 matching lines...) Expand 10 before | Expand all | Expand 10 after
1972 if (value->GetBoolean("cellularDisabled", &tmp)) { 1986 if (value->GetBoolean("cellularDisabled", &tmp)) {
1973 service->SetBoolean(prefs::kDisableGDataOverCellular, tmp); 1987 service->SetBoolean(prefs::kDisableGDataOverCellular, tmp);
1974 } 1988 }
1975 1989
1976 if (value->GetBoolean("hostedFilesDisabled", &tmp)) { 1990 if (value->GetBoolean("hostedFilesDisabled", &tmp)) {
1977 service->SetBoolean(prefs::kDisableGDataHostedFiles, tmp); 1991 service->SetBoolean(prefs::kDisableGDataHostedFiles, tmp);
1978 } 1992 }
1979 1993
1980 return true; 1994 return true;
1981 } 1995 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/file_browser_private_api.h ('k') | chrome/browser/chromeos/extensions/file_handler_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698