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

Unified Diff: chrome/browser/cocoa/content_exceptions_window_controller.mm

Issue 3017011: Make content settings map updates live.
Patch Set: Created 10 years, 5 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
Index: chrome/browser/cocoa/content_exceptions_window_controller.mm
diff --git a/chrome/browser/cocoa/content_exceptions_window_controller.mm b/chrome/browser/cocoa/content_exceptions_window_controller.mm
index 6c2c7c8d0f59afa17611743427258ec85d6c1a6a..d5078ab7f82c6e99f07e1f82f17dbd1d43bc5027 100644
--- a/chrome/browser/cocoa/content_exceptions_window_controller.mm
+++ b/chrome/browser/cocoa/content_exceptions_window_controller.mm
@@ -66,7 +66,32 @@
@end
////////////////////////////////////////////////////////////////////////////////
-// UpdatingContentSettingsObserver
+// ContentExceptionObserverBridge
+
+// Observer for the content settings table model.
+class ContentExceptionsTableModelObserver : public TableModelObserver {
+ public:
+ ContentExceptionsTableModelObserver(
+ ContentExceptionsWindowController* controller)
+ : controller_(controller) {}
+ virtual ~ContentExceptionsTableModelObserver() {}
+
+ virtual void OnModelChanged() {
+ [controller_ modelDidChange];
+ }
+ virtual void OnItemsChanged(int start, int length) {
+ [controller_ modelDidChange];
+ }
+ virtual void OnItemsAdded(int start, int length) {
+ [controller_ modelDidChange];
+ }
+ virtual void OnItemsRemoved(int start, int length) {
+ [controller_ modelDidChange];
+ }
+
+ private:
+ ContentExceptionsWindowController* controller_; // weak
+};
// UpdatingContentSettingsObserver is a notification observer that tells a
// window controller to update its data on every notification.
@@ -163,7 +188,8 @@ static ContentExceptionsWindowController*
settingsMap_ = settingsMap;
model_.reset(new ContentExceptionsTableModel(settingsMap_, settingsType_));
showAsk_ = settingsType_ == CONTENT_SETTINGS_TYPE_COOKIES;
- tableObserver_.reset(new UpdatingContentSettingsObserver(self));
+ tableObserver_.reset(new ContentExceptionsTableModelObserver(self));
+ model_->SetObserver(tableObserver_.get());
updatesEnabled_ = YES;
// TODO(thakis): autoremember window rect.
@@ -430,6 +456,8 @@ static ContentExceptionsWindowController*
}
- (void)modelDidChange {
+// XXX: disable editing mode if active. write test for that.
+
// Some calls on |model_|, e.g. RemoveException(), change something on the
// backing content settings map object (which sends a notification) and then
// change more stuff in |model_|. If |model_| is deleted when the notification
@@ -438,9 +466,6 @@ static ContentExceptionsWindowController*
if (!updatesEnabled_)
return;
- // The model caches its data, meaning we need to recreate it on every change.
- model_.reset(new ContentExceptionsTableModel(settingsMap_, settingsType_));
-
[tableView_ reloadData];
[self adjustEditingButtons];
}

Powered by Google App Engine
This is Rietveld 408576698