| 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/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 base::Bind(&NTPTilesInternalsMessageHandler::HandleRegisterForEvents, | 37 base::Bind(&NTPTilesInternalsMessageHandler::HandleRegisterForEvents, |
| 38 base::Unretained(this))); | 38 base::Unretained(this))); |
| 39 | 39 |
| 40 client_->RegisterMessageCallback( | 40 client_->RegisterMessageCallback( |
| 41 "update", base::Bind(&NTPTilesInternalsMessageHandler::HandleUpdate, | 41 "update", base::Bind(&NTPTilesInternalsMessageHandler::HandleUpdate, |
| 42 base::Unretained(this))); | 42 base::Unretained(this))); |
| 43 } | 43 } |
| 44 | 44 |
| 45 void NTPTilesInternalsMessageHandler::HandleRegisterForEvents( | 45 void NTPTilesInternalsMessageHandler::HandleRegisterForEvents( |
| 46 const base::ListValue* args) { | 46 const base::ListValue* args) { |
| 47 if (!client_->SupportsNTPTiles()) { |
| 48 return; |
| 49 } |
| 47 DCHECK(args->empty()); | 50 DCHECK(args->empty()); |
| 48 | 51 |
| 49 SendSourceInfo(); | 52 SendSourceInfo(); |
| 50 | 53 |
| 51 most_visited_sites_ = client_->MakeMostVisitedSites(); | 54 most_visited_sites_ = client_->MakeMostVisitedSites(); |
| 52 most_visited_sites_->SetMostVisitedURLsObserver(this, site_count_); | 55 most_visited_sites_->SetMostVisitedURLsObserver(this, site_count_); |
| 53 } | 56 } |
| 54 | 57 |
| 55 void NTPTilesInternalsMessageHandler::HandleUpdate( | 58 void NTPTilesInternalsMessageHandler::HandleUpdate( |
| 56 const base::ListValue* args) { | 59 const base::ListValue* args) { |
| 60 if (!client_->SupportsNTPTiles()) { |
| 61 return; |
| 62 } |
| 57 const base::DictionaryValue* dict = nullptr; | 63 const base::DictionaryValue* dict = nullptr; |
| 58 DCHECK_EQ(1u, args->GetSize()); | 64 DCHECK_EQ(1u, args->GetSize()); |
| 59 args->GetDictionary(0, &dict); | 65 args->GetDictionary(0, &dict); |
| 60 DCHECK(dict); | 66 DCHECK(dict); |
| 61 | 67 |
| 62 PrefService* prefs = client_->GetPrefs(); | 68 PrefService* prefs = client_->GetPrefs(); |
| 63 | 69 |
| 64 if (client_->DoesSourceExist(ntp_tiles::NTPTileSource::POPULAR)) { | 70 if (client_->DoesSourceExist(ntp_tiles::NTPTileSource::POPULAR)) { |
| 65 std::string url; | 71 std::string url; |
| 66 dict->GetString("popular.overrideURL", &url); | 72 dict->GetString("popular.overrideURL", &url); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 157 |
| 152 void NTPTilesInternalsMessageHandler::OnMostVisitedURLsAvailable( | 158 void NTPTilesInternalsMessageHandler::OnMostVisitedURLsAvailable( |
| 153 const NTPTilesVector& tiles) { | 159 const NTPTilesVector& tiles) { |
| 154 SendTiles(tiles); | 160 SendTiles(tiles); |
| 155 } | 161 } |
| 156 | 162 |
| 157 void NTPTilesInternalsMessageHandler::OnIconMadeAvailable( | 163 void NTPTilesInternalsMessageHandler::OnIconMadeAvailable( |
| 158 const GURL& site_url) {} | 164 const GURL& site_url) {} |
| 159 | 165 |
| 160 } // namespace ntp_tiles | 166 } // namespace ntp_tiles |
| OLD | NEW |