Skip to content

Commit

Permalink
[iOS] Fix bad import
Browse files Browse the repository at this point in the history
This import was not needed and added a forbidden dependency.

Bug: None
Change-Id: Id3c6ad4f9b987c9609c79cc563260f96e2d36345
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5830793
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: Sylvain Defresne <sdefresne@chromium.org>
Auto-Submit: Aliona Dangla <alionadangla@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#1350744}
  • Loading branch information
adangla authored and pull[bot] committed Sep 7, 2024
1 parent e226967 commit 1024981
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 27 deletions.
5 changes: 1 addition & 4 deletions ios/chrome/browser/device_sharing/model/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ source_set("eg_test_support+eg2") {
"handoff_manager_app_interface.h",
"handoff_manager_app_interface_stub.mm",
]
deps = [
"//ios/chrome/browser/shared/model/profile:forward",
"//ios/testing/earl_grey:eg_test_support+eg2",
]
deps = [ "//ios/testing/earl_grey:eg_test_support+eg2" ]
}

source_set("eg2_tests") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#ifndef IOS_CHROME_BROWSER_DEVICE_SHARING_MODEL_DEVICE_SHARING_MANAGER_IMPL_H_
#define IOS_CHROME_BROWSER_DEVICE_SHARING_MODEL_DEVICE_SHARING_MANAGER_IMPL_H_

#import <Foundation/Foundation.h>

#import <memory>

#import "base/gtest_prod_util.h"
Expand All @@ -18,7 +20,7 @@ class Browser;

class DeviceSharingManagerImpl : public DeviceSharingManager {
public:
explicit DeviceSharingManagerImpl(ChromeBrowserState* browser_state);
explicit DeviceSharingManagerImpl(ProfileIOS* profile);

// Not copyable or moveable.
DeviceSharingManagerImpl(const DeviceSharingManagerImpl&) = delete;
Expand All @@ -35,13 +37,13 @@ class DeviceSharingManagerImpl : public DeviceSharingManager {
// Allow tests to inspect the handoff manager.
friend class DeviceSharingManagerImplTest;
friend class DeviceSharingBrowserAgentTest;
friend class DeviceSharingAppInterfaceWrapper;
friend NSURL* GetCurrentUserActivityURL(ProfileIOS* profile);

void UpdateHandoffManager();

raw_ptr<ChromeBrowserState> browser_state_ = nullptr;
raw_ptr<ProfileIOS> profile_ = nullptr;

// Registrar for pref change notifications to the active browser state.
// Registrar for pref change notifications to the active profile.
PrefChangeRegistrar prefs_change_observer_;

// Responsible for maintaining all state related to the Handoff feature.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
#import "components/prefs/pref_service.h"
#import "ios/chrome/browser/shared/model/profile/profile_ios.h"

DeviceSharingManagerImpl::DeviceSharingManagerImpl(
ChromeBrowserState* browser_state)
: browser_state_(browser_state) {
DCHECK(!browser_state || !browser_state->IsOffTheRecord());
prefs_change_observer_.Init(browser_state_->GetPrefs());
DeviceSharingManagerImpl::DeviceSharingManagerImpl(ProfileIOS* profile)
: profile_(profile) {
DCHECK(!profile || !profile->IsOffTheRecord());
prefs_change_observer_.Init(profile_->GetPrefs());
prefs_change_observer_.Add(
prefs::kIosHandoffToOtherDevices,
base::BindRepeating(&DeviceSharingManagerImpl::UpdateHandoffManager,
Expand Down Expand Up @@ -59,8 +58,7 @@
}

void DeviceSharingManagerImpl::UpdateHandoffManager() {
if (!browser_state_->GetPrefs()->GetBoolean(
prefs::kIosHandoffToOtherDevices)) {
if (!profile_->GetPrefs()->GetBoolean(prefs::kIosHandoffToOtherDevices)) {
handoff_manager_ = nil;
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@

#import <UIKit/UIKit.h>

#import "ios/chrome/browser/shared/model/profile/profile_ios_forward.h"

class DeviceSharingAppInterfaceWrapper {
public:
static NSURL* GetCurrentUserActivityURL(ChromeBrowserState* browser_state);
};

// The app interface for handoff tests.
@interface HandoffManagerAppInterface : NSObject

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,17 @@
#import "ios/chrome/browser/device_sharing/model/device_sharing_manager_impl.h"
#import "ios/chrome/test/app/chrome_test_util.h"

NSURL* DeviceSharingAppInterfaceWrapper::GetCurrentUserActivityURL(
ChromeBrowserState* browser_state) {
NSURL* GetCurrentUserActivityURL(ProfileIOS* profile) {
DeviceSharingManagerImpl* sharing_manager =
static_cast<DeviceSharingManagerImpl*>(
DeviceSharingManagerFactory::GetForBrowserState(browser_state));
DeviceSharingManagerFactory::GetForBrowserState(profile));
return [sharing_manager->handoff_manager_ userActivityWebpageURL];
}

@implementation HandoffManagerAppInterface

+ (NSURL*)currentUserActivityWebPageURL {
return DeviceSharingAppInterfaceWrapper::GetCurrentUserActivityURL(
chrome_test_util::GetOriginalBrowserState());
return GetCurrentUserActivityURL(chrome_test_util::GetOriginalBrowserState());
}

@end

0 comments on commit 1024981

Please sign in to comment.