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/extensions/api/sync_file_system/sync_file_system_api.h" | 5 #include "chrome/browser/extensions/api/sync_file_system/sync_file_system_api.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 ConflictResolutionPolicy policy = ExtensionEnumToConflictResolutionPolicy( | 346 ConflictResolutionPolicy policy = ExtensionEnumToConflictResolutionPolicy( |
347 api::sync_file_system::ParseConflictResolutionPolicy(policy_string)); | 347 api::sync_file_system::ParseConflictResolutionPolicy(policy_string)); |
348 if (policy == sync_file_system::CONFLICT_RESOLUTION_POLICY_UNKNOWN) { | 348 if (policy == sync_file_system::CONFLICT_RESOLUTION_POLICY_UNKNOWN) { |
349 SetError(base::StringPrintf(kUnsupportedConflictResolutionPolicy, | 349 SetError(base::StringPrintf(kUnsupportedConflictResolutionPolicy, |
350 policy_string.c_str())); | 350 policy_string.c_str())); |
351 return false; | 351 return false; |
352 } | 352 } |
353 sync_file_system::SyncFileSystemService* service = | 353 sync_file_system::SyncFileSystemService* service = |
354 GetSyncFileSystemService(GetProfile()); | 354 GetSyncFileSystemService(GetProfile()); |
355 DCHECK(service); | 355 DCHECK(service); |
356 SyncStatusCode status = service->SetConflictResolutionPolicy(policy); | 356 SyncStatusCode status = service->SetConflictResolutionPolicy( |
| 357 source_url().GetOrigin(), policy); |
357 if (status != sync_file_system::SYNC_STATUS_OK) { | 358 if (status != sync_file_system::SYNC_STATUS_OK) { |
358 SetError(ErrorToString(status)); | 359 SetError(ErrorToString(status)); |
359 return false; | 360 return false; |
360 } | 361 } |
361 return true; | 362 return true; |
362 } | 363 } |
363 | 364 |
364 bool SyncFileSystemGetConflictResolutionPolicyFunction::RunImpl() { | 365 bool SyncFileSystemGetConflictResolutionPolicyFunction::RunImpl() { |
365 sync_file_system::SyncFileSystemService* service = | 366 sync_file_system::SyncFileSystemService* service = |
366 GetSyncFileSystemService(GetProfile()); | 367 GetSyncFileSystemService(GetProfile()); |
367 DCHECK(service); | 368 DCHECK(service); |
368 api::sync_file_system::ConflictResolutionPolicy policy = | 369 api::sync_file_system::ConflictResolutionPolicy policy = |
369 ConflictResolutionPolicyToExtensionEnum( | 370 ConflictResolutionPolicyToExtensionEnum( |
370 service->GetConflictResolutionPolicy()); | 371 service->GetConflictResolutionPolicy(source_url().GetOrigin())); |
371 SetResult(new base::StringValue( | 372 SetResult(new base::StringValue( |
372 api::sync_file_system::ToString(policy))); | 373 api::sync_file_system::ToString(policy))); |
373 return true; | 374 return true; |
374 } | 375 } |
375 | 376 |
376 bool SyncFileSystemGetServiceStatusFunction::RunImpl() { | 377 bool SyncFileSystemGetServiceStatusFunction::RunImpl() { |
377 sync_file_system::SyncFileSystemService* service = | 378 sync_file_system::SyncFileSystemService* service = |
378 GetSyncFileSystemService(GetProfile()); | 379 GetSyncFileSystemService(GetProfile()); |
379 results_ = api::sync_file_system::GetServiceStatus::Results::Create( | 380 results_ = api::sync_file_system::GetServiceStatus::Results::Create( |
380 SyncServiceStateToExtensionEnum(service->GetSyncServiceState())); | 381 SyncServiceStateToExtensionEnum(service->GetSyncServiceState())); |
381 return true; | 382 return true; |
382 } | 383 } |
383 | 384 |
384 } // namespace extensions | 385 } // namespace extensions |
OLD | NEW |