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

Side by Side Diff: ios/chrome/browser/tabs/tab.h

Issue 2585233003: Upstream Chrome on iOS source code [2/11]. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef IOS_CHROME_BROWSER_TABS_TAB_H_
6 #define IOS_CHROME_BROWSER_TABS_TAB_H_
7
8 #import <UIKit/UIKit.h>
9
10 #include <memory>
11 #include <vector>
12
13 #import "components/signin/ios/browser/manage_accounts_delegate.h"
14 #include "ios/net/request_tracker.h"
15 #import "ios/web/public/web_state/ui/crw_web_delegate.h"
16 #include "ui/base/page_transition_types.h"
17
18 @class AutofillController;
19 @class AutoReloadBridge;
20 @class CastController;
21 @protocol CRWNativeContentProvider;
22 @class CRWSessionEntry;
23 @class CRWWebController;
24 @class ExternalAppLauncher;
25 @class FindInPageController;
26 @class FormInputAccessoryViewController;
27 @class FullScreenController;
28 @protocol FullScreenControllerDelegate;
29 class GURL;
30 @class NativeAppNavigationController;
31 @class OpenInController;
32 @class OverscrollActionsController;
33 @protocol OverscrollActionsControllerDelegate;
34 @protocol PassKitDialogProvider;
35 @class PasswordController;
36 @class SnapshotManager;
37 @protocol SnapshotOverlayProvider;
38 @protocol StoreKitLauncher;
39 @class FormSuggestionController;
40 @protocol TabDelegate;
41 @protocol TabDialogDelegate;
42 @class Tab;
43 @class TabModel;
44 @protocol TabSnapshottingDelegate;
45 @class TranslateControllerImplIOS;
46 @class WebControllerSnapshotHelper;
47
48 namespace infobars {
49 class InfoBarManager;
50 }
51
52 namespace ios {
53 class ChromeBrowserState;
54 }
55
56 namespace sessions {
57 class SerializedNavigationEntry;
58 struct SessionTab;
59 }
60
61 namespace web {
62 class NavigationManagerImpl;
63 struct Referrer;
64 class WebState;
65 class WebStateImpl;
66 }
67
68 // Notification sent by a Tab when it starts to load a new URL. This
69 // notification must only be used for crash reporting as it is also sent for
70 // pre-rendered tabs.
71 extern NSString* const kTabUrlStartedLoadingNotificationForCrashReporting;
72
73 // Notification sent by a Tab when it is likely about to start loading a new
74 // URL. This notification must only be used for crash reporting as it is also
75 // sent for pre-rendered tabs.
76 extern NSString* const kTabUrlMayStartLoadingNotificationForCrashReporting;
77
78 // Notification sent by a Tab when it is showing an exportable file (e.g a pdf
79 // file.
80 extern NSString* const kTabIsShowingExportableNotificationForCrashReporting;
81
82 // Notification sent by a Tab when it is closing its current document, to go to
83 // another location.
84 extern NSString* const kTabClosingCurrentDocumentNotificationForCrashReporting;
85
86 // The key containing the URL in the userInfo for the
87 // kTabUrlStartedLoadingForCrashReporting and
88 // kTabUrlMayStartLoadingNotificationForCrashReporting notifications.
89 extern NSString* const kTabUrlKey;
90
91 // The header name and value for the data reduction proxy to request an image to
92 // be reloaded without optimizations.
93 extern NSString* const kProxyPassthroughHeaderName;
94 extern NSString* const kProxyPassthroughHeaderValue;
95
96 // Information related to a single tab. The CRWWebController is similar to
97 // desktop Chrome's TabContents in that it encapsulates rendering. Acts as the
98 // delegate for the CRWWebController in order to process info about pages having
99 // loaded.
100 @interface Tab : NSObject<CRWWebDelegate, ManageAccountsDelegate>
101
102 // Browser state associated with this Tab.
103 @property(nonatomic, readonly) ios::ChromeBrowserState* browserState;
104
105 // TODO(crbug.com/546208): Eliminate this; replace calls with either visible URL
106 // or last committed URL, depending on the specific use case.
107 // Do not add new calls to this method.
108 @property(nonatomic, readonly) const GURL& url;
109
110 // The Passkit Dialog provider used to show the UI to download a passkit object.
111 @property(nonatomic, assign) id<PassKitDialogProvider> passKitDialogProvider;
112
113 // The current title of the tab.
114 @property(nonatomic, readonly) NSString* title;
115
116 // Original page title or nil if the page did not provide one.
117 @property(nonatomic, readonly) NSString* originalTitle;
118
119 @property(nonatomic, readonly) NSString* urlDisplayString;
120 @property(nonatomic, readonly) NSString* windowName;
121
122 // ID associated with this tab, from the SessionManager.
123 @property(nonatomic, readonly) NSString* tabId;
124
125 // |YES| if snapshot overlay should load from the grey image cache.
126 @property(nonatomic, assign) BOOL useGreyImageCache;
127
128 // webStateImpl is deprecated: use webState instead.
129 @property(nonatomic, readonly) web::WebStateImpl* webStateImpl;
130 @property(nonatomic, readonly) web::WebState* webState;
131
132 @property(nonatomic, readonly) CRWWebController* webController;
133 @property(nonatomic, readonly) PasswordController* passwordController;
134 @property(nonatomic, readonly) BOOL canGoBack;
135 @property(nonatomic, readonly) BOOL canGoForward;
136 @property(nonatomic, assign) id<TabDelegate> delegate;
137 @property(nonatomic, assign) id<TabSnapshottingDelegate>
138 tabSnapshottingDelegate;
139 @property(nonatomic, readonly) BOOL useDesktopUserAgent;
140 @property(nonatomic, assign) id<StoreKitLauncher> storeKitLauncher;
141 @property(nonatomic, assign) id<FullScreenControllerDelegate>
142 fullScreenControllerDelegate;
143 @property(nonatomic, readonly)
144 OverscrollActionsController* overscrollActionsController;
145 @property(nonatomic, assign) id<OverscrollActionsControllerDelegate>
146 overscrollActionsControllerDelegate;
147 @property(nonatomic, assign) id<SnapshotOverlayProvider>
148 snapshotOverlayProvider;
149
150 // Delegate used to show HTTP Authentication dialogs.
151 @property(nonatomic, weak) id<TabDialogDelegate> dialogDelegate;
152
153 // TODO(crbug.com/661663): Should this property abstract away the concept of
154 // prerendering? Maybe this can move to the TabDelegate interface.
155 @property(nonatomic, assign) BOOL isPrerenderTab;
156 @property(nonatomic, assign) BOOL isLinkLoadingPrerenderTab;
157 @property(nonatomic, assign) BOOL isVoiceSearchResultsTab;
158
159 // Creates a new tab with the given state. |opener| is nil unless another tab
160 // is conceptually the parent of this tab. |openedByDOM| is YES if the page was
161 // opened by DOM. |model| and |browserState| must not be nil.
162 - (instancetype)initWithWindowName:(NSString*)windowName
163 opener:(Tab*)opener
164 openedByDOM:(BOOL)openedByDOM
165 model:(TabModel*)parentModel
166 browserState:(ios::ChromeBrowserState*)browserState;
167
168 // Create a new tab with given web state and tab model. All must be non-nil.
169 - (instancetype)initWithWebState:(std::unique_ptr<web::WebState>)webState
170 model:(TabModel*)parentModel
171 NS_DESIGNATED_INITIALIZER;
172
173 - (instancetype)init NS_UNAVAILABLE;
174
175 // Creates a new Tab instance loading |url| with |transition|, configured
176 // with no TabModel. |opener| may be nil, and behaves exactly as for
177 // -initWithWindowName:opener:model:browserState:.
178 // |configuration| is a block that will be run before |url| starts loading,
179 // and is the correct place to set properties and delegates on the tab.
180 // Calling code must take ownership of the tab -- this is particularly important
181 // with Tab instances, because they will fail a DCHECK if they are deallocated
182 // when falling out of scope without -close being called.
183 + (Tab*)newPreloadingTabWithBrowserState:(ios::ChromeBrowserState*)browserState
184 url:(const GURL&)url
185 referrer:(const web::Referrer&)referrer
186 transition:(ui::PageTransition)transition
187 provider:(id<CRWNativeContentProvider>)provider
188 opener:(Tab*)opener
189 desktopUserAgent:(BOOL)desktopUserAgent
190 configuration:(void (^)(Tab*))configuration;
191
192 // The current ID of the session (each Tab represents a session).
193 - (NSString*)currentSessionID;
194
195 // Sets the parent tab model for this tab. Can only be called if the tab does
196 // not already have a parent tab model set.
197 // TODO(crbug.com/228575): Create a delegate interface and remove this.
198 - (void)setParentTabModel:(TabModel*)model;
199
200 // Replace the content of the tab with the content described by |SessionTab|.
201 - (void)loadSessionTab:(const sessions::SessionTab*)sessionTab;
202
203 // Evaluate JavaScript asynchronously in the tab.
204 - (void)openJavascript:(NSString*)javascript;
205
206 // Stop the page loading.
207 // Equivalent to the user pressing 'stop', or a window.stop() command.
208 - (void)stopLoading;
209
210 // Triggers the asynchronous loading of the tab's favicon. This will be done
211 // automatically when a page loads, but this can be used to trigger favicon
212 // fetch earlier (e.g., for a tab that will be shown without loading).
213 - (void)fetchFavicon;
214
215 // Returns the favicon for the page currently being shown in this Tab, or |nil|
216 // if the current page has no favicon.
217 - (UIImage*)favicon;
218
219 // The view to display in the view hierarchy based on the current URL. Won't be
220 // nil. It is up to the caller to size the view and confirm |webUsageEnabled|.
221 - (UIView*)view;
222
223 // The view that generates print data when printing. It can be nil when printing
224 // is not supported with this tab. It can be different from |Tab view|.
225 - (UIView*)viewForPrinting;
226
227 // Halts the tab's network activity without closing it. This should only be
228 // called during shutdown, since the tab will be unusable but still present
229 // after this method completes.
230 - (void)terminateNetworkActivity;
231
232 // Starts the tab's shutdown sequence.
233 - (void)close;
234
235 // Dismisses all modals owned by the tab.
236 - (void)dismissModals;
237
238 // Opens StoreKit modal to download a native application identified with
239 // |appId|.
240 - (void)openAppStore:(NSString*)appId;
241
242 // Returns the NavigationManager for this tab's WebState. Requires WebState to
243 // be populated. Can return null.
244 - (web::NavigationManagerImpl*)navigationManager;
245
246 // Update the tab's history by replacing all previous navigations with
247 // |navigations|.
248 - (void)replaceHistoryWithNavigations:
249 (const std::vector<sessions::SerializedNavigationEntry>&)navigations
250 currentIndex:(NSInteger)currentIndex;
251
252 // Navigate forwards or backwards to |entry|.
253 - (void)goToEntry:(CRWSessionEntry*)entry;
254 - (void)reload;
255
256 // Navigates forwards or backwards.
257 // TODO(crbug.com/661664): These are passthroughs to CRWWebController. Convert
258 // all callers and remove these methods.
259 - (void)goBack;
260 - (void)goForward;
261
262 // Records the state (scroll position, form values, whatever can be
263 // harvested) from the current page into the current session entry.
264 - (void)recordStateInHistory;
265
266 // Returns the timestamp of the last time the tab is visited.
267 - (double)lastVisitedTimestamp;
268
269 // Updates the timestamp of the last time the tab is visited.
270 - (void)updateLastVisitedTimestamp;
271
272 // Returns the infobars::InfoBarManager object for this tab.
273 - (infobars::InfoBarManager*)infoBarManager;
274
275 // Returns the URLs in the entries that are redirected to the current entry.
276 - (std::vector<GURL>)currentRedirectedUrls;
277
278 // Whether the content of the current tab is compatible with reader mode.
279 - (BOOL)canSwitchToReaderMode;
280
281 // Asks the tab to enter into reader mode, presenting a streamlined view of the
282 // current content.
283 - (void)switchToReaderMode;
284
285 // Update internal state to use the desktop user agent. Must call
286 // -reloadWebViewAndURL for changes to take effect.
287 - (void)enableDesktopUserAgent;
288
289 // Remove the UIWebView and reload the current url. Used by request desktop
290 // so the updated user agent is used.
291 - (void)reloadForDesktopUserAgent;
292
293 // Accessor for Find in Page Controller.
294 - (FindInPageController*)findInPageController;
295
296 // Ensures the toolbar visibility matches |visible|.
297 - (void)updateFullscreenWithToolbarVisible:(BOOL)visible;
298
299 // Returns a snapshot of the current page, backed by disk so it can be purged
300 // and reloaded easily. The snapshot may be in memory, saved on disk or not
301 // present at all.
302 // 1) If the snapshot is in memory |block| will be called synchronously with
303 // the existing image.
304 // 2) If the snapshot is saven on disk |block| will be called asynchronously
305 // once the image is retrieved.
306 // 3) If the snapshot is not present at all |block| will be called
307 // asynchronously with a new snapshot.
308 // It is possible for |block| to not be called at all if there is no way to
309 // build a snapshot. |block| will always call back on the original thread.
310 - (void)retrieveSnapshot:(void (^)(UIImage*))callback;
311
312 // Invalidates the cached snapshot for the webcontroller's current session and
313 // forces a more recent snapshot to be generated and stored. Returns the
314 // snapshot with or without the overlayed views (e.g. infobar, voice search
315 // button, etc.), and either of the visible frame or of the full screen.
316 - (UIImage*)updateSnapshotWithOverlay:(BOOL)shouldAddOverlay
317 visibleFrameOnly:(BOOL)visibleFrameOnly;
318
319 // Snaps a snapshot image for the current page including optional infobars.
320 // Returns an autoreleased image cropped and scaled appropriately, with or
321 // without the overlayed views (e.g. infobar, voice search button, etc.), and
322 // either of the visible frame or of the full screen.
323 // Returns nil if a snapshot cannot be generated.
324 - (UIImage*)generateSnapshotWithOverlay:(BOOL)shouldAddOverlay
325 visibleFrameOnly:(BOOL)visibleFrameOnly;
326
327 // When snapshot coalescing is enabled, mutiple calls to generate a snapshot
328 // with the same parameters may be coalesced.
329 - (void)setSnapshotCoalescingEnabled:(BOOL)snapshotCoalescingEnabled;
330
331 // Returns the rect (in |view|'s coordinate space) to include for snapshotting.
332 - (CGRect)snapshotContentArea;
333
334 // Called when the snapshot of the content will be taken.
335 - (void)willUpdateSnapshot;
336
337 // Enables or disables usage of web views inside the Tab.
338 - (void)setWebUsageEnabled:(BOOL)webUsageEnabled;
339
340 // Returns the NativeAppNavigationController for this tab.
341 - (NativeAppNavigationController*)nativeAppNavigationController;
342
343 // Called when this tab is shown.
344 - (void)wasShown;
345
346 // Called when this tab is hidden.
347 - (void)wasHidden;
348
349 // Evaluates U2F result.
350 - (void)evaluateU2FResultFromURL:(const GURL&)url;
351
352 @end
353
354 #endif // IOS_CHROME_BROWSER_TABS_TAB_H_
OLDNEW
« no previous file with comments | « ios/chrome/browser/snapshots/web_controller_snapshot_helper.mm ('k') | ios/chrome/browser/tabs/tab.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698