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

Side by Side Diff: chrome/browser/chromeos/file_manager/file_browser_handlers.cc

Issue 101323002: Stop setting invalid value to the |tab_id| field of fileBrowserHandler API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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/file_manager/file_browser_handlers.h" 5 #include "chrome/browser/chromeos/file_manager/file_browser_handlers.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/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 // files. The event will launch the file browser handler if not active. 155 // files. The event will launch the file browser handler if not active.
156 // 4) In the file browser handler, onExecute event is handled and executes the 156 // 4) In the file browser handler, onExecute event is handled and executes the
157 // task in JavaScript. 157 // task in JavaScript.
158 // 158 //
159 // That said, the class itself does not execute a task. The task will be 159 // That said, the class itself does not execute a task. The task will be
160 // executed in JavaScript. 160 // executed in JavaScript.
161 class FileBrowserHandlerExecutor { 161 class FileBrowserHandlerExecutor {
162 public: 162 public:
163 FileBrowserHandlerExecutor(Profile* profile, 163 FileBrowserHandlerExecutor(Profile* profile,
164 const Extension* extension, 164 const Extension* extension,
165 int32 tab_id,
166 const std::string& action_id); 165 const std::string& action_id);
167 166
168 // Executes the task for each file. |done| will be run with the result. 167 // Executes the task for each file. |done| will be run with the result.
169 void Execute(const std::vector<FileSystemURL>& file_urls, 168 void Execute(const std::vector<FileSystemURL>& file_urls,
170 const file_tasks::FileTaskFinishedCallback& done); 169 const file_tasks::FileTaskFinishedCallback& done);
171 170
172 private: 171 private:
173 // This object is responsible to delete itself. 172 // This object is responsible to delete itself.
174 virtual ~FileBrowserHandlerExecutor(); 173 virtual ~FileBrowserHandlerExecutor();
175 174
(...skipping 25 matching lines...) Expand all
201 200
202 // Registers file permissions from |handler_host_permissions_| with 201 // Registers file permissions from |handler_host_permissions_| with
203 // ChildProcessSecurityPolicy for process with id |handler_pid|. 202 // ChildProcessSecurityPolicy for process with id |handler_pid|.
204 void SetupHandlerHostFileAccessPermissions( 203 void SetupHandlerHostFileAccessPermissions(
205 const FileDefinitionList& file_list, 204 const FileDefinitionList& file_list,
206 const Extension* extension, 205 const Extension* extension,
207 int handler_pid); 206 int handler_pid);
208 207
209 Profile* profile_; 208 Profile* profile_;
210 scoped_refptr<const Extension> extension_; 209 scoped_refptr<const Extension> extension_;
211 int32 tab_id_;
212 const std::string action_id_; 210 const std::string action_id_;
213 file_tasks::FileTaskFinishedCallback done_; 211 file_tasks::FileTaskFinishedCallback done_;
214 base::WeakPtrFactory<FileBrowserHandlerExecutor> weak_ptr_factory_; 212 base::WeakPtrFactory<FileBrowserHandlerExecutor> weak_ptr_factory_;
215 213
216 DISALLOW_COPY_AND_ASSIGN(FileBrowserHandlerExecutor); 214 DISALLOW_COPY_AND_ASSIGN(FileBrowserHandlerExecutor);
217 }; 215 };
218 216
219 FileBrowserHandlerExecutor::FileDefinition::FileDefinition() 217 FileBrowserHandlerExecutor::FileDefinition::FileDefinition()
220 : is_directory(false) { 218 : is_directory(false) {
221 } 219 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 file.is_directory = file_info.is_directory; 268 file.is_directory = file_info.is_directory;
271 file.absolute_path = local_path; 269 file.absolute_path = local_path;
272 file_list.push_back(file); 270 file_list.push_back(file);
273 } 271 }
274 return file_list; 272 return file_list;
275 } 273 }
276 274
277 FileBrowserHandlerExecutor::FileBrowserHandlerExecutor( 275 FileBrowserHandlerExecutor::FileBrowserHandlerExecutor(
278 Profile* profile, 276 Profile* profile,
279 const Extension* extension, 277 const Extension* extension,
280 int32 tab_id,
281 const std::string& action_id) 278 const std::string& action_id)
282 : profile_(profile), 279 : profile_(profile),
283 extension_(extension), 280 extension_(extension),
284 tab_id_(tab_id),
285 action_id_(action_id), 281 action_id_(action_id),
286 weak_ptr_factory_(this) { 282 weak_ptr_factory_(this) {
287 } 283 }
288 284
289 FileBrowserHandlerExecutor::~FileBrowserHandlerExecutor() {} 285 FileBrowserHandlerExecutor::~FileBrowserHandlerExecutor() {}
290 286
291 void FileBrowserHandlerExecutor::Execute( 287 void FileBrowserHandlerExecutor::Execute(
292 const std::vector<FileSystemURL>& file_urls, 288 const std::vector<FileSystemURL>& file_urls,
293 const file_tasks::FileTaskFinishedCallback& done) { 289 const file_tasks::FileTaskFinishedCallback& done) {
294 done_ = done; 290 done_ = done;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 DictionaryValue* file_def = new DictionaryValue(); 393 DictionaryValue* file_def = new DictionaryValue();
398 file_entries->Append(file_def); 394 file_entries->Append(file_def);
399 file_def->SetString("fileSystemName", file_system_name); 395 file_def->SetString("fileSystemName", file_system_name);
400 file_def->SetString("fileSystemRoot", file_system_root.spec()); 396 file_def->SetString("fileSystemRoot", file_system_root.spec());
401 base::FilePath root(FILE_PATH_LITERAL("/")); 397 base::FilePath root(FILE_PATH_LITERAL("/"));
402 base::FilePath full_path = root.Append(iter->virtual_path); 398 base::FilePath full_path = root.Append(iter->virtual_path);
403 file_def->SetString("fileFullPath", full_path.value()); 399 file_def->SetString("fileFullPath", full_path.value());
404 file_def->SetBoolean("fileIsDirectory", iter->is_directory); 400 file_def->SetBoolean("fileIsDirectory", iter->is_directory);
405 } 401 }
406 402
407 details->SetInteger("tab_id", tab_id_);
408
409 scoped_ptr<extensions::Event> event(new extensions::Event( 403 scoped_ptr<extensions::Event> event(new extensions::Event(
410 "fileBrowserHandler.onExecute", event_args.Pass())); 404 "fileBrowserHandler.onExecute", event_args.Pass()));
411 event->restrict_to_browser_context = profile_; 405 event->restrict_to_browser_context = profile_;
412 event_router->DispatchEventToExtension(extension_->id(), event.Pass()); 406 event_router->DispatchEventToExtension(extension_->id(), event.Pass());
413 407
414 ExecuteDoneOnUIThread(true); 408 ExecuteDoneOnUIThread(true);
415 } 409 }
416 410
417 void FileBrowserHandlerExecutor::SetupHandlerHostFileAccessPermissions( 411 void FileBrowserHandlerExecutor::SetupHandlerHostFileAccessPermissions(
418 const FileDefinitionList& file_list, 412 const FileDefinitionList& file_list,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 } 459 }
466 } 460 }
467 return num_opened > 0; 461 return num_opened > 0;
468 } 462 }
469 463
470 } // namespace 464 } // namespace
471 465
472 bool ExecuteFileBrowserHandler( 466 bool ExecuteFileBrowserHandler(
473 Profile* profile, 467 Profile* profile,
474 const Extension* extension, 468 const Extension* extension,
475 int32 tab_id,
476 const std::string& action_id, 469 const std::string& action_id,
477 const std::vector<FileSystemURL>& file_urls, 470 const std::vector<FileSystemURL>& file_urls,
478 const file_tasks::FileTaskFinishedCallback& done) { 471 const file_tasks::FileTaskFinishedCallback& done) {
479 // Forbid calling undeclared handlers. 472 // Forbid calling undeclared handlers.
480 if (!FindFileBrowserHandlerForActionId(extension, action_id)) 473 if (!FindFileBrowserHandlerForActionId(extension, action_id))
481 return false; 474 return false;
482 475
483 // Some action IDs of the file manager's file browser handlers require the 476 // Some action IDs of the file manager's file browser handlers require the
484 // files to be directly opened with the browser. 477 // files to be directly opened with the browser.
485 if (ShouldBeOpenedWithBrowser(extension->id(), action_id)) { 478 if (ShouldBeOpenedWithBrowser(extension->id(), action_id)) {
486 return OpenFilesWithBrowser(profile, file_urls); 479 return OpenFilesWithBrowser(profile, file_urls);
487 } 480 }
488 481
489 // The executor object will be self deleted on completion. 482 // The executor object will be self deleted on completion.
490 (new FileBrowserHandlerExecutor( 483 (new FileBrowserHandlerExecutor(
491 profile, extension, tab_id, action_id))->Execute(file_urls, done); 484 profile, extension, action_id))->Execute(file_urls, done);
492 return true; 485 return true;
493 } 486 }
494 487
495 bool IsFallbackFileBrowserHandler(const file_tasks::TaskDescriptor& task) { 488 bool IsFallbackFileBrowserHandler(const file_tasks::TaskDescriptor& task) {
496 return (task.task_type == file_tasks::TASK_TYPE_FILE_BROWSER_HANDLER && 489 return (task.task_type == file_tasks::TASK_TYPE_FILE_BROWSER_HANDLER &&
497 (task.app_id == kFileManagerAppId || 490 (task.app_id == kFileManagerAppId ||
498 task.app_id == extension_misc::kQuickOfficeComponentExtensionId || 491 task.app_id == extension_misc::kQuickOfficeComponentExtensionId ||
499 task.app_id == extension_misc::kQuickOfficeDevExtensionId || 492 task.app_id == extension_misc::kQuickOfficeDevExtensionId ||
500 task.app_id == extension_misc::kQuickOfficeExtensionId)); 493 task.app_id == extension_misc::kQuickOfficeExtensionId));
501 } 494 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 common_handlers.erase(gallery_iter); 539 common_handlers.erase(gallery_iter);
547 else 540 else
548 common_handlers.erase(watch_iter); 541 common_handlers.erase(watch_iter);
549 } 542 }
550 543
551 return common_handlers; 544 return common_handlers;
552 } 545 }
553 546
554 } // namespace file_browser_handlers 547 } // namespace file_browser_handlers
555 } // namespace file_manager 548 } // namespace file_manager
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/file_manager/file_browser_handlers.h ('k') | chrome/browser/chromeos/file_manager/file_tasks.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698