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