| 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" | 15 #import "base/ios/weak_nsobject.h" |
| 16 #include "base/json/string_escape.h" | 16 #include "base/json/string_escape.h" |
| 17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/mac/bind_objc_block.h" | 18 #include "base/mac/bind_objc_block.h" |
| 19 #include "base/mac/foundation_util.h" | 19 #include "base/mac/foundation_util.h" |
| 20 #include "base/mac/objc_property_releaser.h" | 20 #include "base/mac/objc_release_properties.h" |
| 21 #include "base/mac/scoped_nsobject.h" | 21 #include "base/mac/scoped_nsobject.h" |
| 22 #include "base/metrics/histogram_macros.h" | 22 #include "base/metrics/histogram_macros.h" |
| 23 #include "base/metrics/user_metrics.h" | 23 #include "base/metrics/user_metrics.h" |
| 24 #include "base/metrics/user_metrics_action.h" | 24 #include "base/metrics/user_metrics_action.h" |
| 25 #include "base/scoped_observer.h" | 25 #include "base/scoped_observer.h" |
| 26 #include "base/strings/string_split.h" | 26 #include "base/strings/string_split.h" |
| 27 #include "base/strings/sys_string_conversions.h" | 27 #include "base/strings/sys_string_conversions.h" |
| 28 #include "base/strings/utf_string_conversions.h" | 28 #include "base/strings/utf_string_conversions.h" |
| 29 #include "base/time/time.h" | 29 #include "base/time/time.h" |
| 30 #include "components/content_settings/core/browser/host_content_settings_map.h" | 30 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 | 224 |
| 225 // YES if this Tab is being prerendered. | 225 // YES if this Tab is being prerendered. |
| 226 BOOL isPrerenderTab_; | 226 BOOL isPrerenderTab_; |
| 227 | 227 |
| 228 // YES if this Tab was initiated from a voice search. | 228 // YES if this Tab was initiated from a voice search. |
| 229 BOOL isVoiceSearchResultsTab_; | 229 BOOL isVoiceSearchResultsTab_; |
| 230 | 230 |
| 231 // YES if the Tab needs to be reloaded after the app becomes active. | 231 // YES if the Tab needs to be reloaded after the app becomes active. |
| 232 BOOL requireReloadAfterBecomingActive_; | 232 BOOL requireReloadAfterBecomingActive_; |
| 233 | 233 |
| 234 base::mac::ObjCPropertyReleaser propertyReleaser_Tab_; | |
| 235 | |
| 236 id<TabDelegate> delegate_; // weak | 234 id<TabDelegate> delegate_; // weak |
| 237 base::WeakNSProtocol<id<TabDialogDelegate>> dialogDelegate_; | 235 base::WeakNSProtocol<id<TabDialogDelegate>> dialogDelegate_; |
| 238 base::WeakNSProtocol<id<SnapshotOverlayProvider>> snapshotOverlayProvider_; | 236 base::WeakNSProtocol<id<SnapshotOverlayProvider>> snapshotOverlayProvider_; |
| 239 | 237 |
| 240 // Delegate used for snapshotting geometry. | 238 // Delegate used for snapshotting geometry. |
| 241 id<TabSnapshottingDelegate> tabSnapshottingDelegate_; // weak | 239 id<TabSnapshottingDelegate> tabSnapshottingDelegate_; // weak |
| 242 | 240 |
| 243 // The Full Screen Controller responsible for hiding/showing the toolbar. | 241 // The Full Screen Controller responsible for hiding/showing the toolbar. |
| 244 base::scoped_nsobject<FullScreenController> fullScreenController_; | 242 base::scoped_nsobject<FullScreenController> fullScreenController_; |
| 245 | 243 |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 model:parentModel | 511 model:parentModel |
| 514 attachTabHelpers:YES]; | 512 attachTabHelpers:YES]; |
| 515 } | 513 } |
| 516 | 514 |
| 517 - (instancetype)initWithWebState:(std::unique_ptr<web::WebState>)webState | 515 - (instancetype)initWithWebState:(std::unique_ptr<web::WebState>)webState |
| 518 model:(TabModel*)parentModel | 516 model:(TabModel*)parentModel |
| 519 attachTabHelpers:(BOOL)attachTabHelpers { | 517 attachTabHelpers:(BOOL)attachTabHelpers { |
| 520 DCHECK(webState); | 518 DCHECK(webState); |
| 521 self = [super init]; | 519 self = [super init]; |
| 522 if (self) { | 520 if (self) { |
| 523 propertyReleaser_Tab_.Init(self, [Tab class]); | |
| 524 tabHistoryContext_.reset(new TabHistoryContext()); | 521 tabHistoryContext_.reset(new TabHistoryContext()); |
| 525 parentTabModel_ = parentModel; | 522 parentTabModel_ = parentModel; |
| 526 browserState_ = | 523 browserState_ = |
| 527 ios::ChromeBrowserState::FromBrowserState(webState->GetBrowserState()); | 524 ios::ChromeBrowserState::FromBrowserState(webState->GetBrowserState()); |
| 528 | 525 |
| 529 webStateImpl_.reset(static_cast<web::WebStateImpl*>(webState.release())); | 526 webStateImpl_.reset(static_cast<web::WebStateImpl*>(webState.release())); |
| 530 webStateObserver_.reset( | 527 webStateObserver_.reset( |
| 531 new web::WebStateObserverBridge(webStateImpl_.get(), self)); | 528 new web::WebStateObserverBridge(webStateImpl_.get(), self)); |
| 532 | 529 |
| 533 // Do not respect |attachTabHelpers| as this tab helper is required for | 530 // Do not respect |attachTabHelpers| as this tab helper is required for |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 [[tab webController] loadWithParams:params]; | 689 [[tab webController] loadWithParams:params]; |
| 693 | 690 |
| 694 return tab; | 691 return tab; |
| 695 } | 692 } |
| 696 | 693 |
| 697 - (void)dealloc { | 694 - (void)dealloc { |
| 698 DCHECK([NSThread isMainThread]); | 695 DCHECK([NSThread isMainThread]); |
| 699 // Note that -[CRWWebController close] has already been called, so nothing | 696 // Note that -[CRWWebController close] has already been called, so nothing |
| 700 // significant should be done with it in this method. | 697 // significant should be done with it in this method. |
| 701 DCHECK_NE(self.webController.delegate, self); | 698 DCHECK_NE(self.webController.delegate, self); |
| 699 base::mac::ReleaseProperties(self); |
| 702 [super dealloc]; | 700 [super dealloc]; |
| 703 } | 701 } |
| 704 | 702 |
| 705 - (void)setParentTabModel:(TabModel*)model { | 703 - (void)setParentTabModel:(TabModel*)model { |
| 706 DCHECK(!model || !parentTabModel_); | 704 DCHECK(!model || !parentTabModel_); |
| 707 parentTabModel_ = model; | 705 parentTabModel_ = model; |
| 708 | 706 |
| 709 if (parentTabModel_.syncedWindowDelegate) { | 707 if (parentTabModel_.syncedWindowDelegate) { |
| 710 IOSChromeSessionTabHelper::FromWebState(self.webState) | 708 IOSChromeSessionTabHelper::FromWebState(self.webState) |
| 711 ->SetWindowID(model.sessionID); | 709 ->SetWindowID(model.sessionID); |
| (...skipping 1498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2210 | 2208 |
| 2211 - (TabModel*)parentTabModel { | 2209 - (TabModel*)parentTabModel { |
| 2212 return parentTabModel_; | 2210 return parentTabModel_; |
| 2213 } | 2211 } |
| 2214 | 2212 |
| 2215 - (FormInputAccessoryViewController*)inputAccessoryViewController { | 2213 - (FormInputAccessoryViewController*)inputAccessoryViewController { |
| 2216 return inputAccessoryViewController_.get(); | 2214 return inputAccessoryViewController_.get(); |
| 2217 } | 2215 } |
| 2218 | 2216 |
| 2219 @end | 2217 @end |
| OLD | NEW |