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

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

Issue 22264004: Remove ConnectivityStateHelper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove redundant IsConnected() check Created 7 years, 4 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/event_router.h" 5 #include "chrome/browser/chromeos/extensions/file_manager/event_router.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/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/prefs/pref_change_registrar.h" 10 #include "base/prefs/pref_change_registrar.h"
11 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "base/threading/sequenced_worker_pool.h" 13 #include "base/threading/sequenced_worker_pool.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chrome/browser/chrome_notification_types.h" 15 #include "chrome/browser/chrome_notification_types.h"
16 #include "chrome/browser/chromeos/drive/drive_integration_service.h" 16 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
17 #include "chrome/browser/chromeos/drive/file_system_interface.h" 17 #include "chrome/browser/chromeos/drive/file_system_interface.h"
18 #include "chrome/browser/chromeos/drive/file_system_util.h" 18 #include "chrome/browser/chromeos/drive/file_system_util.h"
19 #include "chrome/browser/chromeos/extensions/file_manager/desktop_notifications. h" 19 #include "chrome/browser/chromeos/extensions/file_manager/desktop_notifications. h"
20 #include "chrome/browser/chromeos/extensions/file_manager/file_manager_util.h" 20 #include "chrome/browser/chromeos/extensions/file_manager/file_manager_util.h"
21 #include "chrome/browser/chromeos/extensions/file_manager/mounted_disk_monitor.h " 21 #include "chrome/browser/chromeos/extensions/file_manager/mounted_disk_monitor.h "
22 #include "chrome/browser/chromeos/login/login_display_host_impl.h" 22 #include "chrome/browser/chromeos/login/login_display_host_impl.h"
23 #include "chrome/browser/chromeos/login/screen_locker.h" 23 #include "chrome/browser/chromeos/login/screen_locker.h"
24 #include "chrome/browser/chromeos/net/connectivity_state_helper.h"
25 #include "chrome/browser/drive/drive_service_interface.h" 24 #include "chrome/browser/drive/drive_service_interface.h"
26 #include "chrome/browser/extensions/event_names.h" 25 #include "chrome/browser/extensions/event_names.h"
27 #include "chrome/browser/extensions/event_router.h" 26 #include "chrome/browser/extensions/event_router.h"
28 #include "chrome/browser/extensions/extension_service.h" 27 #include "chrome/browser/extensions/extension_service.h"
29 #include "chrome/browser/extensions/extension_system.h" 28 #include "chrome/browser/extensions/extension_system.h"
30 #include "chrome/browser/profiles/profile.h" 29 #include "chrome/browser/profiles/profile.h"
31 #include "chrome/common/pref_names.h" 30 #include "chrome/common/pref_names.h"
32 #include "chromeos/login/login_state.h" 31 #include "chromeos/login/login_state.h"
32 #include "chromeos/network/network_handler.h"
33 #include "chromeos/network/network_state_handler.h"
33 #include "content/public/browser/browser_thread.h" 34 #include "content/public/browser/browser_thread.h"
34 #include "content/public/browser/notification_source.h" 35 #include "content/public/browser/notification_source.h"
35 #include "webkit/common/fileapi/file_system_types.h" 36 #include "webkit/common/fileapi/file_system_types.h"
36 #include "webkit/common/fileapi/file_system_util.h" 37 #include "webkit/common/fileapi/file_system_util.h"
37 38
38 using chromeos::disks::DiskMountManager; 39 using chromeos::disks::DiskMountManager;
40 using chromeos::NetworkHandler;
39 using content::BrowserThread; 41 using content::BrowserThread;
40 using drive::DriveIntegrationService; 42 using drive::DriveIntegrationService;
41 using drive::DriveIntegrationServiceFactory; 43 using drive::DriveIntegrationServiceFactory;
42 44
43 namespace file_manager { 45 namespace file_manager {
44 namespace { 46 namespace {
45 47
46 const char kPathChanged[] = "changed"; 48 const char kPathChanged[] = "changed";
47 const char kPathWatchError[] = "error"; 49 const char kPathWatchError[] = "error";
48 50
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 DriveIntegrationService* integration_service = 250 DriveIntegrationService* integration_service =
249 DriveIntegrationServiceFactory::FindForProfileRegardlessOfStates( 251 DriveIntegrationServiceFactory::FindForProfileRegardlessOfStates(
250 profile_); 252 profile_);
251 if (integration_service) { 253 if (integration_service) {
252 integration_service->RemoveObserver(this); 254 integration_service->RemoveObserver(this);
253 integration_service->file_system()->RemoveObserver(this); 255 integration_service->file_system()->RemoveObserver(this);
254 integration_service->drive_service()->RemoveObserver(this); 256 integration_service->drive_service()->RemoveObserver(this);
255 integration_service->job_list()->RemoveObserver(this); 257 integration_service->job_list()->RemoveObserver(this);
256 } 258 }
257 259
258 if (chromeos::ConnectivityStateHelper::IsInitialized()) { 260 if (NetworkHandler::IsInitialized()) {
259 chromeos::ConnectivityStateHelper::Get()-> 261 NetworkHandler::Get()->network_state_handler()->RemoveObserver(this,
260 RemoveNetworkManagerObserver(this); 262 FROM_HERE);
261 } 263 }
262 profile_ = NULL; 264 profile_ = NULL;
263 } 265 }
264 266
265 void EventRouter::ObserveFileSystemEvents() { 267 void EventRouter::ObserveFileSystemEvents() {
266 if (!profile_) { 268 if (!profile_) {
267 NOTREACHED(); 269 NOTREACHED();
268 return; 270 return;
269 } 271 }
270 if (!chromeos::LoginState::IsInitialized() || 272 if (!chromeos::LoginState::IsInitialized() ||
(...skipping 11 matching lines...) Expand all
282 DriveIntegrationService* integration_service = 284 DriveIntegrationService* integration_service =
283 DriveIntegrationServiceFactory::GetForProfileRegardlessOfStates( 285 DriveIntegrationServiceFactory::GetForProfileRegardlessOfStates(
284 profile_); 286 profile_);
285 if (integration_service) { 287 if (integration_service) {
286 integration_service->AddObserver(this); 288 integration_service->AddObserver(this);
287 integration_service->drive_service()->AddObserver(this); 289 integration_service->drive_service()->AddObserver(this);
288 integration_service->file_system()->AddObserver(this); 290 integration_service->file_system()->AddObserver(this);
289 integration_service->job_list()->AddObserver(this); 291 integration_service->job_list()->AddObserver(this);
290 } 292 }
291 293
292 if (chromeos::ConnectivityStateHelper::IsInitialized()) { 294 if (NetworkHandler::IsInitialized()) {
293 chromeos::ConnectivityStateHelper::Get()-> 295 NetworkHandler::Get()->network_state_handler()->AddObserver(this,
294 AddNetworkManagerObserver(this); 296 FROM_HERE);
295 } 297 }
296 298
297 mounted_disk_monitor_.reset(new MountedDiskMonitor()); 299 mounted_disk_monitor_.reset(new MountedDiskMonitor());
298 300
299 pref_change_registrar_->Init(profile_->GetPrefs()); 301 pref_change_registrar_->Init(profile_->GetPrefs());
300 302
301 pref_change_registrar_->Add( 303 pref_change_registrar_->Add(
302 prefs::kExternalStorageDisabled, 304 prefs::kExternalStorageDisabled,
303 base::Bind(&EventRouter::OnExternalStorageDisabledChanged, 305 base::Bind(&EventRouter::OnExternalStorageDisabledChanged,
304 weak_factory_.GetWeakPtr())); 306 weak_factory_.GetWeakPtr()));
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 NOTREACHED(); 461 NOTREACHED();
460 return; 462 return;
461 } 463 }
462 scoped_ptr<extensions::Event> event(new extensions::Event( 464 scoped_ptr<extensions::Event> event(new extensions::Event(
463 extensions::event_names::kOnFileBrowserDriveConnectionStatusChanged, 465 extensions::event_names::kOnFileBrowserDriveConnectionStatusChanged,
464 scoped_ptr<ListValue>(new ListValue()))); 466 scoped_ptr<ListValue>(new ListValue())));
465 extensions::ExtensionSystem::Get(profile_)->event_router()-> 467 extensions::ExtensionSystem::Get(profile_)->event_router()->
466 BroadcastEvent(event.Pass()); 468 BroadcastEvent(event.Pass());
467 } 469 }
468 470
469 void EventRouter::DefaultNetworkChanged() { 471 void EventRouter::DefaultNetworkChanged(const chromeos::NetworkState* network) {
470 NetworkManagerChanged(); 472 NetworkManagerChanged();
471 } 473 }
472 474
473 void EventRouter::OnExternalStorageDisabledChanged() { 475 void EventRouter::OnExternalStorageDisabledChanged() {
474 // If the policy just got disabled we have to unmount every device currently 476 // If the policy just got disabled we have to unmount every device currently
475 // mounted. The opposite is fine - we can let the user re-plug her device to 477 // mounted. The opposite is fine - we can let the user re-plug her device to
476 // make it available. 478 // make it available.
477 if (profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) { 479 if (profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) {
478 DiskMountManager* manager = DiskMountManager::GetInstance(); 480 DiskMountManager* manager = DiskMountManager::GetInstance();
479 DiskMountManager::MountPointMap mounts(manager->mount_points()); 481 DiskMountManager::MountPointMap mounts(manager->mount_points());
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 chromeos::MOUNT_TYPE_DEVICE); 858 chromeos::MOUNT_TYPE_DEVICE);
857 } else { 859 } else {
858 notifications_->HideNotification(DesktopNotifications::FORMAT_START, 860 notifications_->HideNotification(DesktopNotifications::FORMAT_START,
859 device_path); 861 device_path);
860 notifications_->ShowNotification(DesktopNotifications::FORMAT_FAIL, 862 notifications_->ShowNotification(DesktopNotifications::FORMAT_FAIL,
861 device_path); 863 device_path);
862 } 864 }
863 } 865 }
864 866
865 } // namespace file_manager 867 } // namespace file_manager
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/file_manager/event_router.h ('k') | chrome/browser/chromeos/login/auth_prewarmer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698