| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_event_router.h" | 5 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h" |
| 6 | 6 |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
| 9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 ExtensionFileBrowserEventRouter::ExtensionFileBrowserEventRouter() | 50 ExtensionFileBrowserEventRouter::ExtensionFileBrowserEventRouter() |
| 51 : profile_(NULL) { | 51 : profile_(NULL) { |
| 52 } | 52 } |
| 53 | 53 |
| 54 ExtensionFileBrowserEventRouter::~ExtensionFileBrowserEventRouter() { | 54 ExtensionFileBrowserEventRouter::~ExtensionFileBrowserEventRouter() { |
| 55 } | 55 } |
| 56 | 56 |
| 57 void ExtensionFileBrowserEventRouter::ObserveFileSystemEvents( | 57 void ExtensionFileBrowserEventRouter::ObserveFileSystemEvents( |
| 58 Profile* profile) { | 58 Profile* profile) { |
| 59 if (profile_ || !profile) | 59 if (!profile) |
| 60 return; | 60 return; |
| 61 profile_ = profile; | 61 profile_ = profile; |
| 62 if (!chromeos::CrosLibrary::Get()->EnsureLoaded()) | 62 if (!chromeos::CrosLibrary::Get()->EnsureLoaded()) |
| 63 return; | 63 return; |
| 64 if (chromeos::UserManager::Get()->user_is_logged_in()) { | 64 if (chromeos::UserManager::Get()->user_is_logged_in()) { |
| 65 chromeos::MountLibrary* lib = | 65 chromeos::MountLibrary* lib = |
| 66 chromeos::CrosLibrary::Get()->GetMountLibrary(); | 66 chromeos::CrosLibrary::Get()->GetMountLibrary(); |
| 67 lib->RemoveObserver(this); |
| 67 lib->AddObserver(this); | 68 lib->AddObserver(this); |
| 68 lib->RequestMountInfoRefresh(); | 69 lib->RequestMountInfoRefresh(); |
| 69 } | 70 } |
| 70 } | 71 } |
| 71 | 72 |
| 72 void ExtensionFileBrowserEventRouter::StopObservingFileSystemEvents() { | 73 void ExtensionFileBrowserEventRouter::StopObservingFileSystemEvents() { |
| 73 if (!profile_) | 74 if (!profile_) |
| 74 return; | 75 return; |
| 75 if (!chromeos::CrosLibrary::Get()->EnsureLoaded()) | 76 if (!chromeos::CrosLibrary::Get()->EnsureLoaded()) |
| 76 return; | 77 return; |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 ++iter) { | 250 ++iter) { |
| 250 const std::string& notification_device_path = iter->first; | 251 const std::string& notification_device_path = iter->first; |
| 251 // Doing a sub string match so that we find if this new one is a subdevice | 252 // Doing a sub string match so that we find if this new one is a subdevice |
| 252 // of another already inserted device. | 253 // of another already inserted device. |
| 253 if (StartsWithASCII(system_path, notification_device_path, true)) { | 254 if (StartsWithASCII(system_path, notification_device_path, true)) { |
| 254 return iter; | 255 return iter; |
| 255 } | 256 } |
| 256 } | 257 } |
| 257 return notifications_.end(); | 258 return notifications_.end(); |
| 258 } | 259 } |
| OLD | NEW |