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.
5 #include "ios/chrome/browser/passwords/password_generation_utils.h"
7 #include "base/i18n/rtl.h"
8 #include "ios/chrome/browser/ui/ui_util.h"
14 const CGFloat kPadding = IsIPadIdiom() ? 16 : 8;
16 // The actual implementation of |RunPipeline| that begins with the first block
18 void RunSearchPipeline(NSArray* blocks,
19 PipelineCompletionBlock on_complete,
20 NSUInteger from_index) {
21 if (from_index == [blocks count]) {
22 on_complete(NSNotFound);
25 PipelineBlock block = blocks[from_index];
26 block(^(BOOL success) {
28 on_complete(from_index);
30 RunSearchPipeline(blocks, on_complete, from_index + 1);
36 CGRect GetGenerationAccessoryFrame(CGRect outer_frame, CGRect inner_frame) {
38 if (base::i18n::IsRTL())
39 x = CGRectGetWidth(outer_frame) - CGRectGetWidth(inner_frame) - kPadding;
41 (CGRectGetHeight(outer_frame) - CGRectGetHeight(inner_frame)) / 2.0;
42 inner_frame.origin = CGPointMake(x, y);
46 void RunSearchPipeline(NSArray* blocks, PipelineCompletionBlock on_complete) {
47 RunSearchPipeline(blocks, on_complete, 0);
50 } // namespace passwords