| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/settings/site_settings_handler.h" | 5 #include "chrome/browser/ui/webui/settings/site_settings_handler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 Profile* profile, bool was_destroyed) { | 640 Profile* profile, bool was_destroyed) { |
| 641 if (!IsJavascriptAllowed()) | 641 if (!IsJavascriptAllowed()) |
| 642 return; | 642 return; |
| 643 | 643 |
| 644 // When an incognito profile is destroyed, it sends out the destruction | 644 // When an incognito profile is destroyed, it sends out the destruction |
| 645 // message before destroying, so HasOffTheRecordProfile for profile_ won't | 645 // message before destroying, so HasOffTheRecordProfile for profile_ won't |
| 646 // return false until after the profile actually been destroyed. | 646 // return false until after the profile actually been destroyed. |
| 647 bool incognito_enabled = profile_->HasOffTheRecordProfile() && | 647 bool incognito_enabled = profile_->HasOffTheRecordProfile() && |
| 648 !(was_destroyed && profile == profile_->GetOffTheRecordProfile()); | 648 !(was_destroyed && profile == profile_->GetOffTheRecordProfile()); |
| 649 | 649 |
| 650 CallJavascriptFunction("cr.webUIListenerCallback", | 650 FireWebUIListener("onIncognitoStatusChanged", base::Value(incognito_enabled)); |
| 651 base::Value("onIncognitoStatusChanged"), | |
| 652 base::Value(incognito_enabled)); | |
| 653 } | 651 } |
| 654 | 652 |
| 655 void SiteSettingsHandler::HandleFetchZoomLevels(const base::ListValue* args) { | 653 void SiteSettingsHandler::HandleFetchZoomLevels(const base::ListValue* args) { |
| 656 AllowJavascript(); | 654 AllowJavascript(); |
| 657 SendZoomLevels(); | 655 SendZoomLevels(); |
| 658 } | 656 } |
| 659 | 657 |
| 660 void SiteSettingsHandler::SendZoomLevels() { | 658 void SiteSettingsHandler::SendZoomLevels() { |
| 661 if (!IsJavascriptAllowed()) | 659 if (!IsJavascriptAllowed()) |
| 662 return; | 660 return; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 // number. | 724 // number. |
| 727 int zoom_percent = static_cast<int>( | 725 int zoom_percent = static_cast<int>( |
| 728 content::ZoomLevelToZoomFactor(zoom_level.zoom_level) * 100 + 0.5); | 726 content::ZoomLevelToZoomFactor(zoom_level.zoom_level) * 100 + 0.5); |
| 729 exception->SetString(kZoom, base::FormatPercent(zoom_percent)); | 727 exception->SetString(kZoom, base::FormatPercent(zoom_percent)); |
| 730 exception->SetString( | 728 exception->SetString( |
| 731 site_settings::kSource, site_settings::kPreferencesSource); | 729 site_settings::kSource, site_settings::kPreferencesSource); |
| 732 // Append the new entry to the list and map. | 730 // Append the new entry to the list and map. |
| 733 zoom_levels_exceptions.Append(std::move(exception)); | 731 zoom_levels_exceptions.Append(std::move(exception)); |
| 734 } | 732 } |
| 735 | 733 |
| 736 CallJavascriptFunction("cr.webUIListenerCallback", | 734 FireWebUIListener("onZoomLevelsChanged", zoom_levels_exceptions); |
| 737 base::Value("onZoomLevelsChanged"), | |
| 738 zoom_levels_exceptions); | |
| 739 } | 735 } |
| 740 | 736 |
| 741 void SiteSettingsHandler::HandleRemoveZoomLevel(const base::ListValue* args) { | 737 void SiteSettingsHandler::HandleRemoveZoomLevel(const base::ListValue* args) { |
| 742 CHECK_EQ(1U, args->GetSize()); | 738 CHECK_EQ(1U, args->GetSize()); |
| 743 | 739 |
| 744 std::string origin; | 740 std::string origin; |
| 745 CHECK(args->GetString(0, &origin)); | 741 CHECK(args->GetString(0, &origin)); |
| 746 | 742 |
| 747 if (origin == | 743 if (origin == |
| 748 l10n_util::GetStringUTF8(IDS_ZOOMLEVELS_CHROME_ERROR_PAGES_LABEL)) { | 744 l10n_util::GetStringUTF8(IDS_ZOOMLEVELS_CHROME_ERROR_PAGES_LABEL)) { |
| 749 origin = content::kUnreachableWebDataURL; | 745 origin = content::kUnreachableWebDataURL; |
| 750 } | 746 } |
| 751 | 747 |
| 752 content::HostZoomMap* host_zoom_map; | 748 content::HostZoomMap* host_zoom_map; |
| 753 host_zoom_map = content::HostZoomMap::GetDefaultForBrowserContext(profile_); | 749 host_zoom_map = content::HostZoomMap::GetDefaultForBrowserContext(profile_); |
| 754 double default_level = host_zoom_map->GetDefaultZoomLevel(); | 750 double default_level = host_zoom_map->GetDefaultZoomLevel(); |
| 755 host_zoom_map->SetZoomLevelForHost(origin, default_level); | 751 host_zoom_map->SetZoomLevelForHost(origin, default_level); |
| 756 } | 752 } |
| 757 | 753 |
| 758 } // namespace settings | 754 } // namespace settings |
| OLD | NEW |