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

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: 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"
Evan Stade 2015/11/07 03:03:19 can jstuppy or someone explain why there are multi
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.
bondd 2015/11/07 02:29:38 Can handle "$$" properly if desired by reviewer. N
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(); 60 void ShowBubble();
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 true if Omnibox save credit card should be shown in its "toggled 65 // Returns true if Omnibox save credit card should be shown in its "toggled
37 // on" state. 66 // on" state.
38 bool IsIconToggled() const; 67 bool IsIconToggled() const;
39 68
40 // Returns nullptr if no bubble is currently shown. 69 // Returns nullptr if no bubble is currently shown.
41 SaveCardBubbleView* save_card_bubble_view() const; 70 SaveCardBubbleView* save_card_bubble_view() const;
42 71
43 // SaveCardBubbleController: 72 // SaveCardBubbleController:
44 void OnSaveButton() override; 73 void OnSaveButton() override;
45 void OnCancelButton() override; 74 void OnCancelButton() override;
46 void OnLearnMoreClicked() override; 75 void OnLearnMoreClicked() override;
76 void OnLegalMessageLinkClicked(const gfx::Range& link_range) override;
47 void OnBubbleClosed() override; 77 void OnBubbleClosed() override;
48 78
79 const base::string16& GetLegalMessage() const override;
80 size_t GetLegalMessageNumLinks() const override;
81 const gfx::Range& GetLegalMessageLinkRange(size_t index) const override;
82
49 private: 83 private:
50 friend class content::WebContentsUserData<SaveCardBubbleControllerImpl>; 84 friend class content::WebContentsUserData<SaveCardBubbleControllerImpl>;
51 85
86 // Describes a single link in legal_message_.
87 struct LegalMessageLink {
bondd 2015/11/07 02:29:38 LegalMessageLink instead of Link because the forme
88 gfx::Range range;
89 std::string url;
90 };
91
52 explicit SaveCardBubbleControllerImpl(content::WebContents* web_contents); 92 explicit SaveCardBubbleControllerImpl(content::WebContents* web_contents);
53 ~SaveCardBubbleControllerImpl() override; 93 ~SaveCardBubbleControllerImpl() override;
54 94
55 // Update the visibility and toggled state of the Omnibox save card icon. 95 // Update the visibility and toggled state of the Omnibox save card icon.
56 void UpdateIcon(); 96 void UpdateIcon();
57 97
98 void OpenUrl(const std::string& url);
99
58 // content::WebContentsObserver: 100 // content::WebContentsObserver:
59 void DidNavigateMainFrame( 101 void DidNavigateMainFrame(
60 const content::LoadCommittedDetails& details, 102 const content::LoadCommittedDetails& details,
61 const content::FrameNavigateParams& params) override; 103 const content::FrameNavigateParams& params) override;
62 104
63 // Weak reference. Will be nullptr if no bubble is currently shown. 105 // Weak reference. Will be nullptr if no bubble is currently shown.
64 SaveCardBubbleView* save_card_bubble_view_; 106 SaveCardBubbleView* save_card_bubble_view_;
65 107
66 // Callback to run if user presses Save button in the bubble. 108 // Callback to run if user presses Save button in the bubble.
67 // If save_card_callback_.is_null() is true then no bubble is available to 109 // If save_card_callback_.is_null() is true then no bubble is available to
68 // show and the icon is not visible. 110 // show and the icon is not visible.
69 base::Closure save_card_callback_; 111 base::Closure save_card_callback_;
70 112
113 // If no legal message should be shown then this variable is an empty string.
114 base::string16 legal_message_;
115
116 // Describes all of the links in legal_message_. Invalid if legal_message_
117 // is an empty string.
118 std::vector<LegalMessageLink> legal_message_links_;
119
71 // Used to measure the amount of time on a page; if it's less than some 120 // Used to measure the amount of time on a page; if it's less than some
72 // reasonable limit, then don't close the bubble upon navigation. 121 // reasonable limit, then don't close the bubble upon navigation.
73 scoped_ptr<base::ElapsedTimer> timer_; 122 scoped_ptr<base::ElapsedTimer> timer_;
74 123
75 DISALLOW_COPY_AND_ASSIGN(SaveCardBubbleControllerImpl); 124 DISALLOW_COPY_AND_ASSIGN(SaveCardBubbleControllerImpl);
76 }; 125 };
77 126
78 } // namespace autofill 127 } // namespace autofill
79 128
80 #endif // CHROME_BROWSER_UI_AUTOFILL_SAVE_CARD_BUBBLE_CONTROLLER_IMPL_H_ 129 #endif // CHROME_BROWSER_UI_AUTOFILL_SAVE_CARD_BUBBLE_CONTROLLER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698