summaryrefslogtreecommitdiffstats
path: root/ios
diff options
context:
space:
mode:
authoreugenebut <eugenebut@chromium.org>2016-03-23 18:53:01 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-24 01:54:37 +0000
commitd5712882a2a58be42d3d37b2cb3ef82d555ff22d (patch)
tree5d15550feee0b115918e1c7f2967aa29e1d10ca8 /ios
parent52d7cf606132f69666cc445621db0a0f19e99ecb (diff)
downloadchromium_src-d5712882a2a58be42d3d37b2cb3ef82d555ff22d.zip
chromium_src-d5712882a2a58be42d3d37b2cb3ef82d555ff22d.tar.gz
chromium_src-d5712882a2a58be42d3d37b2cb3ef82d555ff22d.tar.bz2
[ios] Removed unused UIWebView code.
Removed: - TestWebClient::SetUserAgent - BuildAndRegisterUserAgentForUIWebView - CRWRecurringTaskDelegate - CreateWebView BUG=579697 Review URL: https://codereview.chromium.org/1833603002 Cr-Commit-Position: refs/heads/master@{#383011}
Diffstat (limited to 'ios')
-rw-r--r--ios/web/BUILD.gn1
-rw-r--r--ios/web/ios_web.gyp1
-rw-r--r--ios/web/public/test/test_web_client.h8
-rw-r--r--ios/web/public/test/test_web_client.mm12
-rw-r--r--ios/web/ui_web_view_util.h6
-rw-r--r--ios/web/ui_web_view_util.mm25
-rw-r--r--ios/web/ui_web_view_util_unittest.mm41
-rw-r--r--ios/web/web_state/crw_recurring_task_delegate.h16
-rw-r--r--ios/web/web_state/web_view_internal_creation_util.h9
-rw-r--r--ios/web/web_state/web_view_internal_creation_util.mm9
-rw-r--r--ios/web/web_state/web_view_internal_creation_util_unittest.mm42
11 files changed, 4 insertions, 166 deletions
diff --git a/ios/web/BUILD.gn b/ios/web/BUILD.gn
index d1858ca..fcec097 100644
--- a/ios/web/BUILD.gn
+++ b/ios/web/BUILD.gn
@@ -188,7 +188,6 @@ source_set("web") {
"web_state/credential.cc",
"web_state/crw_pass_kit_downloader.h",
"web_state/crw_pass_kit_downloader.mm",
- "web_state/crw_recurring_task_delegate.h",
"web_state/crw_web_view_proxy_impl.h",
"web_state/crw_web_view_proxy_impl.mm",
"web_state/crw_web_view_scroll_view_proxy.mm",
diff --git a/ios/web/ios_web.gyp b/ios/web/ios_web.gyp
index 4797b93..df99221 100644
--- a/ios/web/ios_web.gyp
+++ b/ios/web/ios_web.gyp
@@ -224,7 +224,6 @@
'web_state/credential.cc',
'web_state/crw_pass_kit_downloader.h',
'web_state/crw_pass_kit_downloader.mm',
- 'web_state/crw_recurring_task_delegate.h',
'web_state/crw_web_view_proxy_impl.h',
'web_state/crw_web_view_proxy_impl.mm',
'web_state/crw_web_view_scroll_view_proxy.mm',
diff --git a/ios/web/public/test/test_web_client.h b/ios/web/public/test/test_web_client.h
index 8bb575d..1172ba6 100644
--- a/ios/web/public/test/test_web_client.h
+++ b/ios/web/public/test/test_web_client.h
@@ -20,22 +20,14 @@ class TestWebClient : public web::WebClient {
TestWebClient();
~TestWebClient() override;
// WebClient implementation.
- std::string GetUserAgent(bool is_desktop_user_agent) const override;
NSString* GetEarlyPageScript(web::WebViewType web_view_type) const override;
bool WebViewsNeedActiveStateManager() const override;
- // Changes the user agent for testing purposes. Passing true
- // for |is_desktop_user_agent| affects the result of GetUserAgent(true) call.
- // Passing false affects the result of GetUserAgent(false).
- void SetUserAgent(const std::string& user_agent, bool is_desktop_user_agent);
-
// Changes Early Page Script for testing purposes.
void SetEarlyPageScript(NSString* page_script,
web::WebViewType web_view_type);
private:
- std::string user_agent_;
- std::string desktop_user_agent_;
base::scoped_nsobject<NSMutableDictionary> early_page_scripts_;
};
diff --git a/ios/web/public/test/test_web_client.mm b/ios/web/public/test/test_web_client.mm
index 808f6f2..4d7addf 100644
--- a/ios/web/public/test/test_web_client.mm
+++ b/ios/web/public/test/test_web_client.mm
@@ -15,18 +15,6 @@ TestWebClient::TestWebClient()
TestWebClient::~TestWebClient() {
}
-std::string TestWebClient::GetUserAgent(bool desktop_user_agent) const {
- return desktop_user_agent ? desktop_user_agent_ : user_agent_;
-}
-
-void TestWebClient::SetUserAgent(const std::string& user_agent,
- bool is_desktop_user_agent) {
- if (is_desktop_user_agent)
- desktop_user_agent_ = user_agent;
- else
- user_agent_ = user_agent;
-}
-
NSString* TestWebClient::GetEarlyPageScript(
web::WebViewType web_view_type) const {
NSString* result = [early_page_scripts_ objectForKey:@(web_view_type)];
diff --git a/ios/web/ui_web_view_util.h b/ios/web/ui_web_view_util.h
index 46b36ab..9299de2 100644
--- a/ios/web/ui_web_view_util.h
+++ b/ios/web/ui_web_view_util.h
@@ -9,12 +9,6 @@
namespace web {
-// Registers the user agent encoding |request_group_id| in the user defaults.
-// This is a utility method, used to workaround crbug.com/228397. Do not use
-// it for other purposes.
-void BuildAndRegisterUserAgentForUIWebView(NSString* request_group_id,
- BOOL use_desktop_user_agent);
-
// Registers |user_agent| as the user agent string to be used by the UIWebView
// instances that are created from now on.
void RegisterUserAgentForUIWebView(NSString* user_agent);
diff --git a/ios/web/ui_web_view_util.mm b/ios/web/ui_web_view_util.mm
index 35c6347..8be5f51 100644
--- a/ios/web/ui_web_view_util.mm
+++ b/ios/web/ui_web_view_util.mm
@@ -4,33 +4,8 @@
#import "ios/web/ui_web_view_util.h"
-#include "base/logging.h"
-#include "base/mac/scoped_nsobject.h"
-#include "base/strings/sys_string_conversions.h"
-#include "ios/web/net/request_group_util.h"
-#include "ios/web/public/web_client.h"
-
-namespace {
-// Returns true if given Request Group ID string contains only decimal digits.
-BOOL IsValidRequestGroupID(NSString* request_group_id) {
- return [[NSCharacterSet decimalDigitCharacterSet] isSupersetOfSet:
- [NSCharacterSet characterSetWithCharactersInString:request_group_id]];
-}
-} // namespace
-
namespace web {
-void BuildAndRegisterUserAgentForUIWebView(NSString* request_group_id,
- BOOL use_desktop_user_agent) {
- DCHECK(!request_group_id || IsValidRequestGroupID(request_group_id));
- DCHECK(web::GetWebClient());
- std::string baseUserAgent = web::GetWebClient()->GetUserAgent(
- use_desktop_user_agent);
- web::RegisterUserAgentForUIWebView(
- web::AddRequestGroupIDToUserAgent(base::SysUTF8ToNSString(baseUserAgent),
- request_group_id));
-}
-
void RegisterUserAgentForUIWebView(NSString* user_agent) {
[[NSUserDefaults standardUserDefaults] registerDefaults:@{
@"UserAgent" : user_agent
diff --git a/ios/web/ui_web_view_util_unittest.mm b/ios/web/ui_web_view_util_unittest.mm
index fd2841c..cae48bb 100644
--- a/ios/web/ui_web_view_util_unittest.mm
+++ b/ios/web/ui_web_view_util_unittest.mm
@@ -4,55 +4,22 @@
#import "ios/web/ui_web_view_util.h"
-#include "ios/web/public/test/scoped_testing_web_client.h"
-#import "ios/web/public/test/test_web_client.h"
#include "testing/gtest_mac.h"
-#include "testing/platform_test.h"
namespace {
-
// Returns user agent string registered for UIWebView.
NSString* GetUserAgent() {
return [[NSUserDefaults standardUserDefaults] stringForKey:@"UserAgent"];
}
+} // namespace
-class UIWebViewUtilTest : public PlatformTest {
- public:
- UIWebViewUtilTest() : web_client_(make_scoped_ptr(new web::TestWebClient)) {}
-
- protected:
- void SetUp() override {
- PlatformTest::SetUp();
- test_web_client()->SetUserAgent("DesktopUA", true);
- test_web_client()->SetUserAgent("RegularUA", false);
- }
-
- web::TestWebClient* test_web_client() {
- return static_cast<web::TestWebClient*>(web_client_.Get());
- }
-
- private:
- // WebClient that returns test user agent.
- web::ScopedTestingWebClient web_client_;
-};
-
-// Tests registration of a non-desktop user agent.
-TEST_F(UIWebViewUtilTest, BuildAndRegisterNonDesktopUserAgentForUIWebView) {
- web::BuildAndRegisterUserAgentForUIWebView(@"1231546541321", NO);
- EXPECT_NSEQ(@"RegularUA (1231546541321)", GetUserAgent());
-}
-
-// Tests registration of a desktop user agent.
-TEST_F(UIWebViewUtilTest, BuildAndRegisterDesktopUserAgentForUIWebView) {
- web::BuildAndRegisterUserAgentForUIWebView(@"1231546541321", YES);
- EXPECT_NSEQ(@"DesktopUA (1231546541321)", GetUserAgent());
-}
+namespace web {
// Tests web::RegisterUserAgentForUIWebView function that it correctly registers
// arbitrary user agent.
-TEST_F(UIWebViewUtilTest, RegisterUserAgentForUIWebView) {
+TEST(UIWebViewUtilTest, RegisterUserAgentForUIWebView) {
web::RegisterUserAgentForUIWebView(@"UA");
EXPECT_NSEQ(@"UA", GetUserAgent());
}
-} // namespace
+} // namespace web
diff --git a/ios/web/web_state/crw_recurring_task_delegate.h b/ios/web/web_state/crw_recurring_task_delegate.h
deleted file mode 100644
index 12d6fd8f..0000000
--- a/ios/web/web_state/crw_recurring_task_delegate.h
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef IOS_WEB_WEB_STATE_CRW_RECURRING_TASK_DELEGATE_H_
-#define IOS_WEB_WEB_STATE_CRW_RECURRING_TASK_DELEGATE_H_
-
-// A delegate object to run some recurring task.
-@protocol CRWRecurringTaskDelegate
-
-// Runs a recurring task.
-- (void)runRecurringTask;
-
-@end
-
-#endif // IOS_WEB_WEB_STATE_CRW_RECURRING_TASK_DELEGATE_H_
diff --git a/ios/web/web_state/web_view_internal_creation_util.h b/ios/web/web_state/web_view_internal_creation_util.h
index 74b0c2d..96263da 100644
--- a/ios/web/web_state/web_view_internal_creation_util.h
+++ b/ios/web/web_state/web_view_internal_creation_util.h
@@ -15,15 +15,6 @@
namespace web {
class BrowserState;
-// Returns a new UIWebView for displaying regular web content and registers a
-// user agent for it. The returned UIWebView will have a user agent string that
-// includes the |request_group_id|.
-// Note: Callers are responsible for releasing the returned UIWebView.
-// DEPRECATED: Please use the WKWebView equivalent instead.
-UIWebView* CreateWebView(CGRect frame,
- NSString* request_group_id,
- BOOL use_desktop_user_agent);
-
// Returns a new UIWebView for displaying regular web content.
// Note: Callers are responsible for releasing the returned UIWebView.
// DEPRECATED: Please use the WKWebView equivalent instead.
diff --git a/ios/web/web_state/web_view_internal_creation_util.mm b/ios/web/web_state/web_view_internal_creation_util.mm
index 000da7d..c68c6fd 100644
--- a/ios/web/web_state/web_view_internal_creation_util.mm
+++ b/ios/web/web_state/web_view_internal_creation_util.mm
@@ -17,7 +17,6 @@
#include "ios/web/public/web_client.h"
#import "ios/web/public/web_view_counter.h"
#import "ios/web/public/web_view_creation_util.h"
-#include "ios/web/ui_web_view_util.h"
#import "ios/web/weak_nsobject_counter.h"
#import "ios/web/web_state/ui/crw_wk_simple_web_view_controller.h"
#import "ios/web/web_state/ui/wk_web_view_configuration_provider.h"
@@ -119,14 +118,6 @@ void PostWKWebViewCreation(WKWebView* web_view, BrowserState* browser_state) {
} // namespace
-UIWebView* CreateWebView(CGRect frame,
- NSString* request_group_id,
- BOOL use_desktop_user_agent) {
- web::BuildAndRegisterUserAgentForUIWebView(request_group_id,
- use_desktop_user_agent);
- return web::CreateWebView(frame);
-}
-
UIWebView* CreateWebView(CGRect frame) {
DCHECK(web::GetWebClient());
web::GetWebClient()->PreWebViewCreation();
diff --git a/ios/web/web_state/web_view_internal_creation_util_unittest.mm b/ios/web/web_state/web_view_internal_creation_util_unittest.mm
index 6616a28..cbdf247 100644
--- a/ios/web/web_state/web_view_internal_creation_util_unittest.mm
+++ b/ios/web/web_state/web_view_internal_creation_util_unittest.mm
@@ -22,21 +22,10 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest_mac.h"
-@interface CRWStaticFileWebView (Testing)
-+ (BOOL)isStaticFileUserAgent:(NSString*)userAgent;
-@end
-
namespace web {
namespace {
const CGRect kTestFrame = CGRectMake(5.0f, 10.0f, 15.0f, 20.0f);
-NSString* const kTestRequestGroupID = @"100042";
-
-// Returns user agent for given UIWebView.
-NSString* GetWebViewUserAgent(UIWebView* web_view) {
- NSString* const kGetUserAgentJS = @"navigator.userAgent";
- return [web_view stringByEvaluatingJavaScriptFromString:kGetUserAgentJS];
-}
// A WebClient that stubs PreWebViewCreation/PostWebViewCreation calls for
// testing purposes.
@@ -59,7 +48,6 @@ class WebViewCreationUtilsTest : public WebTest {
WebTest::SetUp();
logJavaScriptPref_ =
[[NSUserDefaults standardUserDefaults] boolForKey:@"LogJavascript"];
- creation_utils_web_client()->SetUserAgent("TestUA", false);
}
void TearDown() override {
[[NSUserDefaults standardUserDefaults] setBool:logJavaScriptPref_
@@ -83,36 +71,6 @@ class WebViewCreationUtilsTest : public WebTest {
web::ScopedTestingWebClient web_client_;
};
-// Tests that a web view created with a certain id returns the same
-// requestGroupID in the user agent string.
-TEST_F(WebViewCreationUtilsTest, CreationWithRequestGroupID) {
- UIWebView* captured_web_view = nil;
- ExpectWebClientCalls(&captured_web_view);
-
- base::scoped_nsobject<UIWebView> web_view(
- CreateWebView(kTestFrame, kTestRequestGroupID, NO));
- EXPECT_TRUE([web_view isMemberOfClass:[UIWebView class]]);
- EXPECT_TRUE(CGRectEqualToRect(kTestFrame, [web_view frame]));
- EXPECT_NSEQ(web_view, captured_web_view);
-
- NSString* const kExpectedUserAgent =
- [NSString stringWithFormat:@"TestUA (%@)", kTestRequestGroupID];
- NSString* const kActualUserAgent = GetWebViewUserAgent(web_view);
- EXPECT_NSEQ(kExpectedUserAgent, kActualUserAgent);
- EXPECT_TRUE([ExtractRequestGroupIDFromUserAgent(kActualUserAgent)
- isEqualToString:kTestRequestGroupID]);
-}
-
-// Tests that a web view not created for displaying static file content from
-// the application bundle does not return a user agent that allows static file
-// content display.
-TEST_F(WebViewCreationUtilsTest, CRWStaticFileWebViewFalse) {
- base::scoped_nsobject<UIWebView> web_view(
- CreateWebView(CGRectZero, kTestRequestGroupID, NO));
- EXPECT_FALSE([CRWStaticFileWebView
- isStaticFileUserAgent:GetWebViewUserAgent(web_view)]);
-}
-
// Tests web::CreateWebView function that it correctly returns a UIWebView with
// the correct frame and calls WebClient::PreWebViewCreation/
// WebClient::PostWebViewCreation methods.