Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(704)

Unified Diff: ios/web/web_state/js/crw_js_invoke_parameter_queue.mm

Issue 1107083002: Upstream more leaf files in ios/web/web_state (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@web-resync
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ios/web/web_state/js/crw_js_invoke_parameter_queue.mm
diff --git a/ios/web/web_state/js/crw_js_invoke_parameter_queue.mm b/ios/web/web_state/js/crw_js_invoke_parameter_queue.mm
new file mode 100644
index 0000000000000000000000000000000000000000..403bcb75a3975ee8d231bae906f58dd4f3134d2b
--- /dev/null
+++ b/ios/web/web_state/js/crw_js_invoke_parameter_queue.mm
@@ -0,0 +1,99 @@
+// 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.
+
+#import "ios/web/web_state/js/crw_js_invoke_parameter_queue.h"
+
+#import "base/mac/scoped_nsobject.h"
+#include "url/gurl.h"
+
+@implementation CRWJSInvokeParameters {
+ base::scoped_nsobject<NSString> _commandString;
+ BOOL _userIsInteracting;
+ base::scoped_nsobject<NSString> _windowId;
+ GURL _originURL;
+}
+
+@synthesize userIsInteracting = _userIsInteracting;
+
+- (id)initWithCommandString:(NSString*)commandString
+ userIsInteracting:(BOOL)userIsInteracting
+ originURL:(const GURL&)originURL
+ forWindowId:(NSString*)windowId {
+ if ((self = [super init])) {
+ _commandString.reset([commandString copy]);
+ _userIsInteracting = userIsInteracting;
+ _windowId.reset([windowId copy]);
+ _originURL = originURL;
+ }
+ return self;
+}
+
+- (NSString*)commandString {
+ return _commandString.get();
+}
+
+- (NSString*)windowId {
+ return _windowId.get();
+}
+
+- (const GURL&)originURL {
+ return _originURL;
+}
+
+@end
+
+@implementation CRWJSInvokeParameterQueue {
+ base::scoped_nsobject<NSMutableArray> _queue;
+}
+
+- (id)init {
+ if ((self = [super init])) {
+ // Under normal circumstainces there will be maximum one message queued.
+ _queue.reset([[NSMutableArray arrayWithCapacity:1] retain]);
+ }
+ return self;
+}
+
+- (BOOL)isEmpty {
+ return [_queue count] == 0;
+}
+
+- (NSUInteger)queueLength {
+ return [_queue count];
+}
+
+- (void)addCommandString:(NSString*)commandString
+ userIsInteracting:(BOOL)userIsInteracting
+ originURL:(const GURL&)originURL
+ forWindowId:(NSString*)windowId {
+ base::scoped_nsobject<CRWJSInvokeParameters> invokeParameters(
+ [[CRWJSInvokeParameters alloc] initWithCommandString:commandString
+ userIsInteracting:userIsInteracting
+ originURL:originURL
+ forWindowId:windowId]);
+ [_queue addObject:invokeParameters];
+}
+
+- (void)removeCommandString:(NSString*)commandString {
+ NSMutableArray* commandsToRemove = [NSMutableArray array];
+ for (CRWJSInvokeParameters* params in _queue.get()) {
+ NSRange range =
+ [[params commandString] rangeOfString:commandString
+ options:NSCaseInsensitiveSearch];
+ if (range.location != NSNotFound)
+ [commandsToRemove addObject:params];
+ }
+ [_queue removeObjectsInArray:commandsToRemove];
+}
+
+- (CRWJSInvokeParameters*)popInvokeParameters {
+ if (![_queue count])
+ return nil;
+ CRWJSInvokeParameters* invokeParameters =
+ [[[_queue objectAtIndex:0] retain] autorelease];
+ [_queue removeObjectAtIndex:0];
+ return invokeParameters;
+}
+
+@end
« no previous file with comments | « ios/web/web_state/js/crw_js_invoke_parameter_queue.h ('k') | ios/web/web_state/js/crw_js_plugin_placeholder_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698