diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-04-05 14:08:31 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-04-11 07:46:53 +0000 |
commit | 6a4cabb866f66d4128a97cdc6d9d08ce074f1247 (patch) | |
tree | ab00f70a5e89278d6a0d16ff0c42578dc4d84a2d /chromium/components/ntp_tiles/webui | |
parent | e733310db58160074f574c429d48f8308c0afe17 (diff) | |
download | qtwebengine-chromium-6a4cabb866f66d4128a97cdc6d9d08ce074f1247.tar.gz |
BASELINE: Update Chromium to 57.0.2987.144
Change-Id: I29db402ff696c71a04c4dbaec822c2e53efe0267
Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
Diffstat (limited to 'chromium/components/ntp_tiles/webui')
10 files changed, 544 insertions, 35 deletions
diff --git a/chromium/components/ntp_tiles/webui/ntp_tiles_internals_message_handler.cc b/chromium/components/ntp_tiles/webui/ntp_tiles_internals_message_handler.cc new file mode 100644 index 00000000000..9f876ee7efb --- /dev/null +++ b/chromium/components/ntp_tiles/webui/ntp_tiles_internals_message_handler.cc @@ -0,0 +1,166 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "components/ntp_tiles/webui/ntp_tiles_internals_message_handler.h" + +#include "base/bind.h" +#include "base/callback.h" +#include "base/logging.h" +#include "base/memory/ptr_util.h" +#include "base/values.h" +#include "components/ntp_tiles/most_visited_sites.h" +#include "components/ntp_tiles/pref_names.h" +#include "components/ntp_tiles/webui/ntp_tiles_internals_message_handler_client.h" +#include "components/prefs/pref_service.h" +#include "components/url_formatter/url_fixer.h" +#include "url/gurl.h" + +namespace ntp_tiles { + +NTPTilesInternalsMessageHandlerClient::NTPTilesInternalsMessageHandlerClient() = + default; +NTPTilesInternalsMessageHandlerClient:: + ~NTPTilesInternalsMessageHandlerClient() = default; + +NTPTilesInternalsMessageHandler::NTPTilesInternalsMessageHandler() + : client_(nullptr), site_count_(8) {} + +NTPTilesInternalsMessageHandler::~NTPTilesInternalsMessageHandler() = default; + +void NTPTilesInternalsMessageHandler::RegisterMessages( + NTPTilesInternalsMessageHandlerClient* client) { + client_ = client; + + client_->RegisterMessageCallback( + "registerForEvents", + base::Bind(&NTPTilesInternalsMessageHandler::HandleRegisterForEvents, + base::Unretained(this))); + + client_->RegisterMessageCallback( + "update", base::Bind(&NTPTilesInternalsMessageHandler::HandleUpdate, + base::Unretained(this))); +} + +void NTPTilesInternalsMessageHandler::HandleRegisterForEvents( + const base::ListValue* args) { + if (!client_->SupportsNTPTiles()) { + return; + } + DCHECK(args->empty()); + + SendSourceInfo(); + + most_visited_sites_ = client_->MakeMostVisitedSites(); + most_visited_sites_->SetMostVisitedURLsObserver(this, site_count_); +} + +void NTPTilesInternalsMessageHandler::HandleUpdate( + const base::ListValue* args) { + if (!client_->SupportsNTPTiles()) { + return; + } + const base::DictionaryValue* dict = nullptr; + DCHECK_EQ(1u, args->GetSize()); + args->GetDictionary(0, &dict); + DCHECK(dict); + + PrefService* prefs = client_->GetPrefs(); + + if (client_->DoesSourceExist(ntp_tiles::NTPTileSource::POPULAR)) { + std::string url; + dict->GetString("popular.overrideURL", &url); + if (url.empty()) { + prefs->ClearPref(ntp_tiles::prefs::kPopularSitesOverrideURL); + } else { + prefs->SetString(ntp_tiles::prefs::kPopularSitesOverrideURL, + url_formatter::FixupURL(url, std::string()).spec()); + } + + std::string country; + dict->GetString("popular.overrideCountry", &country); + if (country.empty()) { + prefs->ClearPref(ntp_tiles::prefs::kPopularSitesOverrideCountry); + } else { + prefs->SetString(ntp_tiles::prefs::kPopularSitesOverrideCountry, country); + } + + std::string version; + dict->GetString("popular.overrideVersion", &version); + if (version.empty()) { + prefs->ClearPref(ntp_tiles::prefs::kPopularSitesOverrideVersion); + } else { + prefs->SetString(ntp_tiles::prefs::kPopularSitesOverrideVersion, version); + } + } + + // Recreate to pick up new values. + // TODO(sfiera): refresh MostVisitedSites without re-creating it, as soon as + // that will pick up changes to the Popular Sites overrides. + most_visited_sites_ = client_->MakeMostVisitedSites(); + most_visited_sites_->SetMostVisitedURLsObserver(this, site_count_); + SendSourceInfo(); +} + +void NTPTilesInternalsMessageHandler::SendSourceInfo() { + PrefService* prefs = client_->GetPrefs(); + base::DictionaryValue value; + + value.SetBoolean("topSites", + client_->DoesSourceExist(NTPTileSource::TOP_SITES)); + value.SetBoolean( + "suggestionsService", + client_->DoesSourceExist(NTPTileSource::SUGGESTIONS_SERVICE)); + value.SetBoolean("whitelist", + client_->DoesSourceExist(NTPTileSource::WHITELIST)); + + if (client_->DoesSourceExist(NTPTileSource::POPULAR)) { + auto popular_sites = client_->MakePopularSites(); + value.SetString("popular.url", popular_sites->GetURLToFetch().spec()); + value.SetString("popular.country", popular_sites->GetCountryToFetch()); + value.SetString("popular.version", popular_sites->GetVersionToFetch()); + + value.SetString( + "popular.overrideURL", + prefs->GetString(ntp_tiles::prefs::kPopularSitesOverrideURL)); + value.SetString( + "popular.overrideCountry", + prefs->GetString(ntp_tiles::prefs::kPopularSitesOverrideCountry)); + value.SetString( + "popular.overrideVersion", + prefs->GetString(ntp_tiles::prefs::kPopularSitesOverrideVersion)); + } else { + value.SetBoolean("popular", false); + } + + client_->CallJavascriptFunction( + "chrome.ntp_tiles_internals.receiveSourceInfo", value); +} + +void NTPTilesInternalsMessageHandler::SendTiles(const NTPTilesVector& tiles) { + auto sites_list = base::MakeUnique<base::ListValue>(); + for (const NTPTile& tile : tiles) { + auto entry = base::MakeUnique<base::DictionaryValue>(); + entry->SetString("title", tile.title); + entry->SetString("url", tile.url.spec()); + entry->SetInteger("source", static_cast<int>(tile.source)); + entry->SetString("whitelistIconPath", + tile.whitelist_icon_path.LossyDisplayName()); + sites_list->Append(std::move(entry)); + } + + base::DictionaryValue result; + result.Set("sites", std::move(sites_list)); + client_->CallJavascriptFunction("chrome.ntp_tiles_internals.receiveSites", + result); +} + +void NTPTilesInternalsMessageHandler::OnMostVisitedURLsAvailable( + const NTPTilesVector& tiles) { + SendTiles(tiles); +} + +void NTPTilesInternalsMessageHandler::OnIconMadeAvailable( + const GURL& site_url) {} + +} // namespace ntp_tiles diff --git a/chromium/components/ntp_tiles/webui/ntp_tiles_internals_message_handler.h b/chromium/components/ntp_tiles/webui/ntp_tiles_internals_message_handler.h new file mode 100644 index 00000000000..23727465e84 --- /dev/null +++ b/chromium/components/ntp_tiles/webui/ntp_tiles_internals_message_handler.h @@ -0,0 +1,61 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_NTP_TILES_WEBUI_NTP_TILES_INTERNALS_MESSAGE_HANDLER_H_ +#define COMPONENTS_NTP_TILES_WEBUI_NTP_TILES_INTERNALS_MESSAGE_HANDLER_H_ + +#include <memory> +#include <string> + +#include "base/macros.h" +#include "base/memory/weak_ptr.h" +#include "components/ntp_tiles/most_visited_sites.h" + +namespace base { +class ListValue; +} // namespace base + +namespace ntp_tiles { + +class MostVisitedSites; +class NTPTilesInternalsMessageHandlerClient; + +// Implements the WebUI message handler for chrome://ntp-tiles-internals/ +// +// Because content and iOS use different implementations of WebUI, this class +// implements the generic portion and depends on the embedder to inject a bridge +// to the embedder's API. It cannot itself implement either API directly. +class NTPTilesInternalsMessageHandler : public MostVisitedSites::Observer { + public: + NTPTilesInternalsMessageHandler(); + ~NTPTilesInternalsMessageHandler() override; + + // Called when the WebUI page's JavaScript has loaded and it is ready to + // receive RegisterMessageCallback() calls. |client| must outlive this object. + void RegisterMessages(NTPTilesInternalsMessageHandlerClient* client); + + private: + // Callbacks registered in RegisterMessages(). + void HandleRegisterForEvents(const base::ListValue* args); + void HandleUpdate(const base::ListValue* args); + + void SendSourceInfo(); + void SendTiles(const NTPTilesVector& tiles); + + // MostVisitedSites::Observer. + void OnMostVisitedURLsAvailable(const NTPTilesVector& tiles) override; + void OnIconMadeAvailable(const GURL& site_url) override; + + // Bridge to embedder's API. + NTPTilesInternalsMessageHandlerClient* client_; + + int site_count_; + std::unique_ptr<MostVisitedSites> most_visited_sites_; + + DISALLOW_COPY_AND_ASSIGN(NTPTilesInternalsMessageHandler); +}; + +} // namespace ntp_tiles + +#endif // COMPONENTS_NTP_TILES_WEBUI_NTP_TILES_INTERNALS_MESSAGE_HANDLER_H_ diff --git a/chromium/components/ntp_tiles/webui/ntp_tiles_internals_message_handler_client.cc b/chromium/components/ntp_tiles/webui/ntp_tiles_internals_message_handler_client.cc new file mode 100644 index 00000000000..3a5f3069b61 --- /dev/null +++ b/chromium/components/ntp_tiles/webui/ntp_tiles_internals_message_handler_client.cc @@ -0,0 +1,14 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "components/ntp_tiles/webui/ntp_tiles_internals_message_handler_client.h" + +namespace ntp_tiles { + +NTPTilesInternalsMessageHandlerClient::NTPTilesInternalsMessageHandlerClient() = + default; +NTPTilesInternalsMessageHandlerClient:: + ~NTPTilesInternalsMessageHandlerClient() = default; + +} // namespace ntp_tiles diff --git a/chromium/components/ntp_tiles/webui/ntp_tiles_internals_message_handler_client.h b/chromium/components/ntp_tiles/webui/ntp_tiles_internals_message_handler_client.h new file mode 100644 index 00000000000..d26972d5fc6 --- /dev/null +++ b/chromium/components/ntp_tiles/webui/ntp_tiles_internals_message_handler_client.h @@ -0,0 +1,74 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_NTP_TILES_WEBUI_NTP_TILES_INTERNALS_MESSAGE_HANDLER_CLIENT_H_ +#define COMPONENTS_NTP_TILES_WEBUI_NTP_TILES_INTERNALS_MESSAGE_HANDLER_CLIENT_H_ + +#include <memory> +#include <string> +#include <vector> + +#include "base/callback_forward.h" +#include "base/macros.h" +#include "components/ntp_tiles/ntp_tile_source.h" + +class PrefService; + +namespace base { +class Value; +class ListValue; +} // namespace base + +namespace ntp_tiles { + +class MostVisitedSites; +class PopularSites; + +// Implemented by embedders to hook up NTPTilesInternalsMessageHandler. +class NTPTilesInternalsMessageHandlerClient { + public: + // Returns the PrefService for the embedder and containing WebUI page. + virtual PrefService* GetPrefs() = 0; + + // False if in a browser mode (e.g. incognito) where tiles aren't supported. + virtual bool SupportsNTPTiles() = 0; + + // Returns true if the given source is enabled (even if, in practice, none of + // the tiles would come from it). + virtual bool DoesSourceExist(NTPTileSource source) = 0; + + // Creates a new MostVisitedSites based on the context pf the WebUI page. + virtual std::unique_ptr<ntp_tiles::MostVisitedSites> + MakeMostVisitedSites() = 0; + + // Creates a new PopularSites based on the context pf the WebUI page. + virtual std::unique_ptr<ntp_tiles::PopularSites> MakePopularSites() = 0; + + // Registers a callback in Javascript. See content::WebUI and web::WebUIIOS. + virtual void RegisterMessageCallback( + const std::string& message, + const base::Callback<void(const base::ListValue*)>& callback) = 0; + + // Invokes a function in Javascript. See content::WebUI and web::WebUIIOS. + virtual void CallJavascriptFunctionVector( + const std::string& name, + const std::vector<const base::Value*>& values) = 0; + + // Convenience function for CallJavascriptFunctionVector(). + template <typename... Arg> + void CallJavascriptFunction(const std::string& name, const Arg&... arg) { + CallJavascriptFunctionVector(name, {&arg...}); + } + + protected: + NTPTilesInternalsMessageHandlerClient(); + virtual ~NTPTilesInternalsMessageHandlerClient(); + + private: + DISALLOW_COPY_AND_ASSIGN(NTPTilesInternalsMessageHandlerClient); +}; + +} // namespace ntp_tiles + +#endif // COMPONENTS_NTP_TILES_WEBUI_NTP_TILES_INTERNALS_MESSAGE_HANDLER_CLIENT_H_ diff --git a/chromium/components/ntp_tiles/webui/popular_sites_internals_message_handler.cc b/chromium/components/ntp_tiles/webui/popular_sites_internals_message_handler.cc index 50f2252944b..29e69b93eb4 100644 --- a/chromium/components/ntp_tiles/webui/popular_sites_internals_message_handler.cc +++ b/chromium/components/ntp_tiles/webui/popular_sites_internals_message_handler.cc @@ -6,10 +6,9 @@ #include "base/bind.h" #include "base/callback.h" -#include "base/files/file_util.h" +#include "base/json/json_writer.h" #include "base/logging.h" #include "base/memory/ptr_util.h" -#include "base/task_runner_util.h" #include "base/values.h" #include "components/ntp_tiles/popular_sites.h" #include "components/ntp_tiles/pref_names.h" @@ -18,17 +17,6 @@ #include "components/url_formatter/url_fixer.h" #include "url/gurl.h" -namespace { - -std::string ReadFileToString(const base::FilePath& path) { - std::string result; - if (!base::ReadFileToString(path, &result)) - result.clear(); - return result; -} - -} // namespace - namespace ntp_tiles { PopularSitesInternalsMessageHandlerClient:: @@ -66,10 +54,7 @@ void PopularSitesInternalsMessageHandler::HandleRegisterForEvents( SendOverrides(); popular_sites_ = web_ui_->MakePopularSites(); - popular_sites_->StartFetch( - false, - base::Bind(&PopularSitesInternalsMessageHandler::OnPopularSitesAvailable, - base::Unretained(this), false)); + SendSites(); } void PopularSitesInternalsMessageHandler::HandleUpdate( @@ -101,25 +86,23 @@ void PopularSitesInternalsMessageHandler::HandleUpdate( prefs->SetString(ntp_tiles::prefs::kPopularSitesOverrideVersion, version); popular_sites_ = web_ui_->MakePopularSites(); - popular_sites_->StartFetch( + popular_sites_->MaybeStartFetch( true, base::Bind(&PopularSitesInternalsMessageHandler::OnPopularSitesAvailable, - base::Unretained(this), true)); + base::Unretained(this))); } void PopularSitesInternalsMessageHandler::HandleViewJson( const base::ListValue* args) { DCHECK_EQ(0u, args->GetSize()); - const base::FilePath& path = popular_sites_->local_path(); - base::PostTaskAndReplyWithResult( - web_ui_->GetBlockingPool() - ->GetTaskRunnerWithShutdownBehavior( - base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN) - .get(), - FROM_HERE, base::Bind(&ReadFileToString, path), - base::Bind(&PopularSitesInternalsMessageHandler::SendJson, - weak_ptr_factory_.GetWeakPtr())); + const base::ListValue* json = popular_sites_->GetCachedJson(); + std::string json_string; + if (json) { + bool success = base::JSONWriter::Write(*json, &json_string); + DCHECK(success); + } + SendJson(json_string); } void PopularSitesInternalsMessageHandler::SendOverrides() { @@ -152,7 +135,7 @@ void PopularSitesInternalsMessageHandler::SendSites() { base::DictionaryValue result; result.Set("sites", std::move(sites_list)); - result.SetString("url", popular_sites_->LastURL().spec()); + result.SetString("url", popular_sites_->GetLastURLFetched().spec()); web_ui_->CallJavascriptFunction("chrome.popular_sites_internals.receiveSites", result); } @@ -163,10 +146,8 @@ void PopularSitesInternalsMessageHandler::SendJson(const std::string& json) { } void PopularSitesInternalsMessageHandler::OnPopularSitesAvailable( - bool explicit_request, bool success) { - if (explicit_request) - SendDownloadResult(success); + SendDownloadResult(success); SendSites(); } diff --git a/chromium/components/ntp_tiles/webui/popular_sites_internals_message_handler.h b/chromium/components/ntp_tiles/webui/popular_sites_internals_message_handler.h index 3dbc74522e6..c0e05d0492b 100644 --- a/chromium/components/ntp_tiles/webui/popular_sites_internals_message_handler.h +++ b/chromium/components/ntp_tiles/webui/popular_sites_internals_message_handler.h @@ -47,7 +47,7 @@ class PopularSitesInternalsMessageHandler { void SendJson(const std::string& json); // Completion handler for popular_sites_->StartFetch(). - void OnPopularSitesAvailable(bool explicit_request, bool success); + void OnPopularSitesAvailable(bool success); // Bridge to embedder's API. PopularSitesInternalsMessageHandlerClient* web_ui_; diff --git a/chromium/components/ntp_tiles/webui/resources/ntp_tiles_internals.css b/chromium/components/ntp_tiles/webui/resources/ntp_tiles_internals.css new file mode 100644 index 00000000000..6de21e508de --- /dev/null +++ b/chromium/components/ntp_tiles/webui/resources/ntp_tiles_internals.css @@ -0,0 +1,54 @@ +/* Copyright 2016 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ + +html { + font-size: 20px; +} + +div.section { + width: 100%; + display: inline-block; + margin-left: auto; + margin-right: auto; +} + +div.section.hidden { + display: none; +} + +h2 { + color: rgb(74, 142, 230); + font-size: 100%; + margin-bottom: 0; +} + +.err { + color: red; +} + +.section-details { + width: 100%; +} + +.section-details th { + background: rgb(239, 243, 255); +} + +.section-details td { + vertical-align: top; +} + +.section-details td.detail { + text-align: right; + width: 1px; + white-space: nowrap; +} + +.section-details td.value input { + width: 100%; +} + +#json-value { + font-size: 75%; +} diff --git a/chromium/components/ntp_tiles/webui/resources/ntp_tiles_internals.html b/chromium/components/ntp_tiles/webui/resources/ntp_tiles_internals.html new file mode 100644 index 00000000000..0fb7e6f250e --- /dev/null +++ b/chromium/components/ntp_tiles/webui/resources/ntp_tiles_internals.html @@ -0,0 +1,117 @@ +<!-- +Copyright 2016 The Chromium Authors. All rights reserved. +Use of this source code is governed by a BSD-style license that can be +found in the LICENSE file. +--> +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<if expr="is_android or is_ios"> +<meta name="viewport" content="width=device-width, initial-scale=1.0"> +</if> +<title>NTP Tiles Internals</title> +<link rel="stylesheet" href="chrome://resources/css/text_defaults.css"> +<link rel="stylesheet" href="chrome://resources/css/list.css"> +<link rel="stylesheet" href="ntp_tiles_internals.css"> +<script src="chrome://resources/js/cr.js"></script> +<script src="chrome://resources/js/jstemplate_compiled.js"></script> +<script src="chrome://resources/js/load_time_data.js"></script> +<script src="chrome://resources/js/util.js"></script> +<if expr="is_ios"> +<!-- TODO(crbug.com/487000): Remove this once injected by web. --> +<script src="chrome://resources/js/ios/web_ui.js"></script> +</if> +<script src="ntp_tiles_internals.js"></script> +</head> + +<body> +<div> + <div id="sources" class="section"> + <h2>Sources</h2> + <table class="section-details"> + <tbody jsselect="topSites"> + <tr> + <th colspan="2">TOP_SITES</th> + </tr> + <tr> + <td class="detail">enabled</td> + <td class="value" jsdisplay="$this">yes</td> + <td class="value" jsdisplay="!$this">no</td> + </tr> + <tr> + <th colspan="2">SUGGESTIONS_SERVICE</th> + </tr> + </tbody> + <tbody jsselect="suggestionsService"> + <tr> + <td class="detail">enabled</td> + <td class="value" jsdisplay="$this">yes</td> + <td class="value" jsdisplay="!$this">no</td> + </tr> + </tbody> + <tbody jsselect="popular"> + <tr> + <th colspan="2">POPULAR</th> + </tr> + <tr jsdisplay="$this"> + <td class="detail">URL</td> + <td class="value"><input id="override-url" type="text" jsvalues="value:overrideURL;placeholder:url"></td> + </tr> + <tr jsdisplay="$this"> + <td class="detail">Country</td> + <td class="value"><input id="override-country" type="text" jsvalues="value:overrideCountry;placeholder:country"></td> + </tr> + <tr jsdisplay="$this"> + <td class="detail">Version</td> + <td class="value"><input id="override-version" type="text" jsvalues="values:overrideVersion;placeholder:version"></td> + </tr> + <tr jsdisplay="!$this"> + <td class="detail">enabled</td> + <td class="value">no</td> + </tr> + </tbody> + <tbody jsselect="whitelist"> + <tr> + <th colspan="2">WHITELIST</th> + </tr> + <tr> + <td class="detail">enabled</td> + <td class="value" jsdisplay="$this">yes</td> + <td class="value" jsdisplay="!$this">no</td> + </tr> + <tr jsskip="true"> + <th colspan="2"><input id="submit-update" type="submit" value="Update"></input></th> + </tr> + </tbody> + </table> + </div> + + <div id="sites" class="section"> + <h2>Sites</h2> + <table class="section-details"> + <tbody jsselect="sites"> + <tr> + <th colspan="2" jscontent="title"></th> + </tr> + <tr> + <td class="detail">Source</td> + <td class="value" jsdisplay="source < 0">???</td> + <td class="value" jsdisplay="source == 0">TOP_SITES</td> + <td class="value" jsdisplay="source == 1">SUGGESTIONS_SERVICE</td> + <td class="value" jsdisplay="source == 2">POPULAR</td> + <td class="value" jsdisplay="source == 3">WHITELIST</td> + <td class="value" jsdisplay="source > 3">???</td> + </tr> + <tr> + <td class="detail">URL</td> + <td class="value"><a jsvalues="href:url" jscontent="url"></a></td> + </tr> + </tbody> + </table> + </div> +</div> + +</body> +</html> + diff --git a/chromium/components/ntp_tiles/webui/resources/ntp_tiles_internals.js b/chromium/components/ntp_tiles/webui/resources/ntp_tiles_internals.js new file mode 100644 index 00000000000..bcb05d5e68c --- /dev/null +++ b/chromium/components/ntp_tiles/webui/resources/ntp_tiles_internals.js @@ -0,0 +1,43 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +cr.define('chrome.ntp_tiles_internals', function() { + 'use strict'; + + var initialize = function() { + receiveSites({}); + + $('submit-update').addEventListener('click', function(event) { + event.preventDefault(); + chrome.send('update', [{ + "popular": { + "overrideURL": $('override-url').value, + "overrideCountry": $('override-country').value, + "overrideVersion": $('override-version').value, + }, + }]) + }); + + chrome.send('registerForEvents'); + } + + var receiveSourceInfo = function(state) { + jstProcess(new JsEvalContext(state), $('sources')); + } + + var receiveSites = function(sites) { + jstProcess(new JsEvalContext(sites), $('sites')); + } + + // Return an object with all of the exports. + return { + initialize: initialize, + receiveSourceInfo: receiveSourceInfo, + receiveSites: receiveSites, + }; +}); + +document.addEventListener('DOMContentLoaded', + chrome.ntp_tiles_internals.initialize); + diff --git a/chromium/components/ntp_tiles/webui/resources/popular_sites_internals.html b/chromium/components/ntp_tiles/webui/resources/popular_sites_internals.html index d82e0940dd0..81d8145c963 100644 --- a/chromium/components/ntp_tiles/webui/resources/popular_sites_internals.html +++ b/chromium/components/ntp_tiles/webui/resources/popular_sites_internals.html @@ -8,8 +8,7 @@ found in the LICENSE file. <head> <meta charset="utf-8"> <if expr="is_android or is_ios"> -<meta name="viewport" content="width=device-width, initial-scale=1.0, - maximum-scale=1.0, user-scalable=no"> +<meta name="viewport" content="width=device-width, initial-scale=1.0"> </if> <title>Popular Sites Internals</title> <link rel="stylesheet" href="chrome://resources/css/text_defaults.css"> |