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 3// found in the LICENSE file. 4 5#include "chrome/browser/ui/startup/obsolete_system_infobar_delegate.h" 6 7#include "chrome/browser/infobars/infobar_service.h" 8#include "chrome/common/url_constants.h" 9#include "chrome/grit/chromium_strings.h" 10#include "components/infobars/core/infobar.h" 11#include "content/public/browser/web_contents.h" 12#include "grit/components_strings.h" 13#include "ui/base/l10n/l10n_util.h" 14 15#if defined(OS_MACOSX) 16#include "chrome/browser/mac/obsolete_system.h" 17#endif 18 19// static 20void ObsoleteSystemInfoBarDelegate::Create(InfoBarService* infobar_service) { 21#if defined(OS_MACOSX) 22 if (!ObsoleteSystemMac::Is32BitObsoleteNowOrSoon() || 23 !ObsoleteSystemMac::Has32BitOnlyCPU()) { 24 return; 25 } 26 infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar( 27 scoped_ptr<ConfirmInfoBarDelegate>(new ObsoleteSystemInfoBarDelegate()))); 28#else 29 // No other platforms currently show this infobar. 30 return; 31#endif 32} 33 34ObsoleteSystemInfoBarDelegate::ObsoleteSystemInfoBarDelegate() 35 : ConfirmInfoBarDelegate() { 36} 37 38ObsoleteSystemInfoBarDelegate::~ObsoleteSystemInfoBarDelegate() { 39} 40 41base::string16 ObsoleteSystemInfoBarDelegate::GetMessageText() const { 42#if defined(OS_MACOSX) 43 return ObsoleteSystemMac::LocalizedObsoleteSystemString(); 44#else 45 return l10n_util::GetStringUTF16(IDS_SYSTEM_OBSOLETE_MESSAGE); 46#endif 47} 48 49int ObsoleteSystemInfoBarDelegate::GetButtons() const { 50 return BUTTON_NONE; 51} 52 53base::string16 ObsoleteSystemInfoBarDelegate::GetLinkText() const { 54 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); 55} 56 57bool ObsoleteSystemInfoBarDelegate::LinkClicked( 58 WindowOpenDisposition disposition) { 59 InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL( 60 content::OpenURLParams( 61#if defined(OS_MACOSX) 62 GURL(chrome::kMac32BitDeprecationURL), 63#else 64 GURL("http://www.google.com/support/chrome/bin/" 65 "answer.py?answer=95411"), 66#endif 67 content::Referrer(), 68 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, 69 ui::PAGE_TRANSITION_LINK, false)); 70 return false; 71} 72