| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/password_generation_bubble_view.h" | 5 #include "chrome/browser/ui/views/password_generation_bubble_view.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/autofill/password_generator.h" | 8 #include "chrome/browser/autofill/password_generator.h" |
| 9 #include "chrome/browser/password_manager/password_manager.h" | 9 #include "chrome/browser/password_manager/password_manager.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "ui/views/layout/layout_constants.h" | 24 #include "ui/views/layout/layout_constants.h" |
| 25 | 25 |
| 26 using views::ColumnSet; | 26 using views::ColumnSet; |
| 27 using views::GridLayout; | 27 using views::GridLayout; |
| 28 | 28 |
| 29 PasswordGenerationBubbleView::PasswordGenerationBubbleView( | 29 PasswordGenerationBubbleView::PasswordGenerationBubbleView( |
| 30 const gfx::Rect& anchor_rect, | 30 const gfx::Rect& anchor_rect, |
| 31 const webkit::forms::PasswordForm& form, | 31 const webkit::forms::PasswordForm& form, |
| 32 views::View* anchor_view, | 32 views::View* anchor_view, |
| 33 content::RenderViewHost* render_view_host, | 33 content::RenderViewHost* render_view_host, |
| 34 autofill::PasswordGenerator* password_generator, |
| 34 content::PageNavigator* navigator, | 35 content::PageNavigator* navigator, |
| 35 PasswordManager* password_manager) | 36 PasswordManager* password_manager) |
| 36 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), | 37 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), |
| 37 accept_button_(NULL), | 38 accept_button_(NULL), |
| 38 text_field_(NULL), | 39 text_field_(NULL), |
| 39 anchor_rect_(anchor_rect), | 40 anchor_rect_(anchor_rect), |
| 40 form_(form), | 41 form_(form), |
| 41 render_view_host_(render_view_host), | 42 render_view_host_(render_view_host), |
| 43 password_generator_(password_generator), |
| 42 navigator_(navigator), | 44 navigator_(navigator), |
| 43 password_manager_(password_manager) {} | 45 password_manager_(password_manager) {} |
| 44 | 46 |
| 45 PasswordGenerationBubbleView::~PasswordGenerationBubbleView() {} | 47 PasswordGenerationBubbleView::~PasswordGenerationBubbleView() {} |
| 46 | 48 |
| 47 void PasswordGenerationBubbleView::Init() { | 49 void PasswordGenerationBubbleView::Init() { |
| 48 // TODO(gcasto): Localize text after we have finalized the UI. | 50 // TODO(gcasto): Localize text after we have finalized the UI. |
| 49 // crbug.com/118062 | 51 // crbug.com/118062 |
| 50 accept_button_ = new views::NativeTextButton(this, | 52 accept_button_ = new views::NativeTextButton(this, |
| 51 ASCIIToUTF16("Try It")); | 53 ASCIIToUTF16("Try It")); |
| 52 | 54 |
| 53 text_field_ = new views::Textfield(); | 55 text_field_ = new views::Textfield(); |
| 54 text_field_->SetText(ASCIIToUTF16(password_generator_.Generate())); | 56 text_field_->SetText( |
| 57 ASCIIToUTF16(password_generator_->Generate())); |
| 55 | 58 |
| 56 views::Label* title_label = new views::Label( | 59 views::Label* title_label = new views::Label( |
| 57 ASCIIToUTF16("Password Suggestion")); | 60 ASCIIToUTF16("Password Suggestion")); |
| 58 | 61 |
| 59 views::Link* learn_more_link = new views::Link( | 62 views::Link* learn_more_link = new views::Link( |
| 60 l10n_util::GetStringUTF16(IDS_LEARN_MORE)); | 63 l10n_util::GetStringUTF16(IDS_LEARN_MORE)); |
| 61 learn_more_link->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 64 learn_more_link->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 62 learn_more_link->set_listener(this); | 65 learn_more_link->set_listener(this); |
| 63 | 66 |
| 64 GridLayout* layout = new GridLayout(this); | 67 GridLayout* layout = new GridLayout(this); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 content::OpenURLParams params( | 111 content::OpenURLParams params( |
| 109 GURL(chrome::kAutoPasswordGenerationLearnMoreURL), content::Referrer(), | 112 GURL(chrome::kAutoPasswordGenerationLearnMoreURL), content::Referrer(), |
| 110 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false); | 113 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false); |
| 111 navigator_->OpenURL(params); | 114 navigator_->OpenURL(params); |
| 112 StartFade(false); | 115 StartFade(false); |
| 113 } | 116 } |
| 114 | 117 |
| 115 views::View* PasswordGenerationBubbleView::GetInitiallyFocusedView() { | 118 views::View* PasswordGenerationBubbleView::GetInitiallyFocusedView() { |
| 116 return text_field_; | 119 return text_field_; |
| 117 } | 120 } |
| OLD | NEW |