| OLD | NEW |
| 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/chrome/browser/tabs/tab.h" | 5 #import "ios/chrome/browser/tabs/tab.h" |
| 6 | 6 |
| 7 #import <CoreLocation/CoreLocation.h> | 7 #import <CoreLocation/CoreLocation.h> |
| 8 #import <UIKit/UIKit.h> | 8 #import <UIKit/UIKit.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/ios/block_types.h" | 14 #include "base/ios/block_types.h" |
| 15 #import "base/ios/weak_nsobject.h" | |
| 16 #include "base/json/string_escape.h" | 15 #include "base/json/string_escape.h" |
| 17 #include "base/logging.h" | 16 #include "base/logging.h" |
| 18 #include "base/mac/bind_objc_block.h" | 17 #include "base/mac/bind_objc_block.h" |
| 19 #include "base/mac/foundation_util.h" | 18 #include "base/mac/foundation_util.h" |
| 20 #include "base/mac/objc_property_releaser.h" | 19 #include "base/memory/ptr_util.h" |
| 21 #include "base/mac/scoped_nsobject.h" | |
| 22 #include "base/metrics/histogram_macros.h" | 20 #include "base/metrics/histogram_macros.h" |
| 23 #include "base/metrics/user_metrics.h" | 21 #include "base/metrics/user_metrics.h" |
| 24 #include "base/metrics/user_metrics_action.h" | 22 #include "base/metrics/user_metrics_action.h" |
| 25 #include "base/scoped_observer.h" | 23 #include "base/scoped_observer.h" |
| 26 #include "base/strings/string_split.h" | 24 #include "base/strings/string_split.h" |
| 27 #include "base/strings/sys_string_conversions.h" | 25 #include "base/strings/sys_string_conversions.h" |
| 28 #include "base/strings/utf_string_conversions.h" | 26 #include "base/strings/utf_string_conversions.h" |
| 29 #include "base/time/time.h" | 27 #include "base/time/time.h" |
| 30 #include "components/favicon/core/favicon_driver_observer.h" | 28 #include "components/favicon/core/favicon_driver_observer.h" |
| 31 #include "components/favicon/ios/web_favicon_driver.h" | 29 #include "components/favicon/ios/web_favicon_driver.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 #import "net/base/mac/url_conversions.h" | 129 #import "net/base/mac/url_conversions.h" |
| 132 #include "net/base/net_errors.h" | 130 #include "net/base/net_errors.h" |
| 133 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 131 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 134 #include "net/cert/x509_certificate.h" | 132 #include "net/cert/x509_certificate.h" |
| 135 #include "net/http/http_response_headers.h" | 133 #include "net/http/http_response_headers.h" |
| 136 #include "net/url_request/url_fetcher.h" | 134 #include "net/url_request/url_fetcher.h" |
| 137 #include "ui/base/l10n/l10n_util.h" | 135 #include "ui/base/l10n/l10n_util.h" |
| 138 #include "ui/base/page_transition_types.h" | 136 #include "ui/base/page_transition_types.h" |
| 139 #include "url/origin.h" | 137 #include "url/origin.h" |
| 140 | 138 |
| 141 using base::UserMetricsAction; | 139 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 142 using web::NavigationManagerImpl; | 140 #error "This file requires ARC support." |
| 143 using net::RequestTracker; | 141 #endif |
| 144 | 142 |
| 145 NSString* const kTabUrlStartedLoadingNotificationForCrashReporting = | 143 NSString* const kTabUrlStartedLoadingNotificationForCrashReporting = |
| 146 @"kTabUrlStartedLoadingNotificationForCrashReporting"; | 144 @"kTabUrlStartedLoadingNotificationForCrashReporting"; |
| 147 NSString* const kTabUrlMayStartLoadingNotificationForCrashReporting = | 145 NSString* const kTabUrlMayStartLoadingNotificationForCrashReporting = |
| 148 @"kTabUrlMayStartLoadingNotificationForCrashReporting"; | 146 @"kTabUrlMayStartLoadingNotificationForCrashReporting"; |
| 149 NSString* const kTabIsShowingExportableNotificationForCrashReporting = | 147 NSString* const kTabIsShowingExportableNotificationForCrashReporting = |
| 150 @"kTabIsShowingExportableNotificationForCrashReporting"; | 148 @"kTabIsShowingExportableNotificationForCrashReporting"; |
| 151 NSString* const kTabClosingCurrentDocumentNotificationForCrashReporting = | 149 NSString* const kTabClosingCurrentDocumentNotificationForCrashReporting = |
| 152 @"kTabClosingCurrentDocumentNotificationForCrashReporting"; | 150 @"kTabClosingCurrentDocumentNotificationForCrashReporting"; |
| 153 | 151 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 | 189 |
| 192 // Returns true if |item| is the result of a HTTP redirect. | 190 // Returns true if |item| is the result of a HTTP redirect. |
| 193 // Returns false if |item| is nullptr; | 191 // Returns false if |item| is nullptr; |
| 194 bool IsItemRedirectItem(web::NavigationItem* item) { | 192 bool IsItemRedirectItem(web::NavigationItem* item) { |
| 195 if (!item) | 193 if (!item) |
| 196 return false; | 194 return false; |
| 197 | 195 |
| 198 return (ui::PageTransition::PAGE_TRANSITION_IS_REDIRECT_MASK & | 196 return (ui::PageTransition::PAGE_TRANSITION_IS_REDIRECT_MASK & |
| 199 item->GetTransitionType()) == 0; | 197 item->GetTransitionType()) == 0; |
| 200 } | 198 } |
| 199 |
| 200 // TabHistoryContext is used by history to scope the lifetime of navigation |
| 201 // entry references to Tab. |
| 202 class TabHistoryContext : public history::Context { |
| 203 public: |
| 204 TabHistoryContext() {} |
| 205 ~TabHistoryContext() {} |
| 206 |
| 207 private: |
| 208 DISALLOW_COPY_AND_ASSIGN(TabHistoryContext); |
| 209 }; |
| 201 } // namespace | 210 } // namespace |
| 202 | 211 |
| 203 @interface Tab ()<CRWWebStateObserver, | 212 @interface Tab ()<CRWWebStateObserver, |
| 204 CRWWebControllerObserver, | 213 CRWWebControllerObserver, |
| 205 FindInPageControllerDelegate, | 214 FindInPageControllerDelegate, |
| 206 ReaderModeControllerDelegate> { | 215 ReaderModeControllerDelegate> { |
| 207 TabModel* parentTabModel_; // weak | 216 __weak TabModel* parentTabModel_; |
| 208 ios::ChromeBrowserState* browserState_; // weak | 217 ios::ChromeBrowserState* browserState_; |
| 209 | 218 |
| 210 base::scoped_nsobject<OpenInController> openInController_; | 219 OpenInController* openInController_; |
| 211 base::WeakNSProtocol<id<PassKitDialogProvider>> passKitDialogProvider_; | |
| 212 | 220 |
| 213 // Whether or not this tab is currently being displayed. | 221 // Whether or not this tab is currently being displayed. |
| 214 BOOL visible_; | 222 BOOL visible_; |
| 215 | 223 |
| 216 // Holds entries that need to be added to the history DB. Prerender tabs do | 224 // Holds entries that need to be added to the history DB. Prerender tabs do |
| 217 // not write navigation data to the history DB. Instead, they cache history | 225 // not write navigation data to the history DB. Instead, they cache history |
| 218 // data in this vector and add it to the DB when the prerender status is | 226 // data in this vector and add it to the DB when the prerender status is |
| 219 // removed (when the Tab is swapped in as a real Tab). | 227 // removed (when the Tab is swapped in as a real Tab). |
| 220 std::vector<history::HistoryAddPageArgs> addPageVector_; | 228 std::vector<history::HistoryAddPageArgs> addPageVector_; |
| 221 | 229 |
| 222 // YES if this Tab is being prerendered. | 230 // YES if this Tab is being prerendered. |
| 223 BOOL isPrerenderTab_; | 231 BOOL isPrerenderTab_; |
| 224 | 232 |
| 225 // YES if this Tab was initiated from a voice search. | 233 // YES if this Tab was initiated from a voice search. |
| 226 BOOL isVoiceSearchResultsTab_; | 234 BOOL isVoiceSearchResultsTab_; |
| 227 | 235 |
| 228 // YES if the Tab needs to be reloaded after the app becomes active. | 236 // YES if the Tab needs to be reloaded after the app becomes active. |
| 229 BOOL requireReloadAfterBecomingActive_; | 237 BOOL requireReloadAfterBecomingActive_; |
| 230 | 238 |
| 231 // Last visited timestamp. | 239 // Last visited timestamp. |
| 232 double lastVisitedTimestamp_; | 240 double lastVisitedTimestamp_; |
| 233 | 241 |
| 234 base::mac::ObjCPropertyReleaser propertyReleaser_Tab_; | |
| 235 | |
| 236 id<TabDelegate> delegate_; // weak | |
| 237 base::WeakNSProtocol<id<TabDialogDelegate>> dialogDelegate_; | |
| 238 base::WeakNSProtocol<id<SnapshotOverlayProvider>> snapshotOverlayProvider_; | |
| 239 | |
| 240 // Delegate used for snapshotting geometry. | |
| 241 id<TabSnapshottingDelegate> tabSnapshottingDelegate_; // weak | |
| 242 | |
| 243 // The Full Screen Controller responsible for hiding/showing the toolbar. | 242 // The Full Screen Controller responsible for hiding/showing the toolbar. |
| 244 base::scoped_nsobject<FullScreenController> fullScreenController_; | 243 FullScreenController* fullScreenController_; |
| 245 | |
| 246 // The delegate responsible for headers over the tab. | |
| 247 id<TabHeadersDelegate> tabHeadersDelegate_; // weak | |
| 248 | |
| 249 base::WeakNSProtocol<id<FullScreenControllerDelegate>> | |
| 250 fullScreenControllerDelegate_; | |
| 251 | 244 |
| 252 // The Overscroll controller responsible for displaying the | 245 // The Overscroll controller responsible for displaying the |
| 253 // overscrollActionsView above the toolbar. | 246 // overscrollActionsView above the toolbar. |
| 254 base::scoped_nsobject<OverscrollActionsController> | 247 OverscrollActionsController* overscrollActionsController_; |
| 255 overscrollActionsController_; | |
| 256 base::WeakNSProtocol<id<OverscrollActionsControllerDelegate>> | |
| 257 overscrollActionsControllerDelegate_; | |
| 258 | |
| 259 base::scoped_nsobject<NSString> tabId_; | |
| 260 | 248 |
| 261 // Lightweight object dealing with various different UI behaviours when | 249 // Lightweight object dealing with various different UI behaviours when |
| 262 // opening a URL in an external application. | 250 // opening a URL in an external application. |
| 263 base::scoped_nsobject<ExternalAppLauncher> externalAppLauncher_; | 251 ExternalAppLauncher* externalAppLauncher_; |
| 264 | 252 |
| 265 // Handles suggestions for form entry. | 253 // Handles suggestions for form entry. |
| 266 base::scoped_nsobject<FormSuggestionController> suggestionController_; | 254 FormSuggestionController* suggestionController_; |
| 267 | 255 |
| 268 // Manages the input accessory view during form input. | 256 // Manages the input accessory view during form input. |
| 269 base::scoped_nsobject<FormInputAccessoryViewController> | 257 FormInputAccessoryViewController* inputAccessoryViewController_; |
| 270 inputAccessoryViewController_; | |
| 271 | |
| 272 // TODO(crbug.com/661665): move the WebContentsObservers into their own | |
| 273 // container. | |
| 274 // Handles saving and autofill of passwords. | |
| 275 base::scoped_nsobject<PasswordController> passwordController_; | |
| 276 | 258 |
| 277 // Handles autofill. | 259 // Handles autofill. |
| 278 base::scoped_nsobject<AutofillController> autofillController_; | 260 AutofillController* autofillController_; |
| 279 | 261 |
| 280 // Handles caching and retrieving of snapshots. | 262 // Handles caching and retrieving of snapshots. |
| 281 base::scoped_nsobject<SnapshotManager> snapshotManager_; | 263 SnapshotManager* snapshotManager_; |
| 282 | 264 |
| 283 // Handles retrieving, generating and updating snapshots of CRWWebController's | 265 // Handles retrieving, generating and updating snapshots of CRWWebController's |
| 284 // web page. | 266 // web page. |
| 285 base::scoped_nsobject<WebControllerSnapshotHelper> | 267 WebControllerSnapshotHelper* webControllerSnapshotHelper_; |
| 286 webControllerSnapshotHelper_; | |
| 287 | 268 |
| 288 // Handles support for window.print JavaScript calls. | 269 // Handles support for window.print JavaScript calls. |
| 289 std::unique_ptr<PrintObserver> printObserver_; | 270 std::unique_ptr<PrintObserver> printObserver_; |
| 290 | 271 |
| 291 // AutoReloadBridge for this tab. | 272 // AutoReloadBridge for this tab. |
| 292 base::scoped_nsobject<AutoReloadBridge> autoReloadBridge_; | 273 AutoReloadBridge* autoReloadBridge_; |
| 293 | 274 |
| 294 // WebStateImpl for this tab. | 275 // WebStateImpl for this tab. |
| 295 web::WebStateImpl* webStateImpl_; | 276 web::WebStateImpl* webStateImpl_; |
| 296 | 277 |
| 297 // Allows Tab to conform CRWWebStateDelegate protocol. | 278 // Allows Tab to conform CRWWebStateDelegate protocol. |
| 298 std::unique_ptr<web::WebStateObserverBridge> webStateObserver_; | 279 std::unique_ptr<web::WebStateObserverBridge> webStateObserver_; |
| 299 | 280 |
| 300 // Context used by history to scope the lifetime of navigation entry | 281 // Context used by history to scope the lifetime of navigation entry |
| 301 // references to Tab. | 282 // references to Tab. |
| 302 std::unique_ptr<TabHistoryContext> tabHistoryContext_; | 283 TabHistoryContext tabHistoryContext_; |
| 303 | |
| 304 // The controller for everything related to reader mode. | |
| 305 base::scoped_nsobject<ReaderModeController> readerModeController_; | |
| 306 | 284 |
| 307 // C++ bridge that receives notifications from the FaviconDriver. | 285 // C++ bridge that receives notifications from the FaviconDriver. |
| 308 std::unique_ptr<FaviconDriverObserverBridge> faviconDriverObserverBridge_; | 286 std::unique_ptr<FaviconDriverObserverBridge> faviconDriverObserverBridge_; |
| 309 | 287 |
| 310 // U2F call controller object. | 288 // U2F call controller object. |
| 311 base::scoped_nsobject<U2FController> U2FController_; | 289 U2FController* U2FController_; |
| 312 | 290 |
| 313 // C++ observer used to trigger snapshots after the removal of InfoBars. | 291 // C++ observer used to trigger snapshots after the removal of InfoBars. |
| 314 std::unique_ptr<TabInfoBarObserver> tabInfoBarObserver_; | 292 std::unique_ptr<TabInfoBarObserver> tabInfoBarObserver_; |
| 315 } | 293 } |
| 316 | 294 |
| 317 // Returns the tab's reader mode controller. May contain nil if the feature is | 295 // Returns the tab's reader mode controller. May contain nil if the feature is |
| 318 // disabled. | 296 // disabled. |
| 319 @property(nonatomic, readonly) ReaderModeController* readerModeController; | 297 @property(nonatomic, readonly) ReaderModeController* readerModeController; |
| 320 | 298 |
| 321 // Returns a list of FormSuggestionProviders to be queried for suggestions | 299 // Returns a list of FormSuggestionProviders to be queried for suggestions |
| (...skipping 25 matching lines...) Expand all Loading... |
| 347 // Called after the session history is replaced, useful for updating members | 325 // Called after the session history is replaced, useful for updating members |
| 348 // with new sessionID. | 326 // with new sessionID. |
| 349 - (void)didReplaceSessionHistory; | 327 - (void)didReplaceSessionHistory; |
| 350 | 328 |
| 351 // Called when the UIApplication's state becomes active. | 329 // Called when the UIApplication's state becomes active. |
| 352 - (void)applicationDidBecomeActive; | 330 - (void)applicationDidBecomeActive; |
| 353 | 331 |
| 354 @end | 332 @end |
| 355 | 333 |
| 356 namespace { | 334 namespace { |
| 357 // TabHistoryContext is used by history to scope the lifetime of navigation | |
| 358 // entry references to Tab. | |
| 359 class TabHistoryContext : public history::Context { | |
| 360 public: | |
| 361 TabHistoryContext() {} | |
| 362 ~TabHistoryContext() {} | |
| 363 | |
| 364 private: | |
| 365 DISALLOW_COPY_AND_ASSIGN(TabHistoryContext); | |
| 366 }; | |
| 367 | |
| 368 class FaviconDriverObserverBridge : public favicon::FaviconDriverObserver { | 335 class FaviconDriverObserverBridge : public favicon::FaviconDriverObserver { |
| 369 public: | 336 public: |
| 370 FaviconDriverObserverBridge(Tab* owner, | 337 FaviconDriverObserverBridge(Tab* owner, |
| 371 favicon::FaviconDriver* favicon_driver); | 338 favicon::FaviconDriver* favicon_driver); |
| 372 ~FaviconDriverObserverBridge() override; | 339 ~FaviconDriverObserverBridge() override; |
| 373 | 340 |
| 374 // favicon::FaviconDriverObserver implementation. | 341 // favicon::FaviconDriverObserver implementation. |
| 375 void OnFaviconUpdated(favicon::FaviconDriver* favicon_driver, | 342 void OnFaviconUpdated(favicon::FaviconDriver* favicon_driver, |
| 376 NotificationIconType notification_icon_type, | 343 NotificationIconType notification_icon_type, |
| 377 const GURL& icon_url, | 344 const GURL& icon_url, |
| 378 bool icon_url_changed, | 345 bool icon_url_changed, |
| 379 const gfx::Image& image) override; | 346 const gfx::Image& image) override; |
| 380 | 347 |
| 381 private: | 348 private: |
| 382 Tab* owner_; // Owns this instance. | 349 __weak Tab* owner_; |
| 383 ScopedObserver<favicon::FaviconDriver, favicon::FaviconDriverObserver> | 350 ScopedObserver<favicon::FaviconDriver, favicon::FaviconDriverObserver> |
| 384 scoped_observer_; | 351 scoped_observer_; |
| 385 DISALLOW_COPY_AND_ASSIGN(FaviconDriverObserverBridge); | 352 DISALLOW_COPY_AND_ASSIGN(FaviconDriverObserverBridge); |
| 386 }; | 353 }; |
| 387 | 354 |
| 388 FaviconDriverObserverBridge::FaviconDriverObserverBridge( | 355 FaviconDriverObserverBridge::FaviconDriverObserverBridge( |
| 389 Tab* owner, | 356 Tab* owner, |
| 390 favicon::FaviconDriver* favicon_driver) | 357 favicon::FaviconDriver* favicon_driver) |
| 391 : owner_(owner), scoped_observer_(this) { | 358 : owner_(owner), scoped_observer_(this) { |
| 392 scoped_observer_.Add(favicon_driver); | 359 scoped_observer_.Add(favicon_driver); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 408 public: | 375 public: |
| 409 explicit TabInfoBarObserver(Tab* owner); | 376 explicit TabInfoBarObserver(Tab* owner); |
| 410 ~TabInfoBarObserver() override; | 377 ~TabInfoBarObserver() override; |
| 411 void SetShouldObserveInfoBarManager(bool should_observe); | 378 void SetShouldObserveInfoBarManager(bool should_observe); |
| 412 void OnInfoBarAdded(infobars::InfoBar* infobar) override; | 379 void OnInfoBarAdded(infobars::InfoBar* infobar) override; |
| 413 void OnInfoBarRemoved(infobars::InfoBar* infobar, bool animate) override; | 380 void OnInfoBarRemoved(infobars::InfoBar* infobar, bool animate) override; |
| 414 void OnInfoBarReplaced(infobars::InfoBar* old_infobar, | 381 void OnInfoBarReplaced(infobars::InfoBar* old_infobar, |
| 415 infobars::InfoBar* new_infobar) override; | 382 infobars::InfoBar* new_infobar) override; |
| 416 | 383 |
| 417 private: | 384 private: |
| 418 Tab* owner_; // Owns this instance; | 385 __weak Tab* owner_; |
| 419 ScopedObserver<infobars::InfoBarManager, TabInfoBarObserver> scoped_observer_; | 386 ScopedObserver<infobars::InfoBarManager, TabInfoBarObserver> scoped_observer_; |
| 420 DISALLOW_COPY_AND_ASSIGN(TabInfoBarObserver); | 387 DISALLOW_COPY_AND_ASSIGN(TabInfoBarObserver); |
| 421 }; | 388 }; |
| 422 | 389 |
| 423 TabInfoBarObserver::TabInfoBarObserver(Tab* owner) | 390 TabInfoBarObserver::TabInfoBarObserver(Tab* owner) |
| 424 : owner_(owner), scoped_observer_(this) {} | 391 : owner_(owner), scoped_observer_(this) {} |
| 425 | 392 |
| 426 TabInfoBarObserver::~TabInfoBarObserver() {} | 393 TabInfoBarObserver::~TabInfoBarObserver() {} |
| 427 | 394 |
| 428 void TabInfoBarObserver::SetShouldObserveInfoBarManager(bool should_observe) { | 395 void TabInfoBarObserver::SetShouldObserveInfoBarManager(bool should_observe) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 453 infobars::InfoBar* new_infobar) { | 420 infobars::InfoBar* new_infobar) { |
| 454 // Update snapshots after the infobar has been replaced. | 421 // Update snapshots after the infobar has been replaced. |
| 455 [owner_ updateSnapshotWithOverlay:YES visibleFrameOnly:YES]; | 422 [owner_ updateSnapshotWithOverlay:YES visibleFrameOnly:YES]; |
| 456 } | 423 } |
| 457 | 424 |
| 458 } // anonymous namespace | 425 } // anonymous namespace |
| 459 | 426 |
| 460 @implementation Tab | 427 @implementation Tab |
| 461 | 428 |
| 462 @synthesize browserState = browserState_; | 429 @synthesize browserState = browserState_; |
| 430 @synthesize tabId = tabId_; |
| 463 @synthesize useGreyImageCache = useGreyImageCache_; | 431 @synthesize useGreyImageCache = useGreyImageCache_; |
| 464 @synthesize isPrerenderTab = isPrerenderTab_; | 432 @synthesize isPrerenderTab = isPrerenderTab_; |
| 465 @synthesize isLinkLoadingPrerenderTab = isLinkLoadingPrerenderTab_; | 433 @synthesize isLinkLoadingPrerenderTab = isLinkLoadingPrerenderTab_; |
| 466 @synthesize isVoiceSearchResultsTab = isVoiceSearchResultsTab_; | 434 @synthesize isVoiceSearchResultsTab = isVoiceSearchResultsTab_; |
| 435 @synthesize passwordController = passwordController_; |
| 436 @synthesize overscrollActionsController = overscrollActionsController_; |
| 437 @synthesize readerModeController = readerModeController_; |
| 438 @synthesize overscrollActionsControllerDelegate = |
| 439 overscrollActionsControllerDelegate_; |
| 440 @synthesize passKitDialogProvider = passKitDialogProvider_; |
| 467 @synthesize delegate = delegate_; | 441 @synthesize delegate = delegate_; |
| 442 @synthesize dialogDelegate = dialogDelegate_; |
| 443 @synthesize snapshotOverlayProvider = snapshotOverlayProvider_; |
| 468 @synthesize tabSnapshottingDelegate = tabSnapshottingDelegate_; | 444 @synthesize tabSnapshottingDelegate = tabSnapshottingDelegate_; |
| 469 @synthesize tabHeadersDelegate = tabHeadersDelegate_; | 445 @synthesize tabHeadersDelegate = tabHeadersDelegate_; |
| 446 @synthesize fullScreenControllerDelegate = fullScreenControllerDelegate_; |
| 470 | 447 |
| 471 - (instancetype)initWithWebState:(web::WebState*)webState { | 448 - (instancetype)initWithWebState:(web::WebState*)webState { |
| 472 DCHECK(webState); | 449 DCHECK(webState); |
| 473 self = [super init]; | 450 self = [super init]; |
| 474 if (self) { | 451 if (self) { |
| 475 propertyReleaser_Tab_.Init(self, [Tab class]); | |
| 476 | |
| 477 // TODO(crbug.com/620465): Tab should only use public API of WebState. | 452 // TODO(crbug.com/620465): Tab should only use public API of WebState. |
| 478 // Remove this cast once this is the case. | 453 // Remove this cast once this is the case. |
| 479 webStateImpl_ = static_cast<web::WebStateImpl*>(webState); | 454 webStateImpl_ = static_cast<web::WebStateImpl*>(webState); |
| 480 browserState_ = | 455 browserState_ = |
| 481 ios::ChromeBrowserState::FromBrowserState(webState->GetBrowserState()); | 456 ios::ChromeBrowserState::FromBrowserState(webState->GetBrowserState()); |
| 482 | |
| 483 tabHistoryContext_ = base::MakeUnique<TabHistoryContext>(); | |
| 484 webStateObserver_ = | 457 webStateObserver_ = |
| 485 base::MakeUnique<web::WebStateObserverBridge>(webState, self); | 458 base::MakeUnique<web::WebStateObserverBridge>(webState, self); |
| 486 | 459 |
| 487 [self updateLastVisitedTimestamp]; | 460 [self updateLastVisitedTimestamp]; |
| 488 [[self webController] addObserver:self]; | 461 [[self webController] addObserver:self]; |
| 489 [[self webController] setDelegate:self]; | 462 [[self webController] setDelegate:self]; |
| 490 | 463 |
| 491 snapshotManager_.reset([[SnapshotManager alloc] init]); | 464 snapshotManager_ = [[SnapshotManager alloc] init]; |
| 492 webControllerSnapshotHelper_.reset([[WebControllerSnapshotHelper alloc] | 465 webControllerSnapshotHelper_ = [[WebControllerSnapshotHelper alloc] |
| 493 initWithSnapshotManager:snapshotManager_ | 466 initWithSnapshotManager:snapshotManager_ |
| 494 tab:self]); | 467 tab:self]; |
| 495 | 468 |
| 496 [[NSNotificationCenter defaultCenter] | 469 [[NSNotificationCenter defaultCenter] |
| 497 addObserver:self | 470 addObserver:self |
| 498 selector:@selector(applicationDidBecomeActive) | 471 selector:@selector(applicationDidBecomeActive) |
| 499 name:UIApplicationDidBecomeActiveNotification | 472 name:UIApplicationDidBecomeActiveNotification |
| 500 object:nil]; | 473 object:nil]; |
| 501 } | 474 } |
| 502 return self; | 475 return self; |
| 503 } | 476 } |
| 504 | 477 |
| 505 - (void)attachTabHelpers { | 478 - (void)attachTabHelpers { |
| 506 tabInfoBarObserver_.reset(new TabInfoBarObserver(self)); | 479 tabInfoBarObserver_ = base::MakeUnique<TabInfoBarObserver>(self); |
| 507 tabInfoBarObserver_->SetShouldObserveInfoBarManager(true); | 480 tabInfoBarObserver_->SetShouldObserveInfoBarManager(true); |
| 508 | 481 |
| 509 if (experimental_flags::IsAutoReloadEnabled()) { | 482 if (experimental_flags::IsAutoReloadEnabled()) |
| 510 autoReloadBridge_.reset([[AutoReloadBridge alloc] initWithTab:self]); | 483 autoReloadBridge_ = [[AutoReloadBridge alloc] initWithTab:self]; |
| 511 } | |
| 512 printObserver_ = base::MakeUnique<PrintObserver>(self.webState); | 484 printObserver_ = base::MakeUnique<PrintObserver>(self.webState); |
| 513 | 485 |
| 514 base::scoped_nsprotocol<id<PasswordsUiDelegate>> passwordsUiDelegate( | 486 id<PasswordsUiDelegate> passwordsUiDelegate = |
| 515 [[PasswordsUiDelegateImpl alloc] init]); | 487 [[PasswordsUiDelegateImpl alloc] init]; |
| 516 passwordController_.reset([[PasswordController alloc] | 488 passwordController_ = |
| 517 initWithWebState:self.webState | 489 [[PasswordController alloc] initWithWebState:self.webState |
| 518 passwordsUiDelegate:passwordsUiDelegate]); | 490 passwordsUiDelegate:passwordsUiDelegate]; |
| 519 password_manager::PasswordGenerationManager* passwordGenerationManager = | 491 password_manager::PasswordGenerationManager* passwordGenerationManager = |
| 520 [passwordController_ passwordGenerationManager]; | 492 [passwordController_ passwordGenerationManager]; |
| 521 autofillController_.reset([[AutofillController alloc] | 493 autofillController_ = |
| 522 initWithBrowserState:browserState_ | 494 [[AutofillController alloc] initWithBrowserState:browserState_ |
| 523 passwordGenerationManager:passwordGenerationManager | 495 passwordGenerationManager:passwordGenerationManager |
| 524 webState:self.webState]); | 496 webState:self.webState]; |
| 525 suggestionController_.reset([[FormSuggestionController alloc] | 497 suggestionController_ = [[FormSuggestionController alloc] |
| 526 initWithWebState:self.webState | 498 initWithWebState:self.webState |
| 527 providers:[self suggestionProviders]]); | 499 providers:[self suggestionProviders]]; |
| 528 inputAccessoryViewController_.reset([[FormInputAccessoryViewController alloc] | 500 inputAccessoryViewController_ = [[FormInputAccessoryViewController alloc] |
| 529 initWithWebState:self.webState | 501 initWithWebState:self.webState |
| 530 providers:[self accessoryViewProviders]]); | 502 providers:[self accessoryViewProviders]]; |
| 531 | 503 |
| 532 [self setShouldObserveFaviconChanges:YES]; | 504 [self setShouldObserveFaviconChanges:YES]; |
| 533 | 505 |
| 534 // Create the ReaderModeController immediately so it can register for | 506 // Create the ReaderModeController immediately so it can register for |
| 535 // WebState changes. | 507 // WebState changes. |
| 536 if (experimental_flags::IsReaderModeEnabled()) { | 508 if (experimental_flags::IsReaderModeEnabled()) { |
| 537 readerModeController_.reset([[ReaderModeController alloc] | 509 readerModeController_ = |
| 538 initWithWebState:self.webState | 510 [[ReaderModeController alloc] initWithWebState:self.webState |
| 539 delegate:self]); | 511 delegate:self]; |
| 540 } | 512 } |
| 541 } | 513 } |
| 542 | 514 |
| 543 - (NSArray*)accessoryViewProviders { | 515 - (NSArray*)accessoryViewProviders { |
| 544 NSMutableArray* providers = [NSMutableArray array]; | 516 NSMutableArray* providers = [NSMutableArray array]; |
| 545 id<FormInputAccessoryViewProvider> provider = | 517 id<FormInputAccessoryViewProvider> provider = |
| 546 [passwordController_ accessoryViewProvider]; | 518 [passwordController_ accessoryViewProvider]; |
| 547 if (provider) | 519 if (provider) |
| 548 [providers addObject:provider]; | 520 [providers addObject:provider]; |
| 549 [providers addObject:[suggestionController_ accessoryViewProvider]]; | 521 [providers addObject:[suggestionController_ accessoryViewProvider]]; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 } | 553 } |
| 582 | 554 |
| 583 - (id<TabDialogDelegate>)dialogDelegate { | 555 - (id<TabDialogDelegate>)dialogDelegate { |
| 584 return dialogDelegate_; | 556 return dialogDelegate_; |
| 585 } | 557 } |
| 586 | 558 |
| 587 - (BOOL)loadFinished { | 559 - (BOOL)loadFinished { |
| 588 return [self.webController loadPhase] == web::PAGE_LOADED; | 560 return [self.webController loadPhase] == web::PAGE_LOADED; |
| 589 } | 561 } |
| 590 | 562 |
| 591 - (void)setDialogDelegate:(id<TabDialogDelegate>)dialogDelegate { | |
| 592 dialogDelegate_.reset(dialogDelegate); | |
| 593 } | |
| 594 | |
| 595 - (void)setIsVoiceSearchResultsTab:(BOOL)isVoiceSearchResultsTab { | 563 - (void)setIsVoiceSearchResultsTab:(BOOL)isVoiceSearchResultsTab { |
| 596 // There is intentionally no equality check in this setter, as we want the | 564 // There is intentionally no equality check in this setter, as we want the |
| 597 // notificaiton to be sent regardless of whether the value has changed. | 565 // notificaiton to be sent regardless of whether the value has changed. |
| 598 isVoiceSearchResultsTab_ = isVoiceSearchResultsTab; | 566 isVoiceSearchResultsTab_ = isVoiceSearchResultsTab; |
| 599 [parentTabModel_ notifyTabChanged:self]; | 567 [parentTabModel_ notifyTabChanged:self]; |
| 600 } | 568 } |
| 601 | 569 |
| 602 - (PasswordController*)passwordController { | |
| 603 return passwordController_.get(); | |
| 604 } | |
| 605 | |
| 606 - (void)retrieveSnapshot:(void (^)(UIImage*))callback { | 570 - (void)retrieveSnapshot:(void (^)(UIImage*))callback { |
| 607 [webControllerSnapshotHelper_ | 571 [webControllerSnapshotHelper_ |
| 608 retrieveSnapshotForWebController:self.webController | 572 retrieveSnapshotForWebController:self.webController |
| 609 sessionID:self.tabId | 573 sessionID:self.tabId |
| 610 withOverlays:[self snapshotOverlays] | 574 withOverlays:[self snapshotOverlays] |
| 611 callback:callback]; | 575 callback:callback]; |
| 612 } | 576 } |
| 613 | 577 |
| 614 - (const GURL&)url { | 578 - (const GURL&)url { |
| 615 // See note in header; this method should be removed. | 579 // See note in header; this method should be removed. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 | 612 |
| 649 - (NSString*)urlDisplayString { | 613 - (NSString*)urlDisplayString { |
| 650 base::string16 urlText = url_formatter::FormatUrl( | 614 base::string16 urlText = url_formatter::FormatUrl( |
| 651 self.url, url_formatter::kFormatUrlOmitNothing, net::UnescapeRule::SPACES, | 615 self.url, url_formatter::kFormatUrlOmitNothing, net::UnescapeRule::SPACES, |
| 652 nullptr, nullptr, nullptr); | 616 nullptr, nullptr, nullptr); |
| 653 return base::SysUTF16ToNSString(urlText); | 617 return base::SysUTF16ToNSString(urlText); |
| 654 } | 618 } |
| 655 | 619 |
| 656 - (NSString*)tabId { | 620 - (NSString*)tabId { |
| 657 if (tabId_) | 621 if (tabId_) |
| 658 return tabId_.get(); | 622 return tabId_; |
| 659 | 623 |
| 660 DCHECK(self.webState); | 624 DCHECK(self.webState); |
| 661 web::SerializableUserDataManager* userDataManager = | 625 web::SerializableUserDataManager* userDataManager = |
| 662 web::SerializableUserDataManager::FromWebState(self.webState); | 626 web::SerializableUserDataManager::FromWebState(self.webState); |
| 663 NSString* tabId = base::mac::ObjCCast<NSString>( | 627 NSString* tabId = base::mac::ObjCCast<NSString>( |
| 664 userDataManager->GetValueForSerializationKey(kTabIDKey)); | 628 userDataManager->GetValueForSerializationKey(kTabIDKey)); |
| 665 | 629 |
| 666 if (!tabId || ![tabId length]) { | 630 if (!tabId || ![tabId length]) { |
| 667 tabId = [[NSUUID UUID] UUIDString]; | 631 tabId = [[NSUUID UUID] UUIDString]; |
| 668 userDataManager->AddSerializableData(tabId, kTabIDKey); | 632 userDataManager->AddSerializableData(tabId, kTabIDKey); |
| 669 } | 633 } |
| 670 | 634 |
| 671 tabId_.reset([tabId copy]); | 635 tabId_ = [tabId copy]; |
| 672 return tabId_.get(); | 636 return tabId_; |
| 673 } | 637 } |
| 674 | 638 |
| 675 - (web::WebState*)webState { | 639 - (web::WebState*)webState { |
| 676 return webStateImpl_; | 640 return webStateImpl_; |
| 677 } | 641 } |
| 678 | 642 |
| 679 - (void)fetchFavicon { | 643 - (void)fetchFavicon { |
| 680 const GURL& url = self.url; | 644 const GURL& url = self.url; |
| 681 if (!url.is_valid()) | 645 if (!url.is_valid()) |
| 682 return; | 646 return; |
| 683 | 647 |
| 684 favicon::FaviconDriver* faviconDriver = | 648 favicon::FaviconDriver* faviconDriver = |
| 685 favicon::WebFaviconDriver::FromWebState(self.webState); | 649 favicon::WebFaviconDriver::FromWebState(self.webState); |
| 686 if (faviconDriver) { | 650 if (faviconDriver) |
| 687 faviconDriver->FetchFavicon(url); | 651 faviconDriver->FetchFavicon(url); |
| 688 } | |
| 689 } | 652 } |
| 690 | 653 |
| 691 - (void)setFavicon:(const gfx::Image*)image { | 654 - (void)setFavicon:(const gfx::Image*)image { |
| 692 web::NavigationItem* item = [self navigationManager]->GetVisibleItem(); | 655 web::NavigationItem* item = [self navigationManager]->GetVisibleItem(); |
| 693 if (!item) | 656 if (!item) |
| 694 return; | 657 return; |
| 695 if (image) { | 658 if (image) { |
| 696 item->GetFavicon().image = *image; | 659 item->GetFavicon().image = *image; |
| 697 item->GetFavicon().valid = true; | 660 item->GetFavicon().valid = true; |
| 698 } | 661 } |
| 699 [parentTabModel_ notifyTabChanged:self]; | 662 [parentTabModel_ notifyTabChanged:self]; |
| 700 } | 663 } |
| 701 | 664 |
| 702 - (UIImage*)favicon { | 665 - (UIImage*)favicon { |
| 703 DCHECK([self navigationManager]); | 666 DCHECK([self navigationManager]); |
| 704 web::NavigationItem* item = [self navigationManager]->GetVisibleItem(); | 667 web::NavigationItem* item = [self navigationManager]->GetVisibleItem(); |
| 705 if (!item) | 668 if (!item) |
| 706 return nil; | 669 return nil; |
| 707 const gfx::Image& image = item->GetFavicon().image; | 670 const gfx::Image& image = item->GetFavicon().image; |
| 708 if (image.IsEmpty()) | 671 if (image.IsEmpty()) |
| 709 return nil; | 672 return nil; |
| 710 return image.ToUIImage(); | 673 return image.ToUIImage(); |
| 711 } | 674 } |
| 712 | 675 |
| 713 - (UIView*)view { | 676 - (UIView*)view { |
| 714 // Record reload of previously-evicted tab. | 677 // Record reload of previously-evicted tab. |
| 715 if (![self.webController isViewAlive] && [parentTabModel_ tabUsageRecorder]) { | 678 if (![self.webController isViewAlive] && [parentTabModel_ tabUsageRecorder]) |
| 716 [parentTabModel_ tabUsageRecorder]->RecordPageLoadStart(self); | 679 [parentTabModel_ tabUsageRecorder]->RecordPageLoadStart(self); |
| 717 } | |
| 718 return self.webState ? self.webState->GetView() : nil; | 680 return self.webState ? self.webState->GetView() : nil; |
| 719 } | 681 } |
| 720 | 682 |
| 721 - (UIView*)viewForPrinting { | 683 - (UIView*)viewForPrinting { |
| 722 return self.webController.viewForPrinting; | 684 return self.webController.viewForPrinting; |
| 723 } | 685 } |
| 724 | 686 |
| 725 - (web::NavigationManager*)navigationManager { | 687 - (web::NavigationManager*)navigationManager { |
| 726 return self.webState ? self.webState->GetNavigationManager() : nullptr; | 688 return self.webState ? self.webState->GetNavigationManager() : nullptr; |
| 727 } | 689 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 747 } | 709 } |
| 748 | 710 |
| 749 - (void)didReplaceSessionHistory { | 711 - (void)didReplaceSessionHistory { |
| 750 // Replace fullScreenController_ with a new sessionID when the navigation | 712 // Replace fullScreenController_ with a new sessionID when the navigation |
| 751 // manager changes. | 713 // manager changes. |
| 752 // TODO(crbug.com/661666): Consider just updating sessionID and not replacing | 714 // TODO(crbug.com/661666): Consider just updating sessionID and not replacing |
| 753 // |fullScreenController_|. | 715 // |fullScreenController_|. |
| 754 if (fullScreenController_) { | 716 if (fullScreenController_) { |
| 755 [fullScreenController_ invalidate]; | 717 [fullScreenController_ invalidate]; |
| 756 [self.webController removeObserver:fullScreenController_]; | 718 [self.webController removeObserver:fullScreenController_]; |
| 757 fullScreenController_.reset([[FullScreenController alloc] | 719 fullScreenController_ = [[FullScreenController alloc] |
| 758 initWithDelegate:fullScreenControllerDelegate_ | 720 initWithDelegate:fullScreenControllerDelegate_ |
| 759 navigationManager:self.navigationManager | 721 navigationManager:self.navigationManager |
| 760 sessionID:self.tabId]); | 722 sessionID:self.tabId]; |
| 761 [self.webController addObserver:fullScreenController_]; | 723 [self.webController addObserver:fullScreenController_]; |
| 762 // If the content of the page was loaded without knowledge of the | 724 // If the content of the page was loaded without knowledge of the |
| 763 // toolbar position it will be misplaced under the toolbar instead of | 725 // toolbar position it will be misplaced under the toolbar instead of |
| 764 // right below. This happens e.g. in the case of preloading. This is to make | 726 // right below. This happens e.g. in the case of preloading. This is to make |
| 765 // sure the content is moved to the right place. | 727 // sure the content is moved to the right place. |
| 766 [fullScreenController_ moveContentBelowHeader]; | 728 [fullScreenController_ moveContentBelowHeader]; |
| 767 } | 729 } |
| 768 } | 730 } |
| 769 | 731 |
| 770 - (void)setIsLinkLoadingPrerenderTab:(BOOL)isLinkLoadingPrerenderTab { | 732 - (void)setIsLinkLoadingPrerenderTab:(BOOL)isLinkLoadingPrerenderTab { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 794 BOOL loadingFinished = self.webController.loadPhase == web::PAGE_LOADED; | 756 BOOL loadingFinished = self.webController.loadPhase == web::PAGE_LOADED; |
| 795 if (loadingFinished) | 757 if (loadingFinished) |
| 796 [self updateSnapshotWithOverlay:YES visibleFrameOnly:YES]; | 758 [self updateSnapshotWithOverlay:YES visibleFrameOnly:YES]; |
| 797 | 759 |
| 798 [[OmniboxGeolocationController sharedInstance] | 760 [[OmniboxGeolocationController sharedInstance] |
| 799 finishPageLoadForTab:self | 761 finishPageLoadForTab:self |
| 800 loadSuccess:loadingFinished]; | 762 loadSuccess:loadingFinished]; |
| 801 [self countMainFrameLoad]; | 763 [self countMainFrameLoad]; |
| 802 } | 764 } |
| 803 | 765 |
| 804 - (id<FullScreenControllerDelegate>)fullScreenControllerDelegate { | |
| 805 return fullScreenControllerDelegate_.get(); | |
| 806 } | |
| 807 | |
| 808 - (void)setFullScreenControllerDelegate: | 766 - (void)setFullScreenControllerDelegate: |
| 809 (id<FullScreenControllerDelegate>)fullScreenControllerDelegate { | 767 (id<FullScreenControllerDelegate>)fullScreenControllerDelegate { |
| 810 if (fullScreenControllerDelegate == fullScreenControllerDelegate_) { | 768 if (fullScreenControllerDelegate == fullScreenControllerDelegate_) |
| 811 return; | 769 return; |
| 812 } | |
| 813 // Lazily create a FullScreenController. | 770 // Lazily create a FullScreenController. |
| 814 // The check for fullScreenControllerDelegate is necessary to avoid recreating | 771 // The check for fullScreenControllerDelegate is necessary to avoid recreating |
| 815 // a FullScreenController during teardown. | 772 // a FullScreenController during teardown. |
| 816 if (!fullScreenController_ && fullScreenControllerDelegate) { | 773 if (!fullScreenController_ && fullScreenControllerDelegate) { |
| 817 fullScreenController_.reset([[FullScreenController alloc] | 774 fullScreenController_ = [[FullScreenController alloc] |
| 818 initWithDelegate:fullScreenControllerDelegate | 775 initWithDelegate:fullScreenControllerDelegate |
| 819 navigationManager:self.navigationManager | 776 navigationManager:self.navigationManager |
| 820 sessionID:self.tabId]); | 777 sessionID:self.tabId]; |
| 821 [self.webController addObserver:fullScreenController_]; | 778 [self.webController addObserver:fullScreenController_]; |
| 822 // If the content of the page was loaded without knowledge of the | 779 // If the content of the page was loaded without knowledge of the |
| 823 // toolbar position it will be misplaced under the toolbar instead of | 780 // toolbar position it will be misplaced under the toolbar instead of |
| 824 // right below. This happens e.g. in the case of preloading. This is to make | 781 // right below. This happens e.g. in the case of preloading. This is to make |
| 825 // sure the content is moved to the right place. | 782 // sure the content is moved to the right place. |
| 826 [fullScreenController_ moveContentBelowHeader]; | 783 [fullScreenController_ moveContentBelowHeader]; |
| 827 } | 784 } |
| 828 fullScreenControllerDelegate_.reset(fullScreenControllerDelegate); | 785 fullScreenControllerDelegate_ = fullScreenControllerDelegate; |
| 829 } | |
| 830 | |
| 831 - (OverscrollActionsController*)overscrollActionsController { | |
| 832 return overscrollActionsController_.get(); | |
| 833 } | |
| 834 | |
| 835 - (id<OverscrollActionsControllerDelegate>)overscrollActionsControllerDelegate { | |
| 836 return overscrollActionsControllerDelegate_.get(); | |
| 837 } | 786 } |
| 838 | 787 |
| 839 - (void)setOverscrollActionsControllerDelegate: | 788 - (void)setOverscrollActionsControllerDelegate: |
| 840 (id<OverscrollActionsControllerDelegate>) | 789 (id<OverscrollActionsControllerDelegate>) |
| 841 overscrollActionsControllerDelegate { | 790 overscrollActionsControllerDelegate { |
| 842 if (overscrollActionsControllerDelegate_ == | 791 if (overscrollActionsControllerDelegate_ == |
| 843 overscrollActionsControllerDelegate) | 792 overscrollActionsControllerDelegate) { |
| 844 return; | 793 return; |
| 794 } |
| 845 | 795 |
| 846 // Lazily create a OverscrollActionsController. | 796 // Lazily create a OverscrollActionsController. |
| 847 // The check for overscrollActionsControllerDelegate is necessary to avoid | 797 // The check for overscrollActionsControllerDelegate is necessary to avoid |
| 848 // recreating a OverscrollActionsController during teardown. | 798 // recreating a OverscrollActionsController during teardown. |
| 849 if (!overscrollActionsController_) { | 799 if (!overscrollActionsController_) { |
| 850 overscrollActionsController_.reset( | 800 overscrollActionsController_ = [[OverscrollActionsController alloc] init]; |
| 851 [[OverscrollActionsController alloc] init]); | |
| 852 [self.webController addObserver:overscrollActionsController_]; | 801 [self.webController addObserver:overscrollActionsController_]; |
| 853 } | 802 } |
| 854 OverscrollStyle style = OverscrollStyle::REGULAR_PAGE_NON_INCOGNITO; | 803 OverscrollStyle style = OverscrollStyle::REGULAR_PAGE_NON_INCOGNITO; |
| 855 if (browserState_->IsOffTheRecord()) { | 804 if (browserState_->IsOffTheRecord()) |
| 856 style = OverscrollStyle::REGULAR_PAGE_INCOGNITO; | 805 style = OverscrollStyle::REGULAR_PAGE_INCOGNITO; |
| 857 } | |
| 858 [overscrollActionsController_ setStyle:style]; | 806 [overscrollActionsController_ setStyle:style]; |
| 859 [overscrollActionsController_ | 807 [overscrollActionsController_ |
| 860 setDelegate:overscrollActionsControllerDelegate]; | 808 setDelegate:overscrollActionsControllerDelegate]; |
| 861 overscrollActionsControllerDelegate_.reset( | 809 overscrollActionsControllerDelegate_ = overscrollActionsControllerDelegate; |
| 862 overscrollActionsControllerDelegate); | |
| 863 } | 810 } |
| 864 | 811 |
| 865 - (void)saveTitleToHistoryDB { | 812 - (void)saveTitleToHistoryDB { |
| 866 // If incognito, don't update history. | 813 // If incognito, don't update history. |
| 867 if (browserState_->IsOffTheRecord()) | 814 if (browserState_->IsOffTheRecord()) |
| 868 return; | 815 return; |
| 869 // Don't update the history if current entry has no title. | 816 // Don't update the history if current entry has no title. |
| 870 NSString* title = [self title]; | 817 NSString* title = [self title]; |
| 871 if (![title length] || | 818 if (![title length] || |
| 872 [title isEqualToString:l10n_util::GetNSString(IDS_DEFAULT_TAB_TITLE)]) | 819 [title isEqualToString:l10n_util::GetNSString(IDS_DEFAULT_TAB_TITLE)]) { |
| 873 return; | 820 return; |
| 821 } |
| 874 | 822 |
| 875 history::HistoryService* historyService = | 823 history::HistoryService* historyService = |
| 876 ios::HistoryServiceFactory::GetForBrowserState( | 824 ios::HistoryServiceFactory::GetForBrowserState( |
| 877 browserState_, ServiceAccessType::IMPLICIT_ACCESS); | 825 browserState_, ServiceAccessType::IMPLICIT_ACCESS); |
| 878 DCHECK(historyService); | 826 DCHECK(historyService); |
| 879 historyService->SetPageTitle(self.url, base::SysNSStringToUTF16(title)); | 827 historyService->SetPageTitle(self.url, base::SysNSStringToUTF16(title)); |
| 880 } | 828 } |
| 881 | 829 |
| 882 - (void)addCurrentEntryToHistoryDB { | 830 - (void)addCurrentEntryToHistoryDB { |
| 883 DCHECK([self navigationManager]->GetVisibleItem()); | 831 DCHECK([self navigationManager]->GetVisibleItem()); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 } | 877 } |
| 930 | 878 |
| 931 DCHECK(item->GetTimestamp().ToInternalValue() > 0); | 879 DCHECK(item->GetTimestamp().ToInternalValue() > 0); |
| 932 if ([self isPrerenderTab]) { | 880 if ([self isPrerenderTab]) { |
| 933 // Clicks on content suggestions on the NTP should not contribute to the | 881 // Clicks on content suggestions on the NTP should not contribute to the |
| 934 // Most Visited tiles in the NTP. | 882 // Most Visited tiles in the NTP. |
| 935 const bool consider_for_ntp_most_visited = | 883 const bool consider_for_ntp_most_visited = |
| 936 referrer.url != GURL(kChromeContentSuggestionsReferrer); | 884 referrer.url != GURL(kChromeContentSuggestionsReferrer); |
| 937 | 885 |
| 938 history::HistoryAddPageArgs args( | 886 history::HistoryAddPageArgs args( |
| 939 url, item->GetTimestamp(), tabHistoryContext_.get(), | 887 url, item->GetTimestamp(), &tabHistoryContext_, item->GetUniqueID(), |
| 940 item->GetUniqueID(), referrer.url, redirects, item->GetTransitionType(), | 888 referrer.url, redirects, item->GetTransitionType(), |
| 941 history::SOURCE_BROWSED, false, consider_for_ntp_most_visited); | 889 history::SOURCE_BROWSED, false, consider_for_ntp_most_visited); |
| 942 addPageVector_.push_back(args); | 890 addPageVector_.push_back(args); |
| 943 } else { | 891 } else { |
| 944 historyService->AddPage(url, item->GetTimestamp(), tabHistoryContext_.get(), | 892 historyService->AddPage(url, item->GetTimestamp(), &tabHistoryContext_, |
| 945 item->GetUniqueID(), referrer.url, redirects, | 893 item->GetUniqueID(), referrer.url, redirects, |
| 946 item->GetTransitionType(), history::SOURCE_BROWSED, | 894 item->GetTransitionType(), history::SOURCE_BROWSED, |
| 947 false); | 895 false); |
| 948 [self saveTitleToHistoryDB]; | 896 [self saveTitleToHistoryDB]; |
| 949 } | 897 } |
| 950 } | 898 } |
| 951 | 899 |
| 952 - (void)commitCachedEntriesToHistoryDB { | 900 - (void)commitCachedEntriesToHistoryDB { |
| 953 // If OTR, don't update history. | 901 // If OTR, don't update history. |
| 954 if (browserState_->IsOffTheRecord()) { | 902 if (browserState_->IsOffTheRecord()) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 982 } | 930 } |
| 983 } | 931 } |
| 984 | 932 |
| 985 ui::PageTransition transition = params.transition_type; | 933 ui::PageTransition transition = params.transition_type; |
| 986 | 934 |
| 987 // Record any explicit, non-redirect navigation as a clobber (as long as it's | 935 // Record any explicit, non-redirect navigation as a clobber (as long as it's |
| 988 // in a real tab). | 936 // in a real tab). |
| 989 if (!initialNavigation && !isPrerenderTab_ && | 937 if (!initialNavigation && !isPrerenderTab_ && |
| 990 !PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_RELOAD) && | 938 !PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_RELOAD) && |
| 991 (transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) == 0) { | 939 (transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) == 0) { |
| 992 base::RecordAction(UserMetricsAction("MobileTabClobbered")); | 940 base::RecordAction(base::UserMetricsAction("MobileTabClobbered")); |
| 993 } | 941 } |
| 994 if ([parentTabModel_ tabUsageRecorder]) | 942 if ([parentTabModel_ tabUsageRecorder]) |
| 995 [parentTabModel_ tabUsageRecorder]->RecordPageLoadStart(self); | 943 [parentTabModel_ tabUsageRecorder]->RecordPageLoadStart(self); |
| 996 | 944 |
| 997 // Reset |isVoiceSearchResultsTab| since a new page is being navigated to. | 945 // Reset |isVoiceSearchResultsTab| since a new page is being navigated to. |
| 998 self.isVoiceSearchResultsTab = NO; | 946 self.isVoiceSearchResultsTab = NO; |
| 999 | 947 |
| 1000 web::NavigationItem* navigationItem = | 948 web::NavigationItem* navigationItem = |
| 1001 [self navigationManager]->GetPendingItem(); | 949 [self navigationManager]->GetPendingItem(); |
| 1002 | 950 |
| 1003 // TODO(crbug.com/676129): the pending item is not correctly set when the | 951 // TODO(crbug.com/676129): the pending item is not correctly set when the |
| 1004 // page is reloading, use the last committed item if pending item is null. | 952 // page is reloading, use the last committed item if pending item is null. |
| 1005 // Remove this once tracking bug is fixed. | 953 // Remove this once tracking bug is fixed. |
| 1006 if (!navigationItem) | 954 if (!navigationItem) |
| 1007 navigationItem = [self navigationManager]->GetLastCommittedItem(); | 955 navigationItem = [self navigationManager]->GetLastCommittedItem(); |
| 1008 | 956 |
| 1009 [[OmniboxGeolocationController sharedInstance] | 957 [[OmniboxGeolocationController sharedInstance] |
| 1010 addLocationToNavigationItem:navigationItem | 958 addLocationToNavigationItem:navigationItem |
| 1011 browserState:browserState_]; | 959 browserState:browserState_]; |
| 1012 } | 960 } |
| 1013 | 961 |
| 1014 - (void)loadSessionTab:(const sessions::SessionTab*)sessionTab { | 962 - (void)loadSessionTab:(const sessions::SessionTab*)sessionTab { |
| 1015 DCHECK(sessionTab); | 963 DCHECK(sessionTab); |
| 1016 [self replaceHistoryWithNavigations:sessionTab->navigations | 964 [self replaceHistoryWithNavigations:sessionTab->navigations |
| 1017 currentIndex:sessionTab->current_navigation_index]; | 965 currentIndex:sessionTab->current_navigation_index]; |
| 1018 } | 966 } |
| 1019 | 967 |
| 1020 - (void)webWillReload { | 968 - (void)webWillReload { |
| 1021 if ([parentTabModel_ tabUsageRecorder]) { | 969 if ([parentTabModel_ tabUsageRecorder]) |
| 1022 [parentTabModel_ tabUsageRecorder]->RecordReload(self); | 970 [parentTabModel_ tabUsageRecorder]->RecordReload(self); |
| 1023 } | |
| 1024 } | 971 } |
| 1025 | 972 |
| 1026 // Halt the tab, which amounts to halting its webController. | 973 // Halt the tab, which amounts to halting its webController. |
| 1027 - (void)terminateNetworkActivity { | 974 - (void)terminateNetworkActivity { |
| 1028 [self.webController terminateNetworkActivity]; | 975 [self.webController terminateNetworkActivity]; |
| 1029 } | 976 } |
| 1030 | 977 |
| 1031 - (void)webStateDestroyed:(web::WebState*)webState { | 978 - (void)webStateDestroyed:(web::WebState*)webState { |
| 1032 DCHECK_EQ(webStateImpl_, webState); | 979 DCHECK_EQ(webStateImpl_, webState); |
| 1033 self.fullScreenControllerDelegate = nil; | 980 self.fullScreenControllerDelegate = nil; |
| 1034 self.overscrollActionsControllerDelegate = nil; | 981 self.overscrollActionsControllerDelegate = nil; |
| 1035 self.passKitDialogProvider = nil; | 982 self.passKitDialogProvider = nil; |
| 1036 self.snapshotOverlayProvider = nil; | 983 self.snapshotOverlayProvider = nil; |
| 1037 | 984 |
| 1038 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 985 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| 1039 | 986 |
| 1040 [passwordController_ detach]; | 987 [passwordController_ detach]; |
| 1041 passwordController_.reset(); | 988 passwordController_ = nil; |
| 1042 tabInfoBarObserver_.reset(); | 989 tabInfoBarObserver_.reset(); |
| 1043 | 990 |
| 1044 faviconDriverObserverBridge_.reset(); | 991 faviconDriverObserverBridge_.reset(); |
| 1045 [openInController_ detachFromWebController]; | 992 [openInController_ detachFromWebController]; |
| 1046 openInController_.reset(); | 993 openInController_ = nil; |
| 1047 [autofillController_ detachFromWebState]; | 994 [autofillController_ detachFromWebState]; |
| 1048 [suggestionController_ detachFromWebState]; | 995 [suggestionController_ detachFromWebState]; |
| 1049 if (fullScreenController_) | 996 if (fullScreenController_) |
| 1050 [self.webController removeObserver:fullScreenController_]; | 997 [self.webController removeObserver:fullScreenController_]; |
| 1051 [fullScreenController_ invalidate]; | 998 [fullScreenController_ invalidate]; |
| 1052 fullScreenController_.reset(); | 999 fullScreenController_ = nil; |
| 1053 if (overscrollActionsController_) | 1000 if (overscrollActionsController_) |
| 1054 [self.webController removeObserver:overscrollActionsController_]; | 1001 [self.webController removeObserver:overscrollActionsController_]; |
| 1055 [overscrollActionsController_ invalidate]; | 1002 [overscrollActionsController_ invalidate]; |
| 1056 overscrollActionsController_.reset(); | 1003 overscrollActionsController_ = nil; |
| 1057 [readerModeController_ detachFromWebState]; | 1004 [readerModeController_ detachFromWebState]; |
| 1058 readerModeController_.reset(); | 1005 readerModeController_ = nil; |
| 1059 | 1006 |
| 1060 // Invalidate any snapshot stored for this session. | 1007 // Invalidate any snapshot stored for this session. |
| 1061 DCHECK(self.tabId); | 1008 DCHECK(self.tabId); |
| 1062 [snapshotManager_ removeImageWithSessionID:self.tabId]; | 1009 [snapshotManager_ removeImageWithSessionID:self.tabId]; |
| 1063 | 1010 |
| 1064 // Cancel any queued dialogs. | 1011 // Cancel any queued dialogs. |
| 1065 [self.dialogDelegate cancelDialogForTab:self]; | 1012 [self.dialogDelegate cancelDialogForTab:self]; |
| 1066 | 1013 |
| 1067 webStateObserver_.reset(); | 1014 webStateObserver_.reset(); |
| 1068 webStateImpl_ = nullptr; | 1015 webStateImpl_ = nullptr; |
| 1069 } | 1016 } |
| 1070 | 1017 |
| 1071 - (void)dismissModals { | 1018 - (void)dismissModals { |
| 1072 [openInController_ disable]; | 1019 [openInController_ disable]; |
| 1073 [self.webController dismissModals]; | 1020 [self.webController dismissModals]; |
| 1074 } | 1021 } |
| 1075 | 1022 |
| 1076 - (void)setShouldObserveInfoBarManager:(BOOL)shouldObserveInfoBarManager { | 1023 - (void)setShouldObserveInfoBarManager:(BOOL)shouldObserveInfoBarManager { |
| 1077 tabInfoBarObserver_->SetShouldObserveInfoBarManager( | 1024 tabInfoBarObserver_->SetShouldObserveInfoBarManager( |
| 1078 shouldObserveInfoBarManager); | 1025 shouldObserveInfoBarManager); |
| 1079 } | 1026 } |
| 1080 | 1027 |
| 1081 - (void)setShouldObserveFaviconChanges:(BOOL)shouldObserveFaviconChanges { | 1028 - (void)setShouldObserveFaviconChanges:(BOOL)shouldObserveFaviconChanges { |
| 1082 if (shouldObserveFaviconChanges) { | 1029 if (shouldObserveFaviconChanges) { |
| 1083 favicon::FaviconDriver* faviconDriver = | 1030 favicon::FaviconDriver* faviconDriver = |
| 1084 favicon::WebFaviconDriver::FromWebState(self.webState); | 1031 favicon::WebFaviconDriver::FromWebState(self.webState); |
| 1085 // Some MockWebContents used in tests do not support the FaviconDriver. | 1032 // Some MockWebContents used in tests do not support the FaviconDriver. |
| 1086 if (faviconDriver) { | 1033 if (faviconDriver) { |
| 1087 faviconDriverObserverBridge_.reset( | 1034 faviconDriverObserverBridge_ = |
| 1088 new FaviconDriverObserverBridge(self, faviconDriver)); | 1035 base::MakeUnique<FaviconDriverObserverBridge>(self, faviconDriver); |
| 1089 } | 1036 } |
| 1090 } else { | 1037 } else { |
| 1091 faviconDriverObserverBridge_.reset(); | 1038 faviconDriverObserverBridge_.reset(); |
| 1092 } | 1039 } |
| 1093 } | 1040 } |
| 1094 | 1041 |
| 1095 - (void)goBack { | 1042 - (void)goBack { |
| 1096 if (self.navigationManager) { | 1043 if (self.navigationManager) { |
| 1097 DCHECK(self.navigationManager->CanGoBack()); | 1044 DCHECK(self.navigationManager->CanGoBack()); |
| 1098 base::RecordAction(UserMetricsAction("Back")); | 1045 base::RecordAction(base::UserMetricsAction("Back")); |
| 1099 self.navigationManager->GoBack(); | 1046 self.navigationManager->GoBack(); |
| 1100 } | 1047 } |
| 1101 } | 1048 } |
| 1102 | 1049 |
| 1103 - (void)goForward { | 1050 - (void)goForward { |
| 1104 if (self.navigationManager) { | 1051 if (self.navigationManager) { |
| 1105 DCHECK(self.navigationManager->CanGoForward()); | 1052 DCHECK(self.navigationManager->CanGoForward()); |
| 1106 base::RecordAction(UserMetricsAction("Forward")); | 1053 base::RecordAction(base::UserMetricsAction("Forward")); |
| 1107 self.navigationManager->GoForward(); | 1054 self.navigationManager->GoForward(); |
| 1108 } | 1055 } |
| 1109 } | 1056 } |
| 1110 | 1057 |
| 1111 - (BOOL)canGoBack { | 1058 - (BOOL)canGoBack { |
| 1112 return self.navigationManager && self.navigationManager->CanGoBack(); | 1059 return self.navigationManager && self.navigationManager->CanGoBack(); |
| 1113 } | 1060 } |
| 1114 | 1061 |
| 1115 - (BOOL)canGoForward { | 1062 - (BOOL)canGoForward { |
| 1116 return self.navigationManager && self.navigationManager->CanGoForward(); | 1063 return self.navigationManager && self.navigationManager->CanGoForward(); |
| 1117 } | 1064 } |
| 1118 | 1065 |
| 1119 - (void)goToItem:(const web::NavigationItem*)item { | 1066 - (void)goToItem:(const web::NavigationItem*)item { |
| 1120 DCHECK(item); | 1067 DCHECK(item); |
| 1121 | 1068 |
| 1122 if (self.navigationManager) { | 1069 if (self.navigationManager) { |
| 1123 CRWSessionController* sessionController = | 1070 CRWSessionController* sessionController = |
| 1124 [self navigationManagerImpl]->GetSessionController(); | 1071 [self navigationManagerImpl]->GetSessionController(); |
| 1125 NSInteger itemIndex = [sessionController indexOfItem:item]; | 1072 NSInteger itemIndex = [sessionController indexOfItem:item]; |
| 1126 DCHECK_NE(itemIndex, NSNotFound); | 1073 DCHECK_NE(itemIndex, NSNotFound); |
| 1127 self.navigationManager->GoToIndex(itemIndex); | 1074 self.navigationManager->GoToIndex(itemIndex); |
| 1128 } | 1075 } |
| 1129 } | 1076 } |
| 1130 | 1077 |
| 1131 - (BOOL)openExternalURL:(const GURL&)url | 1078 - (BOOL)openExternalURL:(const GURL&)url |
| 1132 sourceURL:(const GURL&)sourceURL | 1079 sourceURL:(const GURL&)sourceURL |
| 1133 linkClicked:(BOOL)linkClicked { | 1080 linkClicked:(BOOL)linkClicked { |
| 1134 if (!externalAppLauncher_.get()) | 1081 if (!externalAppLauncher_) |
| 1135 externalAppLauncher_.reset([[ExternalAppLauncher alloc] init]); | 1082 externalAppLauncher_ = [[ExternalAppLauncher alloc] init]; |
| 1136 | |
| 1137 // This method may release CRWWebController which may cause a crash | |
| 1138 // (crbug.com/393949). | |
| 1139 [[self.webController retain] autorelease]; | |
| 1140 | 1083 |
| 1141 // Make a local url copy for possible modification. | 1084 // Make a local url copy for possible modification. |
| 1142 GURL finalURL = url; | 1085 GURL finalURL = url; |
| 1143 | 1086 |
| 1144 // Check if it's a direct FIDO U2F x-callback call. If so, do not open it, to | 1087 // Check if it's a direct FIDO U2F x-callback call. If so, do not open it, to |
| 1145 // prevent pages from spoofing requests with different origins. | 1088 // prevent pages from spoofing requests with different origins. |
| 1146 if (finalURL.SchemeIs("u2f-x-callback")) { | 1089 if (finalURL.SchemeIs("u2f-x-callback")) |
| 1147 return NO; | 1090 return NO; |
| 1148 } | |
| 1149 | 1091 |
| 1150 // Check if it's a FIDO U2F call. | 1092 // Check if it's a FIDO U2F call. |
| 1151 if (finalURL.SchemeIs("u2f")) { | 1093 if (finalURL.SchemeIs("u2f")) { |
| 1152 // Create U2FController object lazily. | 1094 // Create U2FController object lazily. |
| 1153 if (!U2FController_) { | 1095 if (!U2FController_) |
| 1154 U2FController_.reset([[U2FController alloc] init]); | 1096 U2FController_ = [[U2FController alloc] init]; |
| 1155 } | |
| 1156 | 1097 |
| 1157 DCHECK([self navigationManager]); | 1098 DCHECK([self navigationManager]); |
| 1158 GURL origin = | 1099 GURL origin = |
| 1159 [self navigationManager]->GetLastCommittedItem()->GetURL().GetOrigin(); | 1100 [self navigationManager]->GetLastCommittedItem()->GetURL().GetOrigin(); |
| 1160 | 1101 |
| 1161 // Compose u2f-x-callback URL and update urlToOpen. | 1102 // Compose u2f-x-callback URL and update urlToOpen. |
| 1162 finalURL = [U2FController_ XCallbackFromRequestURL:finalURL | 1103 finalURL = [U2FController_ XCallbackFromRequestURL:finalURL |
| 1163 originURL:origin | 1104 originURL:origin |
| 1164 tabURL:self.url | 1105 tabURL:self.url |
| 1165 tabID:self.tabId]; | 1106 tabID:self.tabId]; |
| 1166 | 1107 |
| 1167 if (!finalURL.is_valid()) { | 1108 if (!finalURL.is_valid()) |
| 1168 return NO; | 1109 return NO; |
| 1169 } | |
| 1170 } | 1110 } |
| 1171 | 1111 |
| 1172 if ([externalAppLauncher_ openURL:finalURL linkClicked:linkClicked]) { | 1112 if ([externalAppLauncher_ openURL:finalURL linkClicked:linkClicked]) { |
| 1173 // Clears pending navigation history after successfully launching the | 1113 // Clears pending navigation history after successfully launching the |
| 1174 // external app. | 1114 // external app. |
| 1175 DCHECK([self navigationManager]); | 1115 DCHECK([self navigationManager]); |
| 1176 [self navigationManager]->DiscardNonCommittedItems(); | 1116 [self navigationManager]->DiscardNonCommittedItems(); |
| 1177 // Ensure the UI reflects the current entry, not the just-discarded pending | 1117 // Ensure the UI reflects the current entry, not the just-discarded pending |
| 1178 // entry. | 1118 // entry. |
| 1179 [parentTabModel_ notifyTabChanged:self]; | 1119 [parentTabModel_ notifyTabChanged:self]; |
| 1180 | 1120 |
| 1181 if (sourceURL.is_valid()) { | 1121 if (sourceURL.is_valid()) { |
| 1182 ReadingListModel* model = | 1122 ReadingListModel* model = |
| 1183 ReadingListModelFactory::GetForBrowserState(browserState_); | 1123 ReadingListModelFactory::GetForBrowserState(browserState_); |
| 1184 if (model && model->loaded()) { | 1124 if (model && model->loaded()) |
| 1185 model->SetReadStatus(sourceURL, true); | 1125 model->SetReadStatus(sourceURL, true); |
| 1186 } | |
| 1187 } | 1126 } |
| 1188 | 1127 |
| 1189 return YES; | 1128 return YES; |
| 1190 } | 1129 } |
| 1191 return NO; | 1130 return NO; |
| 1192 } | 1131 } |
| 1193 | 1132 |
| 1194 - (void)webState:(web::WebState*)webState | 1133 - (void)webState:(web::WebState*)webState |
| 1195 didFinishNavigation:(web::NavigationContext*)navigation { | 1134 didFinishNavigation:(web::NavigationContext*)navigation { |
| 1196 if (navigation->IsSameDocument()) { | 1135 if (navigation->IsSameDocument()) { |
| 1136 // Fetch the favicon for the new URL. |
| 1197 auto* faviconDriver = favicon::WebFaviconDriver::FromWebState(webState); | 1137 auto* faviconDriver = favicon::WebFaviconDriver::FromWebState(webState); |
| 1198 if (faviconDriver) { | 1138 if (faviconDriver) |
| 1199 // Fetch the favicon for the new URL. | |
| 1200 faviconDriver->FetchFavicon(navigation->GetUrl()); | 1139 faviconDriver->FetchFavicon(navigation->GetUrl()); |
| 1201 } | |
| 1202 } | 1140 } |
| 1203 | 1141 |
| 1204 if (!navigation->IsErrorPage()) { | 1142 if (!navigation->IsErrorPage()) { |
| 1205 [self addCurrentEntryToHistoryDB]; | 1143 [self addCurrentEntryToHistoryDB]; |
| 1206 [self countMainFrameLoad]; | 1144 [self countMainFrameLoad]; |
| 1207 } | 1145 } |
| 1208 | 1146 |
| 1209 [parentTabModel_ notifyTabChanged:self]; | 1147 [parentTabModel_ notifyTabChanged:self]; |
| 1210 } | 1148 } |
| 1211 | 1149 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1222 break; | 1160 break; |
| 1223 case UIInterfaceOrientationUnknown: | 1161 case UIInterfaceOrientationUnknown: |
| 1224 // TODO(crbug.com/228832): Convert from a boolean histogram to an | 1162 // TODO(crbug.com/228832): Convert from a boolean histogram to an |
| 1225 // enumerated histogram and log this case as well. | 1163 // enumerated histogram and log this case as well. |
| 1226 break; | 1164 break; |
| 1227 } | 1165 } |
| 1228 } | 1166 } |
| 1229 | 1167 |
| 1230 - (OpenInController*)openInController { | 1168 - (OpenInController*)openInController { |
| 1231 if (!openInController_) { | 1169 if (!openInController_) { |
| 1232 openInController_.reset([[OpenInController alloc] | 1170 openInController_ = [[OpenInController alloc] |
| 1233 initWithRequestContext:browserState_->GetRequestContext() | 1171 initWithRequestContext:browserState_->GetRequestContext() |
| 1234 webController:self.webController]); | 1172 webController:self.webController]; |
| 1235 } | 1173 } |
| 1236 return openInController_.get(); | 1174 return openInController_; |
| 1237 } | 1175 } |
| 1238 | 1176 |
| 1239 - (id<CRWNativeContent>)controllerForUnhandledContentAtURL:(const GURL&)url { | 1177 - (id<CRWNativeContent>)controllerForUnhandledContentAtURL:(const GURL&)url { |
| 1240 // Shows download manager UI for unhandled content. | 1178 // Shows download manager UI for unhandled content. |
| 1241 DownloadManagerController* downloadController = | 1179 DownloadManagerController* downloadController = |
| 1242 [[[DownloadManagerController alloc] initWithWebState:self.webState | 1180 [[DownloadManagerController alloc] initWithWebState:self.webState |
| 1243 downloadURL:url] autorelease]; | 1181 downloadURL:url]; |
| 1244 [downloadController start]; | 1182 [downloadController start]; |
| 1245 return downloadController; | 1183 return downloadController; |
| 1246 } | 1184 } |
| 1247 | 1185 |
| 1248 - (void)handleExportableFile:(net::HttpResponseHeaders*)headers { | 1186 - (void)handleExportableFile:(net::HttpResponseHeaders*)headers { |
| 1249 // Only "application/pdf" is supported for now. | 1187 // Only "application/pdf" is supported for now. |
| 1250 if (self.webState->GetContentsMimeType() != "application/pdf") | 1188 if (self.webState->GetContentsMimeType() != "application/pdf") |
| 1251 return; | 1189 return; |
| 1252 | 1190 |
| 1253 [[NSNotificationCenter defaultCenter] | 1191 [[NSNotificationCenter defaultCenter] |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1266 "", // referrer-charset | 1204 "", // referrer-charset |
| 1267 "", // suggested-name | 1205 "", // suggested-name |
| 1268 "application/pdf", // mime-type | 1206 "application/pdf", // mime-type |
| 1269 defaultFilename); | 1207 defaultFilename); |
| 1270 [[self openInController] | 1208 [[self openInController] |
| 1271 enableWithDocumentURL:self.url | 1209 enableWithDocumentURL:self.url |
| 1272 suggestedFilename:base::SysUTF16ToNSString(filename)]; | 1210 suggestedFilename:base::SysUTF16ToNSString(filename)]; |
| 1273 } | 1211 } |
| 1274 | 1212 |
| 1275 - (void)countMainFrameLoad { | 1213 - (void)countMainFrameLoad { |
| 1276 if ([self isPrerenderTab] || [self url].SchemeIs(kChromeUIScheme)) { | 1214 if ([self isPrerenderTab] || [self url].SchemeIs(kChromeUIScheme)) |
| 1277 return; | 1215 return; |
| 1278 } | 1216 base::RecordAction(base::UserMetricsAction("MobilePageLoaded")); |
| 1279 base::RecordAction(UserMetricsAction("MobilePageLoaded")); | |
| 1280 } | 1217 } |
| 1281 | 1218 |
| 1282 - (void)applicationDidBecomeActive { | 1219 - (void)applicationDidBecomeActive { |
| 1283 if (requireReloadAfterBecomingActive_) { | 1220 if (!requireReloadAfterBecomingActive_) |
| 1284 if (visible_) { | 1221 return; |
| 1285 self.navigationManager->Reload(web::ReloadType::NORMAL, | 1222 if (visible_) { |
| 1286 false /* check_for_repost */); | 1223 self.navigationManager->Reload(web::ReloadType::NORMAL, |
| 1287 } else { | 1224 false /* check_for_repost */); |
| 1288 [self.webController requirePageReload]; | 1225 } else { |
| 1289 } | 1226 [self.webController requirePageReload]; |
| 1290 requireReloadAfterBecomingActive_ = NO; | |
| 1291 } | 1227 } |
| 1228 requireReloadAfterBecomingActive_ = NO; |
| 1292 } | 1229 } |
| 1293 | 1230 |
| 1294 #pragma mark - | 1231 #pragma mark - |
| 1295 #pragma mark FindInPageControllerDelegate | 1232 #pragma mark FindInPageControllerDelegate |
| 1296 | 1233 |
| 1297 - (void)willAdjustScrollPosition { | 1234 - (void)willAdjustScrollPosition { |
| 1298 // Skip the next attempt to correct the scroll offset for the toolbar height. | 1235 // Skip the next attempt to correct the scroll offset for the toolbar height. |
| 1299 // Used when programatically scrolling down the y offset. | 1236 // Used when programatically scrolling down the y offset. |
| 1300 [fullScreenController_ shouldSkipNextScrollOffsetForHeader]; | 1237 [fullScreenController_ shouldSkipNextScrollOffsetForHeader]; |
| 1301 } | 1238 } |
| 1302 | 1239 |
| 1303 #pragma mark - | 1240 #pragma mark - |
| 1304 #pragma mark FullScreen | 1241 #pragma mark FullScreen |
| 1305 | 1242 |
| 1306 - (void)updateFullscreenWithToolbarVisible:(BOOL)visible { | 1243 - (void)updateFullscreenWithToolbarVisible:(BOOL)visible { |
| 1307 [fullScreenController_ moveHeaderToRestingPosition:visible]; | 1244 [fullScreenController_ moveHeaderToRestingPosition:visible]; |
| 1308 } | 1245 } |
| 1309 | 1246 |
| 1310 #pragma mark - | 1247 #pragma mark - |
| 1311 #pragma mark Reader mode | 1248 #pragma mark Reader mode |
| 1312 | 1249 |
| 1313 - (UIView*)superviewForReaderModePanel { | 1250 - (UIView*)superviewForReaderModePanel { |
| 1314 return self.view; | 1251 return self.view; |
| 1315 } | 1252 } |
| 1316 | 1253 |
| 1317 - (ReaderModeController*)readerModeController { | |
| 1318 return readerModeController_.get(); | |
| 1319 } | |
| 1320 | |
| 1321 - (BOOL)canSwitchToReaderMode { | 1254 - (BOOL)canSwitchToReaderMode { |
| 1322 // Only if the page is loaded and the page passes suitability checks. | 1255 // Only if the page is loaded and the page passes suitability checks. |
| 1323 ReaderModeController* controller = self.readerModeController; | 1256 ReaderModeController* controller = self.readerModeController; |
| 1324 return controller && controller.checker->CanSwitchToReaderMode(); | 1257 return controller && controller.checker->CanSwitchToReaderMode(); |
| 1325 } | 1258 } |
| 1326 | 1259 |
| 1327 - (void)switchToReaderMode { | 1260 - (void)switchToReaderMode { |
| 1328 DCHECK(self.view); | 1261 DCHECK(self.view); |
| 1329 [self.readerModeController switchToReaderMode]; | 1262 [self.readerModeController switchToReaderMode]; |
| 1330 } | 1263 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1388 params.user_agent_override_option = | 1321 params.user_agent_override_option = |
| 1389 web::NavigationManager::UserAgentOverrideOption::MOBILE; | 1322 web::NavigationManager::UserAgentOverrideOption::MOBILE; |
| 1390 break; | 1323 break; |
| 1391 case web::UserAgentType::NONE: | 1324 case web::UserAgentType::NONE: |
| 1392 NOTREACHED(); | 1325 NOTREACHED(); |
| 1393 } | 1326 } |
| 1394 | 1327 |
| 1395 navigationManager->LoadURLWithParams(params); | 1328 navigationManager->LoadURLWithParams(params); |
| 1396 } | 1329 } |
| 1397 | 1330 |
| 1398 - (id<SnapshotOverlayProvider>)snapshotOverlayProvider { | |
| 1399 return snapshotOverlayProvider_.get(); | |
| 1400 } | |
| 1401 | |
| 1402 - (void)setSnapshotOverlayProvider: | |
| 1403 (id<SnapshotOverlayProvider>)snapshotOverlayProvider { | |
| 1404 snapshotOverlayProvider_.reset(snapshotOverlayProvider); | |
| 1405 } | |
| 1406 | |
| 1407 - (void)evaluateU2FResultFromURL:(const GURL&)URL { | 1331 - (void)evaluateU2FResultFromURL:(const GURL&)URL { |
| 1408 DCHECK(U2FController_); | 1332 DCHECK(U2FController_); |
| 1409 [U2FController_ evaluateU2FResultFromU2FURL:URL webState:self.webState]; | 1333 [U2FController_ evaluateU2FResultFromU2FURL:URL webState:self.webState]; |
| 1410 } | 1334 } |
| 1411 | 1335 |
| 1412 #pragma mark - CRWWebControllerObserver protocol methods. | 1336 #pragma mark - CRWWebControllerObserver protocol methods. |
| 1413 | 1337 |
| 1414 - (void)webControllerWillClose:(CRWWebController*)webController { | 1338 - (void)webControllerWillClose:(CRWWebController*)webController { |
| 1415 DCHECK_EQ(webController, [self webController]); | 1339 DCHECK_EQ(webController, [self webController]); |
| 1416 [[self webController] removeObserver:self]; | 1340 [[self webController] removeObserver:self]; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1437 BOOL isUserNavigationEvent = | 1361 BOOL isUserNavigationEvent = |
| 1438 (transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) == 0; | 1362 (transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) == 0; |
| 1439 // Check for link-follow clobbers. These are changes where there is no | 1363 // Check for link-follow clobbers. These are changes where there is no |
| 1440 // pending entry (since that means the change wasn't caused by this class), | 1364 // pending entry (since that means the change wasn't caused by this class), |
| 1441 // and where the URL changes (to avoid counting page resurrection). | 1365 // and where the URL changes (to avoid counting page resurrection). |
| 1442 // TODO(crbug.com/546401): Consider moving this into NavigationManager, or | 1366 // TODO(crbug.com/546401): Consider moving this into NavigationManager, or |
| 1443 // into a NavigationManager observer callback, so it doesn't need to be | 1367 // into a NavigationManager observer callback, so it doesn't need to be |
| 1444 // checked in several places. | 1368 // checked in several places. |
| 1445 if (isUserNavigationEvent && !isPrerenderTab_ && | 1369 if (isUserNavigationEvent && !isPrerenderTab_ && |
| 1446 ![self navigationManager]->GetPendingItem() && url != self.url) { | 1370 ![self navigationManager]->GetPendingItem() && url != self.url) { |
| 1447 base::RecordAction(UserMetricsAction("MobileTabClobbered")); | 1371 base::RecordAction(base::UserMetricsAction("MobileTabClobbered")); |
| 1448 if ([parentTabModel_ tabUsageRecorder]) | 1372 if ([parentTabModel_ tabUsageRecorder]) |
| 1449 [parentTabModel_ tabUsageRecorder]->RecordPageLoadStart(self); | 1373 [parentTabModel_ tabUsageRecorder]->RecordPageLoadStart(self); |
| 1450 } | 1374 } |
| 1451 if (![self navigationManager]->GetPendingItem()) { | 1375 if (![self navigationManager]->GetPendingItem()) { |
| 1452 // Reset |isVoiceSearchResultsTab| since a new page is being navigated to. | 1376 // Reset |isVoiceSearchResultsTab| since a new page is being navigated to. |
| 1453 self.isVoiceSearchResultsTab = NO; | 1377 self.isVoiceSearchResultsTab = NO; |
| 1454 } | 1378 } |
| 1455 } | 1379 } |
| 1456 | 1380 |
| 1457 - (void)webState:(web::WebState*)webState | 1381 - (void)webState:(web::WebState*)webState |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1476 [autoReloadBridge_ loadStartedForURL:lastCommittedURL]; | 1400 [autoReloadBridge_ loadStartedForURL:lastCommittedURL]; |
| 1477 | 1401 |
| 1478 if (parentTabModel_) { | 1402 if (parentTabModel_) { |
| 1479 [[NSNotificationCenter defaultCenter] | 1403 [[NSNotificationCenter defaultCenter] |
| 1480 postNotificationName:kTabModelTabWillStartLoadingNotification | 1404 postNotificationName:kTabModelTabWillStartLoadingNotification |
| 1481 object:parentTabModel_ | 1405 object:parentTabModel_ |
| 1482 userInfo:@{kTabModelTabKey : self}]; | 1406 userInfo:@{kTabModelTabKey : self}]; |
| 1483 } | 1407 } |
| 1484 favicon::FaviconDriver* faviconDriver = | 1408 favicon::FaviconDriver* faviconDriver = |
| 1485 favicon::WebFaviconDriver::FromWebState(webState); | 1409 favicon::WebFaviconDriver::FromWebState(webState); |
| 1486 if (faviconDriver) { | 1410 if (faviconDriver) |
| 1487 faviconDriver->FetchFavicon(lastCommittedURL); | 1411 faviconDriver->FetchFavicon(lastCommittedURL); |
| 1488 } | |
| 1489 [parentTabModel_ notifyTabChanged:self]; | 1412 [parentTabModel_ notifyTabChanged:self]; |
| 1490 if (parentTabModel_) { | 1413 if (parentTabModel_) { |
| 1491 [[NSNotificationCenter defaultCenter] | 1414 [[NSNotificationCenter defaultCenter] |
| 1492 postNotificationName:kTabModelTabDidStartLoadingNotification | 1415 postNotificationName:kTabModelTabDidStartLoadingNotification |
| 1493 object:parentTabModel_ | 1416 object:parentTabModel_ |
| 1494 userInfo:@{kTabModelTabKey : self}]; | 1417 userInfo:@{kTabModelTabKey : self}]; |
| 1495 } | 1418 } |
| 1496 | 1419 |
| 1497 web::NavigationItem* previousItem = nullptr; | 1420 web::NavigationItem* previousItem = nullptr; |
| 1498 if (details.previous_item_index >= 0) { | 1421 if (details.previous_item_index >= 0) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1531 [self navigationManager]->GetLastCommittedItem(); | 1454 [self navigationManager]->GetLastCommittedItem(); |
| 1532 if (lastCommittedItem) { | 1455 if (lastCommittedItem) { |
| 1533 wasPost = lastCommittedItem->HasPostData(); | 1456 wasPost = lastCommittedItem->HasPostData(); |
| 1534 lastCommittedURL = lastCommittedItem->GetVirtualURL(); | 1457 lastCommittedURL = lastCommittedItem->GetVirtualURL(); |
| 1535 } | 1458 } |
| 1536 if (loadSuccess) | 1459 if (loadSuccess) |
| 1537 [autoReloadBridge_ loadFinishedForURL:lastCommittedURL wasPost:wasPost]; | 1460 [autoReloadBridge_ loadFinishedForURL:lastCommittedURL wasPost:wasPost]; |
| 1538 else | 1461 else |
| 1539 [autoReloadBridge_ loadFailedForURL:lastCommittedURL wasPost:wasPost]; | 1462 [autoReloadBridge_ loadFailedForURL:lastCommittedURL wasPost:wasPost]; |
| 1540 [webControllerSnapshotHelper_ setSnapshotCoalescingEnabled:YES]; | 1463 [webControllerSnapshotHelper_ setSnapshotCoalescingEnabled:YES]; |
| 1541 if (!loadSuccess) { | 1464 if (!loadSuccess) |
| 1542 [fullScreenController_ disableFullScreen]; | 1465 [fullScreenController_ disableFullScreen]; |
| 1543 } | |
| 1544 [self recordInterfaceOrientation]; | 1466 [self recordInterfaceOrientation]; |
| 1545 navigation_metrics::RecordMainFrameNavigation( | 1467 navigation_metrics::RecordMainFrameNavigation( |
| 1546 lastCommittedURL, true, self.browserState->IsOffTheRecord()); | 1468 lastCommittedURL, true, self.browserState->IsOffTheRecord()); |
| 1547 | 1469 |
| 1548 if (loadSuccess) { | 1470 if (loadSuccess) { |
| 1549 scoped_refptr<net::HttpResponseHeaders> headers = | 1471 scoped_refptr<net::HttpResponseHeaders> headers = |
| 1550 webStateImpl_->GetHttpResponseHeaders(); | 1472 webStateImpl_->GetHttpResponseHeaders(); |
| 1551 [self handleExportableFile:headers.get()]; | 1473 [self handleExportableFile:headers.get()]; |
| 1552 } | 1474 } |
| 1553 | 1475 |
| 1554 [parentTabModel_ notifyTabChanged:self]; | 1476 [parentTabModel_ notifyTabChanged:self]; |
| 1555 | 1477 |
| 1556 if (parentTabModel_) { | 1478 if (parentTabModel_) { |
| 1557 if ([parentTabModel_ tabUsageRecorder]) | 1479 if ([parentTabModel_ tabUsageRecorder]) |
| 1558 [parentTabModel_ tabUsageRecorder]->RecordPageLoadDone(self, loadSuccess); | 1480 [parentTabModel_ tabUsageRecorder]->RecordPageLoadDone(self, loadSuccess); |
| 1559 [[NSNotificationCenter defaultCenter] | 1481 [[NSNotificationCenter defaultCenter] |
| 1560 postNotificationName:kTabModelTabDidFinishLoadingNotification | 1482 postNotificationName:kTabModelTabDidFinishLoadingNotification |
| 1561 object:parentTabModel_ | 1483 object:parentTabModel_ |
| 1562 userInfo:[NSDictionary | 1484 userInfo:[NSDictionary |
| 1563 dictionaryWithObjectsAndKeys: | 1485 dictionaryWithObjectsAndKeys: |
| 1564 self, kTabModelTabKey, | 1486 self, kTabModelTabKey, |
| 1565 [NSNumber numberWithBool:loadSuccess], | 1487 [NSNumber numberWithBool:loadSuccess], |
| 1566 kTabModelPageLoadSuccess, nil]]; | 1488 kTabModelPageLoadSuccess, nil]]; |
| 1567 } | 1489 } |
| 1568 [[OmniboxGeolocationController sharedInstance] | 1490 [[OmniboxGeolocationController sharedInstance] |
| 1569 finishPageLoadForTab:self | 1491 finishPageLoadForTab:self |
| 1570 loadSuccess:loadSuccess]; | 1492 loadSuccess:loadSuccess]; |
| 1571 | 1493 |
| 1572 if (loadSuccess) { | 1494 if (loadSuccess) |
| 1573 [self updateSnapshotWithOverlay:YES visibleFrameOnly:YES]; | 1495 [self updateSnapshotWithOverlay:YES visibleFrameOnly:YES]; |
| 1574 } | |
| 1575 [webControllerSnapshotHelper_ setSnapshotCoalescingEnabled:NO]; | 1496 [webControllerSnapshotHelper_ setSnapshotCoalescingEnabled:NO]; |
| 1576 } | 1497 } |
| 1577 | 1498 |
| 1578 - (void)webState:(web::WebState*)webState | 1499 - (void)webState:(web::WebState*)webState |
| 1579 didChangeLoadingProgress:(double)progress { | 1500 didChangeLoadingProgress:(double)progress { |
| 1580 // TODO(crbug.com/546406): It is probably possible to do something smarter, | 1501 // TODO(crbug.com/546406): It is probably possible to do something smarter, |
| 1581 // but the fact that this is not always sent will have to be taken into | 1502 // but the fact that this is not always sent will have to be taken into |
| 1582 // account. | 1503 // account. |
| 1583 [parentTabModel_ notifyTabChanged:self]; | 1504 [parentTabModel_ notifyTabChanged:self]; |
| 1584 } | 1505 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1643 linkClicked:(BOOL)linkClicked { | 1564 linkClicked:(BOOL)linkClicked { |
| 1644 // chrome:// URLs are only allowed if the mainDocumentURL is also a chrome:// | 1565 // chrome:// URLs are only allowed if the mainDocumentURL is also a chrome:// |
| 1645 // URL. | 1566 // URL. |
| 1646 if (url.SchemeIs(kChromeUIScheme) && | 1567 if (url.SchemeIs(kChromeUIScheme) && |
| 1647 !mainDocumentURL.SchemeIs(kChromeUIScheme)) { | 1568 !mainDocumentURL.SchemeIs(kChromeUIScheme)) { |
| 1648 return NO; | 1569 return NO; |
| 1649 } | 1570 } |
| 1650 | 1571 |
| 1651 // Always allow frame loads. | 1572 // Always allow frame loads. |
| 1652 BOOL isFrameLoad = (url != mainDocumentURL); | 1573 BOOL isFrameLoad = (url != mainDocumentURL); |
| 1653 if (isFrameLoad) { | 1574 if (isFrameLoad) |
| 1654 return YES; | 1575 return YES; |
| 1655 } | |
| 1656 | 1576 |
| 1657 // TODO(crbug.com/546402): If this turns out to be useful, find a less hacky | 1577 // TODO(crbug.com/546402): If this turns out to be useful, find a less hacky |
| 1658 // hook point to send this from. | 1578 // hook point to send this from. |
| 1659 NSString* urlString = base::SysUTF8ToNSString(url.spec()); | 1579 NSString* urlString = base::SysUTF8ToNSString(url.spec()); |
| 1660 if ([urlString length]) { | 1580 if ([urlString length]) { |
| 1661 [[NSNotificationCenter defaultCenter] | 1581 [[NSNotificationCenter defaultCenter] |
| 1662 postNotificationName:kTabUrlMayStartLoadingNotificationForCrashReporting | 1582 postNotificationName:kTabUrlMayStartLoadingNotificationForCrashReporting |
| 1663 object:self | 1583 object:self |
| 1664 userInfo:[NSDictionary dictionaryWithObject:urlString | 1584 userInfo:[NSDictionary dictionaryWithObject:urlString |
| 1665 forKey:kTabUrlKey]]; | 1585 forKey:kTabUrlKey]]; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1774 } | 1694 } |
| 1775 UMA_HISTOGRAM_ENUMERATION( | 1695 UMA_HISTOGRAM_ENUMERATION( |
| 1776 kRendererTerminationStateHistogram, static_cast<int>(tab_state), | 1696 kRendererTerminationStateHistogram, static_cast<int>(tab_state), |
| 1777 static_cast<int>( | 1697 static_cast<int>( |
| 1778 RendererTerminationTabState::TERMINATION_TAB_STATE_COUNT)); | 1698 RendererTerminationTabState::TERMINATION_TAB_STATE_COUNT)); |
| 1779 if ([parentTabModel_ tabUsageRecorder]) | 1699 if ([parentTabModel_ tabUsageRecorder]) |
| 1780 [parentTabModel_ tabUsageRecorder]->RendererTerminated(self, visible_); | 1700 [parentTabModel_ tabUsageRecorder]->RendererTerminated(self, visible_); |
| 1781 } | 1701 } |
| 1782 | 1702 |
| 1783 if (visible_) { | 1703 if (visible_) { |
| 1784 if (!applicationIsNotActive) { | 1704 if (!applicationIsNotActive) |
| 1785 [fullScreenController_ disableFullScreen]; | 1705 [fullScreenController_ disableFullScreen]; |
| 1786 } | |
| 1787 } else { | 1706 } else { |
| 1788 [self.webController requirePageReload]; | 1707 [self.webController requirePageReload]; |
| 1789 } | 1708 } |
| 1790 // Returning to the app (after the renderer crashed in the background) and | 1709 // Returning to the app (after the renderer crashed in the background) and |
| 1791 // having the page reload is much less confusing for the user. | 1710 // having the page reload is much less confusing for the user. |
| 1792 // Note: Given that the tab is visible, calling |requirePageReload| will not | 1711 // Note: Given that the tab is visible, calling |requirePageReload| will not |
| 1793 // work when the app becomes active because there is nothing to trigger | 1712 // work when the app becomes active because there is nothing to trigger |
| 1794 // a view redisplay in that scenario. | 1713 // a view redisplay in that scenario. |
| 1795 requireReloadAfterBecomingActive_ = visible_ && applicationIsNotActive; | 1714 requireReloadAfterBecomingActive_ = visible_ && applicationIsNotActive; |
| 1796 [self.dialogDelegate cancelDialogForTab:self]; | 1715 [self.dialogDelegate cancelDialogForTab:self]; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1818 if (isPrerenderTab_) { | 1737 if (isPrerenderTab_) { |
| 1819 [delegate_ discardPrerender]; | 1738 [delegate_ discardPrerender]; |
| 1820 return; | 1739 return; |
| 1821 } | 1740 } |
| 1822 if (self != [parentTabModel_ currentTab]) | 1741 if (self != [parentTabModel_ currentTab]) |
| 1823 return; | 1742 return; |
| 1824 | 1743 |
| 1825 signin_metrics::LogAccountReconcilorStateOnGaiaResponse( | 1744 signin_metrics::LogAccountReconcilorStateOnGaiaResponse( |
| 1826 ios::AccountReconcilorFactory::GetForBrowserState(browserState_) | 1745 ios::AccountReconcilorFactory::GetForBrowserState(browserState_) |
| 1827 ->GetState()); | 1746 ->GetState()); |
| 1828 base::scoped_nsobject<GenericChromeCommand> command( | 1747 GenericChromeCommand* command = |
| 1829 [[GenericChromeCommand alloc] initWithTag:IDC_SHOW_ACCOUNTS_SETTINGS]); | 1748 [[GenericChromeCommand alloc] initWithTag:IDC_SHOW_ACCOUNTS_SETTINGS]; |
| 1830 [self.view chromeExecuteCommand:command]; | 1749 [self.view chromeExecuteCommand:command]; |
| 1831 } | 1750 } |
| 1832 | 1751 |
| 1833 - (void)onAddAccount { | 1752 - (void)onAddAccount { |
| 1834 if (isPrerenderTab_) { | 1753 if (isPrerenderTab_) { |
| 1835 [delegate_ discardPrerender]; | 1754 [delegate_ discardPrerender]; |
| 1836 return; | 1755 return; |
| 1837 } | 1756 } |
| 1838 if (self != [parentTabModel_ currentTab]) | 1757 if (self != [parentTabModel_ currentTab]) |
| 1839 return; | 1758 return; |
| 1840 | 1759 |
| 1841 signin_metrics::LogAccountReconcilorStateOnGaiaResponse( | 1760 signin_metrics::LogAccountReconcilorStateOnGaiaResponse( |
| 1842 ios::AccountReconcilorFactory::GetForBrowserState(browserState_) | 1761 ios::AccountReconcilorFactory::GetForBrowserState(browserState_) |
| 1843 ->GetState()); | 1762 ->GetState()); |
| 1844 base::scoped_nsobject<GenericChromeCommand> command( | 1763 GenericChromeCommand* command = |
| 1845 [[GenericChromeCommand alloc] initWithTag:IDC_SHOW_ADD_ACCOUNT]); | 1764 [[GenericChromeCommand alloc] initWithTag:IDC_SHOW_ADD_ACCOUNT]; |
| 1846 [self.view chromeExecuteCommand:command]; | 1765 [self.view chromeExecuteCommand:command]; |
| 1847 } | 1766 } |
| 1848 | 1767 |
| 1849 - (void)onGoIncognito:(const GURL&)url { | 1768 - (void)onGoIncognito:(const GURL&)url { |
| 1850 if (isPrerenderTab_) { | 1769 if (isPrerenderTab_) { |
| 1851 [delegate_ discardPrerender]; | 1770 [delegate_ discardPrerender]; |
| 1852 return; | 1771 return; |
| 1853 } | 1772 } |
| 1854 if (self != [parentTabModel_ currentTab]) | 1773 if (self != [parentTabModel_ currentTab]) |
| 1855 return; | 1774 return; |
| 1856 | 1775 |
| 1857 // The user taps on go incognito from the mobile U-turn webpage (the web page | 1776 // The user taps on go incognito from the mobile U-turn webpage (the web page |
| 1858 // that displays all users accounts available in the content area). As the | 1777 // that displays all users accounts available in the content area). As the |
| 1859 // user chooses to go to incognito, the mobile U-turn page is no longer | 1778 // user chooses to go to incognito, the mobile U-turn page is no longer |
| 1860 // neeeded. The current solution is to go back in history. This has the | 1779 // neeeded. The current solution is to go back in history. This has the |
| 1861 // advantage of keeping the current browsing session and give a good user | 1780 // advantage of keeping the current browsing session and give a good user |
| 1862 // experience when the user comes back from incognito. | 1781 // experience when the user comes back from incognito. |
| 1863 [self goBack]; | 1782 [self goBack]; |
| 1864 | 1783 |
| 1865 if (url.is_valid()) { | 1784 if (url.is_valid()) { |
| 1866 base::scoped_nsobject<OpenUrlCommand> command([[OpenUrlCommand alloc] | 1785 OpenUrlCommand* command = [[OpenUrlCommand alloc] |
| 1867 initWithURL:url | 1786 initWithURL:url |
| 1868 referrer:web::Referrer() // Strip referrer when switching modes. | 1787 referrer:web::Referrer() // Strip referrer when switching modes. |
| 1869 inIncognito:YES | 1788 inIncognito:YES |
| 1870 inBackground:NO | 1789 inBackground:NO |
| 1871 appendTo:kLastTab]); | 1790 appendTo:kLastTab]; |
| 1872 [self.view chromeExecuteCommand:command]; | 1791 [self.view chromeExecuteCommand:command]; |
| 1873 } else { | 1792 } else { |
| 1874 base::scoped_nsobject<GenericChromeCommand> chromeCommand( | 1793 GenericChromeCommand* command = |
| 1875 [[GenericChromeCommand alloc] initWithTag:IDC_NEW_INCOGNITO_TAB]); | 1794 [[GenericChromeCommand alloc] initWithTag:IDC_NEW_INCOGNITO_TAB]; |
| 1876 [self.view chromeExecuteCommand:chromeCommand]; | 1795 [self.view chromeExecuteCommand:command]; |
| 1877 } | 1796 } |
| 1878 } | 1797 } |
| 1879 | 1798 |
| 1880 - (NativeAppNavigationController*)nativeAppNavigationController { | 1799 - (NativeAppNavigationController*)nativeAppNavigationController { |
| 1881 // TODO(crbug.com/711511): This call should eventually be eliminated. | 1800 // TODO(crbug.com/711511): This call should eventually be eliminated. |
| 1882 return nil; | 1801 return nil; |
| 1883 } | 1802 } |
| 1884 | 1803 |
| 1885 - (id<PassKitDialogProvider>)passKitDialogProvider { | |
| 1886 return passKitDialogProvider_.get(); | |
| 1887 } | |
| 1888 | |
| 1889 - (void)setPassKitDialogProvider:(id<PassKitDialogProvider>)provider { | |
| 1890 passKitDialogProvider_.reset(provider); | |
| 1891 } | |
| 1892 | |
| 1893 - (void)wasShown { | 1804 - (void)wasShown { |
| 1894 visible_ = YES; | 1805 visible_ = YES; |
| 1895 [self updateFullscreenWithToolbarVisible:YES]; | 1806 [self updateFullscreenWithToolbarVisible:YES]; |
| 1896 [self.webController wasShown]; | 1807 [self.webController wasShown]; |
| 1897 [inputAccessoryViewController_ wasShown]; | 1808 [inputAccessoryViewController_ wasShown]; |
| 1898 } | 1809 } |
| 1899 | 1810 |
| 1900 - (void)wasHidden { | 1811 - (void)wasHidden { |
| 1901 visible_ = NO; | 1812 visible_ = NO; |
| 1902 [self updateFullscreenWithToolbarVisible:YES]; | 1813 [self updateFullscreenWithToolbarVisible:YES]; |
| 1903 [self.webController wasHidden]; | 1814 [self.webController wasHidden]; |
| 1904 [inputAccessoryViewController_ wasHidden]; | 1815 [inputAccessoryViewController_ wasHidden]; |
| 1905 } | 1816 } |
| 1906 | 1817 |
| 1907 #pragma mark - SadTabTabHelperDelegate | 1818 #pragma mark - SadTabTabHelperDelegate |
| 1908 | 1819 |
| 1909 - (BOOL)isTabVisibleForTabHelper:(SadTabTabHelper*)tabHelper { | 1820 - (BOOL)isTabVisibleForTabHelper:(SadTabTabHelper*)tabHelper { |
| 1910 UIApplicationState state = UIApplication.sharedApplication.applicationState; | 1821 UIApplicationState state = UIApplication.sharedApplication.applicationState; |
| 1911 return visible_ && !IsApplicationStateNotActive(state); | 1822 return visible_ && !IsApplicationStateNotActive(state); |
| 1912 } | 1823 } |
| 1913 | 1824 |
| 1914 @end | 1825 @end |
| 1915 | 1826 |
| 1916 #pragma mark - TestingSupport | 1827 #pragma mark - TestingSupport |
| 1917 | 1828 |
| 1918 @implementation Tab (TestingSupport) | 1829 @implementation Tab (TestingSupport) |
| 1919 | 1830 |
| 1920 - (void)replaceExternalAppLauncher:(id)externalAppLauncher { | 1831 - (void)replaceExternalAppLauncher:(id)externalAppLauncher { |
| 1921 externalAppLauncher_.reset([externalAppLauncher retain]); | 1832 externalAppLauncher_ = externalAppLauncher; |
| 1922 } | 1833 } |
| 1923 | 1834 |
| 1924 - (TabModel*)parentTabModel { | 1835 - (TabModel*)parentTabModel { |
| 1925 return parentTabModel_; | 1836 return parentTabModel_; |
| 1926 } | 1837 } |
| 1927 | 1838 |
| 1928 - (FormInputAccessoryViewController*)inputAccessoryViewController { | 1839 - (FormInputAccessoryViewController*)inputAccessoryViewController { |
| 1929 return inputAccessoryViewController_.get(); | 1840 return inputAccessoryViewController_; |
| 1930 } | 1841 } |
| 1931 | 1842 |
| 1932 @end | 1843 @end |
| OLD | NEW |