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

Side by Side Diff: ios/web/web_state/ui/crw_web_controller.mm

Issue 2617243002: Remove ScopedVector from ios/. (Closed)
Patch Set: rebase Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « ios/web/public/webui/web_ui_ios.h ('k') | ios/web/webui/crw_web_ui_manager.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ios/web/web_state/ui/crw_web_controller.h" 5 #import "ios/web/web_state/ui/crw_web_controller.h"
6 6
7 #import <WebKit/WebKit.h> 7 #import <WebKit/WebKit.h>
8 8
9 #import <objc/runtime.h> 9 #import <objc/runtime.h>
10 #include <stddef.h> 10 #include <stddef.h>
11 11
12 #include <cmath> 12 #include <cmath>
13 #include <memory> 13 #include <memory>
14 #include <utility> 14 #include <utility>
15 #include <vector>
15 16
16 #include "base/callback.h" 17 #include "base/callback.h"
17 #include "base/containers/mru_cache.h" 18 #include "base/containers/mru_cache.h"
18 #import "base/ios/block_types.h" 19 #import "base/ios/block_types.h"
19 #include "base/ios/ios_util.h" 20 #include "base/ios/ios_util.h"
20 #import "base/ios/ns_error_util.h" 21 #import "base/ios/ns_error_util.h"
21 #import "base/ios/weak_nsobject.h" 22 #import "base/ios/weak_nsobject.h"
22 #include "base/json/string_escape.h" 23 #include "base/json/string_escape.h"
23 #include "base/logging.h" 24 #include "base/logging.h"
24 #import "base/mac/bind_objc_block.h" 25 #import "base/mac/bind_objc_block.h"
25 #include "base/mac/bundle_locations.h" 26 #include "base/mac/bundle_locations.h"
26 #include "base/mac/foundation_util.h" 27 #include "base/mac/foundation_util.h"
27 #import "base/mac/objc_property_releaser.h" 28 #import "base/mac/objc_property_releaser.h"
28 #include "base/mac/scoped_cftyperef.h" 29 #include "base/mac/scoped_cftyperef.h"
29 #import "base/mac/scoped_nsobject.h" 30 #import "base/mac/scoped_nsobject.h"
31 #include "base/memory/ptr_util.h"
30 #include "base/metrics/histogram.h" 32 #include "base/metrics/histogram.h"
31 #include "base/metrics/user_metrics.h" 33 #include "base/metrics/user_metrics.h"
32 #include "base/metrics/user_metrics_action.h" 34 #include "base/metrics/user_metrics_action.h"
33 #include "base/strings/string_util.h" 35 #include "base/strings/string_util.h"
34 #include "base/strings/sys_string_conversions.h" 36 #include "base/strings/sys_string_conversions.h"
35 #include "base/strings/utf_string_conversions.h" 37 #include "base/strings/utf_string_conversions.h"
36 #include "base/time/time.h" 38 #include "base/time/time.h"
37 #include "base/values.h" 39 #include "base/values.h"
38 #include "components/url_formatter/url_formatter.h" 40 #include "components/url_formatter/url_formatter.h"
39 #import "ios/net/http_response_headers_util.h" 41 #import "ios/net/http_response_headers_util.h"
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 base::scoped_nsprotocol<id<CRWNativeContent>> _nativeController; 314 base::scoped_nsprotocol<id<CRWNativeContent>> _nativeController;
313 BOOL _isHalted; // YES if halted. Halting happens prior to destruction. 315 BOOL _isHalted; // YES if halted. Halting happens prior to destruction.
314 BOOL _isBeingDestroyed; // YES if in the process of closing. 316 BOOL _isBeingDestroyed; // YES if in the process of closing.
315 // All CRWWebControllerObservers attached to the CRWWebController. A 317 // All CRWWebControllerObservers attached to the CRWWebController. A
316 // specially-constructed set is used that does not retain its elements. 318 // specially-constructed set is used that does not retain its elements.
317 base::scoped_nsobject<NSMutableSet> _observers; 319 base::scoped_nsobject<NSMutableSet> _observers;
318 // Each observer in |_observers| is associated with a 320 // Each observer in |_observers| is associated with a
319 // WebControllerObserverBridge in order to listen from WebState callbacks. 321 // WebControllerObserverBridge in order to listen from WebState callbacks.
320 // TODO(droger): Remove |_observerBridges| when all CRWWebControllerObservers 322 // TODO(droger): Remove |_observerBridges| when all CRWWebControllerObservers
321 // are converted to WebStateObservers. 323 // are converted to WebStateObservers.
322 ScopedVector<web::WebControllerObserverBridge> _observerBridges; 324 std::vector<std::unique_ptr<web::WebControllerObserverBridge>>
325 _observerBridges;
323 // YES if a user interaction has been registered at any time once the page has 326 // YES if a user interaction has been registered at any time once the page has
324 // loaded. 327 // loaded.
325 BOOL _userInteractionRegistered; 328 BOOL _userInteractionRegistered;
326 // YES if the user has interacted with the content area since the last URL 329 // YES if the user has interacted with the content area since the last URL
327 // change. 330 // change.
328 BOOL _interactionRegisteredSinceLastURLChange; 331 BOOL _interactionRegisteredSinceLastURLChange;
329 // The actual URL of the document object (i.e., the last committed URL). 332 // The actual URL of the document object (i.e., the last committed URL).
330 // TODO(crbug.com/549616): Remove this in favor of just updating the 333 // TODO(crbug.com/549616): Remove this in favor of just updating the
331 // navigation manager and treating that as authoritative. 334 // navigation manager and treating that as authoritative.
332 GURL _documentURL; 335 GURL _documentURL;
(...skipping 5383 matching lines...) Expand 10 before | Expand all | Expand 10 after
5716 // We don't want our observer set to block dealloc on the observers. For the 5719 // We don't want our observer set to block dealloc on the observers. For the
5717 // observer container, make an object compatible with NSMutableSet that does 5720 // observer container, make an object compatible with NSMutableSet that does
5718 // not perform retain or release on the contained objects (weak references). 5721 // not perform retain or release on the contained objects (weak references).
5719 CFSetCallBacks callbacks = 5722 CFSetCallBacks callbacks =
5720 {0, NULL, NULL, CFCopyDescription, CFEqual, CFHash}; 5723 {0, NULL, NULL, CFCopyDescription, CFEqual, CFHash};
5721 _observers.reset(base::mac::CFToNSCast( 5724 _observers.reset(base::mac::CFToNSCast(
5722 CFSetCreateMutable(kCFAllocatorDefault, 1, &callbacks))); 5725 CFSetCreateMutable(kCFAllocatorDefault, 1, &callbacks)));
5723 } 5726 }
5724 DCHECK(![_observers containsObject:observer]); 5727 DCHECK(![_observers containsObject:observer]);
5725 [_observers addObject:observer]; 5728 [_observers addObject:observer];
5726 _observerBridges.push_back( 5729 _observerBridges.push_back(base::MakeUnique<web::WebControllerObserverBridge>(
5727 new web::WebControllerObserverBridge(observer, self.webStateImpl, self)); 5730 observer, self.webStateImpl, self));
5728 5731
5729 if ([observer respondsToSelector:@selector(setWebViewProxy:controller:)]) 5732 if ([observer respondsToSelector:@selector(setWebViewProxy:controller:)])
5730 [observer setWebViewProxy:_webViewProxy controller:self]; 5733 [observer setWebViewProxy:_webViewProxy controller:self];
5731 } 5734 }
5732 5735
5733 - (void)removeObserver:(id<CRWWebControllerObserver>)observer { 5736 - (void)removeObserver:(id<CRWWebControllerObserver>)observer {
5734 DCHECK([_observers containsObject:observer]); 5737 DCHECK([_observers containsObject:observer]);
5735 [_observers removeObject:observer]; 5738 [_observers removeObject:observer];
5736 // Remove the associated WebControllerObserverBridge. 5739 // Remove the associated WebControllerObserverBridge.
5737 auto it = std::find_if(_observerBridges.begin(), _observerBridges.end(), 5740 auto it = std::find_if(
5738 [observer](web::WebControllerObserverBridge* bridge) { 5741 _observerBridges.begin(), _observerBridges.end(),
5739 return bridge->web_controller_observer() == observer; 5742 [observer](
5740 }); 5743 const std::unique_ptr<web::WebControllerObserverBridge>& bridge) {
5744 return bridge->web_controller_observer() == observer;
5745 });
5741 DCHECK(it != _observerBridges.end()); 5746 DCHECK(it != _observerBridges.end());
5742 _observerBridges.erase(it); 5747 _observerBridges.erase(it);
5743 } 5748 }
5744 5749
5745 - (NSUInteger)observerCount { 5750 - (NSUInteger)observerCount {
5746 DCHECK_EQ(_observerBridges.size(), [_observers count]); 5751 DCHECK_EQ(_observerBridges.size(), [_observers count]);
5747 return [_observers count]; 5752 return [_observers count];
5748 } 5753 }
5749 5754
5750 - (void)simulateLoadRequestWithURL:(const GURL&)URL { 5755 - (void)simulateLoadRequestWithURL:(const GURL&)URL {
(...skipping 19 matching lines...) Expand all
5770 } 5775 }
5771 5776
5772 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; 5777 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC;
5773 } 5778 }
5774 5779
5775 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { 5780 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action {
5776 return [action.request valueForHTTPHeaderField:@"Referer"]; 5781 return [action.request valueForHTTPHeaderField:@"Referer"];
5777 } 5782 }
5778 5783
5779 @end 5784 @end
OLDNEW
« no previous file with comments | « ios/web/public/webui/web_ui_ios.h ('k') | ios/web/webui/crw_web_ui_manager.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698