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 "components/ntp_tiles/webui/ntp_tiles_internals_message_handler.h" | 5 #include "components/ntp_tiles/webui/ntp_tiles_internals_message_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 client_->RegisterMessageCallback( | 65 client_->RegisterMessageCallback( |
66 "viewPopularSitesJson", | 66 "viewPopularSitesJson", |
67 base::Bind(&NTPTilesInternalsMessageHandler::HandleViewPopularSitesJson, | 67 base::Bind(&NTPTilesInternalsMessageHandler::HandleViewPopularSitesJson, |
68 base::Unretained(this))); | 68 base::Unretained(this))); |
69 } | 69 } |
70 | 70 |
71 void NTPTilesInternalsMessageHandler::HandleRegisterForEvents( | 71 void NTPTilesInternalsMessageHandler::HandleRegisterForEvents( |
72 const base::ListValue* args) { | 72 const base::ListValue* args) { |
73 if (!client_->SupportsNTPTiles()) { | 73 if (!client_->SupportsNTPTiles()) { |
| 74 base::DictionaryValue disabled; |
| 75 disabled.SetBoolean("topSites", false); |
| 76 disabled.SetBoolean("suggestionsService", false); |
| 77 disabled.SetBoolean("popular", false); |
| 78 disabled.SetBoolean("whitelist", false); |
| 79 client_->CallJavascriptFunction( |
| 80 "chrome.ntp_tiles_internals.receiveSourceInfo", disabled); |
| 81 SendTiles(NTPTilesVector()); |
74 return; | 82 return; |
75 } | 83 } |
76 DCHECK(args->empty()); | 84 DCHECK(args->empty()); |
77 | 85 |
78 suggestions_status_.clear(); | 86 suggestions_status_.clear(); |
79 popular_sites_json_.clear(); | 87 popular_sites_json_.clear(); |
80 most_visited_sites_ = client_->MakeMostVisitedSites(); | 88 most_visited_sites_ = client_->MakeMostVisitedSites(); |
81 most_visited_sites_->SetMostVisitedURLsObserver(this, site_count_); | 89 most_visited_sites_->SetMostVisitedURLsObserver(this, site_count_); |
82 SendSourceInfo(); | 90 SendSourceInfo(); |
83 } | 91 } |
84 | 92 |
85 void NTPTilesInternalsMessageHandler::HandleUpdate( | 93 void NTPTilesInternalsMessageHandler::HandleUpdate( |
86 const base::ListValue* args) { | 94 const base::ListValue* args) { |
87 if (!client_->SupportsNTPTiles()) { | 95 if (!client_->SupportsNTPTiles()) { |
88 return; | 96 return; |
89 } | 97 } |
| 98 |
90 const base::DictionaryValue* dict = nullptr; | 99 const base::DictionaryValue* dict = nullptr; |
91 DCHECK_EQ(1u, args->GetSize()); | 100 DCHECK_EQ(1u, args->GetSize()); |
92 args->GetDictionary(0, &dict); | 101 args->GetDictionary(0, &dict); |
93 DCHECK(dict); | 102 DCHECK(dict); |
94 | 103 |
95 PrefService* prefs = client_->GetPrefs(); | 104 PrefService* prefs = client_->GetPrefs(); |
96 | 105 |
97 if (most_visited_sites_->DoesSourceExist(ntp_tiles::NTPTileSource::POPULAR)) { | 106 if (most_visited_sites_->DoesSourceExist(ntp_tiles::NTPTileSource::POPULAR)) { |
98 popular_sites_json_.clear(); | 107 popular_sites_json_.clear(); |
99 | 108 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 230 |
222 void NTPTilesInternalsMessageHandler::OnMostVisitedURLsAvailable( | 231 void NTPTilesInternalsMessageHandler::OnMostVisitedURLsAvailable( |
223 const NTPTilesVector& tiles) { | 232 const NTPTilesVector& tiles) { |
224 SendTiles(tiles); | 233 SendTiles(tiles); |
225 } | 234 } |
226 | 235 |
227 void NTPTilesInternalsMessageHandler::OnIconMadeAvailable( | 236 void NTPTilesInternalsMessageHandler::OnIconMadeAvailable( |
228 const GURL& site_url) {} | 237 const GURL& site_url) {} |
229 | 238 |
230 } // namespace ntp_tiles | 239 } // namespace ntp_tiles |
OLD | NEW |