Index: chrome/browser/ui/website_settings/permission_bubble_manager.cc |
diff --git a/chrome/browser/ui/website_settings/permission_bubble_manager.cc b/chrome/browser/ui/website_settings/permission_bubble_manager.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ec7e0c91d4cfe12c1a1fc5e5e9c8478f1eb39bcd |
--- /dev/null |
+++ b/chrome/browser/ui/website_settings/permission_bubble_manager.cc |
@@ -0,0 +1,40 @@ |
+// Copyright (c) 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. |
+ |
+#include "chrome/browser/ui/website_settings/permission_bubble_manager.h" |
+ |
+#include "chrome/browser/ui/website_settings/permission_bubble_delegate.h" |
+ |
+void PermissionBubbleManager::AddPermissionBubbleDelegate( |
+ PermissionBubbleDelegate* delegate) { |
+ RemovePermissionBubbleDelegate(delegate); |
+ delegates_.push_back(delegate); |
+} |
+ |
+void PermissionBubbleManager::RemovePermissionBubbleDelegate( |
+ PermissionBubbleDelegate* delegate) { |
+ for (std::vector<PermissionBubbleDelegate*>::const_iterator i = |
+ delegates_.begin(); |
+ i != delegates_.end(); i++) { |
+ if (*i == delegate) { |
+ delegates_.erase(i); |
+ return; |
+ } |
groby-ooo-7-16
2014/01/07 00:31:17
Let's do this with STL -
delegates_.erase(std::re
|
+ } |
+} |
+ |
+PermissionBubbleManager::PermissionBubbleManager( |
+ content::WebContents* web_contents) |
+ : content::WebContentsObserver(web_contents) { |
+} |
+ |
+void PermissionBubbleManager::WebContentsDestroyed( |
+ content::WebContents* web_contents) { |
groby-ooo-7-16
2014/01/07 00:31:17
I'm aware InfoBarService does this, but I don't th
|
+ // The WebContents is going away; be aggressively paranoid and delete |
+ // ourselves lest other parts of the system attempt to add permission bubbles |
+ // or use us otherwise during the destruction. |
+ web_contents->RemoveUserData(UserDataKey()); |
+ // That was the equivalent of "delete this". This object is now destroyed; |
+ // returning from this function is the only safe thing to do. |
+} |