diff options
author | eugenebut <eugenebut@chromium.org> | 2015-03-05 12:04:36 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-05 20:05:51 +0000 |
commit | f3d7f05f224060166db019f7e1eddeadee13f0ff (patch) | |
tree | f3d77732b71f268cae87fa9d6ad9be94dc37f86e /ios | |
parent | 3b53888c71b8eb36138f40f3ec3865bdc340c80a (diff) | |
download | chromium_src-f3d7f05f224060166db019f7e1eddeadee13f0ff.zip chromium_src-f3d7f05f224060166db019f7e1eddeadee13f0ff.tar.gz chromium_src-f3d7f05f224060166db019f7e1eddeadee13f0ff.tar.bz2 |
Fixed dependencies for JsLanguageDetectionManager.
Made JsLanguageDetectionManager depend on CRWJSEarlyScriptManager,
instead of CRWJSBaseManager and CRWJSMessageManager.
Embedded's JS managers should not depend any other managers except
CRWJSEarlyScriptManager.
Also upstreamed modified CRWJSEarlyScriptManager.
BUG=449203
Review URL: https://codereview.chromium.org/981673002
Cr-Commit-Position: refs/heads/master@{#319310}
Diffstat (limited to 'ios')
-rw-r--r-- | ios/web/ios_web.gyp | 2 | ||||
-rw-r--r-- | ios/web/public/web_state/js/crw_js_early_script_manager.h | 23 | ||||
-rw-r--r-- | ios/web/web_state/js/crw_js_early_script_manager.mm | 59 |
3 files changed, 84 insertions, 0 deletions
diff --git a/ios/web/ios_web.gyp b/ios/web/ios_web.gyp index 7e67484..f387fcc 100644 --- a/ios/web/ios_web.gyp +++ b/ios/web/ios_web.gyp @@ -42,6 +42,7 @@ 'public/web_client.cc', 'public/web_client.h', 'public/web_state/js/crw_js_base_manager.h', + 'public/web_state/js/crw_js_early_script_manager.h', 'public/web_state/js/crw_js_injection_evaluator.h', 'public/web_state/js/crw_js_injection_manager.h', 'public/web_state/js/crw_js_injection_receiver.h', @@ -53,6 +54,7 @@ 'web_state/js/crw_js_base_manager.mm', 'web_state/js/crw_js_common_manager.h', 'web_state/js/crw_js_common_manager.mm', + 'web_state/js/crw_js_early_script_manager.mm', 'web_state/js/crw_js_injection_manager.mm', 'web_state/js/crw_js_injection_receiver.mm', 'web_state/js/crw_js_message_dynamic_manager.h', diff --git a/ios/web/public/web_state/js/crw_js_early_script_manager.h b/ios/web/public/web_state/js/crw_js_early_script_manager.h new file mode 100644 index 0000000..356c2f0 --- /dev/null +++ b/ios/web/public/web_state/js/crw_js_early_script_manager.h @@ -0,0 +1,23 @@ +// Copyright 2014 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_PUBLIC_WEB_STATE_JS_CRW_JS_EARLY_SCRIPT_MANAGER_H_ +#define IOS_WEB_PUBLIC_WEB_STATE_JS_CRW_JS_EARLY_SCRIPT_MANAGER_H_ + +#import "ios/web/public/web_state/js/crw_js_injection_manager.h" + +// Manager to handle all the scripts that need to be injected before the page +// scripts take effect. Includes the base scripts and any feature scripts +// that might need to perform global actions such as overriding HTML methods. +@interface CRWJSEarlyScriptManager : CRWJSInjectionManager + +// Adds a |JsInjectionManager| class that should be injected ASAP to pages. +- (void)addDependency:(Class)scriptManager; + +// Removes a class added previously with |addDependency|. +- (void)removeDependency:(Class)scriptManager; + +@end + +#endif // IOS_WEB_PUBLIC_WEB_STATE_JS_CRW_JS_EARLY_SCRIPT_MANAGER_H_ diff --git a/ios/web/web_state/js/crw_js_early_script_manager.mm b/ios/web/web_state/js/crw_js_early_script_manager.mm new file mode 100644 index 0000000..d8a87f3 --- /dev/null +++ b/ios/web/web_state/js/crw_js_early_script_manager.mm @@ -0,0 +1,59 @@ +// Copyright 2014 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. + +#import "ios/web/public/web_state/js/crw_js_early_script_manager.h" + +#import "base/mac/scoped_nsobject.h" +#import "ios/web/public/web_state/js/crw_js_base_manager.h" +#include "ios/web/public/web_state/js/crw_js_injection_receiver.h" +#import "ios/web/public/web_state/js/crw_js_message_manager.h" + +@interface CRWJSEarlyScriptManager () { + base::scoped_nsobject<NSMutableSet> _dependencies; +} +@end + +@implementation CRWJSEarlyScriptManager + +#pragma mark - Protected Methods + +- (id)initWithReceiver:(CRWJSInjectionReceiver*)receiver { + self = [super initWithReceiver:receiver]; + if (self) { + _dependencies.reset([[NSMutableSet alloc] initWithArray:@[ + // TODO(eugenebut): update with correct dependencies when they are + // upstreamed. + [CRWJSBaseManager class], + [CRWJSMessageManager class], + ]]); + } + return self; +} + +- (NSString*)staticInjectionContent { + // Early Script Manager does not supply any scripts of its own. Rather it uses + // its dependencies to ensure all relevant script content is injected into + // pages. + return @""; +} + +- (NSString*)presenceBeacon { + return @"__gCrWeb"; +} + +- (NSArray*)directDependencies { + return [_dependencies allObjects]; +} + +- (void)addDependency:(Class)scriptManager { + [_dependencies addObject:scriptManager]; +} + +- (void)removeDependency:(Class)scriptManager { + [_dependencies removeObject:scriptManager]; +} + +#pragma mark - + +@end |