| 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 class InfoBarTabHelper; | 12 class InfoBarTabHelper; |
| 13 | 13 |
| 14 // This infobar is shown by the GoogleURLTracker when the Google base URL has | 14 // This infobar is shown by the GoogleURLTracker when the Google base URL has |
| 15 // changed. | 15 // changed. |
| 16 class GoogleURLTrackerInfoBarDelegate : public ConfirmInfoBarDelegate { | 16 class GoogleURLTrackerInfoBarDelegate : public ConfirmInfoBarDelegate { |
| 17 public: | 17 public: |
| 18 GoogleURLTrackerInfoBarDelegate(InfoBarTabHelper* infobar_helper, | 18 GoogleURLTrackerInfoBarDelegate(InfoBarTabHelper* infobar_helper, |
| 19 GoogleURLTracker* google_url_tracker, | 19 GoogleURLTracker* google_url_tracker, |
| 20 const GURL& new_google_url); | 20 const GURL& search_url); |
| 21 | 21 |
| 22 // ConfirmInfoBarDelegate: | 22 // ConfirmInfoBarDelegate: |
| 23 virtual bool Accept() OVERRIDE; | 23 virtual bool Accept() OVERRIDE; |
| 24 virtual bool Cancel() OVERRIDE; | 24 virtual bool Cancel() OVERRIDE; |
| 25 virtual string16 GetLinkText() const OVERRIDE; | 25 virtual string16 GetLinkText() const OVERRIDE; |
| 26 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; | 26 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; |
| 27 virtual bool ShouldExpireInternal( | 27 virtual bool ShouldExpireInternal( |
| 28 const content::LoadCommittedDetails& details) const OVERRIDE; | 28 const content::LoadCommittedDetails& details) const OVERRIDE; |
| 29 | 29 |
| 30 // Allows GoogleURLTracker to change the Google base URL after the infobar has | 30 // Other than set_pending_id(), these accessors are only used by test code. |
| 31 // been instantiated. This should only be called with an URL with the same | 31 const GURL& search_url() const { return search_url_; } |
| 32 // TLD as the existing one, so that the prompt we're displaying will still be | 32 void set_search_url(const GURL& search_url) { search_url_ = search_url; } |
| 33 // correct. | 33 int pending_id() const { return pending_id_; } |
| 34 void SetGoogleURL(const GURL& new_google_url); | |
| 35 | |
| 36 bool showing() const { return showing_; } | |
| 37 void set_pending_id(int pending_id) { pending_id_ = pending_id; } | 34 void set_pending_id(int pending_id) { pending_id_ = pending_id; } |
| 38 | 35 |
| 39 // These are virtual so test code can override them in a subclass. | 36 // These are virtual so test code can override them in a subclass. |
| 40 virtual void Show(const GURL& search_url); | 37 virtual void Update(const GURL& search_url); |
| 41 virtual void Close(bool redo_search); | 38 virtual void Close(bool redo_search); |
| 42 | 39 |
| 43 protected: | 40 protected: |
| 44 virtual ~GoogleURLTrackerInfoBarDelegate(); | 41 virtual ~GoogleURLTrackerInfoBarDelegate(); |
| 45 | 42 |
| 46 InfoBarTabHelper* map_key_; // What |google_url_tracker_| uses to track us. | |
| 47 GURL search_url_; | |
| 48 GoogleURLTracker* google_url_tracker_; | |
| 49 GURL new_google_url_; | |
| 50 bool showing_; // True if this delegate has been added to a TabContents. | |
| 51 int pending_id_; | |
| 52 | |
| 53 private: | 43 private: |
| 54 // ConfirmInfoBarDelegate: | 44 // ConfirmInfoBarDelegate: |
| 55 virtual string16 GetMessageText() const OVERRIDE; | 45 virtual string16 GetMessageText() const OVERRIDE; |
| 56 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | 46 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
| 57 | 47 |
| 48 GoogleURLTracker* google_url_tracker_; |
| 49 GURL search_url_; |
| 50 int pending_id_; |
| 51 |
| 58 DISALLOW_COPY_AND_ASSIGN(GoogleURLTrackerInfoBarDelegate); | 52 DISALLOW_COPY_AND_ASSIGN(GoogleURLTrackerInfoBarDelegate); |
| 59 }; | 53 }; |
| 60 | 54 |
| 61 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_INFOBAR_DELEGATE_H_ | 55 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_INFOBAR_DELEGATE_H_ |
| OLD | NEW |