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/autofill/autofill_dialog_controller_impl.h" | 5 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 #include "content/public/browser/notification_service.h" | 60 #include "content/public/browser/notification_service.h" |
61 #include "content/public/browser/notification_types.h" | 61 #include "content/public/browser/notification_types.h" |
62 #include "content/public/browser/web_contents.h" | 62 #include "content/public/browser/web_contents.h" |
63 #include "content/public/browser/web_contents_view.h" | 63 #include "content/public/browser/web_contents_view.h" |
64 #include "content/public/common/url_constants.h" | 64 #include "content/public/common/url_constants.h" |
65 #include "grit/chromium_strings.h" | 65 #include "grit/chromium_strings.h" |
66 #include "grit/component_strings.h" | 66 #include "grit/component_strings.h" |
67 #include "grit/generated_resources.h" | 67 #include "grit/generated_resources.h" |
68 #include "grit/theme_resources.h" | 68 #include "grit/theme_resources.h" |
69 #include "grit/webkit_resources.h" | 69 #include "grit/webkit_resources.h" |
| 70 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
70 #include "net/cert/cert_status_flags.h" | 71 #include "net/cert/cert_status_flags.h" |
71 #include "ui/base/base_window.h" | 72 #include "ui/base/base_window.h" |
72 #include "ui/base/l10n/l10n_util.h" | 73 #include "ui/base/l10n/l10n_util.h" |
73 #include "ui/base/models/combobox_model.h" | 74 #include "ui/base/models/combobox_model.h" |
74 #include "ui/base/resource/resource_bundle.h" | 75 #include "ui/base/resource/resource_bundle.h" |
75 #include "ui/gfx/canvas.h" | 76 #include "ui/gfx/canvas.h" |
76 #include "ui/gfx/color_utils.h" | 77 #include "ui/gfx/color_utils.h" |
77 #include "ui/gfx/skbitmap_operations.h" | 78 #include "ui/gfx/skbitmap_operations.h" |
78 | 79 |
79 namespace autofill { | 80 namespace autofill { |
(...skipping 1929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2009 should_show_wallet_promo_ = false; | 2010 should_show_wallet_promo_ = false; |
2010 account_chooser_model_.SelectActiveWalletAccount(); | 2011 account_chooser_model_.SelectActiveWalletAccount(); |
2011 signin_helper_.reset(new wallet::WalletSigninHelper( | 2012 signin_helper_.reset(new wallet::WalletSigninHelper( |
2012 this, profile_->GetRequestContext())); | 2013 this, profile_->GetRequestContext())); |
2013 signin_helper_->StartWalletCookieValueFetch(); | 2014 signin_helper_->StartWalletCookieValueFetch(); |
2014 HideSignIn(); | 2015 HideSignIn(); |
2015 } | 2016 } |
2016 } | 2017 } |
2017 | 2018 |
2018 //////////////////////////////////////////////////////////////////////////////// | 2019 //////////////////////////////////////////////////////////////////////////////// |
| 2020 // content::WebContentsObserver implementation. |
| 2021 |
| 2022 void AutofillDialogControllerImpl::DidNavigateMainFrame( |
| 2023 const content::LoadCommittedDetails& details, |
| 2024 const content::FrameNavigateParams& params) { |
| 2025 // Close view if necessary. |
| 2026 if (!net::registry_controlled_domains::SameDomainOrHost( |
| 2027 details.previous_url, details.entry->GetURL(), |
| 2028 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES)) { |
| 2029 Hide(); |
| 2030 } |
| 2031 } |
| 2032 |
| 2033 //////////////////////////////////////////////////////////////////////////////// |
2019 // SuggestionsMenuModelDelegate implementation. | 2034 // SuggestionsMenuModelDelegate implementation. |
2020 | 2035 |
2021 void AutofillDialogControllerImpl::SuggestionItemSelected( | 2036 void AutofillDialogControllerImpl::SuggestionItemSelected( |
2022 SuggestionsMenuModel* model, | 2037 SuggestionsMenuModel* model, |
2023 size_t index) { | 2038 size_t index) { |
2024 if (model->GetItemKeyAt(index) == kManageItemsKey) { | 2039 if (model->GetItemKeyAt(index) == kManageItemsKey) { |
2025 GURL url; | 2040 GURL url; |
2026 if (!IsPayingWithWallet()) { | 2041 if (!IsPayingWithWallet()) { |
2027 GURL settings_url(chrome::kChromeUISettingsURL); | 2042 GURL settings_url(chrome::kChromeUISettingsURL); |
2028 url = settings_url.Resolve(chrome::kAutofillSubPage); | 2043 url = settings_url.Resolve(chrome::kAutofillSubPage); |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2278 return source_url_.SchemeIs(chrome::kHttpsScheme); | 2293 return source_url_.SchemeIs(chrome::kHttpsScheme); |
2279 } | 2294 } |
2280 | 2295 |
2281 AutofillDialogControllerImpl::AutofillDialogControllerImpl( | 2296 AutofillDialogControllerImpl::AutofillDialogControllerImpl( |
2282 content::WebContents* contents, | 2297 content::WebContents* contents, |
2283 const FormData& form_structure, | 2298 const FormData& form_structure, |
2284 const GURL& source_url, | 2299 const GURL& source_url, |
2285 const DialogType dialog_type, | 2300 const DialogType dialog_type, |
2286 const base::Callback<void(const FormStructure*, | 2301 const base::Callback<void(const FormStructure*, |
2287 const std::string&)>& callback) | 2302 const std::string&)>& callback) |
2288 : profile_(Profile::FromBrowserContext(contents->GetBrowserContext())), | 2303 : WebContentsObserver(contents), |
| 2304 profile_(Profile::FromBrowserContext(contents->GetBrowserContext())), |
2289 contents_(contents), | 2305 contents_(contents), |
2290 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN), | 2306 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN), |
2291 dialog_type_(dialog_type), | 2307 dialog_type_(dialog_type), |
2292 form_structure_(form_structure, std::string()), | 2308 form_structure_(form_structure, std::string()), |
2293 invoked_from_same_origin_(true), | 2309 invoked_from_same_origin_(true), |
2294 source_url_(source_url), | 2310 source_url_(source_url), |
2295 callback_(callback), | 2311 callback_(callback), |
2296 account_chooser_model_(this, profile_->GetPrefs(), metric_logger_, | 2312 account_chooser_model_(this, profile_->GetPrefs(), metric_logger_, |
2297 dialog_type), | 2313 dialog_type), |
2298 wallet_client_(profile_->GetRequestContext(), this), | 2314 wallet_client_(profile_->GetRequestContext(), this), |
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3408 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL; | 3424 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL; |
3409 } | 3425 } |
3410 | 3426 |
3411 // Has Wallet items. | 3427 // Has Wallet items. |
3412 return has_autofill_profiles ? | 3428 return has_autofill_profiles ? |
3413 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : | 3429 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : |
3414 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; | 3430 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; |
3415 } | 3431 } |
3416 | 3432 |
3417 } // namespace autofill | 3433 } // namespace autofill |
OLD | NEW |