Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5705)

Unified Diff: chrome/browser/infobars/infobar_manager.h

Issue 211273007: Split InfoBarService core code into InfoBarManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + comments Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/infobars/infobar_container.cc ('k') | chrome/browser/infobars/infobar_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..f4e9b4171623b085247f6aa6ab2731aa3fffd4eb 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
@@ -48,6 +52,9 @@ class InfoBarService : public content::WebContentsObserver,
// the infobar (see above).
void RemoveInfoBar(InfoBar* infobar);
+ // Removes all the infobars.
+ void RemoveAllInfoBars(bool animate);
+
// Replaces one infobar with another, without any animation in between. This
// will result in |old_infobar| being synchronously deleted.
//
@@ -63,53 +70,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]; }
// 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/354379.
+ 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 OnWebContentsDestroyed();
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_;
+
+ // TODO(droger): remove this field. See http://crbug.com/354379.
+ content::WebContents* web_contents_;
+
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_
« no previous file with comments | « chrome/browser/infobars/infobar_container.cc ('k') | chrome/browser/infobars/infobar_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698