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

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/file_handler_util.cc

Issue 18308004: Update CrOS to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 5 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_manager/file_handler_util.h" 5 #include "chrome/browser/chromeos/extensions/file_manager/file_handler_util.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/i18n/case_conversion.h" 9 #include "base/i18n/case_conversion.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 if (!service) 141 if (!service)
142 return false; // In unit-tests, we may not have an ExtensionService. 142 return false; // In unit-tests, we may not have an ExtensionService.
143 143
144 // We need case-insensitive matching, and pattern in the handler is already 144 // We need case-insensitive matching, and pattern in the handler is already
145 // in lower case. 145 // in lower case.
146 const GURL lowercase_url(EscapedUtf8ToLower(selected_file_url.spec())); 146 const GURL lowercase_url(EscapedUtf8ToLower(selected_file_url.spec()));
147 147
148 for (ExtensionSet::const_iterator iter = service->extensions()->begin(); 148 for (ExtensionSet::const_iterator iter = service->extensions()->begin();
149 iter != service->extensions()->end(); 149 iter != service->extensions()->end();
150 ++iter) { 150 ++iter) {
151 const Extension* extension = *iter; 151 const Extension* extension = iter->get();
152 if (profile->IsOffTheRecord() && 152 if (profile->IsOffTheRecord() &&
153 !service->IsIncognitoEnabled(extension->id())) 153 !service->IsIncognitoEnabled(extension->id()))
154 continue; 154 continue;
155 155
156 FileBrowserHandler::List* handler_list = 156 FileBrowserHandler::List* handler_list =
157 FileBrowserHandler::GetHandlers(extension); 157 FileBrowserHandler::GetHandlers(extension);
158 if (!handler_list) 158 if (!handler_list)
159 continue; 159 continue;
160 for (FileBrowserHandler::List::const_iterator action_iter = 160 for (FileBrowserHandler::List::const_iterator action_iter =
161 handler_list->begin(); 161 handler_list->begin();
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 const FileDefinitionList& file_list) { 739 const FileDefinitionList& file_list) {
740 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 740 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
741 741
742 if (file_list.empty()) { 742 if (file_list.empty()) {
743 ExecuteDoneOnUIThread(false); 743 ExecuteDoneOnUIThread(false);
744 return; 744 return;
745 } 745 }
746 746
747 int handler_pid = ExtractProcessFromExtensionId(profile_, extension_->id()); 747 int handler_pid = ExtractProcessFromExtensionId(profile_, extension_->id());
748 if (handler_pid <= 0 && 748 if (handler_pid <= 0 &&
749 !extensions::BackgroundInfo::HasLazyBackgroundPage(extension_)) { 749 !extensions::BackgroundInfo::HasLazyBackgroundPage(extension_.get())) {
750 ExecuteDoneOnUIThread(false); 750 ExecuteDoneOnUIThread(false);
751 return; 751 return;
752 } 752 }
753 753
754 if (handler_pid > 0) { 754 if (handler_pid > 0) {
755 SetupPermissionsAndDispatchEvent(file_system_name, file_system_root, 755 SetupPermissionsAndDispatchEvent(file_system_name, file_system_root,
756 file_list, handler_pid, NULL); 756 file_list, handler_pid, NULL);
757 } else { 757 } else {
758 // We have to wake the handler background page before we proceed. 758 // We have to wake the handler background page before we proceed.
759 extensions::LazyBackgroundTaskQueue* queue = 759 extensions::LazyBackgroundTaskQueue* queue =
760 extensions::ExtensionSystem::Get(profile_)-> 760 extensions::ExtensionSystem::Get(profile_)->
761 lazy_background_task_queue(); 761 lazy_background_task_queue();
762 if (!queue->ShouldEnqueueTask(profile_, extension_)) { 762 if (!queue->ShouldEnqueueTask(profile_, extension_.get())) {
763 ExecuteDoneOnUIThread(false); 763 ExecuteDoneOnUIThread(false);
764 return; 764 return;
765 } 765 }
766 queue->AddPendingTask( 766 queue->AddPendingTask(
767 profile_, extension_->id(), 767 profile_, extension_->id(),
768 base::Bind(&ExtensionTaskExecutor::SetupPermissionsAndDispatchEvent, 768 base::Bind(&ExtensionTaskExecutor::SetupPermissionsAndDispatchEvent,
769 weak_ptr_factory_.GetWeakPtr(), 769 weak_ptr_factory_.GetWeakPtr(),
770 file_system_name, 770 file_system_name,
771 file_system_root, 771 file_system_root,
772 file_list, 772 file_list,
(...skipping 15 matching lines...) Expand all
788 return; 788 return;
789 } 789 }
790 790
791 extensions::EventRouter* event_router = 791 extensions::EventRouter* event_router =
792 extensions::ExtensionSystem::Get(profile_)->event_router(); 792 extensions::ExtensionSystem::Get(profile_)->event_router();
793 if (!event_router) { 793 if (!event_router) {
794 ExecuteDoneOnUIThread(false); 794 ExecuteDoneOnUIThread(false);
795 return; 795 return;
796 } 796 }
797 797
798 SetupHandlerHostFileAccessPermissions(file_list, extension_, handler_pid); 798 SetupHandlerHostFileAccessPermissions(
799 file_list, extension_.get(), handler_pid);
799 800
800 scoped_ptr<ListValue> event_args(new ListValue()); 801 scoped_ptr<ListValue> event_args(new ListValue());
801 event_args->Append(new base::StringValue(action_id_)); 802 event_args->Append(new base::StringValue(action_id_));
802 DictionaryValue* details = new DictionaryValue(); 803 DictionaryValue* details = new DictionaryValue();
803 event_args->Append(details); 804 event_args->Append(details);
804 // Get file definitions. These will be replaced with Entry instances by 805 // Get file definitions. These will be replaced with Entry instances by
805 // dispatchEvent() method from event_binding.js. 806 // dispatchEvent() method from event_binding.js.
806 ListValue* files_urls = new ListValue(); 807 ListValue* files_urls = new ListValue();
807 details->Set("entries", files_urls); 808 details->Set("entries", files_urls);
808 for (FileDefinitionList::const_iterator iter = file_list.begin(); 809 for (FileDefinitionList::const_iterator iter = file_list.begin();
(...skipping 22 matching lines...) Expand all
831 void ExtensionTaskExecutor::SetupHandlerHostFileAccessPermissions( 832 void ExtensionTaskExecutor::SetupHandlerHostFileAccessPermissions(
832 const FileDefinitionList& file_list, 833 const FileDefinitionList& file_list,
833 const Extension* extension, 834 const Extension* extension,
834 int handler_pid) { 835 int handler_pid) {
835 for (FileDefinitionList::const_iterator iter = file_list.begin(); 836 for (FileDefinitionList::const_iterator iter = file_list.begin();
836 iter != file_list.end(); 837 iter != file_list.end();
837 ++iter) { 838 ++iter) {
838 content::ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( 839 content::ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile(
839 handler_pid, 840 handler_pid,
840 iter->absolute_path, 841 iter->absolute_path,
841 GetAccessPermissionsForFileBrowserHandler(extension_, action_id_)); 842 GetAccessPermissionsForFileBrowserHandler(extension_.get(),
843 action_id_));
842 } 844 }
843 } 845 }
844 846
845 } // namespace file_handler_util 847 } // namespace file_handler_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698