| 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 auto map = profile->GetOffTheRecordProfile()->GetHostContentSettingsMap(); |
| 505 if (!observer_.IsObserving(map)) |
| 506 observer_.Add(map); |
| 507 } |
| 501 } | 508 } |
| 502 | 509 |
| 503 void ContentSettingsHandler::InitializePage() { | 510 void ContentSettingsHandler::InitializePage() { |
| 504 media_settings_ = MediaSettingsInfo(); | 511 media_settings_ = MediaSettingsInfo(); |
| 505 RefreshFlashMediaSettings(); | 512 RefreshFlashMediaSettings(); |
| 506 | 513 |
| 507 UpdateHandlersEnabledRadios(); | 514 UpdateHandlersEnabledRadios(); |
| 508 UpdateAllExceptionsViewsFromModel(); | 515 UpdateAllExceptionsViewsFromModel(); |
| 509 UpdateProtectedContentExceptionsButton(); | 516 UpdateProtectedContentExceptionsButton(); |
| 510 } | 517 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 522 else | 529 else |
| 523 UpdateExceptionsViewFromModel(details.type()); | 530 UpdateExceptionsViewFromModel(details.type()); |
| 524 } | 531 } |
| 525 | 532 |
| 526 void ContentSettingsHandler::Observe( | 533 void ContentSettingsHandler::Observe( |
| 527 int type, | 534 int type, |
| 528 const content::NotificationSource& source, | 535 const content::NotificationSource& source, |
| 529 const content::NotificationDetails& details) { | 536 const content::NotificationDetails& details) { |
| 530 switch (type) { | 537 switch (type) { |
| 531 case chrome::NOTIFICATION_PROFILE_DESTROYED: { | 538 case chrome::NOTIFICATION_PROFILE_DESTROYED: { |
| 532 if (content::Source<Profile>(source).ptr()->IsOffTheRecord()) { | 539 Profile* profile = content::Source<Profile>(source).ptr(); |
| 540 if (profile->IsOffTheRecord() && |
| 541 observer_.IsObserving(profile->GetHostContentSettingsMap())) { |
| 533 web_ui()->CallJavascriptFunction( | 542 web_ui()->CallJavascriptFunction( |
| 534 "ContentSettingsExceptionsArea.OTRProfileDestroyed"); | 543 "ContentSettingsExceptionsArea.OTRProfileDestroyed"); |
| 544 observer_.Remove(profile->GetHostContentSettingsMap()); |
| 535 } | 545 } |
| 536 break; | 546 break; |
| 537 } | 547 } |
| 538 | 548 |
| 539 case chrome::NOTIFICATION_PROFILE_CREATED: { | 549 case chrome::NOTIFICATION_PROFILE_CREATED: { |
| 540 if (content::Source<Profile>(source).ptr()->IsOffTheRecord()) | 550 Profile* profile = content::Source<Profile>(source).ptr(); |
| 551 if (profile->IsOffTheRecord()) { |
| 541 UpdateAllOTRExceptionsViewsFromModel(); | 552 UpdateAllOTRExceptionsViewsFromModel(); |
| 553 observer_.Add(profile->GetHostContentSettingsMap()); |
| 554 } |
| 542 break; | 555 break; |
| 543 } | 556 } |
| 544 | 557 |
| 545 case chrome::NOTIFICATION_DESKTOP_NOTIFICATION_SETTINGS_CHANGED: { | 558 case chrome::NOTIFICATION_DESKTOP_NOTIFICATION_SETTINGS_CHANGED: { |
| 546 UpdateNotificationExceptionsView(); | 559 UpdateNotificationExceptionsView(); |
| 547 break; | 560 break; |
| 548 } | 561 } |
| 549 | 562 |
| 550 case chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED: { | 563 case chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED: { |
| 551 UpdateHandlersEnabledRadios(); | 564 UpdateHandlersEnabledRadios(); |
| (...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1500 | 1513 |
| 1501 // Exceptions apply only when the feature is enabled. | 1514 // Exceptions apply only when the feature is enabled. |
| 1502 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); | 1515 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); |
| 1503 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); | 1516 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); |
| 1504 web_ui()->CallJavascriptFunction( | 1517 web_ui()->CallJavascriptFunction( |
| 1505 "ContentSettings.enableProtectedContentExceptions", | 1518 "ContentSettings.enableProtectedContentExceptions", |
| 1506 base::FundamentalValue(enable_exceptions)); | 1519 base::FundamentalValue(enable_exceptions)); |
| 1507 } | 1520 } |
| 1508 | 1521 |
| 1509 } // namespace options | 1522 } // namespace options |
| OLD | NEW |