chromium/chrome/browser/ui/views/screen_capture_notification_ui_views.cc

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

#include "chrome/browser/ui/screen_capture_notification_ui.h"

#include <memory>

#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/scoped_multi_source_observation.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/ui/views/chrome_views_export.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/theme_resources.h"
#include "content/public/browser/web_contents.h"
#include "ui/base/hit_test.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/color/color_id.h"
#include "ui/color/color_provider.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/views/background.h"
#include "ui/views/bubble/bubble_border.h"
#include "ui/views/bubble/bubble_frame_view.h"
#include "ui/views/controls/button/md_text_button.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/link.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"

#if BUILDFLAG(IS_WIN)
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/shell_integration_win.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "content/public/browser/web_contents.h"
#include "ui/base/win/shell.h"
#include "ui/views/win/hwnd_util.h"
#endif

#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ash/shell.h"
#endif

namespace {

const int kHorizontalMargin =;
const float kWindowAlphaValue =;

// A ClientView that overrides NonClientHitTest() so that the whole window area
// acts as a window caption, except a rect specified using SetClientRect().
// ScreenCaptureNotificationUIViews uses this class to make the notification bar
// draggable.
class NotificationBarClientView : public views::ClientView {};

BEGIN_METADATA()

class ScreenCaptureNotificationUIViews : public views::WidgetDelegateView,
                                         public views::ViewObserver {};

// ScreenCaptureNotificationUI implementation using Views.
class ScreenCaptureNotificationUIImpl : public ScreenCaptureNotificationUI {};

ScreenCaptureNotificationUIViews::ScreenCaptureNotificationUIViews(
    const std::u16string& text,
    content::WebContents* capturing_web_contents,
    base::OnceClosure stop_callback,
    content::MediaStreamUI::SourceCallback source_callback)
    :{}

ScreenCaptureNotificationUIViews::~ScreenCaptureNotificationUIViews() {}

views::ClientView* ScreenCaptureNotificationUIViews::CreateClientView(
    views::Widget* widget) {}

std::unique_ptr<views::NonClientFrameView>
ScreenCaptureNotificationUIViews::CreateNonClientFrameView(
    views::Widget* widget) {}

void ScreenCaptureNotificationUIViews::OnViewBoundsChanged(
    views::View* observed_view) {}

void ScreenCaptureNotificationUIViews::OnViewIsDeleting(
    views::View* observed_view) {}

void ScreenCaptureNotificationUIViews::NotifySourceChange() {}

void ScreenCaptureNotificationUIViews::NotifyStopped() {}

BEGIN_METADATA()

ScreenCaptureNotificationUIImpl::ScreenCaptureNotificationUIImpl(
    const std::u16string& text,
    content::WebContents* capturing_web_contents)
    :{}

gfx::NativeViewId ScreenCaptureNotificationUIImpl::OnStarted(
    base::OnceClosure stop_callback,
    content::MediaStreamUI::SourceCallback source_callback,
    const std::vector<content::DesktopMediaID>& media_ids) {}

#if BUILDFLAG(IS_WIN)
void ScreenCaptureNotificationUIImpl::SetWindowsAppId(views::Widget* widget) {
  if (!capturing_web_contents_) {
    return;
  }
  Browser* browser = chrome::FindBrowserWithTab(capturing_web_contents_.get());
  // Can be nullptr from extension background page call.
  if (!browser) {
    return;
  }
  const base::FilePath profile_path = browser->profile()->GetPath();
  std::wstring app_user_model_id =
      browser->is_type_app()
          ? shell_integration::win::GetAppUserModelIdForApp(
                base::UTF8ToWide(browser->app_name()), profile_path)
          : shell_integration::win::GetAppUserModelIdForBrowser(profile_path);
  if (!app_user_model_id.empty()) {
    ui::win::SetAppIdForWindow(app_user_model_id, views::HWNDForWidget(widget));
  }
}
#endif  // BUILDFLAG(IS_WIN)

}  // namespace

std::unique_ptr<ScreenCaptureNotificationUI>
ScreenCaptureNotificationUI::Create(
    const std::u16string& text,
    content::WebContents* capturing_web_contents) {}