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