| OLD | NEW |
| 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_browser_event_router.h" | 5 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 if (!profile_) { | 106 if (!profile_) { |
| 107 NOTREACHED(); | 107 NOTREACHED(); |
| 108 return; | 108 return; |
| 109 } | 109 } |
| 110 DiskMountManager::GetInstance()->RemoveObserver(this); | 110 DiskMountManager::GetInstance()->RemoveObserver(this); |
| 111 | 111 |
| 112 DriveSystemService* system_service = | 112 DriveSystemService* system_service = |
| 113 DriveSystemServiceFactory::FindForProfile(profile_); | 113 DriveSystemServiceFactory::FindForProfile(profile_); |
| 114 if (system_service) { | 114 if (system_service) { |
| 115 system_service->file_system()->RemoveObserver(this); | 115 system_service->file_system()->RemoveObserver(this); |
| 116 system_service->drive_service()->operation_registry()->RemoveObserver(this); | 116 system_service->drive_service()->RemoveObserver(this); |
| 117 } | 117 } |
| 118 | 118 |
| 119 chromeos::NetworkLibrary* network_library = | 119 chromeos::NetworkLibrary* network_library = |
| 120 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 120 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
| 121 if (network_library) | 121 if (network_library) |
| 122 network_library->RemoveNetworkManagerObserver(this); | 122 network_library->RemoveNetworkManagerObserver(this); |
| 123 | 123 |
| 124 profile_ = NULL; | 124 profile_ = NULL; |
| 125 } | 125 } |
| 126 | 126 |
| 127 void FileBrowserEventRouter::ObserveFileSystemEvents() { | 127 void FileBrowserEventRouter::ObserveFileSystemEvents() { |
| 128 if (!profile_) { | 128 if (!profile_) { |
| 129 NOTREACHED(); | 129 NOTREACHED(); |
| 130 return; | 130 return; |
| 131 } | 131 } |
| 132 if (!chromeos::UserManager::Get()->IsUserLoggedIn()) | 132 if (!chromeos::UserManager::Get()->IsUserLoggedIn()) |
| 133 return; | 133 return; |
| 134 | 134 |
| 135 DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); | 135 DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); |
| 136 disk_mount_manager->RemoveObserver(this); | 136 disk_mount_manager->RemoveObserver(this); |
| 137 disk_mount_manager->AddObserver(this); | 137 disk_mount_manager->AddObserver(this); |
| 138 disk_mount_manager->RequestMountInfoRefresh(); | 138 disk_mount_manager->RequestMountInfoRefresh(); |
| 139 | 139 |
| 140 DriveSystemService* system_service = | 140 DriveSystemService* system_service = |
| 141 DriveSystemServiceFactory::GetForProfile(profile_); | 141 DriveSystemServiceFactory::GetForProfile(profile_); |
| 142 if (!system_service) { | 142 if (!system_service) { |
| 143 NOTREACHED(); | 143 NOTREACHED(); |
| 144 return; | 144 return; |
| 145 } | 145 } |
| 146 system_service->drive_service()->operation_registry()->AddObserver(this); | 146 system_service->drive_service()->AddObserver(this); |
| 147 system_service->file_system()->AddObserver(this); | 147 system_service->file_system()->AddObserver(this); |
| 148 | 148 |
| 149 chromeos::NetworkLibrary* network_library = | 149 chromeos::NetworkLibrary* network_library = |
| 150 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 150 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
| 151 if (network_library) | 151 if (network_library) |
| 152 network_library->AddNetworkManagerObserver(this); | 152 network_library->AddNetworkManagerObserver(this); |
| 153 | 153 |
| 154 pref_change_registrar_->Init(profile_->GetPrefs()); | 154 pref_change_registrar_->Init(profile_->GetPrefs()); |
| 155 pref_change_registrar_->Add(prefs::kDisableGDataOverCellular, this); | 155 pref_change_registrar_->Add(prefs::kDisableGDataOverCellular, this); |
| 156 pref_change_registrar_->Add(prefs::kDisableGDataHostedFiles, this); | 156 pref_change_registrar_->Add(prefs::kDisableGDataHostedFiles, this); |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 *pref_name == prefs::kDisableGDataHostedFiles || | 405 *pref_name == prefs::kDisableGDataHostedFiles || |
| 406 *pref_name == prefs::kDisableGData) { | 406 *pref_name == prefs::kDisableGData) { |
| 407 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( | 407 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( |
| 408 extensions::event_names::kOnFileBrowserGDataPreferencesChanged, | 408 extensions::event_names::kOnFileBrowserGDataPreferencesChanged, |
| 409 scoped_ptr<ListValue>(new ListValue()), NULL, GURL()); | 409 scoped_ptr<ListValue>(new ListValue()), NULL, GURL()); |
| 410 } | 410 } |
| 411 } | 411 } |
| 412 } | 412 } |
| 413 | 413 |
| 414 void FileBrowserEventRouter::OnProgressUpdate( | 414 void FileBrowserEventRouter::OnProgressUpdate( |
| 415 const std::vector<gdata::OperationRegistry::ProgressStatus>& list) { | 415 const gdata::OperationProgressStatusList& list) { |
| 416 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 416 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 417 | 417 |
| 418 scoped_ptr<ListValue> event_list( | 418 scoped_ptr<ListValue> event_list( |
| 419 file_manager_util::ProgressStatusVectorToListValue( | 419 file_manager_util::ProgressStatusVectorToListValue( |
| 420 profile_, | 420 profile_, |
| 421 file_manager_util::GetFileBrowserExtensionUrl().GetOrigin(), | 421 file_manager_util::GetFileBrowserExtensionUrl().GetOrigin(), |
| 422 list)); | 422 list)); |
| 423 | 423 |
| 424 scoped_ptr<ListValue> args(new ListValue()); | 424 scoped_ptr<ListValue> args(new ListValue()); |
| 425 args->Append(event_list.release()); | 425 args->Append(event_list.release()); |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 return scoped_refptr<RefcountedProfileKeyedService>( | 860 return scoped_refptr<RefcountedProfileKeyedService>( |
| 861 new FileBrowserEventRouter(profile)); | 861 new FileBrowserEventRouter(profile)); |
| 862 } | 862 } |
| 863 | 863 |
| 864 bool FileBrowserEventRouterFactory::ServiceHasOwnInstanceInIncognito() const { | 864 bool FileBrowserEventRouterFactory::ServiceHasOwnInstanceInIncognito() const { |
| 865 // Explicitly and always allow this router in guest login mode. see | 865 // Explicitly and always allow this router in guest login mode. see |
| 866 // chrome/browser/profiles/profile_keyed_base_factory.h comment | 866 // chrome/browser/profiles/profile_keyed_base_factory.h comment |
| 867 // for the details. | 867 // for the details. |
| 868 return true; | 868 return true; |
| 869 } | 869 } |
| OLD | NEW |