OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ios/chrome/browser/passwords/password_generation_utils.h" |
| 6 |
| 7 #include "base/i18n/rtl.h" |
| 8 #include "ios/chrome/browser/ui/ui_util.h" |
| 9 |
| 10 namespace passwords { |
| 11 |
| 12 namespace { |
| 13 |
| 14 const CGFloat kPadding = IsIPadIdiom() ? 16 : 8; |
| 15 |
| 16 // The actual implementation of |RunPipeline| that begins with the first block |
| 17 // in |blocks|. |
| 18 void RunSearchPipeline(NSArray* blocks, |
| 19 PipelineCompletionBlock on_complete, |
| 20 NSUInteger from_index) { |
| 21 if (from_index == [blocks count]) { |
| 22 on_complete(NSNotFound); |
| 23 return; |
| 24 } |
| 25 PipelineBlock block = blocks[from_index]; |
| 26 block(^(BOOL success) { |
| 27 if (success) |
| 28 on_complete(from_index); |
| 29 else |
| 30 RunSearchPipeline(blocks, on_complete, from_index + 1); |
| 31 }); |
| 32 } |
| 33 |
| 34 } // namespace |
| 35 |
| 36 CGRect GetGenerationAccessoryFrame(CGRect outer_frame, CGRect inner_frame) { |
| 37 CGFloat x = kPadding; |
| 38 if (base::i18n::IsRTL()) |
| 39 x = CGRectGetWidth(outer_frame) - CGRectGetWidth(inner_frame) - kPadding; |
| 40 const CGFloat y = |
| 41 (CGRectGetHeight(outer_frame) - CGRectGetHeight(inner_frame)) / 2.0; |
| 42 inner_frame.origin = CGPointMake(x, y); |
| 43 return inner_frame; |
| 44 } |
| 45 |
| 46 void RunSearchPipeline(NSArray* blocks, PipelineCompletionBlock on_complete) { |
| 47 RunSearchPipeline(blocks, on_complete, 0); |
| 48 } |
| 49 |
| 50 } // namespace passwords |
OLD | NEW |