Commit 35bf0120 authored by David Black's avatar David Black Committed by Commit Bot

Rename AssistantWebView2 to AssistantWebView.

The name AssistantWebView is now freed up in Ash and can be used by
the AssistantWebView2 interface.

Bug: b:146520500
Change-Id: I9ddb0e5e7fe9697a7cc3a350e8607c973d4f22bf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2040733
Commit-Queue: David Black <dmblack@google.com>
Reviewed-by: default avatarTao Wu <wutao@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#739143}
parent 508ff059
......@@ -12,7 +12,7 @@ namespace ash {
// AssistantCardElement::Processor ---------------------------------------------
class AssistantCardElement::Processor : public AssistantWebView2::Observer {
class AssistantCardElement::Processor : public AssistantWebView::Observer {
public:
Processor(AssistantCardElement& card_element, ProcessingCallback callback)
: card_element_(card_element), callback_(std::move(callback)) {}
......@@ -34,7 +34,7 @@ class AssistantCardElement::Processor : public AssistantWebView2::Observer {
kPreferredWidthDip - 2 * kUiElementHorizontalMarginDip;
// Configure parameters for the card.
AssistantWebView2::InitParams contents_params;
AssistantWebView::InitParams contents_params;
contents_params.enable_auto_resize = true;
contents_params.min_size = gfx::Size(width_dip, 1);
contents_params.max_size = gfx::Size(width_dip, INT_MAX);
......@@ -59,7 +59,7 @@ class AssistantCardElement::Processor : public AssistantWebView2::Observer {
}
private:
// AssistantWebView2::Observer:
// AssistantWebView::Observer:
void DidStopLoading() override {
contents_view_->RemoveObserver(this);
......@@ -72,7 +72,7 @@ class AssistantCardElement::Processor : public AssistantWebView2::Observer {
AssistantCardElement& card_element_;
ProcessingCallback callback_;
std::unique_ptr<AssistantWebView2> contents_view_;
std::unique_ptr<AssistantWebView> contents_view_;
};
// AssistantCardElement --------------------------------------------------------
......
......@@ -9,7 +9,7 @@
#include <string>
#include "ash/assistant/model/ui/assistant_ui_element.h"
#include "ash/public/cpp/assistant/assistant_web_view_2.h"
#include "ash/public/cpp/assistant/assistant_web_view.h"
#include "base/component_export.h"
#include "base/macros.h"
......@@ -30,12 +30,9 @@ class COMPONENT_EXPORT(ASSISTANT_MODEL) AssistantCardElement
const std::string& html() const { return html_; }
const std::string& fallback() const { return fallback_; }
const AssistantWebView* contents_view() const { return contents_view_.get(); }
const AssistantWebView2* contents_view() const {
return contents_view_.get();
}
void set_contents_view(std::unique_ptr<AssistantWebView2> contents_view) {
void set_contents_view(std::unique_ptr<AssistantWebView> contents_view) {
contents_view_ = std::move(contents_view);
}
......@@ -44,7 +41,7 @@ class COMPONENT_EXPORT(ASSISTANT_MODEL) AssistantCardElement
const std::string html_;
const std::string fallback_;
std::unique_ptr<AssistantWebView2> contents_view_;
std::unique_ptr<AssistantWebView> contents_view_;
std::unique_ptr<Processor> processor_;
......
......@@ -5,20 +5,21 @@
#ifndef ASH_ASSISTANT_TEST_TEST_ASSISTANT_WEB_VIEW_H_
#define ASH_ASSISTANT_TEST_TEST_ASSISTANT_WEB_VIEW_H_
#include "ash/public/cpp/assistant/assistant_web_view_2.h"
#include "ash/public/cpp/assistant/assistant_web_view.h"
#include "base/observer_list.h"
namespace ash {
// An implementation of AssistantWebView2 for use in unittests.
class TestAssistantWebView : public AssistantWebView2 {
// An implementation of AssistantWebView for use in unittests.
class TestAssistantWebView : public AssistantWebView {
public:
TestAssistantWebView();
TestAssistantWebView(const TestAssistantWebView& copy) = delete;
TestAssistantWebView& operator=(const TestAssistantWebView& assign) = delete;
~TestAssistantWebView() override;
// AssistantWebView2:
TestAssistantWebView(const TestAssistantWebView&) = delete;
TestAssistantWebView& operator=(const TestAssistantWebView&) = delete;
// AssistantWebView:
void AddObserver(Observer* observer) override;
void RemoveObserver(Observer* observer) override;
gfx::NativeView GetNativeView() override;
......
......@@ -12,8 +12,8 @@ TestAssistantWebViewFactory::TestAssistantWebViewFactory() = default;
TestAssistantWebViewFactory::~TestAssistantWebViewFactory() = default;
std::unique_ptr<AssistantWebView2> TestAssistantWebViewFactory::Create(
const AssistantWebView2::InitParams& params) {
std::unique_ptr<AssistantWebView> TestAssistantWebViewFactory::Create(
const AssistantWebView::InitParams& params) {
return std::make_unique<TestAssistantWebView>();
}
......
......@@ -21,8 +21,8 @@ class TestAssistantWebViewFactory : public AssistantWebViewFactory {
~TestAssistantWebViewFactory() override;
// AssistantWebViewFactory:
std::unique_ptr<AssistantWebView2> Create(
const AssistantWebView2::InitParams& params) override;
std::unique_ptr<AssistantWebView> Create(
const AssistantWebView::InitParams& params) override;
};
} // namespace ash
......
......@@ -123,7 +123,7 @@ bool AssistantWebContainerView::GoBack() {
void AssistantWebContainerView::OpenUrl(const GURL& url) {
RemoveContents();
AssistantWebView2::InitParams contents_params;
AssistantWebView::InitParams contents_params;
contents_params.suppress_navigation = true;
contents_view_ = AssistantWebViewFactory::Get()->Create(contents_params);
......
......@@ -5,7 +5,7 @@
#ifndef ASH_ASSISTANT_UI_ASSISTANT_WEB_CONTAINER_VIEW_H_
#define ASH_ASSISTANT_UI_ASSISTANT_WEB_CONTAINER_VIEW_H_
#include "ash/public/cpp/assistant/assistant_web_view_2.h"
#include "ash/public/cpp/assistant/assistant_web_view.h"
#include "base/component_export.h"
#include "base/macros.h"
#include "ui/views/widget/widget_delegate.h"
......@@ -18,7 +18,7 @@ class AssistantWebViewDelegate;
// The container for hosting standalone WebContents in Assistant.
class COMPONENT_EXPORT(ASSISTANT_UI) AssistantWebContainerView
: public views::WidgetDelegateView,
public AssistantWebView2::Observer {
public AssistantWebView::Observer {
public:
AssistantWebContainerView(
AssistantViewDelegate* assistant_view_delegate,
......@@ -30,7 +30,7 @@ class COMPONENT_EXPORT(ASSISTANT_UI) AssistantWebContainerView
gfx::Size CalculatePreferredSize() const override;
void ChildPreferredSizeChanged(views::View* child) override;
// AssistantWebView2::Observer:
// AssistantWebView::Observer:
void DidStopLoading() override;
void DidSuppressNavigation(const GURL& url,
WindowOpenDisposition disposition,
......@@ -52,7 +52,7 @@ class COMPONENT_EXPORT(ASSISTANT_UI) AssistantWebContainerView
AssistantViewDelegate* const assistant_view_delegate_;
AssistantWebViewDelegate* const web_container_view_delegate_;
std::unique_ptr<AssistantWebView2> contents_view_;
std::unique_ptr<AssistantWebView> contents_view_;
DISALLOW_COPY_AND_ASSIGN(AssistantWebContainerView);
};
......
......@@ -214,8 +214,8 @@ void AssistantCardElementView::InitLayout(
GetViewAccessibility().OverrideName(card_element->fallback());
}
AssistantWebView2* AssistantCardElementView::contents_view() {
return const_cast<AssistantWebView2*>(card_element_->contents_view());
AssistantWebView* AssistantCardElementView::contents_view() {
return const_cast<AssistantWebView*>(card_element_->contents_view());
}
} // namespace ash
......@@ -8,7 +8,7 @@
#include <string>
#include "ash/assistant/ui/main_stage/assistant_ui_element_view.h"
#include "ash/public/cpp/assistant/assistant_web_view_2.h"
#include "ash/public/cpp/assistant/assistant_web_view.h"
#include "base/component_export.h"
#include "base/macros.h"
......@@ -21,7 +21,7 @@ class AssistantViewDelegate;
// AssistantCardElement. It is a child view of UiElementContainerView.
class COMPONENT_EXPORT(ASSISTANT_UI) AssistantCardElementView
: public AssistantUiElementView,
public AssistantWebView2::Observer {
public AssistantWebView::Observer {
public:
AssistantCardElementView(AssistantViewDelegate* delegate,
const AssistantCardElement* card_element);
......@@ -36,7 +36,7 @@ class COMPONENT_EXPORT(ASSISTANT_UI) AssistantCardElementView
void OnGestureEvent(ui::GestureEvent* event) override;
void ScrollRectToVisible(const gfx::Rect& rect) override;
// AssistantWebView2::Observer:
// AssistantWebView::Observer:
void DidSuppressNavigation(const GURL& url,
WindowOpenDisposition disposition,
bool from_user_gesture) override;
......@@ -51,7 +51,7 @@ class COMPONENT_EXPORT(ASSISTANT_UI) AssistantCardElementView
private:
void InitLayout(const AssistantCardElement* card_element);
AssistantWebView2* contents_view();
AssistantWebView* contents_view();
AssistantViewDelegate* const delegate_;
const AssistantCardElement* const card_element_;
......
......@@ -43,7 +43,7 @@ void ProactiveSuggestionsRichView::InitLayout() {
GetProactiveSuggestionsRichEntryPointCornerRadius());
// Initialize |contents_view_| params.
AssistantWebView2::InitParams params;
AssistantWebView::InitParams params;
params.enable_auto_resize = true;
params.min_size = gfx::Size(1, 1);
params.max_size = gfx::Size(INT_MAX, INT_MAX);
......
......@@ -8,7 +8,7 @@
#include <memory>
#include "ash/assistant/ui/proactive_suggestions_view.h"
#include "ash/public/cpp/assistant/assistant_web_view_2.h"
#include "ash/public/cpp/assistant/assistant_web_view.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "ui/events/event_observer.h"
......@@ -25,13 +25,14 @@ class ViewShadow;
class COMPONENT_EXPORT(ASSISTANT_UI) ProactiveSuggestionsRichView
: public ProactiveSuggestionsView,
public ui::EventObserver,
public AssistantWebView2::Observer {
public AssistantWebView::Observer {
public:
explicit ProactiveSuggestionsRichView(AssistantViewDelegate* delegate);
explicit ProactiveSuggestionsRichView(ProactiveSuggestionsRichView&) = delete;
~ProactiveSuggestionsRichView() override;
ProactiveSuggestionsRichView(ProactiveSuggestionsRichView&) = delete;
ProactiveSuggestionsRichView& operator=(ProactiveSuggestionsRichView&) =
delete;
~ProactiveSuggestionsRichView() override;
// ProactiveSuggestionsView:
const char* GetClassName() const override;
......@@ -49,14 +50,14 @@ class COMPONENT_EXPORT(ASSISTANT_UI) ProactiveSuggestionsRichView
using views::View::OnEvent; // Suppress clang warning.
void OnEvent(const ui::Event& event) override;
// AssistantWebView2::Observer:
// AssistantWebView::Observer:
void DidStopLoading() override;
void DidSuppressNavigation(const GURL& url,
WindowOpenDisposition disposition,
bool from_user_gesture) override;
private:
std::unique_ptr<AssistantWebView2> contents_view_;
std::unique_ptr<AssistantWebView> contents_view_;
std::unique_ptr<views::EventMonitor> event_monitor_;
std::unique_ptr<ViewShadow> view_shadow_;
......
......@@ -69,8 +69,8 @@ component("cpp") {
"assistant/assistant_state.h",
"assistant/assistant_state_base.cc",
"assistant/assistant_state_base.h",
"assistant/assistant_web_view_2.cc",
"assistant/assistant_web_view_2.h",
"assistant/assistant_web_view.cc",
"assistant/assistant_web_view.h",
"assistant/assistant_web_view_factory.cc",
"assistant/assistant_web_view_factory.h",
"assistant/conversation_starter.cc",
......
......@@ -2,19 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/public/cpp/assistant/assistant_web_view_2.h"
#include "ash/public/cpp/assistant/assistant_web_view.h"
namespace ash {
// AssistantWebView2 -----------------------------------------------------------
// AssistantWebView ------------------------------------------------------------
AssistantWebView2::AssistantWebView2() = default;
AssistantWebView2::~AssistantWebView2() = default;
AssistantWebView::AssistantWebView() = default;
AssistantWebView::~AssistantWebView() = default;
// AssistantWebView2::InitParams -----------------------------------------------
// AssistantWebView::InitParams ------------------------------------------------
AssistantWebView2::InitParams::InitParams() = default;
AssistantWebView2::InitParams::InitParams(const InitParams& copy) = default;
AssistantWebView2::InitParams::~InitParams() = default;
AssistantWebView::InitParams::InitParams() = default;
AssistantWebView::InitParams::InitParams(const InitParams& copy) = default;
AssistantWebView::InitParams::~InitParams() = default;
} // namespace ash
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_PUBLIC_CPP_ASSISTANT_ASSISTANT_WEB_VIEW_2_H_
#define ASH_PUBLIC_CPP_ASSISTANT_ASSISTANT_WEB_VIEW_2_H_
#ifndef ASH_PUBLIC_CPP_ASSISTANT_ASSISTANT_WEB_VIEW_H_
#define ASH_PUBLIC_CPP_ASSISTANT_ASSISTANT_WEB_VIEW_H_
#include "ash/public/cpp/ash_public_export.h"
#include "base/observer_list_types.h"
......@@ -15,33 +15,31 @@ enum class WindowOpenDisposition;
namespace ash {
// TODO(b/146520500): Rename to AssistantWebView after freeing up name which is
// currently in use.
// A view which wraps a views::WebView (and associated WebContents) to work
// around dependency restrictions in Ash.
class ASH_PUBLIC_EXPORT AssistantWebView2 : public views::View {
class ASH_PUBLIC_EXPORT AssistantWebView : public views::View {
public:
// Initialization parameters which dictate how an instance of
// AssistantWebView2 should behave.
// Initialization parameters which dictate how an instance of AssistantWebView
// should behave.
struct InitParams {
InitParams();
InitParams(const InitParams& copy);
~InitParams();
// If enabled, AssistantWebView2 will automatically resize to the size
// If enabled, AssistantWebView will automatically resize to the size
// desired by its embedded WebContents. Note that, if specified, the
// WebContents will be bounded by |min_size| and |max_size|.
bool enable_auto_resize = false;
base::Optional<gfx::Size> min_size = base::nullopt;
base::Optional<gfx::Size> max_size = base::nullopt;
// If enabled, AssistantWebView2 will suppress navigation attempts of its
// If enabled, AssistantWebView will suppress navigation attempts of its
// embedded WebContents. When navigation suppression occurs,
// Observer::DidSuppressNavigation() will be invoked.
bool suppress_navigation = false;
};
// An observer which receives AssistantWebView2 events.
// An observer which receives AssistantWebView events.
class Observer : public base::CheckedObserver {
public:
// Invoked when the embedded WebContents has stopped loading.
......@@ -60,7 +58,7 @@ class ASH_PUBLIC_EXPORT AssistantWebView2 : public views::View {
virtual void DidChangeFocusedNode(const gfx::Rect& node_bounds_in_screen) {}
};
~AssistantWebView2() override;
~AssistantWebView() override;
// Adds/removes the specified |observer|.
virtual void AddObserver(Observer* observer) = 0;
......@@ -78,9 +76,9 @@ class ASH_PUBLIC_EXPORT AssistantWebView2 : public views::View {
virtual void Navigate(const GURL& url) = 0;
protected:
AssistantWebView2();
AssistantWebView();
};
} // namespace ash
#endif // ASH_PUBLIC_CPP_ASSISTANT_ASSISTANT_WEB_VIEW_2_H_
#endif // ASH_PUBLIC_CPP_ASSISTANT_ASSISTANT_WEB_VIEW_H_
......@@ -8,20 +8,20 @@
#include <memory>
#include "ash/public/cpp/ash_public_export.h"
#include "ash/public/cpp/assistant/assistant_web_view_2.h"
#include "ash/public/cpp/assistant/assistant_web_view.h"
namespace ash {
// A factory implemented in Browser which is responsible for creating instances
// of AssistantWebView2 to work around dependency restrictions in Ash.
// of AssistantWebView to work around dependency restrictions in Ash.
class ASH_PUBLIC_EXPORT AssistantWebViewFactory {
public:
// Returns the singleton factory instance.
static AssistantWebViewFactory* Get();
// Creates a new AssistantWebView2 instance with the given |params|.
virtual std::unique_ptr<AssistantWebView2> Create(
const AssistantWebView2::InitParams& params) = 0;
// Creates a new AssistantWebView instance with the given |params|.
virtual std::unique_ptr<AssistantWebView> Create(
const AssistantWebView::InitParams& params) = 0;
protected:
AssistantWebViewFactory();
......
......@@ -12,7 +12,7 @@ AssistantWebViewFactoryImpl::AssistantWebViewFactoryImpl(Profile* profile)
AssistantWebViewFactoryImpl::~AssistantWebViewFactoryImpl() = default;
std::unique_ptr<ash::AssistantWebView2> AssistantWebViewFactoryImpl::Create(
const ash::AssistantWebView2::InitParams& params) {
std::unique_ptr<ash::AssistantWebView> AssistantWebViewFactoryImpl::Create(
const ash::AssistantWebView::InitParams& params) {
return std::make_unique<AssistantWebViewImpl>(profile_, params);
}
......@@ -14,14 +14,14 @@ class Profile;
class AssistantWebViewFactoryImpl : public ash::AssistantWebViewFactory {
public:
explicit AssistantWebViewFactoryImpl(Profile* profile);
AssistantWebViewFactoryImpl(AssistantWebViewFactoryImpl& copy) = delete;
AssistantWebViewFactoryImpl& operator=(AssistantWebViewFactoryImpl& assign) =
delete;
~AssistantWebViewFactoryImpl() override;
AssistantWebViewFactoryImpl(AssistantWebViewFactoryImpl&) = delete;
AssistantWebViewFactoryImpl& operator=(AssistantWebViewFactoryImpl&) = delete;
// ash::AssistantWebViewFactory:
std::unique_ptr<ash::AssistantWebView2> Create(
const ash::AssistantWebView2::InitParams& params) override;
std::unique_ptr<ash::AssistantWebView> Create(
const ash::AssistantWebView::InitParams& params) override;
private:
Profile* const profile_;
......
......@@ -5,7 +5,7 @@
#ifndef CHROME_BROWSER_UI_ASH_ASSISTANT_ASSISTANT_WEB_VIEW_IMPL_H_
#define CHROME_BROWSER_UI_ASH_ASSISTANT_ASSISTANT_WEB_VIEW_IMPL_H_
#include "ash/public/cpp/assistant/assistant_web_view_2.h"
#include "ash/public/cpp/assistant/assistant_web_view.h"
#include "base/observer_list.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/browser/web_contents_observer.h"
......@@ -20,18 +20,19 @@ namespace views {
class WebView;
} // namespace views
// Implements AssistantWebView2 used by Ash to work around dependency
// Implements AssistantWebView used by Ash to work around dependency
// restrictions.
class AssistantWebViewImpl : public ash::AssistantWebView2,
class AssistantWebViewImpl : public ash::AssistantWebView,
public content::WebContentsDelegate,
public content::WebContentsObserver {
public:
explicit AssistantWebViewImpl(Profile* profile, const InitParams& params);
AssistantWebViewImpl(AssistantWebViewImpl& copy) = delete;
AssistantWebViewImpl& operator=(AssistantWebViewImpl& assign) = delete;
~AssistantWebViewImpl() override;
// ash::AssistantWebView2:
AssistantWebViewImpl(AssistantWebViewImpl&) = delete;
AssistantWebViewImpl& operator=(AssistantWebViewImpl&) = delete;
// ash::AssistantWebView:
const char* GetClassName() const override;
gfx::NativeView GetNativeView() override;
void ChildPreferredSizeChanged(views::View* child) override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment