#include "chrome/browser/ui/views/hats/hats_next_web_dialog.h"
#include "base/base64url.h"
#include "base/feature_list.h"
#include "base/json/json_writer.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/notreached.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/devtools/devtools_window.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_destroyer.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/hats/hats_service.h"
#include "chrome/browser/ui/hats/hats_service_desktop.h"
#include "chrome/browser/ui/hats/hats_service_factory.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/views/frame/app_menu_button.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/toolbar_button_provider.h"
#include "chrome/browser/ui/views/frame/top_container_view.h"
#include "chrome/browser/ui/webui/chrome_web_contents_handler.h"
#include "chrome/browser/ui/webui/hats/hats_ui.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_isolated_world_ids.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/webui_url_constants.h"
#include "components/constrained_window/constrained_window_views.h"
#include "components/version_info/version_info.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_ui.h"
#include "net/base/url_util.h"
#include "third_party/blink/public/common/page/page_zoom.h"
#include "third_party/re2/src/re2/re2.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/mojom/dialog_button.mojom.h"
#include "ui/base/ui_base_types.h"
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
#include "ui/views/bubble/bubble_frame_view.h"
#include "ui/views/controls/webview/web_dialog_view.h"
#include "ui/views/controls/webview/webview.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/web_dialogs/web_dialog_delegate.h"
constexpr gfx::Size HatsNextWebDialog::kMinSize;
constexpr gfx::Size HatsNextWebDialog::kMaxSize;
constexpr char kSurveyQuestionAnsweredRegex[] = …;
constexpr char kSurveyQuestionAnsweredAnswerRegex[] = …;
constexpr char kHatsHistogramPrefix[] = …;
constexpr char kHatsSurveyCompletedHistogram[] = …;
void LogUmaHistogramSparse(const std::optional<std::string>& histogram_name,
int enumeration) { … }
void LogUmaHistogramSparse(
const std::optional<std::string>& histogram_name,
HatsNextWebDialog::SurveyHistogramEnumeration enumeration) { … }
class HatsNextWebDialog::HatsWebView : public views::WebView { … };
BEGIN_METADATA(…)
END_METADATA
HatsNextWebDialog::HatsNextWebDialog(
Browser* browser,
const std::string& trigger_id,
const std::optional<std::string>& histogram_name,
base::OnceClosure success_callback,
base::OnceClosure failure_callback,
const SurveyBitsData& product_specific_bits_data,
const SurveyStringData& product_specific_string_data)
: … { … }
gfx::Size HatsNextWebDialog::CalculatePreferredSize(
const views::SizeBounds& available_size) const { … }
void HatsNextWebDialog::OnProfileWillBeDestroyed(Profile* profile) { … }
std::string HatsNextWebDialog::GetTriggerId() { … }
bool HatsNextWebDialog::GetEnableTesting() { … }
std::vector<std::string> HatsNextWebDialog::GetLanguageList() { … }
base::Value::Dict HatsNextWebDialog::GetProductSpecificDataJson() { … }
std::optional<std::string> HatsNextWebDialog::GetHistogramName() { … }
void HatsNextWebDialog::OnSurveyLoaded() { … }
void HatsNextWebDialog::OnSurveyCompleted() { … }
void HatsNextWebDialog::OnSurveyClosed() { … }
void HatsNextWebDialog::OnSurveyQuestionAnswered(const std::string& state) { … }
bool HatsNextWebDialog::ParseSurveyQuestionAnswer(const std::string& input,
int* question,
std::vector<int>* answers) { … }
HatsNextWebDialog::HatsNextWebDialog(
Browser* browser,
const std::string& trigger_id,
const std::optional<std::string>& histogram_name,
const GURL& hats_survey_url,
const base::TimeDelta& timeout,
base::OnceClosure success_callback,
base::OnceClosure failure_callback,
const SurveyBitsData& product_specific_bits_data,
const SurveyStringData& product_specific_string_data)
: … { … }
HatsNextWebDialog::~HatsNextWebDialog() { … }
GURL HatsNextWebDialog::GetParameterizedHatsURL() const { … }
void HatsNextWebDialog::LoadTimedOut() { … }
void HatsNextWebDialog::OnSurveyStateUpdateReceived(std::string state) { … }
void HatsNextWebDialog::SetHatsSurveyURLforTesting(GURL url) { … }
void HatsNextWebDialog::ShowWidget() { … }
void HatsNextWebDialog::CloseWidget() { … }
bool HatsNextWebDialog::IsWaitingForSurveyForTesting() { … }
int HatsNextWebDialog::GetHistogramBucket(int question, int answer) { … }
BEGIN_METADATA(…)