diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-14 01:56:05 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-14 01:56:05 +0000 |
commit | f1c9826afffc7f26e760d3a987b822ec401af0d9 (patch) | |
tree | a4b348ca510cda478d9e1d4982b5744e51bbf8b0 /ash/test/ash_test_views_delegate.cc | |
parent | edf82d1c54334d45226bbb91d2cb51cd000f7b6f (diff) | |
download | chromium_src-f1c9826afffc7f26e760d3a987b822ec401af0d9.zip chromium_src-f1c9826afffc7f26e760d3a987b822ec401af0d9.tar.gz chromium_src-f1c9826afffc7f26e760d3a987b822ec401af0d9.tar.bz2 |
Reduce creation of ViewsDelegate
By consolidating override of OnBeforeWidgetInit that finds shell many
of the places that were setting a viewsdelegate no longer need to.
Also, made AshTestHelper install a ViewsDelegate so that tests don't have.
Because of removed an include of views_delegate from ash_test_helper I had to update some includes.
BUG=none
TEST=none
R=ben@chromium.org
Review URL: https://codereview.chromium.org/280863002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@270290 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/test/ash_test_views_delegate.cc')
-rw-r--r-- | ash/test/ash_test_views_delegate.cc | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/ash/test/ash_test_views_delegate.cc b/ash/test/ash_test_views_delegate.cc new file mode 100644 index 0000000..c47bdba --- /dev/null +++ b/ash/test/ash_test_views_delegate.cc @@ -0,0 +1,38 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ash/test/ash_test_views_delegate.h" + +#include "ash/shell.h" +#include "content/public/test/web_contents_tester.h" + +namespace ash { +namespace test { + +AshTestViewsDelegate::AshTestViewsDelegate() { +} + +AshTestViewsDelegate::~AshTestViewsDelegate() { +} + +content::WebContents* AshTestViewsDelegate::CreateWebContents( + content::BrowserContext* browser_context, + content::SiteInstance* site_instance) { + return content::WebContentsTester::CreateTestWebContents(browser_context, + site_instance); +} + +void AshTestViewsDelegate::OnBeforeWidgetInit( + views::Widget::InitParams* params, + views::internal::NativeWidgetDelegate* delegate) { + TestViewsDelegate::OnBeforeWidgetInit(params, delegate); + + if (!params->parent && !params->context && ash::Shell::HasInstance()) { + // If the window has neither a parent nor a context add to the root. + params->parent = ash::Shell::GetInstance()->GetPrimaryRootWindow(); + } +} + +} // namespace test +} // namespace ash |