summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/chromeos/login/account_creation_view.cc167
-rw-r--r--chrome/browser/chromeos/login/account_creation_view.h58
-rw-r--r--chrome/browser/chromeos/login/account_screen.cc21
-rw-r--r--chrome/browser/chromeos/login/account_screen.h30
-rw-r--r--chrome/browser/chromeos/login/web_page_screen.cc26
-rw-r--r--chrome/browser/chromeos/login/web_page_screen.h51
-rw-r--r--chrome/browser/chromeos/login/web_page_view.cc186
-rw-r--r--chrome/browser/chromeos/login/web_page_view.h145
-rw-r--r--chrome/chrome_browser.gypi4
9 files changed, 445 insertions, 243 deletions
diff --git a/chrome/browser/chromeos/login/account_creation_view.cc b/chrome/browser/chromeos/login/account_creation_view.cc
index 0d718b1..5f0c428 100644
--- a/chrome/browser/chromeos/login/account_creation_view.cc
+++ b/chrome/browser/chromeos/login/account_creation_view.cc
@@ -4,59 +4,25 @@
#include "chrome/browser/chromeos/login/account_creation_view.h"
-#include "app/l10n_util.h"
-#include "app/resource_bundle.h"
-#include "base/callback.h"
#include "base/string_util.h"
-#include "base/time.h"
-#include "base/values.h"
-#include "chrome/browser/child_process_security_policy.h"
-#include "chrome/browser/chromeos/login/rounded_rect_painter.h"
-#include "chrome/browser/dom_ui/dom_ui.h"
-#include "chrome/browser/tab_contents/tab_contents.h"
-#include "chrome/common/bindings_policy.h"
-#include "gfx/canvas.h"
-#include "grit/generated_resources.h"
-#include "grit/theme_resources.h"
-#include "ipc/ipc_message.h"
-#include "third_party/skia/include/core/SkColor.h"
-#include "views/background.h"
-#include "views/border.h"
-#include "views/controls/label.h"
-#include "views/controls/throbber.h"
#include "webkit/glue/form_data.h"
-using base::TimeDelta;
-using views::Label;
-using views::Throbber;
-using views::View;
using webkit_glue::FormData;
-// Spacing (vertical/horizontal) between controls.
-const int kSpacing = 10;
-
-// Time in ms per throbber frame.
-const int kThrobberFrameMs = 60;
-
-// Time in ms after that waiting controls are shown on Start.
-const int kStartDelayMs = 500;
-
-// Time in ms after that waiting controls are hidden Stop.
-const int kStopDelayMs = 500;
-
namespace chromeos {
const char kCreateAccountFormName[] = "createaccount";
const char kEmailFieldName[] = "Email";
const char kDomainFieldName[] = "edk";
-class AccountCreationTabContents : public TabContents,
+class AccountCreationTabContents : public WizardWebPageViewTabContents,
public RenderViewHostDelegate::AutoFill {
public:
AccountCreationTabContents(Profile* profile,
SiteInstance* site_instance,
- AccountCreationViewDelegate* delegate)
- : TabContents(profile, site_instance, MSG_ROUTING_NONE, NULL),
+ AccountCreationViewDelegate* delegate,
+ WebPageDelegate* page_delegate)
+ : WizardWebPageViewTabContents(profile, site_instance, page_delegate),
delegate_(delegate) {
}
@@ -100,31 +66,6 @@ class AccountCreationTabContents : public TabContents,
return false;
}
- virtual void DidFailProvisionalLoadWithError(
- RenderViewHost* render_view_host,
- bool is_main_frame,
- int error_code,
- const GURL& url,
- bool showing_repost_interstitial) {
- delegate_->OnPageLoadFailed(url.spec());
- }
-
- virtual void DidDisplayInsecureContent() {
- delegate_->OnPageLoadFailed("");
- }
-
- virtual void DidRunInsecureContent(const std::string& security_origin) {
- delegate_->OnPageLoadFailed(security_origin);
- }
-
- virtual void DocumentLoadedInFrame() {
- delegate_->OnPageLoaded();
- }
-
- virtual void OnContentBlocked(ContentSettingsType type) {
- delegate_->OnPageLoadFailed("");
- }
-
private:
AccountCreationViewDelegate* delegate_;
@@ -145,120 +86,30 @@ void AccountCreationDomView::SetAccountCreationViewDelegate(
delegate_ = delegate;
}
-void AccountCreationDomView::SetTabContentsDelegate(
- TabContentsDelegate* delegate) {
- tab_contents_->set_delegate(delegate);
-}
-
///////////////////////////////////////////////////////////////////////////////
// AccountCreationDomView, DOMView implementation:
TabContents* AccountCreationDomView::CreateTabContents(Profile* profile,
SiteInstance* instance) {
- return new AccountCreationTabContents(profile, instance, delegate_);
+ return new AccountCreationTabContents(profile,
+ instance,
+ delegate_,
+ page_delegate_);
}
///////////////////////////////////////////////////////////////////////////////
// AccountCreationView, public:
AccountCreationView::AccountCreationView()
- : dom_view_(new AccountCreationDomView()),
- throbber_(NULL),
- connecting_label_(NULL) {
+ : dom_view_(new AccountCreationDomView()) {
}
AccountCreationView::~AccountCreationView() {
}
-void AccountCreationView::Init() {
- chromeos::CreateWizardBorder(
- &chromeos::BorderDefinition::kScreenBorder)->GetInsets(&insets_);
- views::Painter* painter = CreateWizardPainter(
- &BorderDefinition::kScreenBorder);
- set_background(
- views::Background::CreateBackgroundPainter(true, painter));
- dom_view_->SetVisible(false);
- AddChildView(dom_view_);
-
- throbber_ = new views::Throbber(kThrobberFrameMs, false);
- throbber_->SetFrames(
- ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_SPINNER));
- AddChildView(throbber_);
-
- connecting_label_ = new views::Label();
- connecting_label_->SetText(l10n_util::GetString(IDS_LOAD_STATE_CONNECTING));
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- connecting_label_->SetFont(rb.GetFont(ResourceBundle::MediumFont));
- connecting_label_->SetVisible(false);
- AddChildView(connecting_label_ );
-
- start_timer_.Start(TimeDelta::FromMilliseconds(kStartDelayMs),
- this,
- &AccountCreationView::ShowWaitingControls);
-}
-
-void AccountCreationView::InitDOM(Profile* profile,
- SiteInstance* site_instance) {
- dom_view_->Init(profile, site_instance);
-}
-
-void AccountCreationView::LoadURL(const GURL& url) {
- dom_view_->LoadURL(url);
-}
-
-void AccountCreationView::SetTabContentsDelegate(
- TabContentsDelegate* delegate) {
- dom_view_->SetTabContentsDelegate(delegate);
-}
-
void AccountCreationView::SetAccountCreationViewDelegate(
AccountCreationViewDelegate* delegate) {
dom_view_->SetAccountCreationViewDelegate(delegate);
}
-void AccountCreationView::ShowPageContent() {
- // TODO(nkostylev): Show throbber as an overlay until page has been rendered.
- start_timer_.Stop();
- if (!stop_timer_.IsRunning()) {
- stop_timer_.Start(TimeDelta::FromMilliseconds(kStopDelayMs),
- this,
- &AccountCreationView::ShowRenderedPage);
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// AccountCreationView, private:
-
-void AccountCreationView::ShowRenderedPage() {
- throbber_->Stop();
- connecting_label_->SetVisible(false);
- dom_view_->SetVisible(true);
-}
-
-void AccountCreationView::ShowWaitingControls() {
- throbber_->Start();
- connecting_label_->SetVisible(true);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// AccountCreationView, views::View implementation:
-
-void AccountCreationView::Layout() {
- dom_view_->SetBounds(insets_.left(),
- insets_.top(),
- bounds().width() - insets_.left() - insets_.right(),
- bounds().height() - insets_.top() - insets_.bottom());
- int y = height() / 2 - throbber_->GetPreferredSize().height() / 2;
- throbber_->SetBounds(
- width() / 2 - throbber_->GetPreferredSize().width() / 2,
- y,
- throbber_->GetPreferredSize().width(),
- throbber_->GetPreferredSize().height());
- connecting_label_->SetBounds(
- width() / 2 - connecting_label_->GetPreferredSize().width() / 2,
- y + throbber_->GetPreferredSize().height() + kSpacing,
- connecting_label_->GetPreferredSize().width(),
- connecting_label_->GetPreferredSize().height());
-}
-
} // namespace chromeos
diff --git a/chrome/browser/chromeos/login/account_creation_view.h b/chrome/browser/chromeos/login/account_creation_view.h
index 7ce943d..cff9c0c 100644
--- a/chrome/browser/chromeos/login/account_creation_view.h
+++ b/chrome/browser/chromeos/login/account_creation_view.h
@@ -8,17 +8,11 @@
#include <string>
#include "base/timer.h"
-#include "chrome/browser/views/dom_view.h"
+#include "chrome/browser/chromeos/login/web_page_view.h"
#include "views/view.h"
class Profile;
class SiteContents;
-class TabContentsDelegate;
-
-namespace views {
-class Label;
-class Throbber;
-} // namespace views
namespace chromeos {
@@ -31,15 +25,9 @@ class AccountCreationViewDelegate {
// this function will be called on each try.
virtual void OnUserCreated(const std::string& username,
const std::string& password) = 0;
-
- // Notify about document load event.
- virtual void OnPageLoaded() = 0;
-
- // Notify about navigation errors.
- virtual void OnPageLoadFailed(const std::string& url) = 0;
};
-class AccountCreationDomView : public DOMView {
+class AccountCreationDomView : public WebPageDomView {
public:
AccountCreationDomView();
virtual ~AccountCreationDomView();
@@ -47,9 +35,6 @@ class AccountCreationDomView : public DOMView {
// Set delegate that will be notified about user actions.
void SetAccountCreationViewDelegate(AccountCreationViewDelegate* delegate);
- // Set delegate that will be notified about tab contents changes.
- void SetTabContentsDelegate(TabContentsDelegate* delegate);
-
protected:
// Overriden from DOMView:
virtual TabContents* CreateTabContents(Profile* profile,
@@ -61,52 +46,21 @@ class AccountCreationDomView : public DOMView {
DISALLOW_COPY_AND_ASSIGN(AccountCreationDomView);
};
-class AccountCreationView : public views::View {
+class AccountCreationView : public WebPageView {
public:
AccountCreationView();
virtual ~AccountCreationView();
- // Initialize view layout.
- void Init();
-
- void InitDOM(Profile* profile, SiteInstance* site_instance);
- void LoadURL(const GURL& url);
- void SetTabContentsDelegate(TabContentsDelegate* delegate);
-
// Set delegate that will be notified about user actions.
void SetAccountCreationViewDelegate(AccountCreationViewDelegate* delegate);
- // Stops throbber and shows page content (starts renderer_timer_ for that).
- void ShowPageContent();
+ protected:
+ virtual WebPageDomView* dom_view() { return dom_view_; }
private:
- // Overriden from views::View:
- virtual void Layout();
-
- // Called by stop_timer_. Shows rendered page.
- void ShowRenderedPage();
-
- // Called by start_timer_. Shows throbber and waiting label.
- void ShowWaitingControls();
-
- // View that renderes account creation page.
+ // View that renders page.
AccountCreationDomView* dom_view_;
- // Screen border insets. Used for layout.
- gfx::Insets insets_;
-
- // Throbber shown during page load.
- views::Throbber* throbber_;
-
- // "Connecting..." label shown while waiting for the page to load/render.
- views::Label* connecting_label_;
-
- // Timer used when waiting for network response.
- base::OneShotTimer<AccountCreationView> start_timer_;
-
- // Timer used before toggling loaded page visibility.
- base::OneShotTimer<AccountCreationView> stop_timer_;
-
DISALLOW_COPY_AND_ASSIGN(AccountCreationView);
};
diff --git a/chrome/browser/chromeos/login/account_screen.cc b/chrome/browser/chromeos/login/account_screen.cc
index c0cb17d..468c884 100644
--- a/chrome/browser/chromeos/login/account_screen.cc
+++ b/chrome/browser/chromeos/login/account_screen.cc
@@ -4,7 +4,6 @@
#include "chrome/browser/chromeos/login/account_screen.h"
-#include "base/logging.h"
#include "base/string_util.h"
#include "chrome/browser/chromeos/login/account_creation_view.h"
#include "chrome/browser/chromeos/login/screen_observer.h"
@@ -85,6 +84,7 @@ bool AccountScreen::check_for_https_ = true;
// AccountScreen, ViewScreen implementation:
void AccountScreen::CreateView() {
ViewScreen<AccountCreationView>::CreateView();
+ view()->SetWebPageDelegate(this);
view()->SetAccountCreationViewDelegate(this);
}
@@ -125,18 +125,8 @@ void AccountScreen::NavigationStateChanged(const TabContents* source,
}
}
-bool AccountScreen::HandleContextMenu(const ContextMenuParams& params) {
- // Just return true because we don't want to show context menue.
- return true;
-}
-
///////////////////////////////////////////////////////////////////////////////
-// AccountScreen, AccountCreationViewDelegate implementation:
-void AccountScreen::OnUserCreated(const std::string& username,
- const std::string& password) {
- delegate()->GetObserver(this)->OnSetUserNamePassword(username, password);
-}
-
+// AccountScreen, WebPageDelegate implementation:
void AccountScreen::OnPageLoaded() {
view()->ShowPageContent();
}
@@ -145,4 +135,11 @@ void AccountScreen::OnPageLoadFailed(const std::string& url) {
delegate()->GetObserver(this)->OnExit(ScreenObserver::CONNECTION_FAILED);
}
+///////////////////////////////////////////////////////////////////////////////
+// AccountScreen, AccountCreationViewDelegate implementation:
+void AccountScreen::OnUserCreated(const std::string& username,
+ const std::string& password) {
+ delegate()->GetObserver(this)->OnSetUserNamePassword(username, password);
+}
+
} // namespace chromeos
diff --git a/chrome/browser/chromeos/login/account_screen.h b/chrome/browser/chromeos/login/account_screen.h
index 058d6f0..cbc2e9d 100644
--- a/chrome/browser/chromeos/login/account_screen.h
+++ b/chrome/browser/chromeos/login/account_screen.h
@@ -10,6 +10,8 @@
#include "base/scoped_ptr.h"
#include "chrome/browser/chromeos/login/account_creation_view.h"
#include "chrome/browser/chromeos/login/view_screen.h"
+#include "chrome/browser/chromeos/login/web_page_screen.h"
+#include "chrome/browser/chromeos/login/web_page_view.h"
#include "chrome/browser/tab_contents/tab_contents_delegate.h"
class GURL;
@@ -17,18 +19,22 @@ class WizardScreenDelegate;
namespace chromeos {
+// AccountScreen is shown when user is creating new Google Account.
class AccountScreen : public ViewScreen<AccountCreationView>,
- public TabContentsDelegate,
+ public WebPageScreen,
+ public WebPageDelegate,
public AccountCreationViewDelegate {
public:
explicit AccountScreen(WizardScreenDelegate* delegate);
virtual ~AccountScreen();
+ // WebPageDelegate implementation:
+ virtual void OnPageLoaded();
+ virtual void OnPageLoadFailed(const std::string& url);
+
// AccountCreationViewDelegate implementation:
virtual void OnUserCreated(const std::string& username,
const std::string& password);
- virtual void OnPageLoaded();
- virtual void OnPageLoadFailed(const std::string& url);
// Sets the url for account creation. Used in tests.
static void set_new_account_page_url(const GURL& url);
@@ -42,27 +48,9 @@ class AccountScreen : public ViewScreen<AccountCreationView>,
virtual AccountCreationView* AllocateView();
// TabContentsDelegate implementation:
- virtual void OpenURLFromTab(TabContents* source,
- const GURL& url, const GURL& referrer,
- WindowOpenDisposition disposition,
- PageTransition::Type transition) {}
virtual void NavigationStateChanged(const TabContents* source,
unsigned changed_flags);
- virtual void AddNewContents(TabContents* source,
- TabContents* new_contents,
- WindowOpenDisposition disposition,
- const gfx::Rect& initial_pos,
- bool user_gesture) {}
- virtual void ActivateContents(TabContents* contents) {}
virtual void LoadingStateChanged(TabContents* source);
- virtual void CloseContents(TabContents* source) {}
- virtual bool IsPopup(TabContents* source) { return false; }
- virtual void URLStarredChanged(TabContents* source, bool starred) {}
- virtual void UpdateTargetURL(TabContents* source, const GURL& url) {}
- virtual bool ShouldAddNavigationToHistory() const { return false; }
- virtual void MoveContents(TabContents* source, const gfx::Rect& pos) {}
- virtual void ToolbarSizeChanged(TabContents* source, bool is_animating) {}
- virtual bool HandleContextMenu(const ContextMenuParams& params);
// Url of account creation page. Overriden by tests.
static scoped_ptr<GURL> new_account_page_url_;
diff --git a/chrome/browser/chromeos/login/web_page_screen.cc b/chrome/browser/chromeos/login/web_page_screen.cc
new file mode 100644
index 0000000..ccc1784
--- /dev/null
+++ b/chrome/browser/chromeos/login/web_page_screen.cc
@@ -0,0 +1,26 @@
+// Copyright (c) 2010 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/chromeos/login/web_page_screen.h"
+
+namespace chromeos {
+
+///////////////////////////////////////////////////////////////////////////////
+// WebPageScreen, public:
+
+WebPageScreen::WebPageScreen() {
+}
+
+WebPageScreen::~WebPageScreen() {
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// WebPageScreen, TabContentsDelegate implementation:
+
+bool WebPageScreen::HandleContextMenu(const ContextMenuParams& params) {
+ // Just return true because we don't want to show context menue.
+ return true;
+}
+
+} // namespace chromeos
diff --git a/chrome/browser/chromeos/login/web_page_screen.h b/chrome/browser/chromeos/login/web_page_screen.h
new file mode 100644
index 0000000..4269900
--- /dev/null
+++ b/chrome/browser/chromeos/login/web_page_screen.h
@@ -0,0 +1,51 @@
+// Copyright (c) 2010 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_CHROMEOS_LOGIN_WEB_PAGE_SCREEN_H_
+#define CHROME_BROWSER_CHROMEOS_LOGIN_WEB_PAGE_SCREEN_H_
+
+#include "base/scoped_ptr.h"
+#include "chrome/browser/tab_contents/tab_contents_delegate.h"
+
+class GURL;
+
+namespace chromeos {
+
+// Base class for wizard screen that holds web page.
+class WebPageScreen : public TabContentsDelegate {
+ public:
+ explicit WebPageScreen();
+ virtual ~WebPageScreen();
+
+ protected:
+ // TabContentsDelegate implementation:
+ virtual void OpenURLFromTab(TabContents* source,
+ const GURL& url, const GURL& referrer,
+ WindowOpenDisposition disposition,
+ PageTransition::Type transition) {}
+ virtual void NavigationStateChanged(const TabContents* source,
+ unsigned changed_flags) = 0;
+ virtual void AddNewContents(TabContents* source,
+ TabContents* new_contents,
+ WindowOpenDisposition disposition,
+ const gfx::Rect& initial_pos,
+ bool user_gesture) {}
+ virtual void ActivateContents(TabContents* contents) {}
+ virtual void LoadingStateChanged(TabContents* source) = 0;
+ virtual void CloseContents(TabContents* source) {}
+ virtual bool IsPopup(TabContents* source) { return false; }
+ virtual void URLStarredChanged(TabContents* source, bool starred) {}
+ virtual void UpdateTargetURL(TabContents* source, const GURL& url) {}
+ virtual bool ShouldAddNavigationToHistory() const { return false; }
+ virtual void MoveContents(TabContents* source, const gfx::Rect& pos) {}
+ virtual void ToolbarSizeChanged(TabContents* source, bool is_animating) {}
+ virtual bool HandleContextMenu(const ContextMenuParams& params);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(WebPageScreen);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_LOGIN_WEB_PAGE_SCREEN_H_
diff --git a/chrome/browser/chromeos/login/web_page_view.cc b/chrome/browser/chromeos/login/web_page_view.cc
new file mode 100644
index 0000000..0ea75b0
--- /dev/null
+++ b/chrome/browser/chromeos/login/web_page_view.cc
@@ -0,0 +1,186 @@
+// Copyright (c) 2009 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/chromeos/login/web_page_view.h"
+
+#include "app/l10n_util.h"
+#include "app/resource_bundle.h"
+#include "base/callback.h"
+#include "base/string_util.h"
+#include "base/time.h"
+#include "base/values.h"
+#include "chrome/browser/child_process_security_policy.h"
+#include "chrome/browser/chromeos/login/rounded_rect_painter.h"
+#include "chrome/browser/dom_ui/dom_ui.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/common/bindings_policy.h"
+#include "gfx/canvas.h"
+#include "grit/generated_resources.h"
+#include "grit/theme_resources.h"
+#include "ipc/ipc_message.h"
+#include "third_party/skia/include/core/SkColor.h"
+#include "views/background.h"
+#include "views/border.h"
+#include "views/controls/label.h"
+#include "views/controls/throbber.h"
+
+using base::TimeDelta;
+using views::Label;
+using views::Throbber;
+using views::View;
+using webkit_glue::FormData;
+
+// Spacing (vertical/horizontal) between controls.
+const int kSpacing = 10;
+
+// Time in ms per throbber frame.
+const int kThrobberFrameMs = 60;
+
+// Time in ms after that waiting controls are shown on Start.
+const int kStartDelayMs = 500;
+
+// Time in ms after that waiting controls are hidden Stop.
+const int kStopDelayMs = 500;
+
+namespace chromeos {
+
+///////////////////////////////////////////////////////////////////////////////
+// WizardWebPageViewTabContents, public:
+
+WizardWebPageViewTabContents::WizardWebPageViewTabContents(
+ Profile* profile,
+ SiteInstance* site_instance,
+ WebPageDelegate* page_delegate)
+ : TabContents(profile, site_instance, MSG_ROUTING_NONE, NULL),
+ page_delegate_(page_delegate) {
+ }
+
+void WizardWebPageViewTabContents::DidFailProvisionalLoadWithError(
+ RenderViewHost* render_view_host,
+ bool is_main_frame,
+ int error_code,
+ const GURL& url,
+ bool showing_repost_interstitial) {
+ page_delegate_->OnPageLoadFailed(url.spec());
+}
+
+void WizardWebPageViewTabContents::DidDisplayInsecureContent() {
+ page_delegate_->OnPageLoadFailed("");
+}
+
+void WizardWebPageViewTabContents::DidRunInsecureContent(
+ const std::string& security_origin) {
+ page_delegate_->OnPageLoadFailed(security_origin);
+}
+
+void WizardWebPageViewTabContents::DocumentLoadedInFrame() {
+ page_delegate_->OnPageLoaded();
+}
+
+void WizardWebPageViewTabContents::OnContentBlocked(ContentSettingsType type) {
+ page_delegate_->OnPageLoadFailed("");
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// WebPageDomView, public:
+
+void WebPageDomView::SetTabContentsDelegate(
+ TabContentsDelegate* delegate) {
+ tab_contents_->set_delegate(delegate);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// WebPageView, public:
+
+void WebPageView::Init() {
+ chromeos::CreateWizardBorder(
+ &chromeos::BorderDefinition::kScreenBorder)->GetInsets(&insets_);
+ views::Painter* painter = CreateWizardPainter(
+ &BorderDefinition::kScreenBorder);
+ set_background(
+ views::Background::CreateBackgroundPainter(true, painter));
+ dom_view()->SetVisible(false);
+ AddChildView(dom_view());
+
+ throbber_ = new views::Throbber(kThrobberFrameMs, false);
+ throbber_->SetFrames(
+ ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_SPINNER));
+ AddChildView(throbber_);
+
+ connecting_label_ = new views::Label();
+ connecting_label_->SetText(l10n_util::GetString(IDS_LOAD_STATE_CONNECTING));
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ connecting_label_->SetFont(rb.GetFont(ResourceBundle::MediumFont));
+ connecting_label_->SetVisible(false);
+ AddChildView(connecting_label_ );
+
+ start_timer_.Start(TimeDelta::FromMilliseconds(kStartDelayMs),
+ this,
+ &WebPageView::ShowWaitingControls);
+}
+
+void WebPageView::InitDOM(Profile* profile,
+ SiteInstance* site_instance) {
+ dom_view()->Init(profile, site_instance);
+}
+
+void WebPageView::LoadURL(const GURL& url) {
+ dom_view()->LoadURL(url);
+}
+
+void WebPageView::SetTabContentsDelegate(
+ TabContentsDelegate* delegate) {
+ dom_view()->SetTabContentsDelegate(delegate);
+}
+
+void WebPageView::SetWebPageDelegate(WebPageDelegate* delegate) {
+ dom_view()->set_web_page_delegate(delegate);
+}
+
+void WebPageView::ShowPageContent() {
+ // TODO(nkostylev): Show throbber as an overlay until page has been rendered.
+ start_timer_.Stop();
+ if (!stop_timer_.IsRunning()) {
+ stop_timer_.Start(TimeDelta::FromMilliseconds(kStopDelayMs),
+ this,
+ &WebPageView::ShowRenderedPage);
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// WebPageView, private:
+
+void WebPageView::ShowRenderedPage() {
+ throbber_->Stop();
+ connecting_label_->SetVisible(false);
+ dom_view()->SetVisible(true);
+}
+
+void WebPageView::ShowWaitingControls() {
+ throbber_->Start();
+ connecting_label_->SetVisible(true);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// WebPageView, views::View implementation:
+
+void WebPageView::Layout() {
+ dom_view()->SetBounds(insets_.left(),
+ insets_.top(),
+ bounds().width() - insets_.left() - insets_.right(),
+ bounds().height() - insets_.top() - insets_.bottom());
+ int y = height() / 2 - throbber_->GetPreferredSize().height() / 2;
+ throbber_->SetBounds(
+ width() / 2 - throbber_->GetPreferredSize().width() / 2,
+ y,
+ throbber_->GetPreferredSize().width(),
+ throbber_->GetPreferredSize().height());
+ connecting_label_->SetBounds(
+ width() / 2 - connecting_label_->GetPreferredSize().width() / 2,
+ y + throbber_->GetPreferredSize().height() + kSpacing,
+ connecting_label_->GetPreferredSize().width(),
+ connecting_label_->GetPreferredSize().height());
+}
+
+} // namespace chromeos
diff --git a/chrome/browser/chromeos/login/web_page_view.h b/chrome/browser/chromeos/login/web_page_view.h
new file mode 100644
index 0000000..224b89d
--- /dev/null
+++ b/chrome/browser/chromeos/login/web_page_view.h
@@ -0,0 +1,145 @@
+// Copyright (c) 2010 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_CHROMEOS_LOGIN_WEB_PAGE_VIEW_H_
+#define CHROME_BROWSER_CHROMEOS_LOGIN_WEB_PAGE_VIEW_H_
+
+#include <string>
+
+#include "base/timer.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/views/dom_view.h"
+#include "views/view.h"
+
+class Profile;
+class SiteContents;
+class TabContentsDelegate;
+
+namespace views {
+class Label;
+class Throbber;
+} // namespace views
+
+namespace chromeos {
+
+// Delegate interface for listening to common events during page load.
+class WebPageDelegate {
+ public:
+ virtual ~WebPageDelegate() {}
+
+ // Notify about document load event.
+ virtual void OnPageLoaded() = 0;
+
+ // Notify about navigation errors.
+ virtual void OnPageLoadFailed(const std::string& url) = 0;
+};
+
+// Base class for tab contents for pages rendered on wizard screens.
+class WizardWebPageViewTabContents : public TabContents {
+ public:
+ WizardWebPageViewTabContents(Profile* profile,
+ SiteInstance* site_instance,
+ WebPageDelegate* page_delegate);
+
+ virtual void DidFailProvisionalLoadWithError(
+ RenderViewHost* render_view_host,
+ bool is_main_frame,
+ int error_code,
+ const GURL& url,
+ bool showing_repost_interstitial);
+
+ virtual void DidDisplayInsecureContent();
+ virtual void DidRunInsecureContent(const std::string& security_origin);
+ virtual void DocumentLoadedInFrame();
+ virtual void OnContentBlocked(ContentSettingsType type);
+
+ private:
+ WebPageDelegate* page_delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(WizardWebPageViewTabContents);
+};
+
+// WebPageDomView is the view that is rendering the page.
+class WebPageDomView : public DOMView {
+ public:
+ WebPageDomView() : page_delegate_(NULL) {}
+
+ // Set delegate that will be notified about tab contents changes.
+ void SetTabContentsDelegate(TabContentsDelegate* delegate);
+
+ // Set delegate that will be notified about page events.
+ void set_web_page_delegate(WebPageDelegate* delegate) {
+ page_delegate_ = delegate;
+ }
+
+ protected:
+ // Overriden from DOMView:
+ virtual TabContents* CreateTabContents(Profile* profile,
+ SiteInstance* instance) = 0;
+ WebPageDelegate* page_delegate_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(WebPageDomView);
+};
+
+// WebPageView represents the view that holds WebPageDomView with
+// page rendered in it. While page is loaded spinner overlay is shown.
+class WebPageView : public views::View {
+ public:
+ WebPageView() : throbber_(NULL), connecting_label_(NULL) {}
+
+ // Initialize view layout.
+ void Init();
+
+ // Initialize the DOM view, creating the contents. This should be
+ // called once the view has been added to a container.
+ void InitDOM(Profile* profile, SiteInstance* site_instance);
+
+ // Loads the given URL into the page.
+ // You must have previously called Init() and SetTabContentsDelegate.
+ void LoadURL(const GURL& url);
+
+ // Sets delegate for tab contents changes.
+ void SetTabContentsDelegate(TabContentsDelegate* delegate);
+
+ // Set delegate that will be notified about page events.
+ void SetWebPageDelegate(WebPageDelegate* delegate);
+
+ // Stops throbber and shows page content (starts renderer_timer_ for that).
+ void ShowPageContent();
+
+ protected:
+ virtual WebPageDomView* dom_view() = 0;
+
+ private:
+ // Overriden from views::View:
+ virtual void Layout();
+
+ // Called by stop_timer_. Shows rendered page.
+ void ShowRenderedPage();
+
+ // Called by start_timer_. Shows throbber and waiting label.
+ void ShowWaitingControls();
+
+ // Screen border insets. Used for layout.
+ gfx::Insets insets_;
+
+ // Throbber shown during page load.
+ views::Throbber* throbber_;
+
+ // "Connecting..." label shown while waiting for the page to load/render.
+ views::Label* connecting_label_;
+
+ // Timer used when waiting for network response.
+ base::OneShotTimer<WebPageView> start_timer_;
+
+ // Timer used before toggling loaded page visibility.
+ base::OneShotTimer<WebPageView> stop_timer_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebPageView);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_LOGIN_WEB_PAGE_VIEW_H_
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index cb442ec..603b68b 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -429,6 +429,10 @@
'browser/chromeos/login/user_manager.cc',
'browser/chromeos/login/user_manager.h',
'browser/chromeos/login/view_screen.h',
+ 'browser/chromeos/login/web_page_screen.cc',
+ 'browser/chromeos/login/web_page_screen.h',
+ 'browser/chromeos/login/web_page_view.cc',
+ 'browser/chromeos/login/web_page_view.h',
'browser/chromeos/login/wizard_controller.cc',
'browser/chromeos/login/wizard_controller.h',
'browser/chromeos/login/wizard_screen.h',