forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide UI for details of payment instrument. R=sail@chromium.org BUG=157274 Review URL: https://chromiumcodereview.appspot.com/14704004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200338 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
groby@chromium.org
committed
May 15, 2013
1 parent
d95ce52
commit a1dae87
Showing
12 changed files
with
417 additions
and
16 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
chrome/browser/ui/cocoa/autofill/autofill_details_container.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) 2013 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. | ||
|
||
#ifndef CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_DETAILS_CONTAINER_H_ | ||
#define CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_DETAILS_CONTAINER_H_ | ||
|
||
#import <Cocoa/Cocoa.h> | ||
|
||
#include "base/memory/scoped_nsobject.h" | ||
|
||
namespace autofill { | ||
class AutofillDialogController; | ||
} | ||
|
||
// UI controller for details for current payment instrument. | ||
@interface AutofillDetailsContainer : NSViewController { | ||
@private | ||
scoped_nsobject<NSMutableArray> details_; // The individual detail sections. | ||
autofill::AutofillDialogController* controller_; // Not owned. | ||
} | ||
|
||
- (id)initWithController:(autofill::AutofillDialogController*)controller; | ||
|
||
@end | ||
|
||
#endif // CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_DETAILS_CONTAINER_H_ |
47 changes: 47 additions & 0 deletions
47
chrome/browser/ui/cocoa/autofill/autofill_details_container.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright (c) 2013 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. | ||
|
||
#import "chrome/browser/ui/cocoa/autofill/autofill_details_container.h" | ||
|
||
#include "chrome/browser/ui/autofill/autofill_dialog_controller.h" | ||
#import "chrome/browser/ui/cocoa/autofill/autofill_section_container.h" | ||
|
||
@implementation AutofillDetailsContainer | ||
|
||
- (id)initWithController:(autofill::AutofillDialogController*)controller { | ||
if (self = [super init]) { | ||
controller_ = controller; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)addSection:(autofill::DialogSection)section { | ||
scoped_nsobject<AutofillSectionContainer> sectionContainer( | ||
[[AutofillSectionContainer alloc] initWithController:controller_ | ||
forSection:section]); | ||
[details_ addObject:sectionContainer]; | ||
} | ||
|
||
- (void)loadView { | ||
details_.reset([[NSMutableArray alloc] init]); | ||
|
||
[self addSection:autofill::SECTION_EMAIL]; | ||
[self addSection:autofill::SECTION_CC]; | ||
[self addSection:autofill::SECTION_BILLING]; | ||
// TODO(groby): Add SECTION_CC_BILLING once toggling is enabled. | ||
[self addSection:autofill::SECTION_SHIPPING]; | ||
|
||
[self setView:[[NSView alloc] init]]; | ||
|
||
NSRect rect = NSZeroRect; | ||
for(AutofillSectionContainer* container in | ||
[details_ reverseObjectEnumerator]) { | ||
[[container view] setFrameOrigin:NSMakePoint(0, NSMaxY(rect))]; | ||
rect = NSUnionRect(rect, [[container view] frame]); | ||
[[self view] addSubview:[container view]]; | ||
} | ||
[[self view] setFrame:rect]; | ||
} | ||
|
||
@end |
36 changes: 36 additions & 0 deletions
36
chrome/browser/ui/cocoa/autofill/autofill_details_container_unittest.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (c) 2013 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. | ||
|
||
#import "chrome/browser/ui/cocoa/autofill/autofill_details_container.h" | ||
|
||
#include "base/memory/scoped_nsobject.h" | ||
#include "chrome/browser/ui/autofill/mock_autofill_dialog_controller.h" | ||
#include "testing/gtest/include/gtest/gtest.h" | ||
#include "testing/platform_test.h" | ||
#import "ui/base/test/ui_cocoa_test_helper.h" | ||
|
||
namespace { | ||
|
||
class AutofillDetailsContainerTest : public ui::CocoaTest { | ||
public: | ||
AutofillDetailsContainerTest() { | ||
container_.reset([[AutofillDetailsContainer alloc] initWithController: | ||
&controller_]); | ||
[[test_window() contentView] addSubview:[container_ view]]; | ||
} | ||
|
||
protected: | ||
scoped_nsobject<AutofillDetailsContainer> container_; | ||
testing::NiceMock<autofill::MockAutofillDialogController> controller_; | ||
}; | ||
|
||
} // namespace | ||
|
||
TEST_VIEW(AutofillDetailsContainerTest, [container_ view]) | ||
|
||
TEST_F(AutofillDetailsContainerTest, BasicProperties) { | ||
EXPECT_GT([[[container_ view] subviews] count], 0U); | ||
EXPECT_GT(NSHeight([[container_ view] frame]), 0); | ||
EXPECT_GT(NSWidth([[container_ view] frame]), 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
chrome/browser/ui/cocoa/autofill/autofill_section_container.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (c) 2013 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. | ||
|
||
#ifndef CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_SECTION_CONTAINER_H_ | ||
#define CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_SECTION_CONTAINER_H_ | ||
|
||
#import <Cocoa/Cocoa.h> | ||
|
||
#include "base/memory/scoped_nsobject.h" | ||
#include "chrome/browser/ui/autofill/autofill_dialog_types.h" | ||
|
||
namespace autofill { | ||
class AutofillDialogController; | ||
} | ||
|
||
@interface AutofillSectionContainer : NSViewController { | ||
@private | ||
autofill::DialogSection section_; | ||
autofill::AutofillDialogController* controller_; // Not owned. | ||
} | ||
|
||
@property(readonly, nonatomic) autofill::DialogSection section; | ||
|
||
- (id)initWithController:(autofill::AutofillDialogController*)controller | ||
forSection:(autofill::DialogSection)section; | ||
|
||
@end | ||
|
||
#endif // CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_SECTION_CONTAINER_H_ |
Oops, something went wrong.