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

Side by Side Diff: ios/chrome/browser/sessions/tab_restore_service_delegate_impl_ios.mm

Issue 2712743008: Remove -insertTabWithWebState:atIndex: from TabModel. (Closed)
Patch Set: Rebase. Created 3 years, 9 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 | « ios/chrome/browser/sessions/DEPS ('k') | ios/chrome/browser/tabs/tab.mm » ('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 #include "ios/chrome/browser/sessions/tab_restore_service_delegate_impl_ios.h" 5 #include "ios/chrome/browser/sessions/tab_restore_service_delegate_impl_ios.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/strings/sys_string_conversions.h" 11 #include "base/strings/sys_string_conversions.h"
12 #include "components/sessions/core/session_types.h" 12 #include "components/sessions/core/session_types.h"
13 #include "components/sessions/ios/ios_serialized_navigation_builder.h" 13 #include "components/sessions/ios/ios_serialized_navigation_builder.h"
14 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" 14 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
15 #import "ios/chrome/browser/tabs/tab.h" 15 #import "ios/chrome/browser/tabs/tab.h"
16 #import "ios/chrome/browser/tabs/tab_model.h" 16 #import "ios/chrome/browser/tabs/tab_model.h"
17 #import "ios/chrome/browser/tabs/tab_model_list.h" 17 #import "ios/chrome/browser/tabs/tab_model_list.h"
18 #import "ios/web/navigation/navigation_manager_impl.h"
19 #include "ios/web/public/navigation_item.h" 18 #include "ios/web/public/navigation_item.h"
20 #import "ios/web/web_state/web_state_impl.h"
21 #import "net/base/mac/url_conversions.h" 19 #import "net/base/mac/url_conversions.h"
22 20
23 using web::WebStateImpl;
24
25 TabRestoreServiceDelegateImplIOS::TabRestoreServiceDelegateImplIOS( 21 TabRestoreServiceDelegateImplIOS::TabRestoreServiceDelegateImplIOS(
26 ios::ChromeBrowserState* browser_state) 22 ios::ChromeBrowserState* browser_state)
27 : browser_state_(browser_state) {} 23 : browser_state_(browser_state) {}
28 24
29 TabRestoreServiceDelegateImplIOS::~TabRestoreServiceDelegateImplIOS() {} 25 TabRestoreServiceDelegateImplIOS::~TabRestoreServiceDelegateImplIOS() {}
30 26
31 TabModel* TabRestoreServiceDelegateImplIOS::tab_model() const { 27 TabModel* TabRestoreServiceDelegateImplIOS::tab_model() const {
32 return GetLastActiveTabModelForChromeBrowserState(browser_state_); 28 return GetLastActiveTabModelForChromeBrowserState(browser_state_);
33 } 29 }
34 30
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 const std::vector<sessions::SerializedNavigationEntry>& navigations, 67 const std::vector<sessions::SerializedNavigationEntry>& navigations,
72 int tab_index, 68 int tab_index,
73 int selected_navigation, 69 int selected_navigation,
74 const std::string& extension_app_id, 70 const std::string& extension_app_id,
75 bool select, 71 bool select,
76 bool pin, 72 bool pin,
77 bool from_last_session, 73 bool from_last_session,
78 const sessions::PlatformSpecificTabData* tab_platform_data, 74 const sessions::PlatformSpecificTabData* tab_platform_data,
79 const std::string& user_agent_override) { 75 const std::string& user_agent_override) {
80 DCHECK_LT(selected_navigation, static_cast<int>(navigations.size())); 76 DCHECK_LT(selected_navigation, static_cast<int>(navigations.size()));
81 77 DCHECK_GE(tab_index, 0);
82 std::unique_ptr<WebStateImpl> webState(new WebStateImpl(browser_state_)); 78 web::ScopedNavigationItemList items =
83 std::vector<std::unique_ptr<web::NavigationItem>> items =
84 sessions::IOSSerializedNavigationBuilder::ToNavigationItems(navigations); 79 sessions::IOSSerializedNavigationBuilder::ToNavigationItems(navigations);
85 webState->GetNavigationManagerImpl().ReplaceSessionHistory( 80 [tab_model() insertTabWithNavigationItems:std::move(items)
86 std::move(items), selected_navigation); 81 selectedNavigationIndex:selected_navigation
87 TabModel* tabModel = tab_model(); 82 atIndex:static_cast<NSUInteger>(tab_index)
88 Tab* tab = 83 inBackground:NO];
89 [tabModel insertTabWithWebState:std::move(webState) atIndex:tab_index];
90 // TODO(crbug.com/661636): Handle tab-switch animation somehow...
91 [tabModel setCurrentTab:tab];
92 return nullptr; 84 return nullptr;
93 } 85 }
94 86
95 sessions::LiveTab* TabRestoreServiceDelegateImplIOS::ReplaceRestoredTab( 87 sessions::LiveTab* TabRestoreServiceDelegateImplIOS::ReplaceRestoredTab(
96 const std::vector<sessions::SerializedNavigationEntry>& navigations, 88 const std::vector<sessions::SerializedNavigationEntry>& navigations,
97 int selected_navigation, 89 int selected_navigation,
98 bool from_last_session, 90 bool from_last_session,
99 const std::string& extension_app_id, 91 const std::string& extension_app_id,
100 const sessions::PlatformSpecificTabData* tab_platform_data, 92 const sessions::PlatformSpecificTabData* tab_platform_data,
101 const std::string& user_agent_override) { 93 const std::string& user_agent_override) {
102 DCHECK_LT(selected_navigation, static_cast<int>(navigations.size())); 94 DCHECK_LT(selected_navigation, static_cast<int>(navigations.size()));
103 95
104 // Desktop Chrome creates a new tab and deletes the old one. The net result 96 // Desktop Chrome creates a new tab and deletes the old one. The net result
105 // is that the NTP is not in the session history of the restored tab. Do 97 // is that the NTP is not in the session history of the restored tab. Do
106 // the same by replacing the tab's navigation history which will also force it 98 // the same by replacing the tab's navigation history which will also force it
107 // to reload. 99 // to reload.
108 Tab* tab = tab_model().currentTab; 100 Tab* tab = tab_model().currentTab;
109 [tab replaceHistoryWithNavigations:navigations 101 [tab replaceHistoryWithNavigations:navigations
110 currentIndex:selected_navigation]; 102 currentIndex:selected_navigation];
111 return nullptr; 103 return nullptr;
112 } 104 }
113 105
114 void TabRestoreServiceDelegateImplIOS::CloseTab() { 106 void TabRestoreServiceDelegateImplIOS::CloseTab() {
115 [[tab_model() currentTab] close]; 107 [[tab_model() currentTab] close];
116 } 108 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/sessions/DEPS ('k') | ios/chrome/browser/tabs/tab.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698