Skip to content

Commit

Permalink
[iOS] Move i/c/b/ui/sync/utils to i/c/b/settings/sync/utils
Browse files Browse the repository at this point in the history
Change-Id: I76d2bab4d024c70491ea6bfe586d6696281e126b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4579021
Reviewed-by: Sergio Collazos <sczs@chromium.org>
Commit-Queue: Ewann Pellé <ewannpv@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1153743}
  • Loading branch information
Ewann Pelle authored and Chromium LUCI CQ committed Jun 6, 2023
1 parent 286e49d commit 33ea99e
Show file tree
Hide file tree
Showing 46 changed files with 148 additions and 182 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ source_set("unit_tests") {
"//ios/chrome/browser/infobars/overlays",
"//ios/chrome/browser/infobars/test",
"//ios/chrome/browser/overlays",
"//ios/chrome/browser/settings/sync/utils",
"//ios/chrome/browser/settings/sync/utils/test",
"//ios/chrome/browser/shared/model/browser_state:test_support",
"//ios/chrome/browser/sync",
"//ios/chrome/browser/sync:test_support",
"//ios/chrome/browser/ui/settings/sync/utils",
"//ios/chrome/browser/ui/settings/sync/utils/test",
"//ios/web/public/test",
"//ios/web/public/test/fakes",
"//testing/gtest",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

#import "ios/chrome/browser/infobars/infobar_type.h"
#import "ios/chrome/browser/infobars/test/fake_infobar_ios.h"
#import "ios/chrome/browser/settings/sync/utils/sync_presenter.h"
#import "ios/chrome/browser/settings/sync/utils/test/mock_sync_error_infobar_delegate.h"
#import "ios/chrome/browser/shared/model/browser_state/test_chrome_browser_state.h"
#import "ios/chrome/browser/ui/settings/sync/utils/sync_presenter.h"
#import "ios/chrome/browser/ui/settings/sync/utils/test/mock_sync_error_infobar_delegate.h"
#import "ios/web/public/test/web_task_environment.h"
#import "testing/gmock/include/gmock/gmock.h"
#import "testing/platform_test.h"
Expand Down
6 changes: 3 additions & 3 deletions ios/chrome/browser/overlays/public/infobar_banner/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ source_set("infobar_banner") {
"//ios/chrome/browser/passwords:infobar_delegates",
"//ios/chrome/browser/permissions:infobar_delegate",
"//ios/chrome/browser/safe_browsing/tailored_security:infobar_delegates",
"//ios/chrome/browser/settings/sync/utils",
"//ios/chrome/browser/ui/authentication",
"//ios/chrome/browser/ui/settings/sync/utils",
"//ios/chrome/browser/web/",
"//ios/web/public/permissions",
"//ui/base",
Expand All @@ -60,11 +60,11 @@ source_set("unit_tests") {
"//ios/chrome/browser/infobars/test",
"//ios/chrome/browser/overlays",
"//ios/chrome/browser/overlays/public/infobar_banner",
"//ios/chrome/browser/settings/sync/utils",
"//ios/chrome/browser/settings/sync/utils/test",
"//ios/chrome/browser/shared/model/browser_state:test_support",
"//ios/chrome/browser/shared/public/features",
"//ios/chrome/browser/ui/infobars/test",
"//ios/chrome/browser/ui/settings/sync/utils",
"//ios/chrome/browser/ui/settings/sync/utils/test",
"//ios/chrome/common/ui/colors",
"//ios/web/public/test",
"//testing/gmock",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#import "components/infobars/core/infobar.h"
#import "ios/chrome/browser/infobars/infobar_ios.h"
#import "ios/chrome/browser/overlays/public/common/infobars/infobar_overlay_request_config.h"
#import "ios/chrome/browser/ui/settings/sync/utils/sync_error_infobar_delegate.h"
#import "ios/chrome/browser/settings/sync/utils/sync_error_infobar_delegate.h"

#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
#import "components/infobars/core/infobar.h"
#import "ios/chrome/browser/infobars/infobar_ios.h"
#import "ios/chrome/browser/overlays/public/overlay_request.h"
#import "ios/chrome/browser/settings/sync/utils/sync_presenter.h"
#import "ios/chrome/browser/settings/sync/utils/test/mock_sync_error_infobar_delegate.h"
#import "ios/chrome/browser/shared/model/browser_state/test_chrome_browser_state.h"
#import "ios/chrome/browser/shared/public/features/features.h"
#import "ios/chrome/browser/ui/settings/sync/utils/sync_presenter.h"
#import "ios/chrome/browser/ui/settings/sync/utils/test/mock_sync_error_infobar_delegate.h"
#import "ios/chrome/common/ui/colors/semantic_color_names.h"
#import "ios/web/public/test/web_task_environment.h"
#import "testing/gmock/include/gmock/gmock.h"
Expand Down
78 changes: 78 additions & 0 deletions ios/chrome/browser/settings/sync/utils/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,38 @@

import("//ios/public/provider/chrome/browser/build_config.gni")

source_set("utils") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [
"sync_error_infobar_delegate.h",
"sync_error_infobar_delegate.mm",
"sync_presenter.h",
"sync_util.h",
"sync_util.mm",
]
deps = [
":identity_error_util",
"//base",
"//components/infobars/core",
"//components/strings",
"//components/sync/service",
"//ios/chrome/app/strings",
"//ios/chrome/browser/infobars",
"//ios/chrome/browser/infobars:public",
"//ios/chrome/browser/shared/model/browser",
"//ios/chrome/browser/shared/model/browser_state",
"//ios/chrome/browser/shared/public/commands",
"//ios/chrome/browser/shared/ui/symbols",
"//ios/chrome/browser/signin",
"//ios/chrome/browser/sync",
"//ios/chrome/browser/ui/settings:settings_root",
"//ios/chrome/common/ui/colors",
"//ui/base",
"//ui/gfx",
]
frameworks = [ "Foundation.framework" ]
}

source_set("identity_error_util") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [
Expand All @@ -15,10 +47,56 @@ source_set("identity_error_util") {
]
deps = [
"//base",
"//components/sync/base",
"//components/sync/service",
"//ios/chrome/app/strings",
"//ios/chrome/browser/shared/public/features",
"//ui/base",
]
frameworks = [ "Foundation.framework" ]
}

source_set("unit_tests") {
configs += [ "//build/config/compiler:enable_arc" ]
testonly = true
sources = [ "sync_error_infobar_delegate_unittest.mm" ]
deps = [
"//base/test:test_support",
"//components/sync:test_support",
"//components/sync/service",
"//ios/chrome/browser/infobars",
"//ios/chrome/browser/settings/sync/utils",
"//ios/chrome/browser/shared/model/browser_state:test_support",
"//ios/chrome/browser/shared/public/features",
"//ios/chrome/browser/shared/ui/symbols",
"//ios/chrome/browser/sync",
"//ios/chrome/browser/sync:test_support",
"//ios/chrome/common/ui/colors",
"//ios/web/public/test",
"//testing/gtest",
"//third_party/ocmock",
"//ui/base",
]
}

source_set("eg2_tests") {
configs += [
"//build/config/compiler:enable_arc",
"//build/config/ios:xctest_config",
]
testonly = true
sources = [ "sync_fake_server_egtest.mm" ]
deps = [
"//base",
"//base/test:test_support",
"//components/sync/base",
"//ios/chrome/browser/signin:fake_system_identity",
"//ios/chrome/browser/ui/authentication:eg_test_support+eg2",
"//ios/chrome/browser/ui/bookmarks:eg_test_support+eg2",
"//ios/chrome/test/earl_grey:eg_test_support+eg2",
"//ios/testing/earl_grey:eg_test_support+eg2",
"//ios/web/public/test/http_server",
"//net",
"//net:test_support",
]
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef IOS_CHROME_BROWSER_UI_SETTINGS_SYNC_UTILS_SYNC_ERROR_INFOBAR_DELEGATE_H_
#define IOS_CHROME_BROWSER_UI_SETTINGS_SYNC_UTILS_SYNC_ERROR_INFOBAR_DELEGATE_H_
#ifndef IOS_CHROME_BROWSER_SETTINGS_SYNC_UTILS_SYNC_ERROR_INFOBAR_DELEGATE_H_
#define IOS_CHROME_BROWSER_SETTINGS_SYNC_UTILS_SYNC_ERROR_INFOBAR_DELEGATE_H_

#import <UIKit/UIKit.h>
#include <memory>
Expand Down Expand Up @@ -71,4 +71,4 @@ class SyncErrorInfoBarDelegate : public ConfirmInfoBarDelegate,
id<SyncPresenter> presenter_;
};

#endif // IOS_CHROME_BROWSER_UI_SETTINGS_SYNC_UTILS_SYNC_ERROR_INFOBAR_DELEGATE_H_
#endif // IOS_CHROME_BROWSER_SETTINGS_SYNC_UTILS_SYNC_ERROR_INFOBAR_DELEGATE_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "ios/chrome/browser/ui/settings/sync/utils/sync_error_infobar_delegate.h"
#import "ios/chrome/browser/settings/sync/utils/sync_error_infobar_delegate.h"

#import <UIKit/UIKit.h>

Expand All @@ -19,11 +19,11 @@
#import "ios/chrome/browser/infobars/infobar_ios.h"
#import "ios/chrome/browser/infobars/infobar_type.h"
#import "ios/chrome/browser/infobars/infobar_utils.h"
#import "ios/chrome/browser/settings/sync/utils/sync_presenter.h"
#import "ios/chrome/browser/settings/sync/utils/sync_util.h"
#import "ios/chrome/browser/shared/model/browser_state/chrome_browser_state.h"
#import "ios/chrome/browser/shared/ui/symbols/symbols.h"
#import "ios/chrome/browser/sync/sync_service_factory.h"
#import "ios/chrome/browser/ui/settings/sync/utils/sync_presenter.h"
#import "ios/chrome/browser/ui/settings/sync/utils/sync_util.h"
#import "ios/chrome/common/ui/colors/semantic_color_names.h"
#import "ui/base/models/image_model.h"

Expand Down Expand Up @@ -175,14 +175,16 @@
void SyncErrorInfoBarDelegate::OnStateChanged(syncer::SyncService* sync) {
// If the inforbar is in the process of being removed, nothing must be done.
infobars::InfoBar* infobar = this->infobar();
if (!infobar)
if (!infobar) {
return;
}
syncer::SyncService* sync_service =
SyncServiceFactory::GetForBrowserState(browser_state_);
syncer::SyncService::UserActionableError new_error_state =
sync_service->GetUserActionableError();
if (error_state_ == new_error_state)
if (error_state_ == new_error_state) {
return;
}
error_state_ = new_error_state;
if (new_error_state == syncer::SyncService::UserActionableError::kNone) {
infobar->RemoveSelf();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "ios/chrome/browser/ui/settings/sync/utils/sync_error_infobar_delegate.h"
#import "ios/chrome/browser/settings/sync/utils/sync_error_infobar_delegate.h"

#import <memory>

Expand All @@ -11,12 +11,12 @@
#import "components/sync/test/mock_sync_service.h"
#import "ios/chrome/browser/infobars/infobar_ios.h"
#import "ios/chrome/browser/infobars/infobar_utils.h"
#import "ios/chrome/browser/settings/sync/utils/sync_presenter.h"
#import "ios/chrome/browser/shared/model/browser_state/test_chrome_browser_state.h"
#import "ios/chrome/browser/shared/public/features/features.h"
#import "ios/chrome/browser/shared/ui/symbols/symbols.h"
#import "ios/chrome/browser/sync/mock_sync_service_utils.h"
#import "ios/chrome/browser/sync/sync_service_factory.h"
#import "ios/chrome/browser/ui/settings/sync/utils/sync_presenter.h"
#import "ios/chrome/common/ui/colors/semantic_color_names.h"
#import "ios/web/public/test/web_task_environment.h"
#import "testing/gtest_mac.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef IOS_CHROME_BROWSER_UI_SETTINGS_SYNC_UTILS_SYNC_PRESENTER_H_
#define IOS_CHROME_BROWSER_UI_SETTINGS_SYNC_UTILS_SYNC_PRESENTER_H_
#ifndef IOS_CHROME_BROWSER_SETTINGS_SYNC_UTILS_SYNC_PRESENTER_H_
#define IOS_CHROME_BROWSER_SETTINGS_SYNC_UTILS_SYNC_PRESENTER_H_

#import <Foundation/Foundation.h>

Expand Down Expand Up @@ -39,4 +39,4 @@ enum class TrustedVaultUserActionTriggerForUMA;

@end

#endif // IOS_CHROME_BROWSER_UI_SETTINGS_SYNC_UTILS_SYNC_PRESENTER_H_
#endif // IOS_CHROME_BROWSER_SETTINGS_SYNC_UTILS_SYNC_PRESENTER_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef IOS_CHROME_BROWSER_UI_SETTINGS_SYNC_UTILS_SYNC_UTIL_H_
#define IOS_CHROME_BROWSER_UI_SETTINGS_SYNC_UTILS_SYNC_UTIL_H_
#ifndef IOS_CHROME_BROWSER_SETTINGS_SYNC_UTILS_SYNC_UTIL_H_
#define IOS_CHROME_BROWSER_SETTINGS_SYNC_UTILS_SYNC_UTIL_H_

#import <Foundation/Foundation.h>

Expand Down Expand Up @@ -47,4 +47,4 @@ bool DisplaySyncErrors(ChromeBrowserState* browser_state,
web::WebState* web_state,
id<SyncPresenter> presenter);

#endif // IOS_CHROME_BROWSER_UI_SETTINGS_SYNC_UTILS_SYNC_UTIL_H_
#endif // IOS_CHROME_BROWSER_SETTINGS_SYNC_UTILS_SYNC_UTIL_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "ios/chrome/browser/ui/settings/sync/utils/sync_util.h"
#import "ios/chrome/browser/settings/sync/utils/sync_util.h"

#import "base/feature_list.h"
#import "base/metrics/histogram_macros.h"
Expand All @@ -15,15 +15,14 @@
#import "ios/chrome/browser/infobars/infobar_manager_impl.h"
#import "ios/chrome/browser/settings/sync/utils/account_error_ui_info.h"
#import "ios/chrome/browser/settings/sync/utils/identity_error_util.h"
#import "ios/chrome/browser/settings/sync/utils/sync_error_infobar_delegate.h"
#import "ios/chrome/browser/shared/model/browser/browser.h"
#import "ios/chrome/browser/shared/model/browser_state/chrome_browser_state.h"
#import "ios/chrome/browser/shared/public/commands/application_commands.h"
#import "ios/chrome/browser/shared/public/commands/browsing_data_commands.h"
#import "ios/chrome/browser/shared/public/commands/show_signin_command.h"
#import "ios/chrome/browser/signin/identity_manager_factory.h"
#import "ios/chrome/browser/sync/sync_service_factory.h"
#import "ios/chrome/browser/ui/settings/settings_root_view_controlling.h"
#import "ios/chrome/browser/ui/settings/sync/utils/sync_error_infobar_delegate.h"
#import "ios/chrome/grit/ios_chromium_strings.h"
#import "ios/chrome/grit/ios_strings.h"
#import "ui/base/l10n/l10n_util.h"
Expand Down Expand Up @@ -287,8 +286,9 @@ bool DisplaySyncErrors(ChromeBrowserState* browser_state,
web::WebState* web_state,
id<SyncPresenter> presenter) {
// Avoid displaying sync errors on incognito tabs.
if (browser_state->IsOffTheRecord())
if (browser_state->IsOffTheRecord()) {
return false;
}

syncer::SyncService* syncService =
SyncServiceFactory::GetForBrowserState(browser_state);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@ source_set("test") {
configs += [ "//build/config/compiler:enable_arc" ]

deps = [
"//base",
"//components/infobars/core",
"//ios/chrome/browser/infobars",
"//ios/chrome/browser/infobars:public",
"//ios/chrome/browser/infobars/test",
"//ios/chrome/browser/ui/infobars/test",
"//ios/chrome/browser/ui/settings/sync/utils",
"//ios/chrome/browser/settings/sync/utils",
"//testing/gmock",
"//ui/base",
"//ui/gfx",
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef IOS_CHROME_BROWSER_UI_SETTINGS_SYNC_UTILS_TEST_MOCK_SYNC_ERROR_INFOBAR_DELEGATE_H_
#define IOS_CHROME_BROWSER_UI_SETTINGS_SYNC_UTILS_TEST_MOCK_SYNC_ERROR_INFOBAR_DELEGATE_H_
#ifndef IOS_CHROME_BROWSER_SETTINGS_SYNC_UTILS_TEST_MOCK_SYNC_ERROR_INFOBAR_DELEGATE_H_
#define IOS_CHROME_BROWSER_SETTINGS_SYNC_UTILS_TEST_MOCK_SYNC_ERROR_INFOBAR_DELEGATE_H_

#import <UIKit/UIKit.h>
#import <string>

#import "ios/chrome/browser/ui/settings/sync/utils/sync_error_infobar_delegate.h"
#import "ios/chrome/browser/settings/sync/utils/sync_error_infobar_delegate.h"
#import "testing/gmock/include/gmock/gmock.h"
#import "ui/base/models/image_model.h"

Expand Down Expand Up @@ -39,4 +39,4 @@ class MockSyncErrorInfoBarDelegate : public SyncErrorInfoBarDelegate {
MOCK_METHOD(ui::ImageModel, GetIcon, (), (const, override));
};

#endif // IOS_CHROME_BROWSER_UI_SETTINGS_SYNC_UTILS_TEST_MOCK_SYNC_ERROR_INFOBAR_DELEGATE_H_
#endif // IOS_CHROME_BROWSER_SETTINGS_SYNC_UTILS_TEST_MOCK_SYNC_ERROR_INFOBAR_DELEGATE_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "ios/chrome/browser/ui/settings/sync/utils/test/mock_sync_error_infobar_delegate.h"
#import "ios/chrome/browser/settings/sync/utils/test/mock_sync_error_infobar_delegate.h"

#import "ui/gfx/image/image.h"

Expand Down
2 changes: 1 addition & 1 deletion ios/chrome/browser/sync/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ source_set("sync_error_browser_agent") {
"sync_error_browser_agent.mm",
]
deps = [
"//ios/chrome/browser/settings/sync/utils",
"//ios/chrome/browser/shared/model/browser",
"//ios/chrome/browser/shared/model/browser_state",
"//ios/chrome/browser/shared/model/web_state_list",
"//ios/chrome/browser/shared/ui/util",
"//ios/chrome/browser/ui/authentication",
"//ios/chrome/browser/ui/authentication:signin_presenter",
"//ios/chrome/browser/ui/settings/sync/utils",
"//ui/base",
]
frameworks = [ "UIKit.framework" ]
Expand Down
2 changes: 1 addition & 1 deletion ios/chrome/browser/sync/sync_error_browser_agent.mm
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

#import "ios/chrome/browser/sync/sync_error_browser_agent.h"

#import "ios/chrome/browser/settings/sync/utils/sync_util.h"
#import "ios/chrome/browser/shared/model/browser_state/chrome_browser_state.h"
#import "ios/chrome/browser/shared/model/web_state_list/web_state_list.h"
#import "ios/chrome/browser/ui/authentication/re_signin_infobar_delegate.h"
#import "ios/chrome/browser/ui/authentication/signin_presenter.h"
#import "ios/chrome/browser/ui/settings/sync/utils/sync_util.h"

#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
Expand Down

0 comments on commit 33ea99e

Please sign in to comment.