1 // Copyright 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 #ifndef CHROME_BROWSER_UI_OMNIBOX_ALTERNATE_NAV_INFOBAR_DELEGATE_H_ 6 #define CHROME_BROWSER_UI_OMNIBOX_ALTERNATE_NAV_INFOBAR_DELEGATE_H_ 7 8 #include "base/memory/scoped_ptr.h" 9 #include "chrome/browser/autocomplete/autocomplete_match.h" 10 #include "chrome/browser/infobars/infobar_delegate.h" 11 12 class AlternateNavInfoBarDelegate : public InfoBarDelegate { 13 public: 14 virtual ~AlternateNavInfoBarDelegate(); 15 16 // Creates an alternate nav infobar and delegate and adds the infobar to the 17 // infobar service for |web_contents|. 18 static void Create(content::WebContents* web_contents, 19 const base::string16& text, 20 const AutocompleteMatch& match, 21 const GURL& search_url); 22 23 base::string16 GetMessageTextWithOffset(size_t* link_offset) const; 24 base::string16 GetLinkText() const; 25 bool LinkClicked(WindowOpenDisposition disposition); 26 27 private: 28 AlternateNavInfoBarDelegate(Profile* profile, 29 const base::string16& text, 30 const AutocompleteMatch& match, 31 const GURL& search_url); 32 33 // Returns an alternate nav infobar that owns |delegate|. 34 static scoped_ptr<InfoBar> CreateInfoBar( 35 scoped_ptr<AlternateNavInfoBarDelegate> delegate); 36 37 // InfoBarDelegate: 38 virtual int GetIconID() const OVERRIDE; 39 virtual Type GetInfoBarType() const OVERRIDE; 40 41 Profile* profile_; 42 const base::string16 text_; 43 const AutocompleteMatch match_; 44 const GURL search_url_; 45 46 DISALLOW_COPY_AND_ASSIGN(AlternateNavInfoBarDelegate); 47 }; 48 49 #endif // CHROME_BROWSER_UI_OMNIBOX_ALTERNATE_NAV_INFOBAR_DELEGATE_H_ 50