OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
490 base::Unretained(this))); | 490 base::Unretained(this))); |
491 | 491 |
492 content::HostZoomMap* host_zoom_map = | 492 content::HostZoomMap* host_zoom_map = |
493 content::HostZoomMap::GetDefaultForBrowserContext(context); | 493 content::HostZoomMap::GetDefaultForBrowserContext(context); |
494 host_zoom_map_subscription_ = | 494 host_zoom_map_subscription_ = |
495 host_zoom_map->AddZoomLevelChangedCallback( | 495 host_zoom_map->AddZoomLevelChangedCallback( |
496 base::Bind(&ContentSettingsHandler::OnZoomLevelChanged, | 496 base::Bind(&ContentSettingsHandler::OnZoomLevelChanged, |
497 base::Unretained(this))); | 497 base::Unretained(this))); |
498 | 498 |
499 flash_settings_manager_.reset(new PepperFlashSettingsManager(this, context)); | 499 flash_settings_manager_.reset(new PepperFlashSettingsManager(this, context)); |
500 observer_.Add(Profile::FromWebUI(web_ui())->GetHostContentSettingsMap()); | 500 |
501 Profile* profile = Profile::FromWebUI(web_ui()); | |
502 observer_.Add(profile->GetHostContentSettingsMap()); | |
503 if (profile->HasOffTheRecordProfile()) { | |
504 observer_.Add( | |
505 profile->GetOffTheRecordProfile()->GetHostContentSettingsMap()); | |
506 } | |
501 } | 507 } |
502 | 508 |
503 void ContentSettingsHandler::InitializePage() { | 509 void ContentSettingsHandler::InitializePage() { |
504 media_settings_ = MediaSettingsInfo(); | 510 media_settings_ = MediaSettingsInfo(); |
505 RefreshFlashMediaSettings(); | 511 RefreshFlashMediaSettings(); |
506 | 512 |
507 UpdateHandlersEnabledRadios(); | 513 UpdateHandlersEnabledRadios(); |
508 UpdateAllExceptionsViewsFromModel(); | 514 UpdateAllExceptionsViewsFromModel(); |
509 UpdateProtectedContentExceptionsButton(); | 515 UpdateProtectedContentExceptionsButton(); |
510 } | 516 } |
(...skipping 11 matching lines...) Expand all Loading... | |
522 else | 528 else |
523 UpdateExceptionsViewFromModel(details.type()); | 529 UpdateExceptionsViewFromModel(details.type()); |
524 } | 530 } |
525 | 531 |
526 void ContentSettingsHandler::Observe( | 532 void ContentSettingsHandler::Observe( |
527 int type, | 533 int type, |
528 const content::NotificationSource& source, | 534 const content::NotificationSource& source, |
529 const content::NotificationDetails& details) { | 535 const content::NotificationDetails& details) { |
530 switch (type) { | 536 switch (type) { |
531 case chrome::NOTIFICATION_PROFILE_DESTROYED: { | 537 case chrome::NOTIFICATION_PROFILE_DESTROYED: { |
532 if (content::Source<Profile>(source).ptr()->IsOffTheRecord()) { | 538 Profile* profile = content::Source<Profile>(source).ptr(); |
539 if (profile->IsOffTheRecord()) { | |
533 web_ui()->CallJavascriptFunction( | 540 web_ui()->CallJavascriptFunction( |
534 "ContentSettingsExceptionsArea.OTRProfileDestroyed"); | 541 "ContentSettingsExceptionsArea.OTRProfileDestroyed"); |
542 observer_.Remove(profile->GetHostContentSettingsMap()); | |
Lei Zhang
2014/10/24 19:57:29
Can't we potentially failed the newly added DCHECK
scheib
2014/10/24 21:46:19
Good catch. I've added a check.
| |
535 } | 543 } |
536 break; | 544 break; |
537 } | 545 } |
538 | 546 |
539 case chrome::NOTIFICATION_PROFILE_CREATED: { | 547 case chrome::NOTIFICATION_PROFILE_CREATED: { |
540 if (content::Source<Profile>(source).ptr()->IsOffTheRecord()) | 548 Profile* profile = content::Source<Profile>(source).ptr(); |
549 if (profile->IsOffTheRecord()) { | |
541 UpdateAllOTRExceptionsViewsFromModel(); | 550 UpdateAllOTRExceptionsViewsFromModel(); |
551 observer_.Add(profile->GetHostContentSettingsMap()); | |
552 } | |
542 break; | 553 break; |
543 } | 554 } |
544 | 555 |
545 case chrome::NOTIFICATION_DESKTOP_NOTIFICATION_SETTINGS_CHANGED: { | 556 case chrome::NOTIFICATION_DESKTOP_NOTIFICATION_SETTINGS_CHANGED: { |
546 UpdateNotificationExceptionsView(); | 557 UpdateNotificationExceptionsView(); |
547 break; | 558 break; |
548 } | 559 } |
549 | 560 |
550 case chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED: { | 561 case chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED: { |
551 UpdateHandlersEnabledRadios(); | 562 UpdateHandlersEnabledRadios(); |
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1500 | 1511 |
1501 // Exceptions apply only when the feature is enabled. | 1512 // Exceptions apply only when the feature is enabled. |
1502 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); | 1513 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); |
1503 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); | 1514 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); |
1504 web_ui()->CallJavascriptFunction( | 1515 web_ui()->CallJavascriptFunction( |
1505 "ContentSettings.enableProtectedContentExceptions", | 1516 "ContentSettings.enableProtectedContentExceptions", |
1506 base::FundamentalValue(enable_exceptions)); | 1517 base::FundamentalValue(enable_exceptions)); |
1507 } | 1518 } |
1508 | 1519 |
1509 } // namespace options | 1520 } // namespace options |
OLD | NEW |