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