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 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
11 #include "base/strings/string_split.h" | 11 #include "base/strings/string_split.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/strings/utf_string_conversion_utils.h" | 13 #include "base/strings/utf_string_conversion_utils.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/sync/profile_sync_service_factory.h" |
15 #include "chrome/browser/ui/autofill/password_generation_popup_observer.h" | 17 #include "chrome/browser/ui/autofill/password_generation_popup_observer.h" |
16 #include "chrome/browser/ui/autofill/password_generation_popup_view.h" | 18 #include "chrome/browser/ui/autofill/password_generation_popup_view.h" |
17 #include "chrome/browser/ui/autofill/popup_constants.h" | 19 #include "chrome/browser/ui/autofill/popup_constants.h" |
18 #include "chrome/browser/ui/browser_finder.h" | 20 #include "chrome/browser/ui/browser_finder.h" |
19 #include "chrome/browser/ui/chrome_pages.h" | 21 #include "chrome/browser/ui/chrome_pages.h" |
20 #include "chrome/common/features.h" | 22 #include "chrome/common/features.h" |
21 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
22 #include "chrome/grit/chromium_strings.h" | 24 #include "chrome/grit/chromium_strings.h" |
23 #include "chrome/grit/generated_resources.h" | 25 #include "chrome/grit/generated_resources.h" |
24 #include "components/autofill/core/browser/password_generator.h" | 26 #include "components/autofill/core/browser/password_generator.h" |
25 #include "components/autofill/core/browser/suggestion.h" | 27 #include "components/autofill/core/browser/suggestion.h" |
| 28 #include "components/browser_sync/profile_sync_service.h" |
26 #include "components/password_manager/core/browser/password_bubble_experiment.h" | 29 #include "components/password_manager/core/browser/password_bubble_experiment.h" |
27 #include "components/password_manager/core/browser/password_manager.h" | 30 #include "components/password_manager/core/browser/password_manager.h" |
28 #include "content/public/browser/native_web_keyboard_event.h" | 31 #include "content/public/browser/native_web_keyboard_event.h" |
29 #include "content/public/browser/render_view_host.h" | 32 #include "content/public/browser/render_view_host.h" |
30 #include "content/public/browser/web_contents.h" | 33 #include "content/public/browser/web_contents.h" |
31 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
32 #include "ui/events/keycodes/keyboard_codes.h" | 35 #include "ui/events/keycodes/keyboard_codes.h" |
33 #include "ui/gfx/geometry/rect_conversions.h" | 36 #include "ui/gfx/geometry/rect_conversions.h" |
34 #include "ui/gfx/text_utils.h" | 37 #include "ui/gfx/text_utils.h" |
35 | 38 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 base::i18n::LEFT_TO_RIGHT, | 90 base::i18n::LEFT_TO_RIGHT, |
88 container_view, | 91 container_view, |
89 web_contents), | 92 web_contents), |
90 password_selected_(false), | 93 password_selected_(false), |
91 display_password_(false), | 94 display_password_(false), |
92 weak_ptr_factory_(this) { | 95 weak_ptr_factory_(this) { |
93 controller_common_.SetKeyPressCallback( | 96 controller_common_.SetKeyPressCallback( |
94 base::Bind(&PasswordGenerationPopupControllerImpl::HandleKeyPressEvent, | 97 base::Bind(&PasswordGenerationPopupControllerImpl::HandleKeyPressEvent, |
95 base::Unretained(this))); | 98 base::Unretained(this))); |
96 | 99 |
97 base::string16 link = l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_LINK); | 100 int link_id = IDS_MANAGE_PASSWORDS_LINK; |
98 size_t offset = 0; | 101 int help_text_id = IDS_PASSWORD_GENERATION_PROMPT; |
99 help_text_ = | 102 const browser_sync::ProfileSyncService* sync_service = |
100 l10n_util::GetStringFUTF16(IDS_PASSWORD_GENERATION_PROMPT, link, &offset); | 103 ProfileSyncServiceFactory::GetForProfile( |
| 104 Profile::FromBrowserContext(web_contents->GetBrowserContext())); |
| 105 if (password_bubble_experiment::IsSmartLockBrandingEnabled(sync_service)) { |
| 106 help_text_id = IDS_PASSWORD_GENERATION_SMART_LOCK_PROMPT; |
| 107 link_id = IDS_PASSWORD_MANAGER_SMART_LOCK_FOR_PASSWORDS; |
| 108 } |
| 109 |
| 110 base::string16 link = l10n_util::GetStringUTF16(link_id); |
| 111 size_t offset; |
| 112 help_text_ = l10n_util::GetStringFUTF16(help_text_id, link, &offset); |
101 link_range_ = gfx::Range(offset, offset + link.length()); | 113 link_range_ = gfx::Range(offset, offset + link.length()); |
102 } | 114 } |
103 | 115 |
104 PasswordGenerationPopupControllerImpl::~PasswordGenerationPopupControllerImpl() | 116 PasswordGenerationPopupControllerImpl::~PasswordGenerationPopupControllerImpl() |
105 {} | 117 {} |
106 | 118 |
107 base::WeakPtr<PasswordGenerationPopupControllerImpl> | 119 base::WeakPtr<PasswordGenerationPopupControllerImpl> |
108 PasswordGenerationPopupControllerImpl::GetWeakPtr() { | 120 PasswordGenerationPopupControllerImpl::GetWeakPtr() { |
109 return weak_ptr_factory_.GetWeakPtr(); | 121 return weak_ptr_factory_.GetWeakPtr(); |
110 } | 122 } |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 | 313 |
302 const base::string16& PasswordGenerationPopupControllerImpl::HelpText() { | 314 const base::string16& PasswordGenerationPopupControllerImpl::HelpText() { |
303 return help_text_; | 315 return help_text_; |
304 } | 316 } |
305 | 317 |
306 const gfx::Range& PasswordGenerationPopupControllerImpl::HelpTextLinkRange() { | 318 const gfx::Range& PasswordGenerationPopupControllerImpl::HelpTextLinkRange() { |
307 return link_range_; | 319 return link_range_; |
308 } | 320 } |
309 | 321 |
310 } // namespace autofill | 322 } // namespace autofill |
OLD | NEW |