| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/save_card_bubble_controller_impl.h" | 5 #include "chrome/browser/ui/autofill/save_card_bubble_controller_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "chrome/browser/ui/autofill/save_card_bubble_view.h" | 9 #include "chrome/browser/ui/autofill/save_card_bubble_view.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/browser_finder.h" | 11 #include "chrome/browser/ui/browser_finder.h" |
| 12 #include "chrome/browser/ui/browser_window.h" | 12 #include "chrome/browser/ui/browser_window.h" |
| 13 #include "chrome/browser/ui/location_bar/location_bar.h" | 13 #include "chrome/browser/ui/location_bar/location_bar.h" |
| 14 #include "components/autofill/core/browser/autofill_metrics.h" | 14 #include "components/autofill/core/browser/autofill_metrics.h" |
| 15 #include "components/autofill/core/common/autofill_constants.h" | 15 #include "components/autofill/core/common/autofill_constants.h" |
| 16 #include "components/strings/grit/components_strings.h" | 16 #include "components/strings/grit/components_strings.h" |
| 17 #include "content/public/browser/navigation_details.h" | 17 #include "content/public/browser/navigation_handle.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 19 | 19 |
| 20 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::SaveCardBubbleControllerImpl); | 20 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::SaveCardBubbleControllerImpl); |
| 21 | 21 |
| 22 namespace autofill { | 22 namespace autofill { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 // Number of seconds the bubble and icon will survive navigations, starting | 26 // Number of seconds the bubble and icon will survive navigations, starting |
| 27 // from when the bubble is shown. | 27 // from when the bubble is shown. |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 156 |
| 157 const LegalMessageLines& SaveCardBubbleControllerImpl::GetLegalMessageLines() | 157 const LegalMessageLines& SaveCardBubbleControllerImpl::GetLegalMessageLines() |
| 158 const { | 158 const { |
| 159 return legal_message_lines_; | 159 return legal_message_lines_; |
| 160 } | 160 } |
| 161 | 161 |
| 162 base::TimeDelta SaveCardBubbleControllerImpl::Elapsed() const { | 162 base::TimeDelta SaveCardBubbleControllerImpl::Elapsed() const { |
| 163 return timer_->Elapsed(); | 163 return timer_->Elapsed(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 void SaveCardBubbleControllerImpl::DidNavigateMainFrame( | 166 void SaveCardBubbleControllerImpl::DidFinishNavigation( |
| 167 const content::LoadCommittedDetails& details, | 167 content::NavigationHandle* navigation_handle) { |
| 168 const content::FrameNavigateParams& params) { | 168 if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted()) |
| 169 return; |
| 170 |
| 169 // Nothing to do if there's no bubble available. | 171 // Nothing to do if there's no bubble available. |
| 170 if (save_card_callback_.is_null()) | 172 if (save_card_callback_.is_null()) |
| 171 return; | 173 return; |
| 172 | 174 |
| 173 // Don't react to in-page (fragment) navigations. | 175 // Don't react to in-page (fragment) navigations. |
| 174 if (details.is_in_page) | 176 if (navigation_handle->IsSamePage()) |
| 175 return; | 177 return; |
| 176 | 178 |
| 177 // Don't do anything if a navigation occurs before a user could reasonably | 179 // Don't do anything if a navigation occurs before a user could reasonably |
| 178 // interact with the bubble. | 180 // interact with the bubble. |
| 179 if (Elapsed() < base::TimeDelta::FromSeconds(kSurviveNavigationSeconds)) | 181 if (Elapsed() < base::TimeDelta::FromSeconds(kSurviveNavigationSeconds)) |
| 180 return; | 182 return; |
| 181 | 183 |
| 182 // Otherwise, get rid of the bubble and icon. | 184 // Otherwise, get rid of the bubble and icon. |
| 183 save_card_callback_.Reset(); | 185 save_card_callback_.Reset(); |
| 184 if (save_card_bubble_view_) { | 186 if (save_card_bubble_view_) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 location_bar->UpdateSaveCreditCardIcon(); | 228 location_bar->UpdateSaveCreditCardIcon(); |
| 227 } | 229 } |
| 228 | 230 |
| 229 void SaveCardBubbleControllerImpl::OpenUrl(const GURL& url) { | 231 void SaveCardBubbleControllerImpl::OpenUrl(const GURL& url) { |
| 230 web_contents()->OpenURL(content::OpenURLParams( | 232 web_contents()->OpenURL(content::OpenURLParams( |
| 231 url, content::Referrer(), WindowOpenDisposition::NEW_FOREGROUND_TAB, | 233 url, content::Referrer(), WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 232 ui::PAGE_TRANSITION_LINK, false)); | 234 ui::PAGE_TRANSITION_LINK, false)); |
| 233 } | 235 } |
| 234 | 236 |
| 235 } // namespace autofill | 237 } // namespace autofill |
| OLD | NEW |