blob: 88de8ee4877509dcde0f322e5041e1e11f2d8c2b [file] [log] [blame]
#include "chrome/browser/glic/shared/webui_shared.h"
#include "base/command_line.h"
#include "base/version_info/version_info.h"
#include "chrome/common/channel_info.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_switches.h"
#include "content/public/browser/web_ui_data_source.h"
namespace glic {
void ConfigureSharedWebUISource(content::WebUIDataSource& source) {
source.AddString("chromeVersion", version_info::GetVersionNumber());
source.AddString("chromeChannel",
version_info::GetChannelString(chrome::GetChannel()));
auto* command_line = base::CommandLine::ForCurrentProcess();
const bool is_glic_dev = command_line->HasSwitch(::switches::kGlicDev);
source.AddBoolean("devMode", is_glic_dev);
// Set up loading notice timeout values.
source.AddInteger("preLoadingTimeMs", features::kGlicPreLoadingTimeMs.Get());
source.AddInteger("minLoadingTimeMs", features::kGlicMinLoadingTimeMs.Get());
int max_loading_time_ms = features::kGlicMaxLoadingTimeMs.Get();
if (is_glic_dev) {
// Bump up timeout value, as dev server may be slow.
max_loading_time_ms *= 100;
}
source.AddInteger("maxLoadingTimeMs", max_loading_time_ms);
}
} // namespace glic