| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/extensions/settings/settings_frontend.h" | 10 #include "chrome/browser/extensions/settings/settings_frontend.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 62 |
| 63 void FinalReplyWhenSatisfied( | 63 void FinalReplyWhenSatisfied( |
| 64 Namespace settings_namespace, | 64 Namespace settings_namespace, |
| 65 const std::string& normal_action, | 65 const std::string& normal_action, |
| 66 const std::string& incognito_action) { | 66 const std::string& incognito_action) { |
| 67 MaybeLoadAndReplyWhenSatisfied( | 67 MaybeLoadAndReplyWhenSatisfied( |
| 68 settings_namespace, normal_action, incognito_action, NULL, true); | 68 settings_namespace, normal_action, incognito_action, NULL, true); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void InitSync(SyncChangeProcessor* sync_processor) { | 71 void InitSync(SyncChangeProcessor* sync_processor) { |
| 72 browser()->profile()->GetExtensionService()-> | |
| 73 settings_frontend()->RunWithSyncableService( | |
| 74 // TODO(kalman): test both EXTENSION_SETTINGS and APP_SETTINGS. | |
| 75 syncable::EXTENSION_SETTINGS, | |
| 76 base::Bind( | |
| 77 &ExtensionSettingsApiTest::InitSyncWithSyncableService, | |
| 78 this, | |
| 79 sync_processor)); | |
| 80 MessageLoop::current()->RunAllPending(); | 72 MessageLoop::current()->RunAllPending(); |
| 73 // TODO(kalman): test both EXTENSION_SETTINGS and APP_SETTINGS. |
| 74 InitSyncWithSyncableService( |
| 75 sync_processor, |
| 76 browser()->profile()->GetExtensionService()->settings_frontend()-> |
| 77 GetBackendForSync(syncable::EXTENSION_SETTINGS)); |
| 81 } | 78 } |
| 82 | 79 |
| 83 void SendChanges(const SyncChangeList& change_list) { | 80 void SendChanges(const SyncChangeList& change_list) { |
| 84 browser()->profile()->GetExtensionService()-> | |
| 85 settings_frontend()->RunWithSyncableService( | |
| 86 // TODO(kalman): test both EXTENSION_SETTINGS and APP_SETTINGS. | |
| 87 syncable::EXTENSION_SETTINGS, | |
| 88 base::Bind( | |
| 89 &ExtensionSettingsApiTest::SendChangesToSyncableService, | |
| 90 this, | |
| 91 change_list)); | |
| 92 MessageLoop::current()->RunAllPending(); | 81 MessageLoop::current()->RunAllPending(); |
| 82 // TODO(kalman): test both EXTENSION_SETTINGS and APP_SETTINGS. |
| 83 SendChangesToSyncableService( |
| 84 change_list, |
| 85 browser()->profile()->GetExtensionService()->settings_frontend()-> |
| 86 GetBackendForSync(syncable::EXTENSION_SETTINGS)); |
| 93 } | 87 } |
| 94 | 88 |
| 95 private: | 89 private: |
| 96 const Extension* MaybeLoadAndReplyWhenSatisfied( | 90 const Extension* MaybeLoadAndReplyWhenSatisfied( |
| 97 Namespace settings_namespace, | 91 Namespace settings_namespace, |
| 98 const std::string& normal_action, | 92 const std::string& normal_action, |
| 99 const std::string& incognito_action, | 93 const std::string& incognito_action, |
| 100 // May be NULL to imply not loading the extension. | 94 // May be NULL to imply not loading the extension. |
| 101 const std::string* extension_dir, | 95 const std::string* extension_dir, |
| 102 bool is_final_action) { | 96 bool is_final_action) { |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 SendChanges(sync_changes); | 344 SendChanges(sync_changes); |
| 351 | 345 |
| 352 FinalReplyWhenSatisfied(LOCAL, | 346 FinalReplyWhenSatisfied(LOCAL, |
| 353 "assertNoNotifications", "assertNoNotifications"); | 347 "assertNoNotifications", "assertNoNotifications"); |
| 354 | 348 |
| 355 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 349 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 356 EXPECT_TRUE(catcher_incognito.GetNextResult()) << catcher.message(); | 350 EXPECT_TRUE(catcher_incognito.GetNextResult()) << catcher.message(); |
| 357 } | 351 } |
| 358 | 352 |
| 359 } // namespace extensions | 353 } // namespace extensions |
| OLD | NEW |