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

Side by Side Diff: ios/chrome/browser/crash_report/crash_restore_helper.mm

Issue 2916253003: [ObjC ARC] Converts ios/chrome/browser/crash_report:crash_report_internal to ARC. (Closed)
Patch Set: Created 3 years, 6 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/crash_report/crash_report_helper.mm ('k') | no next file » | 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/crash_report/crash_restore_helper.h" 5 #import "ios/chrome/browser/crash_report/crash_restore_helper.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 11 matching lines...) Expand all
22 #include "ios/chrome/browser/sessions/ios_chrome_tab_restore_service_factory.h" 22 #include "ios/chrome/browser/sessions/ios_chrome_tab_restore_service_factory.h"
23 #import "ios/chrome/browser/sessions/session_ios.h" 23 #import "ios/chrome/browser/sessions/session_ios.h"
24 #import "ios/chrome/browser/sessions/session_service_ios.h" 24 #import "ios/chrome/browser/sessions/session_service_ios.h"
25 #import "ios/chrome/browser/sessions/session_window_ios.h" 25 #import "ios/chrome/browser/sessions/session_window_ios.h"
26 #import "ios/chrome/browser/tabs/tab.h" 26 #import "ios/chrome/browser/tabs/tab.h"
27 #import "ios/chrome/browser/tabs/tab_model.h" 27 #import "ios/chrome/browser/tabs/tab_model.h"
28 #include "ios/chrome/grit/ios_theme_resources.h" 28 #include "ios/chrome/grit/ios_theme_resources.h"
29 #include "ui/base/l10n/l10n_util.h" 29 #include "ui/base/l10n/l10n_util.h"
30 #include "ui/base/resource/resource_bundle.h" 30 #include "ui/base/resource/resource_bundle.h"
31 31
32 #if !defined(__has_feature) || !__has_feature(objc_arc)
33 #error "This file requires ARC support."
34 #endif
35
32 @protocol InfoBarManagerObserverBridgeProtocol 36 @protocol InfoBarManagerObserverBridgeProtocol
33 - (void)infoBarRemoved:(infobars::InfoBar*)infobar; 37 - (void)infoBarRemoved:(infobars::InfoBar*)infobar;
34 @end 38 @end
35 39
36 // Private methods. 40 // Private methods.
37 @interface CrashRestoreHelper ()<InfoBarManagerObserverBridgeProtocol> 41 @interface CrashRestoreHelper ()<InfoBarManagerObserverBridgeProtocol>
38 // Deletes the session file for the given browser state, optionally backing it 42 // Deletes the session file for the given browser state, optionally backing it
39 // up beforehand to |backupFile| if it is not nil. This method returns YES in 43 // up beforehand to |backupFile| if it is not nil. This method returns YES in
40 // case of success, NO otherwise. 44 // case of success, NO otherwise.
41 - (BOOL)deleteSessionForBrowserState:(ios::ChromeBrowserState*)browserState 45 - (BOOL)deleteSessionForBrowserState:(ios::ChromeBrowserState*)browserState
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 InfoBarIdentifier GetIdentifier() const override; 107 InfoBarIdentifier GetIdentifier() const override;
104 108
105 // ConfirmInfoBarDelegate: 109 // ConfirmInfoBarDelegate:
106 base::string16 GetMessageText() const override; 110 base::string16 GetMessageText() const override;
107 int GetButtons() const override; 111 int GetButtons() const override;
108 base::string16 GetButtonLabel(InfoBarButton button) const override; 112 base::string16 GetButtonLabel(InfoBarButton button) const override;
109 bool Accept() override; 113 bool Accept() override;
110 int GetIconId() const override; 114 int GetIconId() const override;
111 115
112 // The CrashRestoreHelper to restore sessions. 116 // The CrashRestoreHelper to restore sessions.
113 base::scoped_nsobject<CrashRestoreHelper> crash_restore_helper_; 117 CrashRestoreHelper* crash_restore_helper_;
114 // The TabModel to restore sessions to.
115 base::scoped_nsobject<TabModel> tab_model_;
116 118
117 DISALLOW_COPY_AND_ASSIGN(SessionCrashedInfoBarDelegate); 119 DISALLOW_COPY_AND_ASSIGN(SessionCrashedInfoBarDelegate);
118 }; 120 };
119 121
120 SessionCrashedInfoBarDelegate::SessionCrashedInfoBarDelegate( 122 SessionCrashedInfoBarDelegate::SessionCrashedInfoBarDelegate(
121 CrashRestoreHelper* crash_restore_helper) 123 CrashRestoreHelper* crash_restore_helper)
122 : crash_restore_helper_([crash_restore_helper retain]) {} 124 : crash_restore_helper_(crash_restore_helper) {}
123 125
124 SessionCrashedInfoBarDelegate::~SessionCrashedInfoBarDelegate() {} 126 SessionCrashedInfoBarDelegate::~SessionCrashedInfoBarDelegate() {}
125 127
126 // static 128 // static
127 bool SessionCrashedInfoBarDelegate::Create( 129 bool SessionCrashedInfoBarDelegate::Create(
128 infobars::InfoBarManager* infobar_manager, 130 infobars::InfoBarManager* infobar_manager,
129 CrashRestoreHelper* crash_restore_helper) { 131 CrashRestoreHelper* crash_restore_helper) {
130 DCHECK(infobar_manager); 132 DCHECK(infobar_manager);
131 std::unique_ptr<ConfirmInfoBarDelegate> delegate( 133 std::unique_ptr<ConfirmInfoBarDelegate> delegate(
132 new SessionCrashedInfoBarDelegate(crash_restore_helper)); 134 new SessionCrashedInfoBarDelegate(crash_restore_helper));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 return IDR_IOS_INFOBAR_RESTORE_SESSION; 166 return IDR_IOS_INFOBAR_RESTORE_SESSION;
165 } 167 }
166 168
167 } // namespace 169 } // namespace
168 170
169 @implementation CrashRestoreHelper { 171 @implementation CrashRestoreHelper {
170 ios::ChromeBrowserState* _browserState; 172 ios::ChromeBrowserState* _browserState;
171 BOOL _needRestoration; 173 BOOL _needRestoration;
172 std::unique_ptr<InfoBarManagerObserverBridge> _infoBarBridge; 174 std::unique_ptr<InfoBarManagerObserverBridge> _infoBarBridge;
173 // The TabModel to restore sessions to. 175 // The TabModel to restore sessions to.
174 base::scoped_nsobject<TabModel> _tabModel; 176 TabModel* _tabModel;
175 177
176 // Indicate that the session has been restored to tabs or to recently closed 178 // Indicate that the session has been restored to tabs or to recently closed
177 // and should not be rerestored. 179 // and should not be rerestored.
178 BOOL _sessionRestored; 180 BOOL _sessionRestored;
179 } 181 }
180 182
181 - (id)initWithBrowserState:(ios::ChromeBrowserState*)browserState { 183 - (id)initWithBrowserState:(ios::ChromeBrowserState*)browserState {
182 if (self = [super init]) { 184 if (self = [super init]) {
183 _browserState = browserState; 185 _browserState = browserState;
184 } 186 }
185 return self; 187 return self;
186 } 188 }
187 189
188 - (void)showRestoreIfNeeded:(TabModel*)tabModel { 190 - (void)showRestoreIfNeeded:(TabModel*)tabModel {
189 if (!_needRestoration) 191 if (!_needRestoration)
190 return; 192 return;
191 193
192 // The last session didn't exit cleanly. Show an infobar to the user so 194 // The last session didn't exit cleanly. Show an infobar to the user so
193 // that they can restore if they want. The delegate deletes itself when 195 // that they can restore if they want. The delegate deletes itself when
194 // it is closed. 196 // it is closed.
195 DCHECK([tabModel currentTab]); 197 DCHECK([tabModel currentTab]);
196 infobars::InfoBarManager* infoBarManager = 198 infobars::InfoBarManager* infoBarManager =
197 [[tabModel currentTab] infoBarManager]; 199 [[tabModel currentTab] infoBarManager];
198 _tabModel.reset([tabModel retain]); 200 _tabModel = tabModel;
199 SessionCrashedInfoBarDelegate::Create(infoBarManager, self); 201 SessionCrashedInfoBarDelegate::Create(infoBarManager, self);
200 _infoBarBridge.reset(new InfoBarManagerObserverBridge(infoBarManager, self)); 202 _infoBarBridge.reset(new InfoBarManagerObserverBridge(infoBarManager, self));
201 } 203 }
202 204
203 - (BOOL)deleteSessionForBrowserState:(ios::ChromeBrowserState*)browserState 205 - (BOOL)deleteSessionForBrowserState:(ios::ChromeBrowserState*)browserState
204 backupFile:(NSString*)file { 206 backupFile:(NSString*)file {
205 NSString* stashPath = 207 NSString* stashPath =
206 base::SysUTF8ToNSString(browserState->GetStatePath().value()); 208 base::SysUTF8ToNSString(browserState->GetStatePath().value());
207 NSString* sessionPath = [SessionServiceIOS sessionPathForDirectory:stashPath]; 209 NSString* sessionPath = [SessionServiceIOS sessionPathForDirectory:stashPath];
208 NSFileManager* fileManager = [NSFileManager defaultManager]; 210 NSFileManager* fileManager = [NSFileManager defaultManager];
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 web::WebState::CreateWithStorageSession(params, session); 304 web::WebState::CreateWithStorageSession(params, session);
303 // Add all tabs at the 0 position as the position is relative to an old 305 // Add all tabs at the 0 position as the position is relative to an old
304 // tabModel. 306 // tabModel.
305 tabRestoreService->CreateHistoricalTab( 307 tabRestoreService->CreateHistoricalTab(
306 sessions::IOSLiveTab::GetForWebState(webState.get()), 0); 308 sessions::IOSLiveTab::GetForWebState(webState.get()), 0);
307 } 309 }
308 return; 310 return;
309 } 311 }
310 312
311 @end 313 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/crash_report/crash_report_helper.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698