OLD | NEW |
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 #ifndef CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_INFOBAR_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_INFOBAR_DELEGATE_H_ |
6 #define CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_INFOBAR_DELEGATE_H_ | 6 #define CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_INFOBAR_DELEGATE_H_ |
7 | 7 |
8 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" | 8 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" |
9 #include "googleurl/src/gurl.h" | 9 #include "googleurl/src/gurl.h" |
10 | 10 |
11 class GoogleURLTracker; | 11 class GoogleURLTracker; |
12 | 12 |
13 // This infobar is shown by the GoogleURLTracker when the Google base URL has | 13 // This infobar is shown by the GoogleURLTracker when the Google base URL has |
14 // changed. | 14 // changed. |
15 class GoogleURLTrackerInfoBarDelegate : public ConfirmInfoBarDelegate { | 15 class GoogleURLTrackerInfoBarDelegate : public ConfirmInfoBarDelegate { |
16 public: | 16 public: |
17 GoogleURLTrackerInfoBarDelegate(InfoBarService* infobar_service, | 17 // Creates a Google URL tracker delegate and adds it to |infobar_service|. |
18 GoogleURLTracker* google_url_tracker, | 18 // Returns the delegate if it was successfully added. |
19 const GURL& search_url); | 19 static GoogleURLTrackerInfoBarDelegate* Create( |
| 20 InfoBarService* infobar_service, |
| 21 GoogleURLTracker* google_url_tracker, |
| 22 const GURL& search_url); |
20 | 23 |
21 // ConfirmInfoBarDelegate: | 24 // ConfirmInfoBarDelegate: |
22 virtual bool Accept() OVERRIDE; | 25 virtual bool Accept() OVERRIDE; |
23 virtual bool Cancel() OVERRIDE; | 26 virtual bool Cancel() OVERRIDE; |
24 virtual string16 GetLinkText() const OVERRIDE; | 27 virtual string16 GetLinkText() const OVERRIDE; |
25 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; | 28 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; |
26 virtual bool ShouldExpireInternal( | 29 virtual bool ShouldExpireInternal( |
27 const content::LoadCommittedDetails& details) const OVERRIDE; | 30 const content::LoadCommittedDetails& details) const OVERRIDE; |
28 | 31 |
29 // Other than set_pending_id(), these accessors are only used by test code. | 32 // Other than set_pending_id(), these accessors are only used by test code. |
30 const GURL& search_url() const { return search_url_; } | 33 const GURL& search_url() const { return search_url_; } |
31 void set_search_url(const GURL& search_url) { search_url_ = search_url; } | 34 void set_search_url(const GURL& search_url) { search_url_ = search_url; } |
32 int pending_id() const { return pending_id_; } | 35 int pending_id() const { return pending_id_; } |
33 void set_pending_id(int pending_id) { pending_id_ = pending_id; } | 36 void set_pending_id(int pending_id) { pending_id_ = pending_id; } |
34 | 37 |
35 // These are virtual so test code can override them in a subclass. | 38 // These are virtual so test code can override them in a subclass. |
36 virtual void Update(const GURL& search_url); | 39 virtual void Update(const GURL& search_url); |
37 virtual void Close(bool redo_search); | 40 virtual void Close(bool redo_search); |
38 | 41 |
39 protected: | 42 protected: |
| 43 GoogleURLTrackerInfoBarDelegate(InfoBarService* infobar_service, |
| 44 GoogleURLTracker* google_url_tracker, |
| 45 const GURL& search_url); |
40 virtual ~GoogleURLTrackerInfoBarDelegate(); | 46 virtual ~GoogleURLTrackerInfoBarDelegate(); |
41 | 47 |
42 private: | 48 private: |
43 // ConfirmInfoBarDelegate: | 49 // ConfirmInfoBarDelegate: |
44 virtual string16 GetMessageText() const OVERRIDE; | 50 virtual string16 GetMessageText() const OVERRIDE; |
45 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | 51 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
46 | 52 |
47 GoogleURLTracker* google_url_tracker_; | 53 GoogleURLTracker* google_url_tracker_; |
48 GURL search_url_; | 54 GURL search_url_; |
49 int pending_id_; | 55 int pending_id_; |
50 | 56 |
51 DISALLOW_COPY_AND_ASSIGN(GoogleURLTrackerInfoBarDelegate); | 57 DISALLOW_COPY_AND_ASSIGN(GoogleURLTrackerInfoBarDelegate); |
52 }; | 58 }; |
53 | 59 |
54 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_INFOBAR_DELEGATE_H_ | 60 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_INFOBAR_DELEGATE_H_ |
OLD | NEW |