OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/autofill/password_generation_popup_controller_impl.h
" | 5 #include "chrome/browser/ui/autofill/password_generation_popup_controller_impl.h
" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 | 8 |
9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversion_utils.h" | 12 #include "base/strings/utf_string_conversion_utils.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/ui/autofill/password_generation_popup_observer.h" | 15 #include "chrome/browser/ui/autofill/password_generation_popup_observer.h" |
15 #include "chrome/browser/ui/autofill/password_generation_popup_view.h" | 16 #include "chrome/browser/ui/autofill/password_generation_popup_view.h" |
16 #include "chrome/browser/ui/autofill/popup_constants.h" | 17 #include "chrome/browser/ui/autofill/popup_constants.h" |
17 #include "chrome/browser/ui/browser_finder.h" | 18 #include "chrome/browser/ui/browser_finder.h" |
18 #include "chrome/browser/ui/chrome_pages.h" | 19 #include "chrome/browser/ui/chrome_pages.h" |
| 20 #include "chrome/browser/ui/passwords/password_bubble_experiment.h" |
19 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
20 #include "chrome/grit/chromium_strings.h" | 22 #include "chrome/grit/chromium_strings.h" |
21 #include "chrome/grit/generated_resources.h" | 23 #include "chrome/grit/generated_resources.h" |
22 #include "components/autofill/content/common/autofill_messages.h" | 24 #include "components/autofill/content/common/autofill_messages.h" |
23 #include "components/autofill/core/browser/password_generator.h" | 25 #include "components/autofill/core/browser/password_generator.h" |
24 #include "components/password_manager/core/browser/password_manager.h" | 26 #include "components/password_manager/core/browser/password_manager.h" |
25 #include "content/public/browser/native_web_keyboard_event.h" | 27 #include "content/public/browser/native_web_keyboard_event.h" |
26 #include "content/public/browser/render_view_host.h" | 28 #include "content/public/browser/render_view_host.h" |
27 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
28 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 observer_(observer), | 82 observer_(observer), |
81 generator_(new PasswordGenerator(max_length)), | 83 generator_(new PasswordGenerator(max_length)), |
82 controller_common_(bounds, container_view, web_contents), | 84 controller_common_(bounds, container_view, web_contents), |
83 password_selected_(false), | 85 password_selected_(false), |
84 display_password_(false), | 86 display_password_(false), |
85 weak_ptr_factory_(this) { | 87 weak_ptr_factory_(this) { |
86 controller_common_.SetKeyPressCallback( | 88 controller_common_.SetKeyPressCallback( |
87 base::Bind(&PasswordGenerationPopupControllerImpl::HandleKeyPressEvent, | 89 base::Bind(&PasswordGenerationPopupControllerImpl::HandleKeyPressEvent, |
88 base::Unretained(this))); | 90 base::Unretained(this))); |
89 | 91 |
90 std::vector<base::string16> pieces; | 92 int link_id = IDS_MANAGE_PASSWORDS_LINK; |
91 base::SplitStringDontTrim( | 93 int help_text_id = IDS_PASSWORD_GENERATION_PROMPT; |
92 l10n_util::GetStringUTF16(IDS_PASSWORD_GENERATION_PROMPT), | 94 if (password_bubble_experiment::IsSmartLockBrandingEnabled( |
93 '|', // separator | 95 Profile::FromBrowserContext(web_contents->GetBrowserContext()))) { |
94 &pieces); | 96 help_text_id = IDS_PASSWORD_GENERATION_SMART_LOCK_PROMPT; |
95 DCHECK_EQ(3u, pieces.size()); | 97 link_id = IDS_PASSWORD_MANAGER_SMART_LOCK_FOR_PASSWORDS; |
96 link_range_ = gfx::Range(pieces[0].size(), | 98 } |
97 pieces[0].size() + pieces[1].size()); | 99 |
98 help_text_ = JoinString(pieces, base::string16()); | 100 base::string16 link = l10n_util::GetStringUTF16(link_id); |
| 101 size_t offset; |
| 102 help_text_ = l10n_util::GetStringFUTF16(help_text_id, link, &offset); |
| 103 link_range_ = gfx::Range(offset, offset + link.length()); |
99 } | 104 } |
100 | 105 |
101 PasswordGenerationPopupControllerImpl::~PasswordGenerationPopupControllerImpl() | 106 PasswordGenerationPopupControllerImpl::~PasswordGenerationPopupControllerImpl() |
102 {} | 107 {} |
103 | 108 |
104 base::WeakPtr<PasswordGenerationPopupControllerImpl> | 109 base::WeakPtr<PasswordGenerationPopupControllerImpl> |
105 PasswordGenerationPopupControllerImpl::GetWeakPtr() { | 110 PasswordGenerationPopupControllerImpl::GetWeakPtr() { |
106 return weak_ptr_factory_.GetWeakPtr(); | 111 return weak_ptr_factory_.GetWeakPtr(); |
107 } | 112 } |
108 | 113 |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 | 285 |
281 const base::string16& PasswordGenerationPopupControllerImpl::HelpText() { | 286 const base::string16& PasswordGenerationPopupControllerImpl::HelpText() { |
282 return help_text_; | 287 return help_text_; |
283 } | 288 } |
284 | 289 |
285 const gfx::Range& PasswordGenerationPopupControllerImpl::HelpTextLinkRange() { | 290 const gfx::Range& PasswordGenerationPopupControllerImpl::HelpTextLinkRange() { |
286 return link_range_; | 291 return link_range_; |
287 } | 292 } |
288 | 293 |
289 } // namespace autofill | 294 } // namespace autofill |
OLD | NEW |