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

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

Issue 2630583002: Add setting to isolate zoom changes by default. (Closed)
Patch Set: Use code review comments for questions instead of TODOs. Created 3 years, 10 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
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 // USB devices. 473 // USB devices.
474 {"usbDevicesHeader", IDS_USB_DEVICES_HEADER_AND_TAB_LABEL}, 474 {"usbDevicesHeader", IDS_USB_DEVICES_HEADER_AND_TAB_LABEL},
475 {"usbDevicesManage", IDS_USB_DEVICES_MANAGE_BUTTON}, 475 {"usbDevicesManage", IDS_USB_DEVICES_MANAGE_BUTTON},
476 // Background sync. 476 // Background sync.
477 {"backgroundSyncHeader", IDS_BACKGROUND_SYNC_HEADER}, 477 {"backgroundSyncHeader", IDS_BACKGROUND_SYNC_HEADER},
478 {"backgroundSyncAllow", IDS_BACKGROUND_SYNC_ALLOW_RADIO}, 478 {"backgroundSyncAllow", IDS_BACKGROUND_SYNC_ALLOW_RADIO},
479 {"backgroundSyncBlock", IDS_BACKGROUND_SYNC_BLOCK_RADIO}, 479 {"backgroundSyncBlock", IDS_BACKGROUND_SYNC_BLOCK_RADIO},
480 // Zoom levels. 480 // Zoom levels.
481 {"zoomlevelsHeader", IDS_ZOOMLEVELS_HEADER_AND_TAB_LABEL}, 481 {"zoomlevelsHeader", IDS_ZOOMLEVELS_HEADER_AND_TAB_LABEL},
482 {"zoomLevelsManage", IDS_ZOOMLEVELS_MANAGE_BUTTON}, 482 {"zoomLevelsManage", IDS_ZOOMLEVELS_MANAGE_BUTTON},
483 {"zoomLevelsIgnoredExplanation", IDS_ZOOMLEVELS_IGNORED_LABEL},
483 // PDF Plugin filter. 484 // PDF Plugin filter.
484 {"pdfTabLabel", IDS_PDF_TAB_LABEL}, 485 {"pdfTabLabel", IDS_PDF_TAB_LABEL},
485 {"pdfEnable", IDS_PDF_ENABLE_CHECKBOX}, 486 {"pdfEnable", IDS_PDF_ENABLE_CHECKBOX},
486 }; 487 };
487 488
488 RegisterStrings(localized_strings, resources, arraysize(resources)); 489 RegisterStrings(localized_strings, resources, arraysize(resources));
489 490
490 // TODO(tommycli): When the HTML5 By Default feature flag is on, we want to 491 // TODO(tommycli): When the HTML5 By Default feature flag is on, we want to
491 // display strings that begin with "Ask...", even though the setting remains 492 // display strings that begin with "Ask...", even though the setting remains
492 // DETECT. Once this feature is finalized, then we migrate the setting to ASK. 493 // DETECT. Once this feature is finalized, then we migrate the setting to ASK.
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 // Here we only subscribe to the HostZoomMap for the default storage partition 606 // Here we only subscribe to the HostZoomMap for the default storage partition
606 // since we don't allow the user to manage the zoom levels for apps. 607 // since we don't allow the user to manage the zoom levels for apps.
607 // We're only interested in zoom-levels that are persisted, since the user 608 // We're only interested in zoom-levels that are persisted, since the user
608 // is given the opportunity to view/delete these in the content-settings page. 609 // is given the opportunity to view/delete these in the content-settings page.
609 host_zoom_map_subscription_ = 610 host_zoom_map_subscription_ =
610 content::HostZoomMap::GetDefaultForBrowserContext(context) 611 content::HostZoomMap::GetDefaultForBrowserContext(context)
611 ->AddZoomLevelChangedCallback( 612 ->AddZoomLevelChangedCallback(
612 base::Bind(&ContentSettingsHandler::OnZoomLevelChanged, 613 base::Bind(&ContentSettingsHandler::OnZoomLevelChanged,
613 base::Unretained(this))); 614 base::Unretained(this)));
614 615
616 Profile* profile = Profile::FromWebUI(web_ui());
617
618 ChromeZoomLevelPrefs* zoom_level_prefs = profile->GetZoomLevelPrefs();
619 if (zoom_level_prefs) {
620 default_zoom_scope_subscription_ =
621 zoom_level_prefs->RegisterDefaultZoomScopeCallback(
622 base::Bind(&ContentSettingsHandler::OnZoomScopeChanged,
623 base::Unretained(this)));
624 }
625
615 flash_settings_manager_.reset(new PepperFlashSettingsManager(this, context)); 626 flash_settings_manager_.reset(new PepperFlashSettingsManager(this, context));
616 627
617 Profile* profile = Profile::FromWebUI(web_ui());
618 observer_.Add(HostContentSettingsMapFactory::GetForProfile(profile)); 628 observer_.Add(HostContentSettingsMapFactory::GetForProfile(profile));
619 if (profile->HasOffTheRecordProfile()) { 629 if (profile->HasOffTheRecordProfile()) {
620 auto* map = HostContentSettingsMapFactory::GetForProfile( 630 auto* map = HostContentSettingsMapFactory::GetForProfile(
621 profile->GetOffTheRecordProfile()); 631 profile->GetOffTheRecordProfile());
622 if (!observer_.IsObserving(map)) 632 if (!observer_.IsObserving(map))
623 observer_.Add(map); 633 observer_.Add(map);
624 } 634 }
625 } 635 }
626 636
627 void ContentSettingsHandler::InitializePage() { 637 void ContentSettingsHandler::InitializePage() {
628 media_settings_.reset(new MediaSettingsInfo()); 638 media_settings_.reset(new MediaSettingsInfo());
629 RefreshFlashMediaSettings(); 639 RefreshFlashMediaSettings();
630 640
631 UpdateHandlersEnabledRadios(); 641 UpdateHandlersEnabledRadios();
632 UpdateAllExceptionsViewsFromModel(); 642 UpdateAllExceptionsViewsFromModel();
633 UpdateAllChooserExceptionsViewsFromModel(); 643 UpdateAllChooserExceptionsViewsFromModel();
634 UpdateProtectedContentExceptionsButton(); 644 UpdateProtectedContentExceptionsButton();
645 UpdateZoomScopeExplanationVisibility();
635 } 646 }
636 647
637 void ContentSettingsHandler::OnContentSettingChanged( 648 void ContentSettingsHandler::OnContentSettingChanged(
638 const ContentSettingsPattern& primary_pattern, 649 const ContentSettingsPattern& primary_pattern,
639 const ContentSettingsPattern& secondary_pattern, 650 const ContentSettingsPattern& secondary_pattern,
640 ContentSettingsType content_type, 651 ContentSettingsType content_type,
641 std::string resource_identifier) { 652 std::string resource_identifier) {
642 const ContentSettingsDetails details( 653 const ContentSettingsDetails details(
643 primary_pattern, secondary_pattern, content_type, resource_identifier); 654 primary_pattern, secondary_pattern, content_type, resource_identifier);
644 // TODO(estade): we pretend update_all() is always true. 655 // TODO(estade): we pretend update_all() is always true.
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
1397 RefreshFlashMediaSettings(); 1408 RefreshFlashMediaSettings();
1398 else 1409 else
1399 media_settings_->forFlash().initialized = false; 1410 media_settings_->forFlash().initialized = false;
1400 } 1411 }
1401 1412
1402 void ContentSettingsHandler::OnZoomLevelChanged( 1413 void ContentSettingsHandler::OnZoomLevelChanged(
1403 const content::HostZoomMap::ZoomLevelChange& change) { 1414 const content::HostZoomMap::ZoomLevelChange& change) {
1404 UpdateZoomLevelsExceptionsView(); 1415 UpdateZoomLevelsExceptionsView();
1405 } 1416 }
1406 1417
1418 void ContentSettingsHandler::OnZoomScopeChanged() {
1419 UpdateZoomScopeExplanationVisibility();
1420 }
1421
1407 void ContentSettingsHandler::ShowFlashMediaLink( 1422 void ContentSettingsHandler::ShowFlashMediaLink(
1408 LinkType link_type, ContentSettingsType content_type, bool show) { 1423 LinkType link_type, ContentSettingsType content_type, bool show) {
1409 MediaSettingsInfo::ForOneType& settings = 1424 MediaSettingsInfo::ForOneType& settings =
1410 media_settings_->forType(content_type); 1425 media_settings_->forType(content_type);
1411 1426
1412 bool& show_link = link_type == DEFAULT_SETTING ? 1427 bool& show_link = link_type == DEFAULT_SETTING ?
1413 settings.show_flash_default_link : 1428 settings.show_flash_default_link :
1414 settings.show_flash_exceptions_link; 1429 settings.show_flash_exceptions_link;
1415 1430
1416 if (show_link != show) { 1431 if (show_link != show) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 #endif 1505 #endif
1491 1506
1492 // Exceptions apply only when the feature is enabled. 1507 // Exceptions apply only when the feature is enabled.
1493 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); 1508 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui()));
1494 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); 1509 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM);
1495 web_ui()->CallJavascriptFunctionUnsafe( 1510 web_ui()->CallJavascriptFunctionUnsafe(
1496 "ContentSettings.enableProtectedContentExceptions", 1511 "ContentSettings.enableProtectedContentExceptions",
1497 base::FundamentalValue(enable_exceptions)); 1512 base::FundamentalValue(enable_exceptions));
1498 } 1513 }
1499 1514
1515 void ContentSettingsHandler::UpdateZoomScopeExplanationVisibility() {
1516 ChromeZoomLevelPrefs* zoom_level_prefs =
1517 Profile::FromWebUI(web_ui())->GetZoomLevelPrefs();
1518 base::FundamentalValue per_tab_scope(
1519 !(zoom_level_prefs
1520 ? zoom_level_prefs->GetZoomScopeIsPerOriginPref()
1521 : ChromeZoomLevelPrefs::kZoomScopeSettingDefault));
1522
1523 web_ui()->CallJavascriptFunctionUnsafe(
1524 "ContentSettings.showZoomScopeExplanation", per_tab_scope);
1525 }
1526
1500 } // namespace options 1527 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698