Commit bbf59b20 authored by xiyuan@chromium.org's avatar xiyuan@chromium.org

Share TabFirstRenderWatcher with HtmlDialogView.

- Move TabFirstRenderWatcher out of chromeos and combine the logic with HTMLDialgoView.
- Update HtmlDialogBrowserTest.TestStateTransition and move state transition test into TabFirstRenderWatcherTest.TestStateTransition;
- HtmlDialogBrowserTest.TestStateTransition -> WebContentRendered as it only tests OnTabMainFrameFirstRender is callled now;
- Conslidate two TestHtmlDialogUIDelegate into one;

Will share it with the auro app list window to avoid initial jankiness.

BUG=98308,86059
TEST=Hold until all app list changes are in.


Review URL: http://codereview.chromium.org/8417005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108206 0039d316-1c4b-4281-b951-d872f2087c98
parent ac08b147
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "chrome/browser/chromeos/login/login_html_dialog.h" #include "chrome/browser/chromeos/login/login_html_dialog.h"
#include "chrome/browser/chromeos/status/status_area_host.h" #include "chrome/browser/chromeos/status/status_area_host.h"
#include "chrome/browser/chromeos/tab_first_render_watcher.h" #include "chrome/browser/tab_first_render_watcher.h"
#include "chrome/browser/ui/views/unhandled_keyboard_event_handler.h" #include "chrome/browser/ui/views/unhandled_keyboard_event_handler.h"
#include "content/browser/tab_contents/tab_contents_delegate.h" #include "content/browser/tab_contents/tab_contents_delegate.h"
#include "views/widget/widget_delegate.h" #include "views/widget/widget_delegate.h"
...@@ -26,7 +26,6 @@ class Widget; ...@@ -26,7 +26,6 @@ class Widget;
namespace chromeos { namespace chromeos {
class StatusAreaView; class StatusAreaView;
class TabFirstRenderWatcher;
// View used to render a WebUI supporting Widget. This widget is used for the // View used to render a WebUI supporting Widget. This widget is used for the
// WebUI based start up and lock screens. It contains a StatusAreaView and // WebUI based start up and lock screens. It contains a StatusAreaView and
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/chromeos/tab_first_render_watcher.h" #include "chrome/browser/tab_first_render_watcher.h"
#include "content/browser/renderer_host/render_widget_host.h" #include "content/browser/renderer_host/render_widget_host.h"
#include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/render_view_host.h"
...@@ -10,8 +10,6 @@ ...@@ -10,8 +10,6 @@
#include "content/public/browser/notification_source.h" #include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_types.h" #include "content/public/browser/notification_types.h"
namespace chromeos {
TabFirstRenderWatcher::TabFirstRenderWatcher(TabContents* tab, TabFirstRenderWatcher::TabFirstRenderWatcher(TabContents* tab,
Delegate* delegate) Delegate* delegate)
: state_(NONE), : state_(NONE),
...@@ -54,5 +52,3 @@ void TabFirstRenderWatcher::Observe(int type, ...@@ -54,5 +52,3 @@ void TabFirstRenderWatcher::Observe(int type,
NOTREACHED() << "unknown type" << type; NOTREACHED() << "unknown type" << type;
} }
} }
} // namespace chromeos
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_TAB_FIRST_RENDER_WATCHER_H_ #ifndef CHROME_BROWSER_TAB_FIRST_RENDER_WATCHER_H_
#define CHROME_BROWSER_CHROMEOS_TAB_FIRST_RENDER_WATCHER_H_ #define CHROME_BROWSER_TAB_FIRST_RENDER_WATCHER_H_
#pragma once #pragma once
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
...@@ -13,10 +13,7 @@ ...@@ -13,10 +13,7 @@
class RenderViewHost; class RenderViewHost;
class TabContents; class TabContents;
namespace chromeos {
// This class watches given TabContent's loading and rendering state change. // This class watches given TabContent's loading and rendering state change.
// TODO(xiyuan): Move this to a proper place and share with HTMLDialogView.
class TabFirstRenderWatcher : public content::NotificationObserver { class TabFirstRenderWatcher : public content::NotificationObserver {
public: public:
class Delegate { class Delegate {
...@@ -52,6 +49,4 @@ class TabFirstRenderWatcher : public content::NotificationObserver { ...@@ -52,6 +49,4 @@ class TabFirstRenderWatcher : public content::NotificationObserver {
DISALLOW_COPY_AND_ASSIGN(TabFirstRenderWatcher); DISALLOW_COPY_AND_ASSIGN(TabFirstRenderWatcher);
}; };
} // namespace chromeos #endif // CHROME_BROWSER_TAB_FIRST_RENDER_WATCHER_H_
#endif // CHROME_BROWSER_CHROMEOS_TAB_FIRST_RENDER_WATCHER_H_
// Copyright (c) 2011 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 "base/message_loop.h"
#include "chrome/browser/tab_first_render_watcher.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/views/dom_view.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "views/widget/widget.h"
namespace {
views::Widget* CreateWindowForContents(views::View* contents) {
views::Widget::InitParams widget_params(
views::Widget::InitParams::TYPE_WINDOW);
views::Widget* widget = new views::Widget;
widget->Init(widget_params);
widget->SetContentsView(contents);
return widget;
}
} // namespace
class TabFirstRenderWatcherTest : public InProcessBrowserTest,
public TabFirstRenderWatcher::Delegate {
public:
TabFirstRenderWatcherTest()
: host_created_(false),
main_frame_loaded_(false),
main_frame_rendered_(false) {
}
// TabFirstRenderWatcher::Delegate implementation.
virtual void OnRenderHostCreated(RenderViewHost* host) OVERRIDE {
host_created_ = true;
}
virtual void OnTabMainFrameLoaded() OVERRIDE {
main_frame_loaded_ = true;
MessageLoop::current()->Quit();
}
virtual void OnTabMainFrameFirstRender() OVERRIDE {
main_frame_rendered_ = true;
MessageLoop::current()->Quit();
}
protected:
bool host_created_;
bool main_frame_loaded_;
bool main_frame_rendered_;
};
// Migrated from HtmlDialogBrowserTest.TestStateTransition, which times out
// about 5~10% of runs. See crbug.com/86059.
IN_PROC_BROWSER_TEST_F(TabFirstRenderWatcherTest,
DISABLED_TestStateTransition) {
DOMView* dom_view = new DOMView;
dom_view->Init(browser()->profile(), NULL);
CreateWindowForContents(dom_view);
dom_view->GetWidget()->Show();
scoped_ptr<TabFirstRenderWatcher> watcher(
new TabFirstRenderWatcher(dom_view->dom_contents()->tab_contents(),
this));
EXPECT_FALSE(host_created_);
EXPECT_FALSE(main_frame_loaded_);
EXPECT_FALSE(main_frame_rendered_);
dom_view->LoadURL(GURL(chrome::kChromeUIChromeURLsURL));
EXPECT_TRUE(host_created_);
// OnTabMainFrameLoaded() will Quit().
MessageLoopForUI::current()->Run();
EXPECT_TRUE(main_frame_loaded_);
// OnTabMainFrameFirstRender() will Quit().
MessageLoopForUI::current()->Run();
EXPECT_TRUE(main_frame_rendered_);
dom_view->GetWidget()->Close();
}
...@@ -52,7 +52,7 @@ HtmlDialogView::HtmlDialogView(Profile* profile, ...@@ -52,7 +52,7 @@ HtmlDialogView::HtmlDialogView(Profile* profile,
HtmlDialogUIDelegate* delegate) HtmlDialogUIDelegate* delegate)
: DOMView(), : DOMView(),
HtmlDialogTabContentsDelegate(profile), HtmlDialogTabContentsDelegate(profile),
state_(NONE), initialized_(false),
delegate_(delegate) { delegate_(delegate) {
} }
...@@ -79,8 +79,8 @@ bool HtmlDialogView::AcceleratorPressed(const views::Accelerator& accelerator) { ...@@ -79,8 +79,8 @@ bool HtmlDialogView::AcceleratorPressed(const views::Accelerator& accelerator) {
void HtmlDialogView::ViewHierarchyChanged( void HtmlDialogView::ViewHierarchyChanged(
bool is_add, View* parent, View* child) { bool is_add, View* parent, View* child) {
DOMView::ViewHierarchyChanged(is_add, parent, child); DOMView::ViewHierarchyChanged(is_add, parent, child);
if (is_add && GetWidget() && state_ == NONE) { if (is_add && GetWidget() && !initialized_) {
state_ = INITIALIZED; initialized_ = true;
#if defined(OS_CHROMEOS) && defined(TOOLKIT_USES_GTK) #if defined(OS_CHROMEOS) && defined(TOOLKIT_USES_GTK)
CHECK( CHECK(
static_cast<views::NativeWidgetGtk*>( static_cast<views::NativeWidgetGtk*>(
...@@ -250,49 +250,27 @@ void HtmlDialogView::InitDialog() { ...@@ -250,49 +250,27 @@ void HtmlDialogView::InitDialog() {
// the comment above HtmlDialogUI in its header file for why. // the comment above HtmlDialogUI in its header file for why.
HtmlDialogUI::GetPropertyAccessor().SetProperty( HtmlDialogUI::GetPropertyAccessor().SetProperty(
tab_contents->property_bag(), this); tab_contents->property_bag(), this);
notification_registrar_.Add( tab_watcher_.reset(new TabFirstRenderWatcher(tab_contents, this));
this,
content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB,
content::Source<TabContents>(tab_contents));
notification_registrar_.Add(
this,
content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
content::Source<TabContents>(tab_contents));
DOMView::LoadURL(GetDialogContentURL()); DOMView::LoadURL(GetDialogContentURL());
} }
void HtmlDialogView::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
switch (type) {
case content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB: {
RenderWidgetHost* rwh = content::Details<RenderWidgetHost>(details).ptr();
notification_registrar_.Add(
this,
content::NOTIFICATION_RENDER_WIDGET_HOST_DID_PAINT,
content::Source<RenderWidgetHost>(rwh));
break;
}
case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME:
if (state_ == INITIALIZED)
state_ = LOADED;
break;
case content::NOTIFICATION_RENDER_WIDGET_HOST_DID_PAINT:
if (state_ == LOADED) {
state_ = PAINTED;
#if defined(OS_CHROMEOS) && defined(TOOLKIT_USES_GTK)
views::NativeWidgetGtk::UpdateFreezeUpdatesProperty(
GTK_WINDOW(GetWidget()->GetNativeView()), false);
#endif
}
break;
default:
NOTREACHED() << "unknown type" << type;
}
}
void HtmlDialogView::RegisterDialogAccelerators() { void HtmlDialogView::RegisterDialogAccelerators() {
// Pressing the ESC key will close the dialog. // Pressing the ESC key will close the dialog.
AddAccelerator(views::Accelerator(ui::VKEY_ESCAPE, false, false, false)); AddAccelerator(views::Accelerator(ui::VKEY_ESCAPE, false, false, false));
} }
void HtmlDialogView::OnRenderHostCreated(RenderViewHost* host) {
}
void HtmlDialogView::OnTabMainFrameLoaded() {
}
void HtmlDialogView::OnTabMainFrameFirstRender() {
#if defined(OS_CHROMEOS) && defined(TOOLKIT_USES_GTK)
if (initialized_) {
views::NativeWidgetGtk::UpdateFreezeUpdatesProperty(
GTK_WINDOW(GetWidget()->GetNativeView()), false);
}
#endif
}
...@@ -10,11 +10,11 @@ ...@@ -10,11 +10,11 @@
#include <vector> #include <vector>
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/tab_first_render_watcher.h"
#include "chrome/browser/ui/views/dom_view.h" #include "chrome/browser/ui/views/dom_view.h"
#include "chrome/browser/ui/webui/html_dialog_tab_contents_delegate.h" #include "chrome/browser/ui/webui/html_dialog_tab_contents_delegate.h"
#include "chrome/browser/ui/webui/html_dialog_ui.h" #include "chrome/browser/ui/webui/html_dialog_ui.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "ui/gfx/size.h" #include "ui/gfx/size.h"
#include "views/widget/widget_delegate.h" #include "views/widget/widget_delegate.h"
...@@ -38,7 +38,7 @@ class HtmlDialogView ...@@ -38,7 +38,7 @@ class HtmlDialogView
public HtmlDialogTabContentsDelegate, public HtmlDialogTabContentsDelegate,
public HtmlDialogUIDelegate, public HtmlDialogUIDelegate,
public views::WidgetDelegate, public views::WidgetDelegate,
public content::NotificationObserver { public TabFirstRenderWatcher::Delegate {
public: public:
HtmlDialogView(Profile* profile, HtmlDialogUIDelegate* delegate); HtmlDialogView(Profile* profile, HtmlDialogUIDelegate* delegate);
virtual ~HtmlDialogView(); virtual ~HtmlDialogView();
...@@ -84,30 +84,25 @@ class HtmlDialogView ...@@ -84,30 +84,25 @@ class HtmlDialogView
OVERRIDE; OVERRIDE;
virtual void CloseContents(TabContents* source) OVERRIDE; virtual void CloseContents(TabContents* source) OVERRIDE;
// Overridden from content::NotificationObserver
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
protected: protected:
// Register accelerators for this dialog. // Register accelerators for this dialog.
virtual void RegisterDialogAccelerators(); virtual void RegisterDialogAccelerators();
// TabFirstRenderWatcher::Delegate implementation.
virtual void OnRenderHostCreated(RenderViewHost* host) OVERRIDE;
virtual void OnTabMainFrameLoaded() OVERRIDE;
virtual void OnTabMainFrameFirstRender() OVERRIDE;
private: private:
FRIEND_TEST_ALL_PREFIXES(HtmlDialogBrowserTest, TestStateTransition); FRIEND_TEST_ALL_PREFIXES(HtmlDialogBrowserTest, WebContentRendered);
// A state used to ensure that we show the window only after the // Whether the view is initialized. That is, dialog acceleartors is registered
// renderer painted the full page. // and FreezeUpdates property is set to prevent WM from showing the window
enum DialogState { // until the property is removed.
NONE, bool initialized_;
INITIALIZED, // FreezeUpdates property is set to prevent WM from showing
// the window until the property is remoevd. // Watches for TabContents rendering.
LOADED, // Renderer loaded the page. scoped_ptr<TabFirstRenderWatcher> tab_watcher_;
PAINTED, // 1st paint event after the page is loaded.
// FreezeUpdates property is removed to tell WM to shows
// the window.
};
DialogState state_;
// This view is a delegate to the HTML content since it needs to get notified // This view is a delegate to the HTML content since it needs to get notified
// about when the dialog is closing. For all other actions (besides dialog // about when the dialog is closing. For all other actions (besides dialog
...@@ -115,8 +110,6 @@ class HtmlDialogView ...@@ -115,8 +110,6 @@ class HtmlDialogView
// using this variable. // using this variable.
HtmlDialogUIDelegate* delegate_; HtmlDialogUIDelegate* delegate_;
content::NotificationRegistrar notification_registrar_;
DISALLOW_COPY_AND_ASSIGN(HtmlDialogView); DISALLOW_COPY_AND_ASSIGN(HtmlDialogView);
}; };
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/views/html_dialog_view.h" #include "chrome/browser/ui/views/html_dialog_view.h"
#include "chrome/browser/ui/webui/html_dialog_ui.h" #include "chrome/browser/ui/webui/test_html_dialog_ui_delegate.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h" #include "chrome/test/base/ui_test_utils.h"
...@@ -28,37 +28,33 @@ namespace { ...@@ -28,37 +28,33 @@ namespace {
const int kMinimumWidthToTestFor = 20; const int kMinimumWidthToTestFor = 20;
const int kMinimumHeightToTestFor = 30; const int kMinimumHeightToTestFor = 30;
class TestHtmlDialogUIDelegate : public HtmlDialogUIDelegate { // Initial size of HTMLDialog for SizeWindow test case. They must be different
public: // from the above kMinimumWidthToTestFor/kMinimumHeightToTestFor.
TestHtmlDialogUIDelegate() {} const int kInitialWidth = 40;
virtual ~TestHtmlDialogUIDelegate() {} const int kInitialHeight = 40;
// HTMLDialogUIDelegate implementation: class TestHtmlDialogView: public HtmlDialogView {
virtual bool IsDialogModal() const OVERRIDE { public:
return true; TestHtmlDialogView(Profile* profile, HtmlDialogUIDelegate* delegate)
} : HtmlDialogView(profile, delegate),
virtual string16 GetDialogTitle() const OVERRIDE { painted_(false) {
return ASCIIToUTF16("Test");
}
virtual GURL GetDialogContentURL() const OVERRIDE {
return GURL(chrome::kChromeUIChromeURLsURL);
}
virtual void GetWebUIMessageHandlers(
std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE { }
virtual void GetDialogSize(gfx::Size* size) const OVERRIDE {
size->set_width(40);
size->set_height(40);
} }
virtual std::string GetDialogArgs() const OVERRIDE {
return std::string(); bool painted() const {
return painted_;
} }
virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE { }
virtual void OnCloseContents(TabContents* source, bool* out_close_dialog) protected:
OVERRIDE { virtual void OnTabMainFrameFirstRender() OVERRIDE {
if (out_close_dialog) HtmlDialogView::OnTabMainFrameFirstRender();
*out_close_dialog = true; painted_ = true;
MessageLoop::current()->Quit();
} }
virtual bool ShouldShowDialogTitle() const OVERRIDE { return true; }
private:
bool painted_;
DISALLOW_COPY_AND_ASSIGN(TestHtmlDialogView);
}; };
} // namespace } // namespace
...@@ -132,7 +128,9 @@ class HtmlDialogBrowserTest : public InProcessBrowserTest { ...@@ -132,7 +128,9 @@ class HtmlDialogBrowserTest : public InProcessBrowserTest {
#endif #endif
IN_PROC_BROWSER_TEST_F(HtmlDialogBrowserTest, MAYBE_SizeWindow) { IN_PROC_BROWSER_TEST_F(HtmlDialogBrowserTest, MAYBE_SizeWindow) {
HtmlDialogUIDelegate* delegate = new TestHtmlDialogUIDelegate(); test::TestHtmlDialogUIDelegate* delegate = new test::TestHtmlDialogUIDelegate(
GURL(chrome::kChromeUIChromeURLsURL));
delegate->set_size(kInitialWidth, kInitialHeight);
HtmlDialogView* html_view = HtmlDialogView* html_view =
new HtmlDialogView(browser()->profile(), delegate); new HtmlDialogView(browser()->profile(), delegate);
...@@ -214,29 +212,25 @@ IN_PROC_BROWSER_TEST_F(HtmlDialogBrowserTest, MAYBE_SizeWindow) { ...@@ -214,29 +212,25 @@ IN_PROC_BROWSER_TEST_F(HtmlDialogBrowserTest, MAYBE_SizeWindow) {
} }
// This is timing out about 5~10% of runs. See crbug.com/86059. // This is timing out about 5~10% of runs. See crbug.com/86059.
IN_PROC_BROWSER_TEST_F(HtmlDialogBrowserTest, DISABLED_TestStateTransition) { IN_PROC_BROWSER_TEST_F(HtmlDialogBrowserTest, DISABLED_WebContentRendered) {
HtmlDialogUIDelegate* delegate = new TestHtmlDialogUIDelegate(); HtmlDialogUIDelegate* delegate = new test::TestHtmlDialogUIDelegate(
GURL(chrome::kChromeUIChromeURLsURL));
HtmlDialogView* html_view = TestHtmlDialogView* html_view =
new HtmlDialogView(browser()->profile(), delegate); new TestHtmlDialogView(browser()->profile(), delegate);
TabContents* tab_contents = browser()->GetSelectedTabContents(); TabContents* tab_contents = browser()->GetSelectedTabContents();
ASSERT_TRUE(tab_contents != NULL); ASSERT_TRUE(tab_contents != NULL);
views::Widget::CreateWindowWithParent(html_view, views::Widget::CreateWindowWithParent(html_view,
tab_contents->GetDialogRootWindow()); tab_contents->GetDialogRootWindow());
// Test if the state transitions from INITIALIZED to -> PAINTED EXPECT_TRUE(html_view->initialized_);
EXPECT_EQ(HtmlDialogView::INITIALIZED, html_view->state_);
html_view->InitDialog(); html_view->InitDialog();
html_view->GetWidget()->Show(); html_view->GetWidget()->Show();
MessageLoopForUI::current()->AddObserver( // TestHtmlDialogView::OnTabMainFrameFirstRender() will Quit().
WindowChangedObserver::GetInstance()); MessageLoopForUI::current()->Run();
// We use busy loop because the state is updated in notifications.
while (html_view->state_ != HtmlDialogView::PAINTED)
MessageLoop::current()->RunAllPending();
EXPECT_EQ(HtmlDialogView::PAINTED, html_view->state_); EXPECT_TRUE(html_view->painted());
MessageLoopForUI::current()->RemoveObserver( html_view->GetWidget()->Close();
WindowChangedObserver::GetInstance());
} }
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "chrome/browser/ui/constrained_window_tab_helper.h" #include "chrome/browser/ui/constrained_window_tab_helper.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/browser/ui/webui/constrained_html_ui.h" #include "chrome/browser/ui/webui/constrained_html_ui.h"
#include "chrome/browser/ui/webui/html_dialog_ui.h" #include "chrome/browser/ui/webui/test_html_dialog_ui_delegate.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h" #include "chrome/test/base/ui_test_utils.h"
...@@ -18,39 +18,6 @@ ...@@ -18,39 +18,6 @@
namespace { namespace {
class TestHtmlDialogUIDelegate : public HtmlDialogUIDelegate {
public:
TestHtmlDialogUIDelegate() {}
virtual ~TestHtmlDialogUIDelegate() {}
// HTMLDialogUIDelegate implementation:
virtual bool IsDialogModal() const OVERRIDE {
return true;
}
virtual string16 GetDialogTitle() const OVERRIDE {
return UTF8ToUTF16("Test");
}
virtual GURL GetDialogContentURL() const OVERRIDE {
return GURL(chrome::kChromeUIConstrainedHTMLTestURL);
}
virtual void GetWebUIMessageHandlers(
std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE {}
virtual void GetDialogSize(gfx::Size* size) const OVERRIDE {
size->set_width(400);
size->set_height(400);
}
virtual std::string GetDialogArgs() const OVERRIDE {
return std::string();
}
virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE { }
virtual void OnCloseContents(TabContents* source, bool* out_close_dialog)
OVERRIDE {
if (out_close_dialog)
*out_close_dialog = true;
}
virtual bool ShouldShowDialogTitle() const OVERRIDE { return true; }
};
class ConstrainedHtmlDialogBrowserTestObserver : public TabContentsObserver { class ConstrainedHtmlDialogBrowserTestObserver : public TabContentsObserver {
public: public:
explicit ConstrainedHtmlDialogBrowserTestObserver(TabContents* contents) explicit ConstrainedHtmlDialogBrowserTestObserver(TabContents* contents)
...@@ -84,7 +51,8 @@ class ConstrainedHtmlDialogBrowserTest : public InProcessBrowserTest { ...@@ -84,7 +51,8 @@ class ConstrainedHtmlDialogBrowserTest : public InProcessBrowserTest {
// Tests that opening/closing the constrained window won't crash it. // Tests that opening/closing the constrained window won't crash it.
IN_PROC_BROWSER_TEST_F(ConstrainedHtmlDialogBrowserTest, BasicTest) { IN_PROC_BROWSER_TEST_F(ConstrainedHtmlDialogBrowserTest, BasicTest) {
// The delegate deletes itself. // The delegate deletes itself.
HtmlDialogUIDelegate* delegate = new TestHtmlDialogUIDelegate(); HtmlDialogUIDelegate* delegate = new test::TestHtmlDialogUIDelegate(
GURL(chrome::kChromeUIConstrainedHTMLTestURL));
TabContentsWrapper* wrapper = browser()->GetSelectedTabContentsWrapper(); TabContentsWrapper* wrapper = browser()->GetSelectedTabContentsWrapper();
ASSERT_TRUE(wrapper); ASSERT_TRUE(wrapper);
...@@ -101,7 +69,8 @@ IN_PROC_BROWSER_TEST_F(ConstrainedHtmlDialogBrowserTest, BasicTest) { ...@@ -101,7 +69,8 @@ IN_PROC_BROWSER_TEST_F(ConstrainedHtmlDialogBrowserTest, BasicTest) {
IN_PROC_BROWSER_TEST_F(ConstrainedHtmlDialogBrowserTest, IN_PROC_BROWSER_TEST_F(ConstrainedHtmlDialogBrowserTest,
ReleaseTabContentsOnDialogClose) { ReleaseTabContentsOnDialogClose) {
// The delegate deletes itself. // The delegate deletes itself.
TestHtmlDialogUIDelegate* delegate = new TestHtmlDialogUIDelegate(); HtmlDialogUIDelegate* delegate = new test::TestHtmlDialogUIDelegate(
GURL(chrome::kChromeUIConstrainedHTMLTestURL));
TabContentsWrapper* wrapper = browser()->GetSelectedTabContentsWrapper(); TabContentsWrapper* wrapper = browser()->GetSelectedTabContentsWrapper();
ASSERT_TRUE(wrapper); ASSERT_TRUE(wrapper);
......
// Copyright (c) 2011 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 "chrome/browser/ui/webui/test_html_dialog_ui_delegate.h"
#include "base/utf_string_conversions.h"
namespace test {
TestHtmlDialogUIDelegate::TestHtmlDialogUIDelegate(const GURL& url)
: url_(url),
size_(400, 400) {
}
TestHtmlDialogUIDelegate::~TestHtmlDialogUIDelegate() {
}
bool TestHtmlDialogUIDelegate::IsDialogModal() const {
return true;
}
string16 TestHtmlDialogUIDelegate::GetDialogTitle() const {
return UTF8ToUTF16("Test");
}
GURL TestHtmlDialogUIDelegate::GetDialogContentURL() const {
return url_;
}
void TestHtmlDialogUIDelegate::GetWebUIMessageHandlers(
std::vector<WebUIMessageHandler*>* handlers) const {
}
void TestHtmlDialogUIDelegate::GetDialogSize(gfx::Size* size) const {
*size = size_;
}
std::string TestHtmlDialogUIDelegate::GetDialogArgs() const {
return std::string();
}
void TestHtmlDialogUIDelegate::OnDialogClosed(const std::string& json_retval) {
}
void TestHtmlDialogUIDelegate::OnCloseContents(TabContents* source,
bool* out_close_dialog) {
if (out_close_dialog)
*out_close_dialog = true;
}
bool TestHtmlDialogUIDelegate::ShouldShowDialogTitle() const {
return true;
}
} // namespace test
// Copyright (c) 2011 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.
#ifndef CHROME_BROWSER_UI_WEBUI_TEST_HTML_DIALOG_UI_DELEGATE_H_
#define CHROME_BROWSER_UI_WEBUI_TEST_HTML_DIALOG_UI_DELEGATE_H_
#pragma once
#include <string>
#include "base/compiler_specific.h"
#include "chrome/browser/ui/webui/html_dialog_ui.h"
#include "ui/gfx/size.h"
namespace test {
class TestHtmlDialogUIDelegate : public HtmlDialogUIDelegate {
public:
explicit TestHtmlDialogUIDelegate(const GURL& url);
virtual ~TestHtmlDialogUIDelegate();
void set_size(int width, int height) {
size_.SetSize(width, height);
}
// HTMLDialogUIDelegate implementation:
virtual bool IsDialogModal() const OVERRIDE;
virtual string16 GetDialogTitle() const OVERRIDE;
virtual GURL GetDialogContentURL() const OVERRIDE;
virtual void GetWebUIMessageHandlers(
std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE;
virtual void GetDialogSize(gfx::Size* size) const OVERRIDE;
virtual std::string GetDialogArgs() const OVERRIDE;
virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE;
virtual void OnCloseContents(TabContents* source, bool* out_close_dialog)
OVERRIDE;
virtual bool ShouldShowDialogTitle() const OVERRIDE;
protected:
const GURL url_;
gfx::Size size_;
DISALLOW_COPY_AND_ASSIGN(TestHtmlDialogUIDelegate);
};
} // namespace test
#endif // CHROME_BROWSER_UI_WEBUI_TEST_HTML_DIALOG_UI_DELEGATE_H_
...@@ -812,8 +812,6 @@ ...@@ -812,8 +812,6 @@
'browser/chromeos/system_key_event_listener.h', 'browser/chromeos/system_key_event_listener.h',
'browser/chromeos/tab_closeable_state_watcher.cc', 'browser/chromeos/tab_closeable_state_watcher.cc',
'browser/chromeos/tab_closeable_state_watcher.h', 'browser/chromeos/tab_closeable_state_watcher.h',
'browser/chromeos/tab_first_render_watcher.cc',
'browser/chromeos/tab_first_render_watcher.h',
'browser/chromeos/upgrade_detector_chromeos.cc', 'browser/chromeos/upgrade_detector_chromeos.cc',
'browser/chromeos/upgrade_detector_chromeos.h', 'browser/chromeos/upgrade_detector_chromeos.h',
'browser/chromeos/user_cros_settings_provider.cc', 'browser/chromeos/user_cros_settings_provider.cc',
...@@ -2296,6 +2294,8 @@ ...@@ -2296,6 +2294,8 @@
'browser/sync/sync_ui_util_mac.mm', 'browser/sync/sync_ui_util_mac.mm',
'browser/tab_closeable_state_watcher.cc', 'browser/tab_closeable_state_watcher.cc',
'browser/tab_closeable_state_watcher.h', 'browser/tab_closeable_state_watcher.h',
'browser/tab_first_render_watcher.cc',
'browser/tab_first_render_watcher.h',
'browser/tab_contents/background_contents.cc', 'browser/tab_contents/background_contents.cc',
'browser/tab_contents/background_contents.h', 'browser/tab_contents/background_contents.h',
'browser/tab_contents/chrome_interstitial_page.cc', 'browser/tab_contents/chrome_interstitial_page.cc',
......
...@@ -2522,6 +2522,7 @@ ...@@ -2522,6 +2522,7 @@
'browser/speech/speech_input_bubble_browsertest.cc', 'browser/speech/speech_input_bubble_browsertest.cc',
'browser/spellchecker/spellcheck_host_browsertest.cc', 'browser/spellchecker/spellcheck_host_browsertest.cc',
'browser/ssl/ssl_browser_tests.cc', 'browser/ssl/ssl_browser_tests.cc',
'browser/tab_first_render_watcher_browsertest.cc',
'browser/task_manager/task_manager_browsertest.cc', 'browser/task_manager/task_manager_browsertest.cc',
'browser/task_manager/task_manager_browsertest_util.cc', 'browser/task_manager/task_manager_browsertest_util.cc',
'browser/task_manager/task_manager_browsertest_util.h', 'browser/task_manager/task_manager_browsertest_util.h',
...@@ -2567,6 +2568,8 @@ ...@@ -2567,6 +2568,8 @@
'browser/ui/webui/options/password_manager_browsertest.js', 'browser/ui/webui/options/password_manager_browsertest.js',
'browser/ui/webui/options/personal_options_browsertest.js', 'browser/ui/webui/options/personal_options_browsertest.js',
'browser/ui/webui/options/search_engine_manager_browsertest.js', 'browser/ui/webui/options/search_engine_manager_browsertest.js',
'browser/ui/webui/test_html_dialog_ui_delegate.cc',
'browser/ui/webui/test_html_dialog_ui_delegate.h',
'browser/ui/webui/web_ui_browsertest.cc', 'browser/ui/webui/web_ui_browsertest.cc',
'browser/ui/webui/web_ui_browsertest.h', 'browser/ui/webui/web_ui_browsertest.h',
'browser/ui/webui/web_ui_test_handler.cc', 'browser/ui/webui/web_ui_test_handler.cc',
...@@ -2851,6 +2854,7 @@ ...@@ -2851,6 +2854,7 @@
}, { # else: toolkit_views == 0 }, { # else: toolkit_views == 0
'sources!': [ 'sources!': [
'browser/extensions/browser_action_test_util_views.cc', 'browser/extensions/browser_action_test_util_views.cc',
'browser/tab_first_render_watcher_browsertest.cc',
'browser/ui/panels/panel_browser_view_browsertest.cc', 'browser/ui/panels/panel_browser_view_browsertest.cc',
'browser/ui/views/browser_actions_container_browsertest.cc', 'browser/ui/views/browser_actions_container_browsertest.cc',
'browser/ui/views/dom_view_browsertest.cc', 'browser/ui/views/dom_view_browsertest.cc',
......
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