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

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

Issue 238633009: cleanup: Use EventRouter instead of ExtensionSystem::Get->event_router() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile error for chromeos build. Created 6 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
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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 int handler_pid_in, 352 int handler_pid_in,
353 extensions::ExtensionHost* host) { 353 extensions::ExtensionHost* host) {
354 int handler_pid = host ? host->render_process_host()->GetID() : 354 int handler_pid = host ? host->render_process_host()->GetID() :
355 handler_pid_in; 355 handler_pid_in;
356 356
357 if (handler_pid <= 0) { 357 if (handler_pid <= 0) {
358 ExecuteDoneOnUIThread(false); 358 ExecuteDoneOnUIThread(false);
359 return; 359 return;
360 } 360 }
361 361
362 extensions::EventRouter* event_router = 362 extensions::EventRouter* router = extensions::EventRouter::Get(profile_);
363 extensions::ExtensionSystem::Get(profile_)->event_router(); 363 if (!router) {
364 if (!event_router) {
365 ExecuteDoneOnUIThread(false); 364 ExecuteDoneOnUIThread(false);
366 return; 365 return;
367 } 366 }
368 367
369 SetupHandlerHostFileAccessPermissions( 368 SetupHandlerHostFileAccessPermissions(
370 file_definition_list.get(), extension_.get(), handler_pid); 369 file_definition_list.get(), extension_.get(), handler_pid);
371 370
372 scoped_ptr<base::ListValue> event_args(new base::ListValue()); 371 scoped_ptr<base::ListValue> event_args(new base::ListValue());
373 event_args->Append(new base::StringValue(action_id_)); 372 event_args->Append(new base::StringValue(action_id_));
374 base::DictionaryValue* details = new base::DictionaryValue(); 373 base::DictionaryValue* details = new base::DictionaryValue();
(...skipping 12 matching lines...) Expand all
387 file_def->SetString("fileSystemName", iter->file_system_name); 386 file_def->SetString("fileSystemName", iter->file_system_name);
388 file_def->SetString("fileSystemRoot", iter->file_system_root_url); 387 file_def->SetString("fileSystemRoot", iter->file_system_root_url);
389 file_def->SetString("fileFullPath", 388 file_def->SetString("fileFullPath",
390 "/" + iter->full_path.AsUTF8Unsafe()); 389 "/" + iter->full_path.AsUTF8Unsafe());
391 file_def->SetBoolean("fileIsDirectory", iter->is_directory); 390 file_def->SetBoolean("fileIsDirectory", iter->is_directory);
392 } 391 }
393 392
394 scoped_ptr<extensions::Event> event(new extensions::Event( 393 scoped_ptr<extensions::Event> event(new extensions::Event(
395 "fileBrowserHandler.onExecute", event_args.Pass())); 394 "fileBrowserHandler.onExecute", event_args.Pass()));
396 event->restrict_to_browser_context = profile_; 395 event->restrict_to_browser_context = profile_;
397 event_router->DispatchEventToExtension(extension_->id(), event.Pass()); 396 router->DispatchEventToExtension(extension_->id(), event.Pass());
398 397
399 ExecuteDoneOnUIThread(true); 398 ExecuteDoneOnUIThread(true);
400 } 399 }
401 400
402 void FileBrowserHandlerExecutor::SetupHandlerHostFileAccessPermissions( 401 void FileBrowserHandlerExecutor::SetupHandlerHostFileAccessPermissions(
403 FileDefinitionList* file_definition_list, 402 FileDefinitionList* file_definition_list,
404 const Extension* extension, 403 const Extension* extension,
405 int handler_pid) { 404 int handler_pid) {
406 const FileBrowserHandler* action = FindFileBrowserHandlerForActionId( 405 const FileBrowserHandler* action = FindFileBrowserHandlerForActionId(
407 extension_, action_id_); 406 extension_, action_id_);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 if (common_handlers.empty()) 524 if (common_handlers.empty())
526 return FileBrowserHandlerList(); 525 return FileBrowserHandlerList();
527 } 526 }
528 } 527 }
529 528
530 return common_handlers; 529 return common_handlers;
531 } 530 }
532 531
533 } // namespace file_browser_handlers 532 } // namespace file_browser_handlers
534 } // namespace file_manager 533 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698