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

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

Issue 1839323003: Move _changingHistoryState to superclass. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 unified diff | Download patch
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 <objc/runtime.h> 7 #import <objc/runtime.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <cmath> 10 #include <cmath>
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 // Show overlay view, don't reload web page. 251 // Show overlay view, don't reload web page.
252 BOOL _overlayPreviewMode; 252 BOOL _overlayPreviewMode;
253 // If |YES|, calls |setShouldSuppressDialogs:YES| when window id is injected 253 // If |YES|, calls |setShouldSuppressDialogs:YES| when window id is injected
254 // into the web view. 254 // into the web view.
255 BOOL _shouldSuppressDialogsOnWindowIDInjection; 255 BOOL _shouldSuppressDialogsOnWindowIDInjection;
256 // The URL of an expected future recreation of the |webView|. Valid 256 // The URL of an expected future recreation of the |webView|. Valid
257 // only if the web view was discarded for non-user-visible reasons, such that 257 // only if the web view was discarded for non-user-visible reasons, such that
258 // if the next load request is for that URL, it should be treated as a 258 // if the next load request is for that URL, it should be treated as a
259 // reconstruction that should use cache aggressively. 259 // reconstruction that should use cache aggressively.
260 GURL _expectedReconstructionURL; 260 GURL _expectedReconstructionURL;
261 // Whether the web page is currently performing window.history.pushState or
262 // window.history.replaceState
263 // Set to YES on window.history.willChangeState message. To NO on
264 // window.history.didPushState or window.history.didReplaceState.
265 BOOL _changingHistoryState;
261 266
262 scoped_ptr<web::NewWindowInfo> _externalRequest; 267 scoped_ptr<web::NewWindowInfo> _externalRequest;
263 268
264 // The WebStateImpl instance associated with this CRWWebController. 269 // The WebStateImpl instance associated with this CRWWebController.
265 scoped_ptr<WebStateImpl> _webStateImpl; 270 scoped_ptr<WebStateImpl> _webStateImpl;
266 271
267 // A set of URLs opened in external applications; stored so that errors 272 // A set of URLs opened in external applications; stored so that errors
268 // from the web view can be identified as resulting from these events. 273 // from the web view can be identified as resulting from these events.
269 base::scoped_nsobject<NSMutableSet> _openedApplicationURL; 274 base::scoped_nsobject<NSMutableSet> _openedApplicationURL;
270 275
(...skipping 1621 matching lines...) Expand 10 before | Expand all | Expand 10 after
1892 } 1897 }
1893 1898
1894 - (BOOL)isBeingDestroyed { 1899 - (BOOL)isBeingDestroyed {
1895 return _isBeingDestroyed; 1900 return _isBeingDestroyed;
1896 } 1901 }
1897 1902
1898 - (BOOL)isHalted { 1903 - (BOOL)isHalted {
1899 return _isHalted; 1904 return _isHalted;
1900 } 1905 }
1901 1906
1907 - (BOOL)changingHistoryState {
1908 return _changingHistoryState;
1909 }
1910
1902 - (web::ReferrerPolicy)referrerPolicyFromString:(const std::string&)policy { 1911 - (web::ReferrerPolicy)referrerPolicyFromString:(const std::string&)policy {
1903 // TODO(stuartmorgan): Remove this temporary bridge to the helper function 1912 // TODO(stuartmorgan): Remove this temporary bridge to the helper function
1904 // once the referrer handling moves into the subclasses. 1913 // once the referrer handling moves into the subclasses.
1905 return web::ReferrerPolicyFromString(policy); 1914 return web::ReferrerPolicyFromString(policy);
1906 } 1915 }
1907 1916
1908 #pragma mark - 1917 #pragma mark -
1909 #pragma mark CRWWebControllerContainerViewDelegate 1918 #pragma mark CRWWebControllerContainerViewDelegate
1910 1919
1911 - (CRWWebViewProxyImpl*)contentViewProxyForContainerView: 1920 - (CRWWebViewProxyImpl*)contentViewProxyForContainerView:
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
2390 - (BOOL)handleWindowHistoryGoMessage:(base::DictionaryValue*)message 2399 - (BOOL)handleWindowHistoryGoMessage:(base::DictionaryValue*)message
2391 context:(NSDictionary*)context { 2400 context:(NSDictionary*)context {
2392 int delta; 2401 int delta;
2393 message->GetInteger("value", &delta); 2402 message->GetInteger("value", &delta);
2394 [self goDelta:delta]; 2403 [self goDelta:delta];
2395 return YES; 2404 return YES;
2396 } 2405 }
2397 2406
2398 - (BOOL)handleWindowHistoryWillChangeStateMessage:(base::DictionaryValue*)unused 2407 - (BOOL)handleWindowHistoryWillChangeStateMessage:(base::DictionaryValue*)unused
2399 context:(NSDictionary*)unusedContext { 2408 context:(NSDictionary*)unusedContext {
2400 // This dummy handler is a workaround for crbug.com/490673. Issue was 2409 // This dummy handler is a workaround for crbug.com/490673. Issue was
Eugene But (OOO till 7-30) 2016/03/30 16:56:21 This comment needs to be revised as handler is not
michaeldo 2016/03/30 17:04:17 I will re-verify.
michaeldo 2016/03/30 21:49:07 That bug is actually reproducible on master irrega
2401 // happening when two sequential calls of window.history.pushState were 2410 // happening when two sequential calls of window.history.pushState were
2402 // performed by the page. In that case state was changed twice before 2411 // performed by the page. In that case state was changed twice before
2403 // first change was reported to embedder (and first URL change was reported 2412 // first change was reported to embedder (and first URL change was reported
2404 // incorrectly). 2413 // incorrectly).
2405 2414
2406 // Using dummy handler for window.history.willChangeState message holds 2415 // Using dummy handler for window.history.willChangeState message holds
2407 // second state change until the first change is reported, because messages 2416 // second state change until the first change is reported, because messages
2408 // are queued. This is essentially a sleep, and not the real fix of the 2417 // are queued. This is essentially a sleep, and not the real fix of the
2409 // problem. TODO(eugenebut): refactor handleWindowHistoryDidPushStateMessage: 2418 // problem. TODO(eugenebut): refactor handleWindowHistoryDidPushStateMessage:
2410 // to avoid this "sleep". 2419 // to avoid this "sleep".
2420 _changingHistoryState = YES;
2411 return YES; 2421 return YES;
2412 } 2422 }
2413 2423
2414 - (BOOL)handleWindowHistoryDidPushStateMessage:(base::DictionaryValue*)message 2424 - (BOOL)handleWindowHistoryDidPushStateMessage:(base::DictionaryValue*)message
2415 context:(NSDictionary*)context { 2425 context:(NSDictionary*)context {
2426 DCHECK(_changingHistoryState);
2427 _changingHistoryState = NO;
2428
2416 // If there is a pending entry, a new navigation has been registered but 2429 // If there is a pending entry, a new navigation has been registered but
2417 // hasn't begun loading. Since the pushState message is coming from the 2430 // hasn't begun loading. Since the pushState message is coming from the
2418 // previous page, ignore it and allow the previously registered navigation to 2431 // previous page, ignore it and allow the previously registered navigation to
2419 // continue. This can ocur if a pushState is issued from an anchor tag 2432 // continue. This can ocur if a pushState is issued from an anchor tag
2420 // onClick event, as the click would have already been registered. 2433 // onClick event, as the click would have already been registered.
2421 if ([self sessionController].pendingEntry) 2434 if ([self sessionController].pendingEntry)
2422 return NO; 2435 return NO;
2423 2436
2424 std::string pageURL; 2437 std::string pageURL;
2425 std::string baseURL; 2438 std::string baseURL;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2487 // Notify the observers. 2500 // Notify the observers.
2488 strongSelf.get()->_webStateImpl->OnHistoryStateChanged(); 2501 strongSelf.get()->_webStateImpl->OnHistoryStateChanged();
2489 [strongSelf didFinishNavigation]; 2502 [strongSelf didFinishNavigation];
2490 }]; 2503 }];
2491 return YES; 2504 return YES;
2492 } 2505 }
2493 2506
2494 - (BOOL)handleWindowHistoryDidReplaceStateMessage: 2507 - (BOOL)handleWindowHistoryDidReplaceStateMessage:
2495 (base::DictionaryValue*)message 2508 (base::DictionaryValue*)message
2496 context:(NSDictionary*)context { 2509 context:(NSDictionary*)context {
2510 DCHECK(_changingHistoryState);
2511 _changingHistoryState = NO;
2512
2497 std::string pageURL; 2513 std::string pageURL;
2498 std::string baseURL; 2514 std::string baseURL;
2499 if (!message->GetString("pageUrl", &pageURL) || 2515 if (!message->GetString("pageUrl", &pageURL) ||
2500 !message->GetString("baseUrl", &baseURL)) { 2516 !message->GetString("baseUrl", &baseURL)) {
2501 DLOG(WARNING) << "JS message parameter not found: pageUrl or baseUrl"; 2517 DLOG(WARNING) << "JS message parameter not found: pageUrl or baseUrl";
2502 return NO; 2518 return NO;
2503 } 2519 }
2504 GURL replaceURL = web::history_state_util::GetHistoryStateChangeUrl( 2520 GURL replaceURL = web::history_state_util::GetHistoryStateChangeUrl(
2505 [self currentURL], GURL(baseURL), pageURL); 2521 [self currentURL], GURL(baseURL), pageURL);
2506 // UIWebView seems to choke on unicode characters that haven't been 2522 // UIWebView seems to choke on unicode characters that haven't been
(...skipping 1309 matching lines...) Expand 10 before | Expand all | Expand 10 after
3816 if ([MIMEType isEqualToString:@"text/html"] || 3832 if ([MIMEType isEqualToString:@"text/html"] ||
3817 [MIMEType isEqualToString:@"application/xhtml+xml"] || 3833 [MIMEType isEqualToString:@"application/xhtml+xml"] ||
3818 [MIMEType isEqualToString:@"application/xml"]) { 3834 [MIMEType isEqualToString:@"application/xml"]) {
3819 return web::WEB_VIEW_DOCUMENT_TYPE_HTML; 3835 return web::WEB_VIEW_DOCUMENT_TYPE_HTML;
3820 } 3836 }
3821 3837
3822 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; 3838 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC;
3823 } 3839 }
3824 3840
3825 @end 3841 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698