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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 void SiteSettingsHandler::OnGetUsageInfo( | 196 void SiteSettingsHandler::OnGetUsageInfo( |
197 const storage::UsageInfoEntries& entries) { | 197 const storage::UsageInfoEntries& entries) { |
198 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 198 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
199 | 199 |
200 for (const auto& entry : entries) { | 200 for (const auto& entry : entries) { |
201 if (entry.usage <= 0) continue; | 201 if (entry.usage <= 0) continue; |
202 if (entry.host == usage_host_) { | 202 if (entry.host == usage_host_) { |
203 CallJavascriptFunction("settings.WebsiteUsagePrivateApi.returnUsageTotal", | 203 CallJavascriptFunction("settings.WebsiteUsagePrivateApi.returnUsageTotal", |
204 base::StringValue(entry.host), | 204 base::StringValue(entry.host), |
205 base::StringValue(ui::FormatBytes(entry.usage)), | 205 base::StringValue(ui::FormatBytes(entry.usage)), |
206 base::FundamentalValue(entry.type)); | 206 base::Value(entry.type)); |
207 return; | 207 return; |
208 } | 208 } |
209 } | 209 } |
210 } | 210 } |
211 | 211 |
212 void SiteSettingsHandler::OnUsageInfoCleared(storage::QuotaStatusCode code) { | 212 void SiteSettingsHandler::OnUsageInfoCleared(storage::QuotaStatusCode code) { |
213 if (code == storage::kQuotaStatusOk) { | 213 if (code == storage::kQuotaStatusOk) { |
214 CallJavascriptFunction("settings.WebsiteUsagePrivateApi.onUsageCleared", | 214 CallJavascriptFunction("settings.WebsiteUsagePrivateApi.onUsageCleared", |
215 base::StringValue(clearing_origin_)); | 215 base::StringValue(clearing_origin_)); |
216 } | 216 } |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 const base::ListValue* args) { | 574 const base::ListValue* args) { |
575 CHECK_EQ(2U, args->GetSize()); | 575 CHECK_EQ(2U, args->GetSize()); |
576 const base::Value* callback_id; | 576 const base::Value* callback_id; |
577 CHECK(args->Get(0, &callback_id)); | 577 CHECK(args->Get(0, &callback_id)); |
578 std::string pattern_string; | 578 std::string pattern_string; |
579 CHECK(args->GetString(1, &pattern_string)); | 579 CHECK(args->GetString(1, &pattern_string)); |
580 | 580 |
581 ContentSettingsPattern pattern = | 581 ContentSettingsPattern pattern = |
582 ContentSettingsPattern::FromString(pattern_string); | 582 ContentSettingsPattern::FromString(pattern_string); |
583 ResolveJavascriptCallback( | 583 ResolveJavascriptCallback( |
584 *callback_id, base::FundamentalValue(pattern.IsValid())); | 584 *callback_id, base::Value(pattern.IsValid())); |
585 } | 585 } |
586 | 586 |
587 void SiteSettingsHandler::HandleUpdateIncognitoStatus( | 587 void SiteSettingsHandler::HandleUpdateIncognitoStatus( |
588 const base::ListValue* args) { | 588 const base::ListValue* args) { |
589 AllowJavascript(); | 589 AllowJavascript(); |
590 SendIncognitoStatus(profile_, /*was_destroyed=*/ false); | 590 SendIncognitoStatus(profile_, /*was_destroyed=*/ false); |
591 } | 591 } |
592 | 592 |
593 void SiteSettingsHandler::SendIncognitoStatus( | 593 void SiteSettingsHandler::SendIncognitoStatus( |
594 Profile* profile, bool was_destroyed) { | 594 Profile* profile, bool was_destroyed) { |
595 if (!IsJavascriptAllowed()) | 595 if (!IsJavascriptAllowed()) |
596 return; | 596 return; |
597 | 597 |
598 // When an incognito profile is destroyed, it sends out the destruction | 598 // When an incognito profile is destroyed, it sends out the destruction |
599 // message before destroying, so HasOffTheRecordProfile for profile_ won't | 599 // message before destroying, so HasOffTheRecordProfile for profile_ won't |
600 // return false until after the profile actually been destroyed. | 600 // return false until after the profile actually been destroyed. |
601 bool incognito_enabled = profile_->HasOffTheRecordProfile() && | 601 bool incognito_enabled = profile_->HasOffTheRecordProfile() && |
602 !(was_destroyed && profile == profile_->GetOffTheRecordProfile()); | 602 !(was_destroyed && profile == profile_->GetOffTheRecordProfile()); |
603 | 603 |
604 CallJavascriptFunction("cr.webUIListenerCallback", | 604 CallJavascriptFunction("cr.webUIListenerCallback", |
605 base::StringValue("onIncognitoStatusChanged"), | 605 base::StringValue("onIncognitoStatusChanged"), |
606 base::FundamentalValue(incognito_enabled)); | 606 base::Value(incognito_enabled)); |
607 } | 607 } |
608 | 608 |
609 void SiteSettingsHandler::HandleFetchZoomLevels(const base::ListValue* args) { | 609 void SiteSettingsHandler::HandleFetchZoomLevels(const base::ListValue* args) { |
610 AllowJavascript(); | 610 AllowJavascript(); |
611 SendZoomLevels(); | 611 SendZoomLevels(); |
612 } | 612 } |
613 | 613 |
614 void SiteSettingsHandler::SendZoomLevels() { | 614 void SiteSettingsHandler::SendZoomLevels() { |
615 if (!IsJavascriptAllowed()) | 615 if (!IsJavascriptAllowed()) |
616 return; | 616 return; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 origin = content::kUnreachableWebDataURL; | 688 origin = content::kUnreachableWebDataURL; |
689 } | 689 } |
690 | 690 |
691 content::HostZoomMap* host_zoom_map; | 691 content::HostZoomMap* host_zoom_map; |
692 host_zoom_map = content::HostZoomMap::GetDefaultForBrowserContext(profile_); | 692 host_zoom_map = content::HostZoomMap::GetDefaultForBrowserContext(profile_); |
693 double default_level = host_zoom_map->GetDefaultZoomLevel(); | 693 double default_level = host_zoom_map->GetDefaultZoomLevel(); |
694 host_zoom_map->SetZoomLevelForHost(origin, default_level); | 694 host_zoom_map->SetZoomLevelForHost(origin, default_level); |
695 } | 695 } |
696 | 696 |
697 } // namespace settings | 697 } // namespace settings |
OLD | NEW |