| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui/first_run/first_run_util.h" | 5 #import "ios/chrome/browser/ui/first_run/first_run_util.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "components/signin/core/browser/signin_manager.h" | 12 #include "components/signin/core/browser/signin_manager.h" |
| 13 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 13 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 14 #import "ios/chrome/browser/crash_report/breakpad_helper.h" | 14 #import "ios/chrome/browser/crash_report/breakpad_helper.h" |
| 15 #include "ios/chrome/browser/first_run/first_run.h" | 15 #include "ios/chrome/browser/first_run/first_run.h" |
| 16 #import "ios/chrome/browser/first_run/first_run_configuration.h" | 16 #import "ios/chrome/browser/first_run/first_run_configuration.h" |
| 17 #include "ios/chrome/browser/first_run/first_run_metrics.h" | 17 #include "ios/chrome/browser/first_run/first_run_metrics.h" |
| 18 #include "ios/chrome/browser/signin/signin_manager_factory.h" | 18 #include "ios/chrome/browser/signin/signin_manager_factory.h" |
| 19 #include "ios/chrome/browser/tabs/tab.h" | 19 #include "ios/chrome/browser/tabs/tab.h" |
| 20 #include "ios/chrome/browser/ui/first_run/first_run_histograms.h" | 20 #include "ios/chrome/browser/ui/first_run/first_run_histograms.h" |
| 21 #import "ios/chrome/browser/ui/settings/settings_utils.h" | 21 #import "ios/chrome/browser/ui/settings/settings_utils.h" |
| 22 #import "ios/chrome/browser/ui/sync/sync_util.h" | 22 #import "ios/chrome/browser/ui/sync/sync_util.h" |
| 23 #include "ios/chrome/browser/ui/ui_util.h" | 23 #include "ios/chrome/browser/ui/ui_util.h" |
| 24 #include "ios/web/public/web_thread.h" | 24 #include "ios/web/public/web_thread.h" |
| 25 #import "ui/gfx/ios/NSString+CrStringDrawing.h" | 25 #import "ui/gfx/ios/NSString+CrStringDrawing.h" |
| 26 | 26 |
| 27 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 28 #error "This file requires ARC support." |
| 29 #endif |
| 30 |
| 27 NSString* const kChromeFirstRunUIWillFinishNotification = | 31 NSString* const kChromeFirstRunUIWillFinishNotification = |
| 28 @"kChromeFirstRunUIWillFinishNotification"; | 32 @"kChromeFirstRunUIWillFinishNotification"; |
| 29 | 33 |
| 30 NSString* const kChromeFirstRunUIDidFinishNotification = | 34 NSString* const kChromeFirstRunUIDidFinishNotification = |
| 31 @"kChromeFirstRunUIDidFinishNotification"; | 35 @"kChromeFirstRunUIDidFinishNotification"; |
| 32 | 36 |
| 33 namespace { | 37 namespace { |
| 34 | 38 |
| 35 NSString* RemoveLastWord(NSString* text) { | 39 NSString* RemoveLastWord(NSString* text) { |
| 36 __block NSRange range = NSMakeRange(0, [text length]); | 40 __block NSRange range = NSMakeRange(0, [text length]); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 59 NSStringEnumerationSubstringNotRequired; | 63 NSStringEnumerationSubstringNotRequired; |
| 60 [text | 64 [text |
| 61 enumerateSubstringsInRange:range | 65 enumerateSubstringsInRange:range |
| 62 options:options | 66 options:options |
| 63 usingBlock:^(NSString* substring, NSRange substringRange, | 67 usingBlock:^(NSString* substring, NSRange substringRange, |
| 64 NSRange enclosingRange, BOOL* stop) { | 68 NSRange enclosingRange, BOOL* stop) { |
| 65 range = substringRange; | 69 range = substringRange; |
| 66 count++; | 70 count++; |
| 67 *stop = count == index; | 71 *stop = count == index; |
| 68 }]; | 72 }]; |
| 69 NSMutableString* textWithNewline = [[text mutableCopy] autorelease]; | 73 NSMutableString* textWithNewline = [text mutableCopy]; |
| 70 [textWithNewline insertString:@"\n" atIndex:range.location]; | 74 [textWithNewline insertString:@"\n" atIndex:range.location]; |
| 71 return textWithNewline; | 75 return textWithNewline; |
| 72 } | 76 } |
| 73 | 77 |
| 74 // Trampoline method for Bind to create the sentinel file. | 78 // Trampoline method for Bind to create the sentinel file. |
| 75 bool CreateSentinel() { | 79 bool CreateSentinel() { |
| 76 return FirstRun::CreateSentinel(); | 80 return FirstRun::CreateSentinel(); |
| 77 } | 81 } |
| 78 | 82 |
| 79 // Helper function for recording first run metrics. Takes an additional | 83 // Helper function for recording first run metrics. Takes an additional |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 base::TimeDelta::FromMinutes(3), 50); | 182 base::TimeDelta::FromMinutes(3), 50); |
| 179 } | 183 } |
| 180 | 184 |
| 181 void FirstRunDismissed() { | 185 void FirstRunDismissed() { |
| 182 [[NSNotificationCenter defaultCenter] | 186 [[NSNotificationCenter defaultCenter] |
| 183 postNotificationName:kChromeFirstRunUIDidFinishNotification | 187 postNotificationName:kChromeFirstRunUIDidFinishNotification |
| 184 object:nil]; | 188 object:nil]; |
| 185 } | 189 } |
| 186 | 190 |
| 187 } // namespace ios_internal | 191 } // namespace ios_internal |
| OLD | NEW |