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

Side by Side Diff: chrome/browser/ui/cocoa/content_settings_dialog_controller.mm

Issue 5574001: Move ContentSettingsDetails and Pattern out of HostContentSettingsMap as separate classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/browser/content_settings
Patch Set: updates Created 10 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #import "chrome/browser/ui/cocoa/content_settings_dialog_controller.h" 5 #import "chrome/browser/ui/cocoa/content_settings_dialog_controller.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/mac_util.h" 11 #include "base/mac_util.h"
12 #import "chrome/browser/content_settings/content_settings_details.h"
12 #import "chrome/browser/content_settings/host_content_settings_map.h" 13 #import "chrome/browser/content_settings/host_content_settings_map.h"
13 #import "chrome/browser/geolocation/geolocation_content_settings_map.h" 14 #import "chrome/browser/geolocation/geolocation_content_settings_map.h"
14 #import "chrome/browser/geolocation/geolocation_exceptions_table_model.h" 15 #import "chrome/browser/geolocation/geolocation_exceptions_table_model.h"
15 #import "chrome/browser/notifications/desktop_notification_service.h" 16 #import "chrome/browser/notifications/desktop_notification_service.h"
16 #import "chrome/browser/notifications/notification_exceptions_table_model.h" 17 #import "chrome/browser/notifications/notification_exceptions_table_model.h"
17 #include "chrome/browser/plugin_exceptions_table_model.h" 18 #include "chrome/browser/plugin_exceptions_table_model.h"
18 #include "chrome/browser/prefs/pref_service.h" 19 #include "chrome/browser/prefs/pref_service.h"
19 #include "chrome/browser/profile.h" 20 #include "chrome/browser/profile.h"
20 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
21 #include "chrome/browser/ui/browser_window.h" 22 #include "chrome/browser/ui/browser_window.h"
(...skipping 20 matching lines...) Expand all
42 @interface ContentSettingsDialogController(Private) 43 @interface ContentSettingsDialogController(Private)
43 - (id)initWithProfile:(Profile*)profile; 44 - (id)initWithProfile:(Profile*)profile;
44 - (void)selectTab:(ContentSettingsType)settingsType; 45 - (void)selectTab:(ContentSettingsType)settingsType;
45 - (void)showExceptionsForType:(ContentSettingsType)settingsType; 46 - (void)showExceptionsForType:(ContentSettingsType)settingsType;
46 47
47 // Callback when preferences are changed. |prefName| is the name of the 48 // Callback when preferences are changed. |prefName| is the name of the
48 // pref that has changed. 49 // pref that has changed.
49 - (void)prefChanged:(const std::string&)prefName; 50 - (void)prefChanged:(const std::string&)prefName;
50 51
51 // Callback when content settings are changed. 52 // Callback when content settings are changed.
52 - (void)contentSettingsChanged: 53 - (void)contentSettingsChanged:(ContentSettingsDetails*)details;
53 (HostContentSettingsMap::ContentSettingsDetails*)details;
54 54
55 @end 55 @end
56 56
57 namespace ContentSettingsDialogControllerInternal { 57 namespace ContentSettingsDialogControllerInternal {
58 58
59 // A C++ class registered for changes in preferences. 59 // A C++ class registered for changes in preferences.
60 class PrefObserverBridge : public NotificationObserver { 60 class PrefObserverBridge : public NotificationObserver {
61 public: 61 public:
62 PrefObserverBridge(ContentSettingsDialogController* controller) 62 PrefObserverBridge(ContentSettingsDialogController* controller)
63 : controller_(controller), disabled_(false) {} 63 : controller_(controller), disabled_(false) {}
64 64
65 virtual ~PrefObserverBridge() {} 65 virtual ~PrefObserverBridge() {}
66 66
67 virtual void Observe(NotificationType type, 67 virtual void Observe(NotificationType type,
68 const NotificationSource& source, 68 const NotificationSource& source,
69 const NotificationDetails& details) { 69 const NotificationDetails& details) {
70 if (disabled_) 70 if (disabled_)
71 return; 71 return;
72 72
73 // This is currently used by most notifications. 73 // This is currently used by most notifications.
74 if (type == NotificationType::PREF_CHANGED) { 74 if (type == NotificationType::PREF_CHANGED) {
75 std::string* detail = Details<std::string>(details).ptr(); 75 std::string* detail = Details<std::string>(details).ptr();
76 if (detail) 76 if (detail)
77 [controller_ prefChanged:*detail]; 77 [controller_ prefChanged:*detail];
78 } 78 }
79 79
80 // This is sent when the "is managed" state changes. 80 // This is sent when the "is managed" state changes.
81 // TODO(markusheintz): Move all content settings to this notification. 81 // TODO(markusheintz): Move all content settings to this notification.
82 if (type == NotificationType::CONTENT_SETTINGS_CHANGED) { 82 if (type == NotificationType::CONTENT_SETTINGS_CHANGED) {
83 HostContentSettingsMap::ContentSettingsDetails* settings_details = 83 ContentSettingsDetails* settings_details =
84 Details<HostContentSettingsMap::ContentSettingsDetails>(details).ptr(); 84 Details<ContentSettingsDetails>(details).ptr();
85 [controller_ contentSettingsChanged:settings_details]; 85 [controller_ contentSettingsChanged:settings_details];
86 } 86 }
87 } 87 }
88 88
89 void SetDisabled(bool disabled) { 89 void SetDisabled(bool disabled) {
90 disabled_ = disabled; 90 disabled_ = disabled;
91 } 91 }
92 92
93 private: 93 private:
94 ContentSettingsDialogController* controller_; // weak, owns us 94 ContentSettingsDialogController* controller_; // weak, owns us
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 if (prefName == prefs::kGeolocationDefaultContentSetting) { 631 if (prefName == prefs::kGeolocationDefaultContentSetting) {
632 [self willChangeValueForKey:@"geolocationSettingIndex"]; 632 [self willChangeValueForKey:@"geolocationSettingIndex"];
633 [self didChangeValueForKey:@"geolocationSettingIndex"]; 633 [self didChangeValueForKey:@"geolocationSettingIndex"];
634 } 634 }
635 if (prefName == prefs::kDesktopNotificationDefaultContentSetting) { 635 if (prefName == prefs::kDesktopNotificationDefaultContentSetting) {
636 [self willChangeValueForKey:@"notificationsSettingIndex"]; 636 [self willChangeValueForKey:@"notificationsSettingIndex"];
637 [self didChangeValueForKey:@"notificationsSettingIndex"]; 637 [self didChangeValueForKey:@"notificationsSettingIndex"];
638 } 638 }
639 } 639 }
640 640
641 - (void)contentSettingsChanged: 641 - (void)contentSettingsChanged:(ContentSettingsDetails*)details {
642 (HostContentSettingsMap::ContentSettingsDetails*)details {
643 [self prefChanged:prefs::kBlockNonsandboxedPlugins]; 642 [self prefChanged:prefs::kBlockNonsandboxedPlugins];
644 [self prefChanged:prefs::kDefaultContentSettings]; 643 [self prefChanged:prefs::kDefaultContentSettings];
645 } 644 }
646 645
647 @end 646 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698