Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(278)

Side by Side Diff: chrome/browser/ui/autofill/save_card_bubble_controller_impl.h

Issue 1407093007: Autofill: Add legal message footer to save credit card bubble. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit tests. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef CHROME_BROWSER_UI_AUTOFILL_SAVE_CARD_BUBBLE_CONTROLLER_IMPL_H_ 5 #ifndef CHROME_BROWSER_UI_AUTOFILL_SAVE_CARD_BUBBLE_CONTROLLER_IMPL_H_
6 #define CHROME_BROWSER_UI_AUTOFILL_SAVE_CARD_BUBBLE_CONTROLLER_IMPL_H_ 6 #define CHROME_BROWSER_UI_AUTOFILL_SAVE_CARD_BUBBLE_CONTROLLER_IMPL_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/timer/elapsed_timer.h" 10 #include "base/timer/elapsed_timer.h"
11 #include "chrome/browser/ui/autofill/save_card_bubble_controller.h" 11 #include "chrome/browser/ui/autofill/save_card_bubble_controller.h"
12 #include "content/public/browser/web_contents_observer.h" 12 #include "content/public/browser/web_contents_observer.h"
13 #include "content/public/browser/web_contents_user_data.h" 13 #include "content/public/browser/web_contents_user_data.h"
14 14
15 namespace autofill { 15 namespace autofill {
16 16
17 // Implementation of per-tab class to control the save credit card bubble and 17 // Implementation of per-tab class to control the save credit card bubble and
18 // Omnibox icon. 18 // Omnibox icon.
19 // 19 //
20 // TODO(bondd): Add text strings so different dialog contents can be shown 20 // TODO(bondd): Add text strings so different dialog contents can be shown
21 // depending upon whether upstreaming is available. 21 // depending upon whether upstreaming is available.
22 class SaveCardBubbleControllerImpl 22 class SaveCardBubbleControllerImpl
23 : public SaveCardBubbleController, 23 : public SaveCardBubbleController,
24 public content::WebContentsObserver, 24 public content::WebContentsObserver,
25 public content::WebContentsUserData<SaveCardBubbleControllerImpl> { 25 public content::WebContentsUserData<SaveCardBubbleControllerImpl> {
26 public: 26 public:
27 // |save_card_callback| will be invoked if/when the Save button is pressed. 27 // |save_card_callback| will be invoked if/when the Save button is pressed.
28 void SetCallback(const base::Closure& save_card_callback); 28 void SetCallback(const base::Closure& save_card_callback);
29 29
30 // Example of valid |lines| data:
31 // [ {
32 // "template" : "The legal documents are: {0} and {1}",
33 // "template_parameter" : [ {
34 // "display_text" : "Terms of Service",
35 // "url": "http://www.example.com/tos"
36 // }, {
37 // "display_text" : "Privacy Policy",
38 // "url": "http://www.example.com/pp"
39 // } ],
40 // }, {
41 // "template" : "This is the second line and it has no parameters"
42 // } ]
43 //
44 // Caveats:
45 // 1. '{' and '}' may be displayed by escaping them with an apostrophe in the
46 // template string, e.g. "template" : "Here is a literal '{'"
47 // 2. Two or more consecutive dollar signs in the template string will not
48 // expand correctly.
49 // 3. "${" anywhere in the template string is invalid.
50 // 4. "\n" embedded anywhere in the template string, or an empty template
51 // string, can be used to separate paragraphs. It is not possible to create
52 // a completely blank line by using two consecutive newlines (they will be
53 // treated as a single newline by views::StyledLabel).
54 //
55 // Returns false if contents of |lines| are invalid.
56 bool SetLegalMessage(const base::ListValue& lines);
57 void ClearLegalMessage();
58
30 // SetCallback() must be called first. 59 // SetCallback() must be called first.
31 void ShowBubble(bool user_action); 60 void ShowBubble(bool user_action);
32 61
33 // Returns true if Omnibox save credit card icon should be visible. 62 // Returns true if Omnibox save credit card icon should be visible.
34 bool IsIconVisible() const; 63 bool IsIconVisible() const;
35 64
36 // Returns nullptr if no bubble is currently shown. 65 // Returns nullptr if no bubble is currently shown.
37 SaveCardBubbleView* save_card_bubble_view() const; 66 SaveCardBubbleView* save_card_bubble_view() const;
38 67
39 // SaveCardBubbleController: 68 // SaveCardBubbleController:
40 void OnSaveButton() override; 69 void OnSaveButton() override;
41 void OnCancelButton() override; 70 void OnCancelButton() override;
42 void OnLearnMoreClicked() override; 71 void OnLearnMoreClicked() override;
72 void OnLegalMessageLinkClicked(const GURL& url) override;
43 void OnBubbleClosed() override; 73 void OnBubbleClosed() override;
44 74
75 const std::vector<LegalMessageLine>& GetLegalMessageLines() const override;
76
45 private: 77 private:
46 friend class content::WebContentsUserData<SaveCardBubbleControllerImpl>; 78 friend class content::WebContentsUserData<SaveCardBubbleControllerImpl>;
47 79
48 explicit SaveCardBubbleControllerImpl(content::WebContents* web_contents); 80 explicit SaveCardBubbleControllerImpl(content::WebContents* web_contents);
49 ~SaveCardBubbleControllerImpl() override; 81 ~SaveCardBubbleControllerImpl() override;
50 82
51 // Update the visibility and toggled state of the Omnibox save card icon. 83 // Update the visibility and toggled state of the Omnibox save card icon.
52 void UpdateIcon(); 84 void UpdateIcon();
53 85
86 void OpenUrl(const GURL& url);
87
54 // content::WebContentsObserver: 88 // content::WebContentsObserver:
55 void DidNavigateMainFrame( 89 void DidNavigateMainFrame(
56 const content::LoadCommittedDetails& details, 90 const content::LoadCommittedDetails& details,
57 const content::FrameNavigateParams& params) override; 91 const content::FrameNavigateParams& params) override;
58 92
59 // Weak reference. Will be nullptr if no bubble is currently shown. 93 // Weak reference. Will be nullptr if no bubble is currently shown.
60 SaveCardBubbleView* save_card_bubble_view_; 94 SaveCardBubbleView* save_card_bubble_view_;
61 95
62 // Callback to run if user presses Save button in the bubble. 96 // Callback to run if user presses Save button in the bubble.
63 // If save_card_callback_.is_null() is true then no bubble is available to 97 // If save_card_callback_.is_null() is true then no bubble is available to
64 // show and the icon is not visible. 98 // show and the icon is not visible.
65 base::Closure save_card_callback_; 99 base::Closure save_card_callback_;
66 100
101 // If no legal message should be shown then this variable is an empty vector.
102 std::vector<LegalMessageLine> legal_message_lines_;
103
67 // Used to measure the amount of time on a page; if it's less than some 104 // Used to measure the amount of time on a page; if it's less than some
68 // reasonable limit, then don't close the bubble upon navigation. 105 // reasonable limit, then don't close the bubble upon navigation.
69 scoped_ptr<base::ElapsedTimer> timer_; 106 scoped_ptr<base::ElapsedTimer> timer_;
70 107
71 DISALLOW_COPY_AND_ASSIGN(SaveCardBubbleControllerImpl); 108 DISALLOW_COPY_AND_ASSIGN(SaveCardBubbleControllerImpl);
72 }; 109 };
73 110
74 } // namespace autofill 111 } // namespace autofill
75 112
76 #endif // CHROME_BROWSER_UI_AUTOFILL_SAVE_CARD_BUBBLE_CONTROLLER_IMPL_H_ 113 #endif // CHROME_BROWSER_UI_AUTOFILL_SAVE_CARD_BUBBLE_CONTROLLER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698