Revert "Fix broken channel icon in chrome://help on CrOS" and try again
[chromium-blink-merge.git] / ios / chrome / browser / passwords / password_generation_utils.mm
blob7f1abd44dba9920598c3052e76e67307dae93191
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"
10 namespace passwords {
12 namespace {
14 const CGFloat kPadding = IsIPadIdiom() ? 16 : 8;
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   });
34 }  // namespace
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;
46 void RunSearchPipeline(NSArray* blocks, PipelineCompletionBlock on_complete) {
47   RunSearchPipeline(blocks, on_complete, 0);
50 }  // namespace passwords