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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 void SiteSettingsHandler::OnGetUsageInfo( | 201 void SiteSettingsHandler::OnGetUsageInfo( |
202 const storage::UsageInfoEntries& entries) { | 202 const storage::UsageInfoEntries& entries) { |
203 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 203 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
204 | 204 |
205 for (const auto& entry : entries) { | 205 for (const auto& entry : entries) { |
206 if (entry.usage <= 0) continue; | 206 if (entry.usage <= 0) continue; |
207 if (entry.host == usage_host_) { | 207 if (entry.host == usage_host_) { |
208 CallJavascriptFunction("settings.WebsiteUsagePrivateApi.returnUsageTotal", | 208 CallJavascriptFunction("settings.WebsiteUsagePrivateApi.returnUsageTotal", |
209 base::StringValue(entry.host), | 209 base::StringValue(entry.host), |
210 base::StringValue(ui::FormatBytes(entry.usage)), | 210 base::StringValue(ui::FormatBytes(entry.usage)), |
211 base::FundamentalValue(entry.type)); | 211 base::Value(entry.type)); |
212 return; | 212 return; |
213 } | 213 } |
214 } | 214 } |
215 } | 215 } |
216 | 216 |
217 void SiteSettingsHandler::OnUsageInfoCleared(storage::QuotaStatusCode code) { | 217 void SiteSettingsHandler::OnUsageInfoCleared(storage::QuotaStatusCode code) { |
218 if (code == storage::kQuotaStatusOk) { | 218 if (code == storage::kQuotaStatusOk) { |
219 CallJavascriptFunction("settings.WebsiteUsagePrivateApi.onUsageCleared", | 219 CallJavascriptFunction("settings.WebsiteUsagePrivateApi.onUsageCleared", |
220 base::StringValue(clearing_origin_)); | 220 base::StringValue(clearing_origin_)); |
221 } | 221 } |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 void SiteSettingsHandler::HandleIsPatternValid( | 589 void SiteSettingsHandler::HandleIsPatternValid( |
590 const base::ListValue* args) { | 590 const base::ListValue* args) { |
591 CHECK_EQ(2U, args->GetSize()); | 591 CHECK_EQ(2U, args->GetSize()); |
592 const base::Value* callback_id; | 592 const base::Value* callback_id; |
593 CHECK(args->Get(0, &callback_id)); | 593 CHECK(args->Get(0, &callback_id)); |
594 std::string pattern_string; | 594 std::string pattern_string; |
595 CHECK(args->GetString(1, &pattern_string)); | 595 CHECK(args->GetString(1, &pattern_string)); |
596 | 596 |
597 ContentSettingsPattern pattern = | 597 ContentSettingsPattern pattern = |
598 ContentSettingsPattern::FromString(pattern_string); | 598 ContentSettingsPattern::FromString(pattern_string); |
599 ResolveJavascriptCallback( | 599 ResolveJavascriptCallback(*callback_id, base::Value(pattern.IsValid())); |
600 *callback_id, base::FundamentalValue(pattern.IsValid())); | |
601 } | 600 } |
602 | 601 |
603 void SiteSettingsHandler::HandleUpdateIncognitoStatus( | 602 void SiteSettingsHandler::HandleUpdateIncognitoStatus( |
604 const base::ListValue* args) { | 603 const base::ListValue* args) { |
605 AllowJavascript(); | 604 AllowJavascript(); |
606 SendIncognitoStatus(profile_, /*was_destroyed=*/ false); | 605 SendIncognitoStatus(profile_, /*was_destroyed=*/ false); |
607 } | 606 } |
608 | 607 |
609 void SiteSettingsHandler::SendIncognitoStatus( | 608 void SiteSettingsHandler::SendIncognitoStatus( |
610 Profile* profile, bool was_destroyed) { | 609 Profile* profile, bool was_destroyed) { |
611 if (!IsJavascriptAllowed()) | 610 if (!IsJavascriptAllowed()) |
612 return; | 611 return; |
613 | 612 |
614 // When an incognito profile is destroyed, it sends out the destruction | 613 // When an incognito profile is destroyed, it sends out the destruction |
615 // message before destroying, so HasOffTheRecordProfile for profile_ won't | 614 // message before destroying, so HasOffTheRecordProfile for profile_ won't |
616 // return false until after the profile actually been destroyed. | 615 // return false until after the profile actually been destroyed. |
617 bool incognito_enabled = profile_->HasOffTheRecordProfile() && | 616 bool incognito_enabled = profile_->HasOffTheRecordProfile() && |
618 !(was_destroyed && profile == profile_->GetOffTheRecordProfile()); | 617 !(was_destroyed && profile == profile_->GetOffTheRecordProfile()); |
619 | 618 |
620 CallJavascriptFunction("cr.webUIListenerCallback", | 619 CallJavascriptFunction("cr.webUIListenerCallback", |
621 base::StringValue("onIncognitoStatusChanged"), | 620 base::StringValue("onIncognitoStatusChanged"), |
622 base::FundamentalValue(incognito_enabled)); | 621 base::Value(incognito_enabled)); |
623 } | 622 } |
624 | 623 |
625 void SiteSettingsHandler::HandleFetchZoomLevels(const base::ListValue* args) { | 624 void SiteSettingsHandler::HandleFetchZoomLevels(const base::ListValue* args) { |
626 AllowJavascript(); | 625 AllowJavascript(); |
627 SendZoomLevels(); | 626 SendZoomLevels(); |
628 } | 627 } |
629 | 628 |
630 void SiteSettingsHandler::SendZoomLevels() { | 629 void SiteSettingsHandler::SendZoomLevels() { |
631 if (!IsJavascriptAllowed()) | 630 if (!IsJavascriptAllowed()) |
632 return; | 631 return; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 origin = content::kUnreachableWebDataURL; | 718 origin = content::kUnreachableWebDataURL; |
720 } | 719 } |
721 | 720 |
722 content::HostZoomMap* host_zoom_map; | 721 content::HostZoomMap* host_zoom_map; |
723 host_zoom_map = content::HostZoomMap::GetDefaultForBrowserContext(profile_); | 722 host_zoom_map = content::HostZoomMap::GetDefaultForBrowserContext(profile_); |
724 double default_level = host_zoom_map->GetDefaultZoomLevel(); | 723 double default_level = host_zoom_map->GetDefaultZoomLevel(); |
725 host_zoom_map->SetZoomLevelForHost(origin, default_level); | 724 host_zoom_map->SetZoomLevelForHost(origin, default_level); |
726 } | 725 } |
727 | 726 |
728 } // namespace settings | 727 } // namespace settings |
OLD | NEW |