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> |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" | 94 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" |
95 #import "ios/chrome/browser/ui/commands/open_url_command.h" | 95 #import "ios/chrome/browser/ui/commands/open_url_command.h" |
96 #import "ios/chrome/browser/ui/commands/show_signin_command.h" | 96 #import "ios/chrome/browser/ui/commands/show_signin_command.h" |
97 #import "ios/chrome/browser/ui/downloads/download_manager_controller.h" | 97 #import "ios/chrome/browser/ui/downloads/download_manager_controller.h" |
98 #import "ios/chrome/browser/ui/fullscreen_controller.h" | 98 #import "ios/chrome/browser/ui/fullscreen_controller.h" |
99 #import "ios/chrome/browser/ui/open_in_controller.h" | 99 #import "ios/chrome/browser/ui/open_in_controller.h" |
100 #import "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_controller.
h" | 100 #import "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_controller.
h" |
101 #import "ios/chrome/browser/ui/prerender_delegate.h" | 101 #import "ios/chrome/browser/ui/prerender_delegate.h" |
102 #import "ios/chrome/browser/ui/reader_mode/reader_mode_checker.h" | 102 #import "ios/chrome/browser/ui/reader_mode/reader_mode_checker.h" |
103 #import "ios/chrome/browser/ui/reader_mode/reader_mode_controller.h" | 103 #import "ios/chrome/browser/ui/reader_mode/reader_mode_controller.h" |
104 #import "ios/chrome/browser/ui/sad_tab/sad_tab_view.h" | |
105 #include "ios/chrome/browser/ui/ui_util.h" | 104 #include "ios/chrome/browser/ui/ui_util.h" |
106 #import "ios/chrome/browser/web/auto_reload_bridge.h" | 105 #import "ios/chrome/browser/web/auto_reload_bridge.h" |
107 #import "ios/chrome/browser/web/external_app_launcher.h" | 106 #import "ios/chrome/browser/web/external_app_launcher.h" |
108 #import "ios/chrome/browser/web/navigation_manager_util.h" | 107 #import "ios/chrome/browser/web/navigation_manager_util.h" |
109 #import "ios/chrome/browser/web/passkit_dialog_provider.h" | 108 #import "ios/chrome/browser/web/passkit_dialog_provider.h" |
110 #include "ios/chrome/browser/web/print_observer.h" | 109 #include "ios/chrome/browser/web/print_observer.h" |
111 #import "ios/chrome/browser/xcallback_parameters.h" | 110 #import "ios/chrome/browser/xcallback_parameters.h" |
112 #include "ios/chrome/grit/ios_strings.h" | 111 #include "ios/chrome/grit/ios_strings.h" |
113 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 112 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
114 #import "ios/public/provider/chrome/browser/native_app_launcher/native_app_metad
ata.h" | 113 #import "ios/public/provider/chrome/browser/native_app_launcher/native_app_metad
ata.h" |
(...skipping 1823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1938 UMA_HISTOGRAM_ENUMERATION( | 1937 UMA_HISTOGRAM_ENUMERATION( |
1939 kRendererTerminationStateHistogram, static_cast<int>(tab_state), | 1938 kRendererTerminationStateHistogram, static_cast<int>(tab_state), |
1940 static_cast<int>( | 1939 static_cast<int>( |
1941 RendererTerminationTabState::TERMINATION_TAB_STATE_COUNT)); | 1940 RendererTerminationTabState::TERMINATION_TAB_STATE_COUNT)); |
1942 if ([parentTabModel_ tabUsageRecorder]) | 1941 if ([parentTabModel_ tabUsageRecorder]) |
1943 [parentTabModel_ tabUsageRecorder]->RendererTerminated(self, visible_); | 1942 [parentTabModel_ tabUsageRecorder]->RendererTerminated(self, visible_); |
1944 } | 1943 } |
1945 | 1944 |
1946 if (visible_) { | 1945 if (visible_) { |
1947 if (!applicationIsNotActive) { | 1946 if (!applicationIsNotActive) { |
1948 base::WeakNSObject<Tab> weakSelf(self); | |
1949 base::scoped_nsobject<SadTabView> sadTabView( | |
1950 [[SadTabView alloc] initWithReloadHandler:^{ | |
1951 base::scoped_nsobject<Tab> strongSelf([weakSelf retain]); | |
1952 | |
1953 // |check_for_repost| is true because this is called from SadTab and | |
1954 // explicitly initiated by the user. | |
1955 [strongSelf navigationManager]->Reload(web::ReloadType::NORMAL, | |
1956 true /* check_for_repost */); | |
1957 }]); | |
1958 base::scoped_nsobject<CRWContentView> contentView( | |
1959 [[CRWGenericContentView alloc] initWithView:sadTabView]); | |
1960 self.webState->ShowTransientContentView(contentView); | |
1961 [fullScreenController_ disableFullScreen]; | 1947 [fullScreenController_ disableFullScreen]; |
1962 } | 1948 } |
1963 } else { | 1949 } else { |
1964 [self.webController requirePageReload]; | 1950 [self.webController requirePageReload]; |
1965 } | 1951 } |
1966 // Returning to the app (after the renderer crashed in the background) and | 1952 // Returning to the app (after the renderer crashed in the background) and |
1967 // having the page reload is much less confusing for the user. | 1953 // having the page reload is much less confusing for the user. |
1968 // Note: Given that the tab is visible, calling |requirePageReload| will not | 1954 // Note: Given that the tab is visible, calling |requirePageReload| will not |
1969 // work when the app becomes active because there is nothing to trigger | 1955 // work when the app becomes active because there is nothing to trigger |
1970 // a view redisplay in that scenario. | 1956 // a view redisplay in that scenario. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2081 [inputAccessoryViewController_ wasShown]; | 2067 [inputAccessoryViewController_ wasShown]; |
2082 } | 2068 } |
2083 | 2069 |
2084 - (void)wasHidden { | 2070 - (void)wasHidden { |
2085 visible_ = NO; | 2071 visible_ = NO; |
2086 [self updateFullscreenWithToolbarVisible:YES]; | 2072 [self updateFullscreenWithToolbarVisible:YES]; |
2087 [self.webController wasHidden]; | 2073 [self.webController wasHidden]; |
2088 [inputAccessoryViewController_ wasHidden]; | 2074 [inputAccessoryViewController_ wasHidden]; |
2089 } | 2075 } |
2090 | 2076 |
| 2077 #pragma mark - SadTabTabHelperDelegate |
| 2078 |
| 2079 - (BOOL)isTabVisibleForTabHelper:(SadTabTabHelper*)tabHelper { |
| 2080 UIApplicationState state = UIApplication.sharedApplication.applicationState; |
| 2081 return visible_ && !IsApplicationStateNotActive(state); |
| 2082 } |
| 2083 |
2091 @end | 2084 @end |
2092 | 2085 |
2093 #pragma mark - TestingSupport | 2086 #pragma mark - TestingSupport |
2094 | 2087 |
2095 @implementation Tab (TestingSupport) | 2088 @implementation Tab (TestingSupport) |
2096 | 2089 |
2097 - (void)replaceExternalAppLauncher:(id)externalAppLauncher { | 2090 - (void)replaceExternalAppLauncher:(id)externalAppLauncher { |
2098 externalAppLauncher_.reset([externalAppLauncher retain]); | 2091 externalAppLauncher_.reset([externalAppLauncher retain]); |
2099 } | 2092 } |
2100 | 2093 |
2101 - (TabModel*)parentTabModel { | 2094 - (TabModel*)parentTabModel { |
2102 return parentTabModel_; | 2095 return parentTabModel_; |
2103 } | 2096 } |
2104 | 2097 |
2105 - (FormInputAccessoryViewController*)inputAccessoryViewController { | 2098 - (FormInputAccessoryViewController*)inputAccessoryViewController { |
2106 return inputAccessoryViewController_.get(); | 2099 return inputAccessoryViewController_.get(); |
2107 } | 2100 } |
2108 | 2101 |
2109 @end | 2102 @end |
OLD | NEW |