Index: chrome/browser/infobars/infobar_manager.h |
diff --git a/chrome/browser/infobars/infobar_service.h b/chrome/browser/infobars/infobar_manager.h |
similarity index 66% |
copy from chrome/browser/infobars/infobar_service.h |
copy to chrome/browser/infobars/infobar_manager.h |
index 7be2e7c096ef703eec5aa72348990d6f8d04f7a8..b69fe01a86bf500f887c78765b37aed186ce8de1 100644 |
--- a/chrome/browser/infobars/infobar_service.h |
+++ b/chrome/browser/infobars/infobar_manager.h |
@@ -1,25 +1,26 @@ |
-// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#ifndef CHROME_BROWSER_INFOBARS_INFOBAR_SERVICE_H_ |
-#define CHROME_BROWSER_INFOBARS_INFOBAR_SERVICE_H_ |
+#ifndef CHROME_BROWSER_INFOBARS_INFOBAR_MANAGER_H_ |
+#define CHROME_BROWSER_INFOBARS_INFOBAR_MANAGER_H_ |
#include <vector> |
#include "base/memory/scoped_ptr.h" |
#include "base/observer_list.h" |
-#include "content/public/browser/web_contents_observer.h" |
-#include "content/public/browser/web_contents_user_data.h" |
+ |
+namespace content { |
+struct LoadCommittedDetails; |
+class WebContents; |
+} |
class InfoBar; |
// Provides access to creating, removing and enumerating info bars |
// attached to a tab. |
-class InfoBarService : public content::WebContentsObserver, |
- public content::WebContentsUserData<InfoBarService> { |
+class InfoBarManager { |
public: |
- |
// Observer class for infobar events. |
class Observer { |
public: |
@@ -27,9 +28,12 @@ class InfoBarService : public content::WebContentsObserver, |
virtual void OnInfoBarRemoved(InfoBar* infobar, bool animate) = 0; |
virtual void OnInfoBarReplaced(InfoBar* old_infobar, |
InfoBar* new_infobar) = 0; |
- virtual void OnServiceShuttingDown(InfoBarService* service) = 0; |
+ virtual void OnManagerShuttingDown(InfoBarManager* manager) = 0; |
}; |
+ explicit InfoBarManager(content::WebContents* web_contents); |
+ ~InfoBarManager(); |
+ |
// Adds the specified |infobar|, which already owns a delegate. |
// |
// If infobars are disabled for this tab or the tab already has an infobar |
@@ -63,53 +67,45 @@ class InfoBarService : public content::WebContentsObserver, |
// Returns the number of infobars for this tab. |
size_t infobar_count() const { return infobars_.size(); } |
- // Returns the infobar at the given |index|. The InfoBarService retains |
+ // Returns the infobar at the given |index|. The InfoBarManager retains |
// ownership. |
// |
// Warning: Does not sanity check |index|. |
InfoBar* infobar_at(size_t index) { return infobars_[index]; } |
+ // Removes all the infobars. |
Peter Kasting
2014/03/26 23:51:30
Nit: This should be up be RemoveInfoBar().
|
+ void RemoveAllInfoBars(bool animate); |
+ |
// Retrieve the WebContents for the tab this service is associated with. |
- content::WebContents* web_contents() { |
- return content::WebContentsObserver::web_contents(); |
- } |
+ // Do not add new call sites for this. |
+ // TODO(droger): remove this method. See http://crbug.com/ |
blundell
2014/03/27 09:40:30
bug number?
|
+ content::WebContents* web_contents() { return web_contents_; } |
+ |
+ // Must be called when a navigation happens. |
+ void OnNavigation(const content::LoadCommittedDetails& load_details); |
+ |
+ // Called when the associated WebContents is being destroyed. |
+ void CleanUp(); |
Peter Kasting
2014/03/26 23:51:30
Nit: Why is the name of this so vague? Why isn't
blundell
2014/03/27 09:40:30
This method is going to stay in InfoBarManager aft
Peter Kasting
2014/03/27 17:51:33
What's it going to do at that point?
(Side note:
|
void AddObserver(Observer* obs); |
void RemoveObserver(Observer* obs); |
private: |
- friend class content::WebContentsUserData<InfoBarService>; |
- |
- // InfoBars associated with this InfoBarService. We own these pointers. |
+ // InfoBars associated with this InfoBarManager. We own these pointers. |
// However, this is not a ScopedVector, because we don't delete the infobars |
// directly once they've been added to this; instead, when we're done with an |
// infobar, we instruct it to delete itself and then orphan it. See |
// RemoveInfoBarInternal(). |
typedef std::vector<InfoBar*> InfoBars; |
- explicit InfoBarService(content::WebContents* web_contents); |
- virtual ~InfoBarService(); |
- |
- // content::WebContentsObserver: |
- virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE; |
- virtual void NavigationEntryCommitted( |
- const content::LoadCommittedDetails& load_details) OVERRIDE; |
- virtual void WebContentsDestroyed( |
- content::WebContents* web_contents) OVERRIDE; |
- virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
- |
void RemoveInfoBarInternal(InfoBar* infobar, bool animate); |
- void RemoveAllInfoBars(bool animate); |
- |
- // Message handlers. |
- void OnDidBlockDisplayingInsecureContent(); |
- void OnDidBlockRunningInsecureContent(); |
InfoBars infobars_; |
bool infobars_enabled_; |
+ content::WebContents* web_contents_; |
blundell
2014/03/27 09:40:30
Put a TODO and bug reference here as well.
|
ObserverList<Observer, true> observer_list_; |
- DISALLOW_COPY_AND_ASSIGN(InfoBarService); |
+ DISALLOW_COPY_AND_ASSIGN(InfoBarManager); |
}; |
-#endif // CHROME_BROWSER_INFOBARS_INFOBAR_SERVICE_H_ |
+#endif // CHROME_BROWSER_INFOBARS_INFOBAR_MANAGER_H_ |