| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/webui/options/password_manager_handler.h" | 5 #include "chrome/browser/ui/webui/options/password_manager_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/feature_list.h" | 8 #include "base/feature_list.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 #if defined(OS_WIN) && defined(USE_ASH) | 39 #if defined(OS_WIN) && defined(USE_ASH) |
| 40 #include "chrome/browser/ui/ash/ash_util.h" | 40 #include "chrome/browser/ui/ash/ash_util.h" |
| 41 #endif | 41 #endif |
| 42 | 42 |
| 43 namespace options { | 43 namespace options { |
| 44 | 44 |
| 45 namespace { | 45 namespace { |
| 46 // The following constants should be synchronized with the constants in | 46 // The following constants should be synchronized with the constants in |
| 47 // chrome/browser/resources/options/password_manager_list.js. | 47 // chrome/browser/resources/options/password_manager_list.js. |
| 48 const char kOriginField[] = "origin"; | 48 const char kUrlField[] = "url"; |
| 49 const char kShownUrlField[] = "shownUrl"; | 49 const char kShownOriginField[] = "shownOrigin"; |
| 50 const char kIsAndroidUriField[] = "isAndroidUri"; | 50 const char kIsAndroidUriField[] = "isAndroidUri"; |
| 51 const char kIsClickable[] = "isClickable"; |
| 51 const char kIsSecureField[] = "isSecure"; | 52 const char kIsSecureField[] = "isSecure"; |
| 52 const char kUsernameField[] = "username"; | 53 const char kUsernameField[] = "username"; |
| 53 const char kPasswordField[] = "password"; | 54 const char kPasswordField[] = "password"; |
| 54 const char kFederationField[] = "federation"; | 55 const char kFederationField[] = "federation"; |
| 55 | 56 |
| 56 // Copies from |form| to |entry| the origin, shown origin, whether the origin is | 57 // Copies from |form| to |entry| the origin, shown origin, whether the origin is |
| 57 // Android URI, and whether the origin is secure. | 58 // Android URI, and whether the origin is secure. |
| 58 void CopyOriginInfoOfPasswordForm(const autofill::PasswordForm& form, | 59 void CopyOriginInfoOfPasswordForm(const autofill::PasswordForm& form, |
| 59 const std::string& languages, | 60 const std::string& languages, |
| 60 base::DictionaryValue* entry) { | 61 base::DictionaryValue* entry) { |
| 62 bool is_android_uri = false; |
| 63 bool origin_is_clickable = false; |
| 64 GURL link_url; |
| 61 entry->SetString( | 65 entry->SetString( |
| 62 kOriginField, | 66 kShownOriginField, |
| 63 url_formatter::FormatUrl( | 67 password_manager::GetShownOriginAndLinkUrl( |
| 64 form.origin, languages, url_formatter::kFormatUrlOmitNothing, | 68 form, languages, &is_android_uri, &link_url, &origin_is_clickable)); |
| 65 net::UnescapeRule::SPACES, nullptr, nullptr, nullptr)); | 69 DCHECK(link_url.is_valid()); |
| 66 bool is_android_uri = false; | 70 entry->SetString( |
| 67 entry->SetString(kShownUrlField, password_manager::GetShownOrigin( | 71 kUrlField, url_formatter::FormatUrl( |
| 68 form, languages, &is_android_uri)); | 72 link_url, languages, url_formatter::kFormatUrlOmitNothing, |
| 73 net::UnescapeRule::SPACES, nullptr, nullptr, nullptr)); |
| 69 entry->SetBoolean(kIsAndroidUriField, is_android_uri); | 74 entry->SetBoolean(kIsAndroidUriField, is_android_uri); |
| 70 entry->SetBoolean(kIsSecureField, content::IsOriginSecure(form.origin)); | 75 entry->SetBoolean(kIsClickable, origin_is_clickable); |
| 76 entry->SetBoolean(kIsSecureField, content::IsOriginSecure(link_url)); |
| 71 } | 77 } |
| 72 | 78 |
| 73 } // namespace | 79 } // namespace |
| 74 | 80 |
| 75 PasswordManagerHandler::PasswordManagerHandler() | 81 PasswordManagerHandler::PasswordManagerHandler() |
| 76 : password_manager_presenter_(this) {} | 82 : password_manager_presenter_(this) {} |
| 77 | 83 |
| 78 PasswordManagerHandler::~PasswordManagerHandler() {} | 84 PasswordManagerHandler::~PasswordManagerHandler() {} |
| 79 | 85 |
| 80 Profile* PasswordManagerHandler::GetProfile() { | 86 Profile* PasswordManagerHandler::GetProfile() { |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue); | 268 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue); |
| 263 CopyOriginInfoOfPasswordForm(*exception, languages_, entry.get()); | 269 CopyOriginInfoOfPasswordForm(*exception, languages_, entry.get()); |
| 264 entries.Append(entry.release()); | 270 entries.Append(entry.release()); |
| 265 } | 271 } |
| 266 | 272 |
| 267 web_ui()->CallJavascriptFunction("PasswordManager.setPasswordExceptionsList", | 273 web_ui()->CallJavascriptFunction("PasswordManager.setPasswordExceptionsList", |
| 268 entries); | 274 entries); |
| 269 } | 275 } |
| 270 | 276 |
| 271 } // namespace options | 277 } // namespace options |
| OLD | NEW |