1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45

ash / webui / annotator / annotations_overlay_view_impl.h [blame]

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ASH_WEBUI_ANNOTATOR_ANNOTATIONS_OVERLAY_VIEW_IMPL_H_
#define ASH_WEBUI_ANNOTATOR_ANNOTATIONS_OVERLAY_VIEW_IMPL_H_

#include "ash/public/cpp/annotator/annotations_overlay_view.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "ui/base/metadata/metadata_header_macros.h"

namespace content {
class BrowserContext;
}  // namespace content

namespace views {
class WebView;
}  // namespace views

// The actual implementation of the view that will be used as the contents view
// of the annotations overlay widget. This view hosts a |views::WebView| which
// will show the contents of the annotator embedder URL.
class AnnotationsOverlayViewImpl : public ash::AnnotationsOverlayView {
  METADATA_HEADER(AnnotationsOverlayViewImpl, ash::AnnotationsOverlayView)

 public:
  explicit AnnotationsOverlayViewImpl(content::BrowserContext* profile);
  AnnotationsOverlayViewImpl(const AnnotationsOverlayViewImpl&) = delete;
  AnnotationsOverlayViewImpl& operator=(const AnnotationsOverlayViewImpl&) =
      delete;
  ~AnnotationsOverlayViewImpl() override;

  views::WebView* GetWebViewForTest() { return web_view_; }

 private:
  // Initializes `web_view_` to load the annotator app.
  void InitializeAnnotator();

  raw_ptr<views::WebView> web_view_;

  base::WeakPtrFactory<AnnotationsOverlayViewImpl> weak_ptr_factory_{this};
};

#endif  // ASH_WEBUI_ANNOTATOR_ANNOTATIONS_OVERLAY_VIEW_IMPL_H_