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

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

Issue 2784843002: Reading List: Mark entry read when opening external app. (Closed)
Patch Set: feedback Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ios/web/public/web_state/ui/crw_web_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ios/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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 #import "ios/chrome/browser/geolocation/omnibox_geolocation_controller.h" 61 #import "ios/chrome/browser/geolocation/omnibox_geolocation_controller.h"
62 #include "ios/chrome/browser/history/history_service_factory.h" 62 #include "ios/chrome/browser/history/history_service_factory.h"
63 #include "ios/chrome/browser/history/top_sites_factory.h" 63 #include "ios/chrome/browser/history/top_sites_factory.h"
64 #include "ios/chrome/browser/infobars/infobar_manager_impl.h" 64 #include "ios/chrome/browser/infobars/infobar_manager_impl.h"
65 #include "ios/chrome/browser/metrics/ios_chrome_origins_seen_service_factory.h" 65 #include "ios/chrome/browser/metrics/ios_chrome_origins_seen_service_factory.h"
66 #import "ios/chrome/browser/metrics/tab_usage_recorder.h" 66 #import "ios/chrome/browser/metrics/tab_usage_recorder.h"
67 #import "ios/chrome/browser/native_app_launcher/native_app_navigation_controller .h" 67 #import "ios/chrome/browser/native_app_launcher/native_app_navigation_controller .h"
68 #import "ios/chrome/browser/passwords/password_controller.h" 68 #import "ios/chrome/browser/passwords/password_controller.h"
69 #import "ios/chrome/browser/passwords/passwords_ui_delegate_impl.h" 69 #import "ios/chrome/browser/passwords/passwords_ui_delegate_impl.h"
70 #include "ios/chrome/browser/pref_names.h" 70 #include "ios/chrome/browser/pref_names.h"
71 #include "ios/chrome/browser/reading_list/reading_list_model_factory.h"
71 #include "ios/chrome/browser/search_engines/template_url_service_factory.h" 72 #include "ios/chrome/browser/search_engines/template_url_service_factory.h"
72 #include "ios/chrome/browser/sessions/ios_chrome_session_tab_helper.h" 73 #include "ios/chrome/browser/sessions/ios_chrome_session_tab_helper.h"
73 #include "ios/chrome/browser/signin/account_consistency_service_factory.h" 74 #include "ios/chrome/browser/signin/account_consistency_service_factory.h"
74 #include "ios/chrome/browser/signin/account_reconcilor_factory.h" 75 #include "ios/chrome/browser/signin/account_reconcilor_factory.h"
75 #include "ios/chrome/browser/signin/authentication_service.h" 76 #include "ios/chrome/browser/signin/authentication_service.h"
76 #include "ios/chrome/browser/signin/authentication_service_factory.h" 77 #include "ios/chrome/browser/signin/authentication_service_factory.h"
77 #include "ios/chrome/browser/signin/signin_capability.h" 78 #include "ios/chrome/browser/signin/signin_capability.h"
78 #import "ios/chrome/browser/snapshots/snapshot_manager.h" 79 #import "ios/chrome/browser/snapshots/snapshot_manager.h"
79 #import "ios/chrome/browser/snapshots/snapshot_overlay_provider.h" 80 #import "ios/chrome/browser/snapshots/snapshot_overlay_provider.h"
80 #import "ios/chrome/browser/snapshots/web_controller_snapshot_helper.h" 81 #import "ios/chrome/browser/snapshots/web_controller_snapshot_helper.h"
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 341
341 // Adds any cached entries from |addPageVector_| to the history DB. 342 // Adds any cached entries from |addPageVector_| to the history DB.
342 - (void)commitCachedEntriesToHistoryDB; 343 - (void)commitCachedEntriesToHistoryDB;
343 344
344 // Returns the OpenInController for this tab. 345 // Returns the OpenInController for this tab.
345 - (OpenInController*)openInController; 346 - (OpenInController*)openInController;
346 347
347 // Initialize the Native App Launcher controller. 348 // Initialize the Native App Launcher controller.
348 - (void)initNativeAppNavigationController; 349 - (void)initNativeAppNavigationController;
349 350
350 // Opens a link in an external app. Returns YES iff |url| is launched in an
351 // external app.
352 - (BOOL)openExternalURL:(const GURL&)url linkClicked:(BOOL)linkClicked;
353
354 // Handles exportable files if possible. 351 // Handles exportable files if possible.
355 - (void)handleExportableFile:(net::HttpResponseHeaders*)headers; 352 - (void)handleExportableFile:(net::HttpResponseHeaders*)headers;
356 353
357 // Called after the session history is replaced, useful for updating members 354 // Called after the session history is replaced, useful for updating members
358 // with new sessionID. 355 // with new sessionID.
359 - (void)didReplaceSessionHistory; 356 - (void)didReplaceSessionHistory;
360 357
361 // Called when the UIApplication's state becomes active. 358 // Called when the UIApplication's state becomes active.
362 - (void)applicationDidBecomeActive; 359 - (void)applicationDidBecomeActive;
363 360
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 1254
1258 if (self.navigationManager) { 1255 if (self.navigationManager) {
1259 CRWSessionController* sessionController = 1256 CRWSessionController* sessionController =
1260 [self navigationManagerImpl]->GetSessionController(); 1257 [self navigationManagerImpl]->GetSessionController();
1261 NSInteger itemIndex = [sessionController indexOfItem:item]; 1258 NSInteger itemIndex = [sessionController indexOfItem:item];
1262 DCHECK_NE(itemIndex, NSNotFound); 1259 DCHECK_NE(itemIndex, NSNotFound);
1263 self.navigationManager->GoToIndex(itemIndex); 1260 self.navigationManager->GoToIndex(itemIndex);
1264 } 1261 }
1265 } 1262 }
1266 1263
1267 - (BOOL)openExternalURL:(const GURL&)url linkClicked:(BOOL)linkClicked { 1264 - (BOOL)openExternalURL:(const GURL&)url
1265 sourceURL:(const GURL&)sourceURL
1266 linkClicked:(BOOL)linkClicked {
1268 if (!externalAppLauncher_.get()) 1267 if (!externalAppLauncher_.get())
1269 externalAppLauncher_.reset([[ExternalAppLauncher alloc] init]); 1268 externalAppLauncher_.reset([[ExternalAppLauncher alloc] init]);
1270 1269
1271 // This method may release CRWWebController which may cause a crash 1270 // This method may release CRWWebController which may cause a crash
1272 // (crbug.com/393949). 1271 // (crbug.com/393949).
1273 [[self.webController retain] autorelease]; 1272 [[self.webController retain] autorelease];
1274 1273
1275 // Make a local url copy for possible modification. 1274 // Make a local url copy for possible modification.
1276 GURL finalURL = url; 1275 GURL finalURL = url;
1277 1276
(...skipping 26 matching lines...) Expand all
1304 } 1303 }
1305 1304
1306 if ([externalAppLauncher_ openURL:finalURL linkClicked:linkClicked]) { 1305 if ([externalAppLauncher_ openURL:finalURL linkClicked:linkClicked]) {
1307 // Clears pending navigation history after successfully launching the 1306 // Clears pending navigation history after successfully launching the
1308 // external app. 1307 // external app.
1309 DCHECK([self navigationManager]); 1308 DCHECK([self navigationManager]);
1310 [self navigationManager]->DiscardNonCommittedItems(); 1309 [self navigationManager]->DiscardNonCommittedItems();
1311 // Ensure the UI reflects the current entry, not the just-discarded pending 1310 // Ensure the UI reflects the current entry, not the just-discarded pending
1312 // entry. 1311 // entry.
1313 [parentTabModel_ notifyTabChanged:self]; 1312 [parentTabModel_ notifyTabChanged:self];
1313
1314 if (sourceURL.is_valid()) {
1315 ReadingListModel* model =
1316 ReadingListModelFactory::GetForBrowserState(browserState_);
1317 if (model && model->loaded()) {
1318 model->SetReadStatus(sourceURL, true);
1319 }
1320 }
1321
1314 return YES; 1322 return YES;
1315 } 1323 }
1316 return NO; 1324 return NO;
1317 } 1325 }
1318 1326
1319 - (void)webState:(web::WebState*)webState 1327 - (void)webState:(web::WebState*)webState
1320 didFinishNavigation:(web::NavigationContext*)navigation { 1328 didFinishNavigation:(web::NavigationContext*)navigation {
1321 if (navigation->IsSameDocument()) { 1329 if (navigation->IsSameDocument()) {
1322 auto* faviconDriver = favicon::WebFaviconDriver::FromWebState(webState); 1330 auto* faviconDriver = favicon::WebFaviconDriver::FromWebState(webState);
1323 if (faviconDriver) { 1331 if (faviconDriver) {
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
1739 nativeAppForURL:url] retain]); 1747 nativeAppForURL:url] retain]);
1740 if (![metadata shouldAutoOpenLinks]) 1748 if (![metadata shouldAutoOpenLinks])
1741 return NO; 1749 return NO;
1742 1750
1743 AuthenticationService* authenticationService = 1751 AuthenticationService* authenticationService =
1744 AuthenticationServiceFactory::GetForBrowserState(self.browserState); 1752 AuthenticationServiceFactory::GetForBrowserState(self.browserState);
1745 ChromeIdentity* identity = authenticationService->GetAuthenticatedIdentity(); 1753 ChromeIdentity* identity = authenticationService->GetAuthenticatedIdentity();
1746 1754
1747 // Attempts to open external app without x-callback. 1755 // Attempts to open external app without x-callback.
1748 if ([self openExternalURL:[metadata launchURLWithURL:url identity:identity] 1756 if ([self openExternalURL:[metadata launchURLWithURL:url identity:identity]
1757 sourceURL:sourceURL
1749 linkClicked:linkClicked]) { 1758 linkClicked:linkClicked]) {
1750 return YES; 1759 return YES;
1751 } 1760 }
1752 1761
1753 // Auto-open didn't work. Reset the auto-open flag. 1762 // Auto-open didn't work. Reset the auto-open flag.
1754 [metadata unsetShouldAutoOpenLinks]; 1763 [metadata unsetShouldAutoOpenLinks];
1755 return NO; 1764 return NO;
1756 } 1765 }
1757 1766
1758 - (double)lastVisitedTimestamp { 1767 - (double)lastVisitedTimestamp {
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
2087 2096
2088 - (TabModel*)parentTabModel { 2097 - (TabModel*)parentTabModel {
2089 return parentTabModel_; 2098 return parentTabModel_;
2090 } 2099 }
2091 2100
2092 - (FormInputAccessoryViewController*)inputAccessoryViewController { 2101 - (FormInputAccessoryViewController*)inputAccessoryViewController {
2093 return inputAccessoryViewController_.get(); 2102 return inputAccessoryViewController_.get();
2094 } 2103 }
2095 2104
2096 @end 2105 @end
OLDNEW
« no previous file with comments | « no previous file | ios/web/public/web_state/ui/crw_web_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698