BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / chromeos / file_system_provider / operations / operation.cc
bloba573f555a838f20d7cfcd8efee0a19b2b97412d3
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/file_system_provider/operations/operation.h"
7 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info.h"
8 #include "extensions/browser/event_router.h"
10 namespace chromeos {
11 namespace file_system_provider {
12 namespace operations {
13 namespace {
15 // Default implementation for dispatching an event. Can be replaced for unit
16 // tests by Operation::SetDispatchEventImplForTest().
17 bool DispatchEventImpl(extensions::EventRouter* event_router,
18 const std::string& extension_id,
19 scoped_ptr<extensions::Event> event) {
20 if (!event_router->ExtensionHasEventListener(extension_id, event->event_name))
21 return false;
23 event_router->DispatchEventToExtension(extension_id, event.Pass());
24 return true;
27 } // namespace
29 Operation::Operation(extensions::EventRouter* event_router,
30 const ProvidedFileSystemInfo& file_system_info)
31 : file_system_info_(file_system_info),
32 dispatch_event_impl_(base::Bind(&DispatchEventImpl,
33 event_router,
34 file_system_info_.extension_id())) {
37 Operation::~Operation() {
40 void Operation::SetDispatchEventImplForTesting(
41 const DispatchEventImplCallback& callback) {
42 dispatch_event_impl_ = callback;
45 bool Operation::SendEvent(int request_id,
46 extensions::events::HistogramValue histogram_value,
47 const std::string& event_name,
48 scoped_ptr<base::ListValue> event_args) {
49 return dispatch_event_impl_.Run(make_scoped_ptr(
50 new extensions::Event(histogram_value, event_name, event_args.Pass())));
53 } // namespace operations
54 } // namespace file_system_provider
55 } // namespace chromeos