Commit bb2966ae authored by dnicoara@chromium.org's avatar dnicoara@chromium.org

Don't bother asking the platform for the delegates if they are already set

For Ozone, there is no default platform. Since the unittests use their own
delegates this simplifies things by not requiring an Ozone platform when
executing the unittests.

BUG=none

Review URL: https://codereview.chromium.org/383463002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282188 0039d316-1c4b-4281-b951-d872f2087c98
parent 40b18bec
...@@ -164,7 +164,8 @@ void DisplayConfigurator::SetDelegatesForTesting( ...@@ -164,7 +164,8 @@ void DisplayConfigurator::SetDelegatesForTesting(
DCHECK(!native_display_delegate_); DCHECK(!native_display_delegate_);
DCHECK(!touchscreen_delegate_); DCHECK(!touchscreen_delegate_);
InitializeDelegates(display_delegate.Pass(), touchscreen_delegate.Pass()); native_display_delegate_ = display_delegate.Pass();
touchscreen_delegate_ = touchscreen_delegate.Pass();
configure_display_ = true; configure_display_ = true;
} }
...@@ -179,18 +180,15 @@ void DisplayConfigurator::Init(bool is_panel_fitting_enabled) { ...@@ -179,18 +180,15 @@ void DisplayConfigurator::Init(bool is_panel_fitting_enabled) {
if (!configure_display_) if (!configure_display_)
return; return;
PlatformInitialize(); // If the delegates are already initialized don't update them (For example,
} // tests set their own delegates).
if (!native_display_delegate_) {
void DisplayConfigurator::InitializeDelegates( native_display_delegate_ = CreatePlatformNativeDisplayDelegate();
scoped_ptr<NativeDisplayDelegate> display_delegate,
scoped_ptr<TouchscreenDelegate> touchscreen_delegate) {
if (!native_display_delegate_ && !touchscreen_delegate_) {
native_display_delegate_ = display_delegate.Pass();
touchscreen_delegate_ = touchscreen_delegate.Pass();
native_display_delegate_->AddObserver(this); native_display_delegate_->AddObserver(this);
} }
if (!touchscreen_delegate_)
touchscreen_delegate_ = CreatePlatformTouchscreenDelegate();
} }
void DisplayConfigurator::ForceInitialConfigure( void DisplayConfigurator::ForceInitialConfigure(
......
...@@ -255,14 +255,9 @@ class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver { ...@@ -255,14 +255,9 @@ class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver {
typedef std::map<ContentProtectionClientId, ContentProtections> typedef std::map<ContentProtectionClientId, ContentProtections>
ProtectionRequests; ProtectionRequests;
// If |native_display_delegate_| and |touchscreen_delegate_| are not set, then
// set them to the passed in values.
void InitializeDelegates(
scoped_ptr<NativeDisplayDelegate> display_delegate,
scoped_ptr<TouchscreenDelegate> touchscreen_delegate);
// Performs platform specific delegate initialization. // Performs platform specific delegate initialization.
void PlatformInitialize(); scoped_ptr<NativeDisplayDelegate> CreatePlatformNativeDisplayDelegate();
scoped_ptr<TouchscreenDelegate> CreatePlatformTouchscreenDelegate();
// Updates |cached_displays_| to contain currently-connected displays. Calls // Updates |cached_displays_| to contain currently-connected displays. Calls
// |delegate_->GetDisplays()| and then does additional work, like finding the // |delegate_->GetDisplays()| and then does additional work, like finding the
......
...@@ -11,11 +11,15 @@ ...@@ -11,11 +11,15 @@
namespace ui { namespace ui {
void DisplayConfigurator::PlatformInitialize() { scoped_ptr<NativeDisplayDelegate>
InitializeDelegates( DisplayConfigurator::CreatePlatformNativeDisplayDelegate() {
ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate(), return ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate();
scoped_ptr<TouchscreenDelegate>(new TouchscreenDelegateImpl( }
ui::OzonePlatform::GetInstance()->CreateTouchscreenDeviceManager())));
scoped_ptr<DisplayConfigurator::TouchscreenDelegate>
DisplayConfigurator::CreatePlatformTouchscreenDelegate() {
return scoped_ptr<TouchscreenDelegate>(new TouchscreenDelegateImpl(
ui::OzonePlatform::GetInstance()->CreateTouchscreenDeviceManager()));
} }
} // namespace ui } // namespace ui
...@@ -10,12 +10,16 @@ ...@@ -10,12 +10,16 @@
namespace ui { namespace ui {
void DisplayConfigurator::PlatformInitialize() { scoped_ptr<NativeDisplayDelegate>
InitializeDelegates( DisplayConfigurator::CreatePlatformNativeDisplayDelegate() {
scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateX11()), return scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateX11());
scoped_ptr<TouchscreenDelegate>(new TouchscreenDelegateImpl( }
scoped_ptr<TouchscreenDeviceManager>(
new TouchscreenDeviceManagerX11())))); scoped_ptr<DisplayConfigurator::TouchscreenDelegate>
DisplayConfigurator::CreatePlatformTouchscreenDelegate() {
return scoped_ptr<TouchscreenDelegate>(new TouchscreenDelegateImpl(
scoped_ptr<TouchscreenDeviceManager>(
new TouchscreenDeviceManagerX11())));
} }
} // namespace ui } // namespace ui
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