Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #ifndef COMPONENTS_AUTOFILL_BROWSER_AUTOCHECKOUT_MANAGER_H_ | 5 #ifndef COMPONENTS_AUTOFILL_BROWSER_AUTOCHECKOUT_MANAGER_H_ |
| 6 #define COMPONENTS_AUTOFILL_BROWSER_AUTOCHECKOUT_MANAGER_H_ | 6 #define COMPONENTS_AUTOFILL_BROWSER_AUTOCHECKOUT_MANAGER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| 11 #include "base/gtest_prod_util.h" | |
| 11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 13 #include "base/string16.h" | 14 #include "base/string16.h" |
| 14 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
| 15 #include "components/autofill/browser/autocheckout_page_meta_data.h" | 16 #include "components/autofill/browser/autocheckout_page_meta_data.h" |
| 16 #include "components/autofill/common/autocheckout_status.h" | 17 #include "components/autofill/common/autocheckout_status.h" |
| 17 | 18 |
| 18 class GURL; | 19 class GURL; |
| 19 | 20 |
| 20 namespace content { | 21 namespace content { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 // |status| is the reason for the failure. | 55 // |status| is the reason for the failure. |
| 55 void OnClickFailed(AutocheckoutStatus status); | 56 void OnClickFailed(AutocheckoutStatus status); |
| 56 | 57 |
| 57 // Sets |page_meta_data_| with the meta data for the current page. | 58 // Sets |page_meta_data_| with the meta data for the current page. |
| 58 void OnLoadedPageMetaData( | 59 void OnLoadedPageMetaData( |
| 59 scoped_ptr<AutocheckoutPageMetaData> page_meta_data); | 60 scoped_ptr<AutocheckoutPageMetaData> page_meta_data); |
| 60 | 61 |
| 61 // Called when a page containing forms is loaded. | 62 // Called when a page containing forms is loaded. |
| 62 void OnFormsSeen(); | 63 void OnFormsSeen(); |
| 63 | 64 |
| 65 // Whether dynamic form changes on the current page should be ignored during | |
| 66 // an Autocheckout flow. | |
| 67 bool ShouldIgnoreDynamicFormChanges(); | |
| 68 | |
| 64 // Causes the Autocheckout bubble to be displayed if the user hasn't seen it | 69 // Causes the Autocheckout bubble to be displayed if the user hasn't seen it |
| 65 // yet for the current page. |frame_url| is the page where Autocheckout is | 70 // yet for the current page. |frame_url| is the page where Autocheckout is |
| 66 // being initiated. |ssl_status| is the SSL status of the page. |bounding_box| | 71 // being initiated. |ssl_status| is the SSL status of the page. |bounding_box| |
| 67 // is the bounding box of the input field in focus. | 72 // is the bounding box of the input field in focus. |
| 68 virtual void MaybeShowAutocheckoutBubble(const GURL& frame_url, | 73 virtual void MaybeShowAutocheckoutBubble(const GURL& frame_url, |
| 69 const content::SSLStatus& ssl_status, | 74 const content::SSLStatus& ssl_status, |
| 70 const gfx::RectF& bounding_box); | 75 const gfx::RectF& bounding_box); |
| 71 | 76 |
| 72 bool is_autocheckout_bubble_showing() const { | 77 bool is_autocheckout_bubble_showing() const { |
| 73 return is_autocheckout_bubble_showing_; | 78 return is_autocheckout_bubble_showing_; |
| 74 } | 79 } |
| 75 | 80 |
| 76 protected: | 81 protected: |
| 77 // Exposed for testing. | 82 // Exposed for testing. |
| 78 bool in_autocheckout_flow() const { return in_autocheckout_flow_; } | 83 bool in_autocheckout_flow() const { return in_autocheckout_flow_; } |
| 79 | 84 |
| 80 // Exposed for testing. | 85 // Exposed for testing. |
| 81 bool autocheckout_offered() const { return autocheckout_offered_; } | 86 bool autocheckout_offered() const { return autocheckout_offered_; } |
| 82 | 87 |
| 88 // Exposed for testing. | |
| 89 void set_in_autocheckout_flow(bool in_autocheckout_flow) { | |
| 90 in_autocheckout_flow_ = in_autocheckout_flow; | |
|
Ilya Sherman
2013/06/11 01:11:20
nit: Reduce indentation by two spaces.
Dane Wallinga
2013/06/11 19:03:32
Done.
| |
| 91 } | |
| 92 | |
| 83 // Show the requestAutocomplete dialog if |show_dialog| is true. Also, does | 93 // Show the requestAutocomplete dialog if |show_dialog| is true. Also, does |
| 84 // bookkeeping for whether or not the bubble is showing. | 94 // bookkeeping for whether or not the bubble is showing. |
| 85 virtual void MaybeShowAutocheckoutDialog(const GURL& frame_url, | 95 virtual void MaybeShowAutocheckoutDialog(const GURL& frame_url, |
| 86 const content::SSLStatus& ssl_status, | 96 const content::SSLStatus& ssl_status, |
| 87 bool show_dialog); | 97 bool show_dialog); |
| 88 | 98 |
| 89 const AutofillMetrics& metric_logger() const { return *metric_logger_; } | 99 const AutofillMetrics& metric_logger() const { return *metric_logger_; } |
| 90 void set_metric_logger(scoped_ptr<AutofillMetrics> metric_logger); | 100 void set_metric_logger(scoped_ptr<AutofillMetrics> metric_logger); |
| 91 | 101 |
| 92 private: | 102 private: |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 | 155 |
| 146 // Whether or not the user is in an Autocheckout flow. | 156 // Whether or not the user is in an Autocheckout flow. |
| 147 bool in_autocheckout_flow_; | 157 bool in_autocheckout_flow_; |
| 148 | 158 |
| 149 std::string google_transaction_id_; | 159 std::string google_transaction_id_; |
| 150 | 160 |
| 151 base::WeakPtrFactory<AutocheckoutManager> weak_ptr_factory_; | 161 base::WeakPtrFactory<AutocheckoutManager> weak_ptr_factory_; |
| 152 | 162 |
| 153 base::ThreadChecker thread_checker_; | 163 base::ThreadChecker thread_checker_; |
| 154 | 164 |
| 165 friend class AutofillManagerTest; | |
| 166 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, DynamicFormsSeenAndIgnored); | |
|
Ilya Sherman
2013/06/11 01:11:20
Why are these needed? Almost always, you should p
Dane Wallinga
2013/06/11 19:03:32
*shrug* - this is the pattern we appear to be usin
Ilya Sherman
2013/06/11 23:14:32
Alright, let me be clearer: Please do not friend t
Dane Wallinga
2013/06/12 20:33:37
Ok, so AutofillManager has a member AutocheckoutMa
Ilya Sherman
2013/06/15 01:18:19
Looking more closely at the test code, IMO the bes
| |
| 167 | |
| 155 DISALLOW_COPY_AND_ASSIGN(AutocheckoutManager); | 168 DISALLOW_COPY_AND_ASSIGN(AutocheckoutManager); |
| 156 }; | 169 }; |
| 157 | 170 |
| 158 } // namespace autofill | 171 } // namespace autofill |
| 159 | 172 |
| 160 #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOCHECKOUT_MANAGER_H_ | 173 #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOCHECKOUT_MANAGER_H_ |
| OLD | NEW |