0

ios: Minor ContentWebState fixes.

Change-Id: I51fa331e53b71d970ef0c0065ae4028bc7eb5b23
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4295248
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Rohit Rao <rohitrao@chromium.org>
Auto-Submit: Justin Cohen <justincohen@chromium.org>
Commit-Queue: Rohit Rao <rohitrao@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1111877}
This commit is contained in:
Justin Cohen
2023-03-01 22:47:13 +00:00
committed by Chromium LUCI CQ
parent b91624381e
commit c6f3d173f6
4 changed files with 42 additions and 7 deletions

@ -21,8 +21,10 @@ source_set("content") {
deps = [
"//base",
"//build:blink_buildflags",
"//ios/web/find_in_page:find_in_page",
"//ios/web/public",
"//ios/web/public/favicon",
"//ios/web/public/js_messaging",
"//ios/web/text_fragments:text_fragments",
]
}

@ -11,6 +11,7 @@
#import <UIKit/UIKit.h>
#import "base/observer_list.h"
#import "build/blink_buildflags.h"
#import "ios/web/content/js_messaging/content_web_frames_manager.h"
#import "ios/web/content/navigation/content_navigation_manager.h"
@ -119,6 +120,9 @@ class ContentWebState : public WebState {
private:
UIScrollView* web_view_;
id<CRWWebViewProxy> web_view_proxy_;
NSString* UUID_;
base::ObserverList<WebStatePolicyDecider, true> policy_deciders_;
base::ObserverList<WebStateObserver, true> observers_;
std::unique_ptr<ContentNavigationManager> navigation_manager_;
std::unique_ptr<ContentWebFramesManager> web_frames_manager_;
};

@ -6,7 +6,11 @@
#import "base/strings/utf_string_conversions.h"
#import "ios/web/content/web_state/crc_web_view_proxy_impl.h"
#import "ios/web/find_in_page/java_script_find_in_page_manager_impl.h"
#import "ios/web/public/favicon/favicon_status.h"
#import "ios/web/public/navigation/web_state_policy_decider.h"
#import "ios/web/public/web_state_observer.h"
#import "ios/web/text_fragments/text_fragments_manager_impl.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
@ -26,9 +30,25 @@ ContentWebState::ContentWebState(const CreateParams& params) {
CRCWebViewProxyImpl* proxy = [[CRCWebViewProxyImpl alloc] init];
proxy.contentView = web_view_;
web_view_proxy_ = proxy;
// These should be moved when the are removed from CRWWebController.
web::JavaScriptFindInPageManagerImpl::CreateForWebState(this);
web::TextFragmentsManagerImpl::CreateForWebState(this);
UUID_ = [[NSUUID UUID] UUIDString];
}
ContentWebState::~ContentWebState() {}
ContentWebState::~ContentWebState() {
for (auto& observer : observers_) {
observer.WebStateDestroyed(this);
}
for (auto& observer : policy_deciders_) {
observer.WebStateDestroyed();
}
for (auto& observer : policy_deciders_) {
observer.ResetWebState();
}
}
WebStateDelegate* ContentWebState::GetDelegate() {
return nullptr;
@ -128,7 +148,7 @@ void ContentWebState::LoadData(NSData* data,
void ContentWebState::ExecuteUserJavaScript(NSString* javaScript) {}
NSString* ContentWebState::GetStableIdentifier() const {
return @"content";
return UUID_;
}
const std::string& ContentWebState::GetContentsMimeType() const {
@ -204,9 +224,13 @@ CRWWebViewProxyType ContentWebState::GetWebViewProxy() const {
return web_view_proxy_;
}
void ContentWebState::AddObserver(WebStateObserver* observer) {}
void ContentWebState::AddObserver(WebStateObserver* observer) {
observers_.AddObserver(observer);
}
void ContentWebState::RemoveObserver(WebStateObserver* observer) {}
void ContentWebState::RemoveObserver(WebStateObserver* observer) {
observers_.RemoveObserver(observer);
}
void ContentWebState::CloseWebState() {}
@ -257,9 +281,13 @@ id ContentWebState::GetActivityItem() {
return nil;
}
void ContentWebState::AddPolicyDecider(WebStatePolicyDecider* decider) {}
void ContentWebState::AddPolicyDecider(WebStatePolicyDecider* decider) {
policy_deciders_.AddObserver(decider);
}
void ContentWebState::RemovePolicyDecider(WebStatePolicyDecider* decider) {}
void ContentWebState::RemovePolicyDecider(WebStatePolicyDecider* decider) {
policy_deciders_.RemoveObserver(decider);
}
void ContentWebState::DidChangeVisibleSecurityState() {}

@ -151,8 +151,9 @@ class WebStatePolicyDecider : public base::CheckedObserver {
explicit WebStatePolicyDecider(WebState* web_state);
private:
friend class WebStateImpl;
friend class ContentWebState;
friend class FakeWebState;
friend class WebStateImpl;
// Resets the current web state.
void ResetWebState();