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

Side by Side Diff: chrome/browser/autofill/autofill_infobar_delegate.cc

Issue 2818033: AutoFill: Aggregate profile data. Remove the AutoFill InfoBar. (Closed)
Patch Set: Comment. Created 10 years, 5 months 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
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/autofill/autofill_infobar_delegate.h"
6
7 #include "app/l10n_util.h"
8 #include "app/resource_bundle.h"
9 #include "chrome/browser/autofill/autofill_manager.h"
10 #include "chrome/browser/browser.h"
11 #include "chrome/browser/pref_service.h"
12 #include "chrome/browser/profile.h"
13 #include "chrome/browser/tab_contents/tab_contents.h"
14 #include "chrome/browser/tab_contents/tab_contents_delegate.h"
15 #include "chrome/common/pref_names.h"
16 #include "grit/chromium_strings.h"
17 #include "grit/generated_resources.h"
18 #include "grit/theme_resources.h"
19 #include "third_party/skia/include/core/SkBitmap.h"
20
21 AutoFillInfoBarDelegate::AutoFillInfoBarDelegate(TabContents* tab_contents,
22 AutoFillManager* host)
23 : ConfirmInfoBarDelegate(tab_contents),
24 browser_(NULL),
25 host_(host) {
26 if (tab_contents) {
27 // This is NULL for TestTabContents.
28 if (tab_contents->delegate())
29 browser_ = tab_contents->delegate()->GetBrowser();
30
31 PrefService* prefs = tab_contents->profile()->GetPrefs();
32 prefs->SetBoolean(prefs::kAutoFillInfoBarShown, true);
33 tab_contents->AddInfoBar(this);
34 }
35 }
36
37 AutoFillInfoBarDelegate::~AutoFillInfoBarDelegate() {
38 }
39
40 bool AutoFillInfoBarDelegate::ShouldExpire(
41 const NavigationController::LoadCommittedDetails& details) const {
42 // The user has submitted a form, causing the page to navigate elsewhere. We
43 // don't want the infobar to be expired at this point, because the user won't
44 // get a chance to answer the question.
45 return false;
46 }
47
48 void AutoFillInfoBarDelegate::InfoBarClosed() {
49 if (host_) {
50 host_->OnInfoBarClosed();
51 host_ = NULL;
52 }
53
54 // This will delete us.
55 ConfirmInfoBarDelegate::InfoBarClosed();
56 }
57
58 std::wstring AutoFillInfoBarDelegate::GetMessageText() const {
59 return l10n_util::GetString(IDS_AUTOFILL_INFOBAR_TEXT);
60 }
61
62 SkBitmap* AutoFillInfoBarDelegate::GetIcon() const {
63 return ResourceBundle::GetSharedInstance().GetBitmapNamed(
64 IDR_INFOBAR_AUTOFILL);
65 }
66
67 int AutoFillInfoBarDelegate::GetButtons() const {
68 return BUTTON_OK | BUTTON_CANCEL;
69 }
70
71 std::wstring AutoFillInfoBarDelegate::GetButtonLabel(
72 ConfirmInfoBarDelegate::InfoBarButton button) const {
73 if (button == BUTTON_OK)
74 return l10n_util::GetString(IDS_AUTOFILL_INFOBAR_ACCEPT);
75 else if (button == BUTTON_CANCEL)
76 return l10n_util::GetString(IDS_AUTOFILL_INFOBAR_DENY);
77 else
78 NOTREACHED();
79
80 return std::wstring();
81 }
82
83 bool AutoFillInfoBarDelegate::Accept() {
84 if (host_) {
85 host_->OnInfoBarAccepted();
86 host_ = NULL;
87 }
88 return true;
89 }
90
91 bool AutoFillInfoBarDelegate::Cancel() {
92 if (host_) {
93 host_->OnInfoBarCancelled();
94 host_ = NULL;
95 }
96 return true;
97 }
98
99 std::wstring AutoFillInfoBarDelegate::GetLinkText() {
100 return l10n_util::GetString(IDS_AUTOFILL_LEARN_MORE);
101 }
102
103 bool AutoFillInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
104 browser_->OpenURL(GURL(kAutoFillLearnMoreUrl), GURL(), NEW_FOREGROUND_TAB,
105 PageTransition::TYPED);
106 return true;
107 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_infobar_delegate.h ('k') | chrome/browser/autofill/autofill_infobar_delegate_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698