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

Side by Side Diff: chrome/browser/ui/startup/obsolete_os_info_bar.cc

Issue 11644059: Change infobar creation to use a public static Create() method on the infobar delegate classes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/startup/obsolete_os_info_bar.h" 5 #include "chrome/browser/ui/startup/obsolete_os_info_bar.h"
6 6
7 #include "chrome/browser/api/infobars/infobar_service.h" 7 #include "chrome/browser/api/infobars/infobar_service.h"
8 #include "content/public/browser/web_contents.h" 8 #include "content/public/browser/web_contents.h"
9 #include "grit/chromium_strings.h"
9 #include "grit/generated_resources.h" 10 #include "grit/generated_resources.h"
10 #include "ui/base/l10n/l10n_util.h" 11 #include "ui/base/l10n/l10n_util.h"
11 12
13 #if defined(TOOLKIT_GTK)
14 #include <gtk/gtk.h>
15 #endif
16
12 using content::OpenURLParams; 17 using content::OpenURLParams;
13 using content::Referrer; 18 using content::Referrer;
14 19
15 namespace chrome { 20 namespace chrome {
16 21
17 ObsoleteOSInfoBar::ObsoleteOSInfoBar(InfoBarService* infobar_service, 22 // static
18 const string16& message, 23 void ObsoleteOSInfoBar::Create(InfoBarService* infobar_service) {
19 const GURL& url) 24 #if defined(TOOLKIT_GTK)
20 : ConfirmInfoBarDelegate(infobar_service), 25 // We've deprecated support for Ubuntu Hardy. Rather than attempting to
21 message_(message), 26 // determine whether you're using that, we instead key off the GTK version;
22 learn_more_url_(url) { 27 // this will also deprecate other distributions (including variants of Ubuntu)
23 } 28 // that are of a similar age.
29 // Version key:
30 // Ubuntu Hardy: GTK 2.12
31 // RHEL 6: GTK 2.18
32 // Ubuntu Lucid: GTK 2.20
33 if (!gtk_check_version(2, 18, 0))
34 return;
35 #else
36 // No other platforms currently show this infobar.
37 return;
38 #endif
24 39
25 ObsoleteOSInfoBar::~ObsoleteOSInfoBar() { 40 string16 message = l10n_util::GetStringUTF16(IDS_SYSTEM_OBSOLETE_MESSAGE);
41 // Link to an article in the help center on minimum system requirements.
42 const char* kLearnMoreURL =
43 "http://www.google.com/support/chrome/bin/answer.py?answer=95411";
44 infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>(
45 new ObsoleteOSInfoBar(infobar_service, message, GURL(kLearnMoreURL))));
26 } 46 }
27 47
28 string16 ObsoleteOSInfoBar::GetMessageText() const { 48 string16 ObsoleteOSInfoBar::GetMessageText() const {
29 return message_; 49 return message_;
30 } 50 }
31 51
32 int ObsoleteOSInfoBar::GetButtons() const { 52 int ObsoleteOSInfoBar::GetButtons() const {
33 return BUTTON_NONE; 53 return BUTTON_NONE;
34 } 54 }
35 55
36 string16 ObsoleteOSInfoBar::GetLinkText() const { 56 string16 ObsoleteOSInfoBar::GetLinkText() const {
37 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); 57 return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
38 } 58 }
39 59
40 bool ObsoleteOSInfoBar::LinkClicked(WindowOpenDisposition disposition) { 60 bool ObsoleteOSInfoBar::LinkClicked(WindowOpenDisposition disposition) {
41 OpenURLParams params(learn_more_url_, Referrer(), 61 OpenURLParams params(learn_more_url_, Referrer(),
42 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, 62 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
43 content::PAGE_TRANSITION_LINK, false); 63 content::PAGE_TRANSITION_LINK, false);
44 owner()->GetWebContents()->OpenURL(params); 64 owner()->GetWebContents()->OpenURL(params);
45 return false; 65 return false;
46 } 66 }
47 67
68 ObsoleteOSInfoBar::ObsoleteOSInfoBar(InfoBarService* infobar_service,
69 const string16& message,
70 const GURL& url)
71 : ConfirmInfoBarDelegate(infobar_service),
72 message_(message),
73 learn_more_url_(url) {
74 }
75
76 ObsoleteOSInfoBar::~ObsoleteOSInfoBar() {
77 }
78
48 } // namespace chrome 79 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/startup/obsolete_os_info_bar.h ('k') | chrome/browser/ui/startup/obsolete_os_prompt.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698