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

Side by Side Diff: chrome/browser/ui/webui/options/content_settings_handler.cc

Issue 7383012: Start and stop the safe browsing service depending on whether any profile is using it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "chrome/browser/ui/webui/options/content_settings_handler.h" 5 #include "chrome/browser/ui/webui/options/content_settings_handler.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 RegisterTitle(localized_strings, "contentSettingsPage", 262 RegisterTitle(localized_strings, "contentSettingsPage",
263 IDS_CONTENT_SETTINGS_TITLE); 263 IDS_CONTENT_SETTINGS_TITLE);
264 localized_strings->SetBoolean("enable_click_to_play", 264 localized_strings->SetBoolean("enable_click_to_play",
265 CommandLine::ForCurrentProcess()->HasSwitch( 265 CommandLine::ForCurrentProcess()->HasSwitch(
266 switches::kEnableClickToPlay)); 266 switches::kEnableClickToPlay));
267 } 267 }
268 268
269 void ContentSettingsHandler::Initialize() { 269 void ContentSettingsHandler::Initialize() {
270 const HostContentSettingsMap* settings_map = GetContentSettingsMap(); 270 const HostContentSettingsMap* settings_map = GetContentSettingsMap();
271 notification_registrar_.Add( 271 notification_registrar_.Add(
272 this, chrome::NOTIFICATION_OTR_PROFILE_CREATED, 272 this, chrome::NOTIFICATION_PROFILE_CREATED,
273 NotificationService::AllSources()); 273 NotificationService::AllSources());
274 notification_registrar_.Add( 274 notification_registrar_.Add(
275 this, chrome::NOTIFICATION_PROFILE_DESTROYED, 275 this, chrome::NOTIFICATION_PROFILE_DESTROYED,
276 NotificationService::AllSources()); 276 NotificationService::AllSources());
277 277
278 UpdateHandlersEnabledRadios(); 278 UpdateHandlersEnabledRadios();
279 UpdateAllExceptionsViewsFromModel(); 279 UpdateAllExceptionsViewsFromModel();
280 notification_registrar_.Add( 280 notification_registrar_.Add(
281 this, chrome::NOTIFICATION_CONTENT_SETTINGS_CHANGED, 281 this, chrome::NOTIFICATION_CONTENT_SETTINGS_CHANGED,
282 Source<HostContentSettingsMap>(settings_map)); 282 Source<HostContentSettingsMap>(settings_map));
(...skipping 11 matching lines...) Expand all
294 pref_change_registrar_.Init(prefs); 294 pref_change_registrar_.Init(prefs);
295 pref_change_registrar_.Add(prefs::kGeolocationDefaultContentSetting, this); 295 pref_change_registrar_.Add(prefs::kGeolocationDefaultContentSetting, this);
296 pref_change_registrar_.Add(prefs::kGeolocationContentSettings, this); 296 pref_change_registrar_.Add(prefs::kGeolocationContentSettings, this);
297 } 297 }
298 298
299 void ContentSettingsHandler::Observe(int type, 299 void ContentSettingsHandler::Observe(int type,
300 const NotificationSource& source, 300 const NotificationSource& source,
301 const NotificationDetails& details) { 301 const NotificationDetails& details) {
302 switch (type) { 302 switch (type) {
303 case chrome::NOTIFICATION_PROFILE_DESTROYED: { 303 case chrome::NOTIFICATION_PROFILE_DESTROYED: {
304 Profile* profile = static_cast<Source<Profile> >(source).ptr(); 304 if (Source<Profile>(source).ptr()->IsOffTheRecord()) {
305 if (profile->IsOffTheRecord()) {
306 web_ui_->CallJavascriptFunction( 305 web_ui_->CallJavascriptFunction(
307 "ContentSettingsExceptionsArea.OTRProfileDestroyed"); 306 "ContentSettingsExceptionsArea.OTRProfileDestroyed");
308 } 307 }
309 break; 308 break;
310 } 309 }
311 310
312 case chrome::NOTIFICATION_OTR_PROFILE_CREATED: { 311 case chrome::NOTIFICATION_PROFILE_CREATED: {
313 UpdateAllOTRExceptionsViewsFromModel(); 312 if (Source<Profile>(source).ptr()->IsOffTheRecord())
313 UpdateAllOTRExceptionsViewsFromModel();
314 break; 314 break;
315 } 315 }
316 316
317 case chrome::NOTIFICATION_CONTENT_SETTINGS_CHANGED: { 317 case chrome::NOTIFICATION_CONTENT_SETTINGS_CHANGED: {
318 const ContentSettingsDetails* settings_details = 318 const ContentSettingsDetails* settings_details =
319 Details<const ContentSettingsDetails>(details).ptr(); 319 Details<const ContentSettingsDetails>(details).ptr();
320 320
321 // TODO(estade): we pretend update_all() is always true. 321 // TODO(estade): we pretend update_all() is always true.
322 if (settings_details->update_all_types()) 322 if (settings_details->update_all_types())
323 UpdateAllExceptionsViewsFromModel(); 323 UpdateAllExceptionsViewsFromModel();
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 return web_ui_->GetProfile()->GetProtocolHandlerRegistry(); 736 return web_ui_->GetProfile()->GetProtocolHandlerRegistry();
737 } 737 }
738 738
739 HostContentSettingsMap* 739 HostContentSettingsMap*
740 ContentSettingsHandler::GetOTRContentSettingsMap() { 740 ContentSettingsHandler::GetOTRContentSettingsMap() {
741 Profile* profile = web_ui_->GetProfile(); 741 Profile* profile = web_ui_->GetProfile();
742 if (profile->HasOffTheRecordProfile()) 742 if (profile->HasOffTheRecordProfile())
743 return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap(); 743 return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap();
744 return NULL; 744 return NULL;
745 } 745 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc ('k') | chrome/common/chrome_notification_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698