| 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_INFOBARS_INFOBAR_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_INFOBARS_INFOBAR_SERVICE_H_ |
| 6 #define CHROME_BROWSER_INFOBARS_INFOBAR_SERVICE_H_ | 6 #define CHROME_BROWSER_INFOBARS_INFOBAR_SERVICE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 namespace infobars { | 23 namespace infobars { |
| 24 class InfoBar; | 24 class InfoBar; |
| 25 } | 25 } |
| 26 | 26 |
| 27 // Associates a Tab to a InfoBarManager and manages its lifetime. | 27 // Associates a Tab to a InfoBarManager and manages its lifetime. |
| 28 // It manages the infobar notifications and responds to navigation events. | 28 // It manages the infobar notifications and responds to navigation events. |
| 29 class InfoBarService : public infobars::InfoBarManager, | 29 class InfoBarService : public infobars::InfoBarManager, |
| 30 public content::WebContentsObserver, | 30 public content::WebContentsObserver, |
| 31 public content::WebContentsUserData<InfoBarService> { | 31 public content::WebContentsUserData<InfoBarService> { |
| 32 public: | 32 public: |
| 33 ~InfoBarService() override; |
| 34 |
| 33 static infobars::InfoBarDelegate::NavigationDetails | 35 static infobars::InfoBarDelegate::NavigationDetails |
| 34 NavigationDetailsFromLoadCommittedDetails( | 36 NavigationDetailsFromLoadCommittedDetails( |
| 35 const content::LoadCommittedDetails& details); | 37 const content::LoadCommittedDetails& details); |
| 36 | 38 |
| 37 // This function must only be called on infobars that are owned by an | 39 // This function must only be called on infobars that are owned by an |
| 38 // InfoBarService instance (or not owned at all, in which case this returns | 40 // InfoBarService instance (or not owned at all, in which case this returns |
| 39 // NULL). | 41 // NULL). |
| 40 static content::WebContents* WebContentsFromInfoBar( | 42 static content::WebContents* WebContentsFromInfoBar( |
| 41 infobars::InfoBar* infobar); | 43 infobars::InfoBar* infobar); |
| 42 | 44 |
| 43 // Makes it so the next reload is ignored. That is, if the next commit is a | 45 // Makes it so the next reload is ignored. That is, if the next commit is a |
| 44 // reload then it is treated as if nothing happened and no infobars are | 46 // reload then it is treated as if nothing happened and no infobars are |
| 45 // attempted to be closed. | 47 // attempted to be closed. |
| 46 // This is useful for non-user triggered reloads that should not dismiss | 48 // This is useful for non-user triggered reloads that should not dismiss |
| 47 // infobars. For example, instant may trigger a reload when the google URL | 49 // infobars. For example, instant may trigger a reload when the google URL |
| 48 // changes. | 50 // changes. |
| 49 void set_ignore_next_reload() { ignore_next_reload_ = true; } | 51 void set_ignore_next_reload() { ignore_next_reload_ = true; } |
| 50 | 52 |
| 51 // InfoBarManager: | 53 // InfoBarManager: |
| 52 // TODO(sdefresne): Change clients to invoke this on infobars::InfoBarManager | 54 // TODO(sdefresne): Change clients to invoke this on infobars::InfoBarManager |
| 53 // and turn the method override private. | 55 // and turn the method override private. |
| 54 std::unique_ptr<infobars::InfoBar> CreateConfirmInfoBar( | 56 std::unique_ptr<infobars::InfoBar> CreateConfirmInfoBar( |
| 55 std::unique_ptr<ConfirmInfoBarDelegate> delegate) override; | 57 std::unique_ptr<ConfirmInfoBarDelegate> delegate) override; |
| 56 void OpenURL(const GURL& url, WindowOpenDisposition disposition) override; | 58 void OpenURL(const GURL& url, WindowOpenDisposition disposition) override; |
| 57 | 59 |
| 58 private: | 60 private: |
| 59 friend class content::WebContentsUserData<InfoBarService>; | 61 friend class content::WebContentsUserData<InfoBarService>; |
| 60 | 62 |
| 61 explicit InfoBarService(content::WebContents* web_contents); | 63 explicit InfoBarService(content::WebContents* web_contents); |
| 62 ~InfoBarService() override; | |
| 63 | 64 |
| 64 // InfoBarManager: | 65 // InfoBarManager: |
| 65 int GetActiveEntryID() override; | 66 int GetActiveEntryID() override; |
| 66 // TODO(droger): Remove these functions once infobar notifications are | 67 // TODO(droger): Remove these functions once infobar notifications are |
| 67 // removed. See http://crbug.com/354380 | 68 // removed. See http://crbug.com/354380 |
| 68 void NotifyInfoBarAdded(infobars::InfoBar* infobar) override; | 69 void NotifyInfoBarAdded(infobars::InfoBar* infobar) override; |
| 69 void NotifyInfoBarRemoved(infobars::InfoBar* infobar, bool animate) override; | 70 void NotifyInfoBarRemoved(infobars::InfoBar* infobar, bool animate) override; |
| 70 | 71 |
| 71 // content::WebContentsObserver: | 72 // content::WebContentsObserver: |
| 72 void RenderProcessGone(base::TerminationStatus status) override; | 73 void RenderProcessGone(base::TerminationStatus status) override; |
| 73 void DidStartNavigation( | 74 void DidStartNavigation( |
| 74 content::NavigationHandle* navigation_handle) override; | 75 content::NavigationHandle* navigation_handle) override; |
| 75 void NavigationEntryCommitted( | 76 void NavigationEntryCommitted( |
| 76 const content::LoadCommittedDetails& load_details) override; | 77 const content::LoadCommittedDetails& load_details) override; |
| 77 void WebContentsDestroyed() override; | 78 void WebContentsDestroyed() override; |
| 78 | 79 |
| 79 // See description in set_ignore_next_reload(). | 80 // See description in set_ignore_next_reload(). |
| 80 bool ignore_next_reload_; | 81 bool ignore_next_reload_; |
| 81 | 82 |
| 82 DISALLOW_COPY_AND_ASSIGN(InfoBarService); | 83 DISALLOW_COPY_AND_ASSIGN(InfoBarService); |
| 83 }; | 84 }; |
| 84 | 85 |
| 85 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_SERVICE_H_ | 86 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_SERVICE_H_ |
| OLD | NEW |