summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authoraltimofeev@chromium.org <altimofeev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-06 18:49:19 +0000
committeraltimofeev@chromium.org <altimofeev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-06 18:49:19 +0000
commit83af80b25e45896da6b2947144c27795b0b2b61c (patch)
treea7a4ee0b12e7ea745e58440d93fac1ba3755b6e1 /chrome
parent21c7ff9afa9017603dd43007ce98939c2676a2c6 (diff)
downloadchromium_src-83af80b25e45896da6b2947144c27795b0b2b61c.zip
chromium_src-83af80b25e45896da6b2947144c27795b0b2b61c.tar.gz
chromium_src-83af80b25e45896da6b2947144c27795b0b2b61c.tar.bz2
Implements frame sniffer to watch iframe loading state.
Also sniffer listener was implemented on the WebUI side, which signals when GAIA page loading error appears. BUG=chromium-os:18744 TEST=Behind captive portal, try to click 'Add new user'. Corresponding message page should be shown. Review URL: http://codereview.chromium.org/7779010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99777 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/generated_resources.grd3
-rw-r--r--chrome/browser/chromeos/login/webui_login_view.cc42
-rw-r--r--chrome/browser/chromeos/login/webui_login_view.h1
-rw-r--r--chrome/browser/chromeos/tab_first_render_watcher.cc2
-rw-r--r--chrome/browser/chromeos/tab_first_render_watcher.h2
-rw-r--r--chrome/browser/resources/chromeos/login/oobe.js1
-rw-r--r--chrome/browser/resources/chromeos/login/screen_gaia_signin.js1
-rw-r--r--chrome/browser/resources/chromeos/login/screen_offline_message.html6
-rw-r--r--chrome/browser/resources/chromeos/login/screen_offline_message.js49
-rw-r--r--chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc2
-rw-r--r--chrome/chrome_renderer.gypi2
-rw-r--r--chrome/common/render_messages.h9
-rw-r--r--chrome/renderer/chrome_render_view_observer.cc10
-rw-r--r--chrome/renderer/chrome_render_view_observer.h1
-rw-r--r--chrome/renderer/frame_sniffer.cc30
-rw-r--r--chrome/renderer/frame_sniffer.h32
16 files changed, 182 insertions, 11 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 34e2a59..03da44d 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -13317,6 +13317,9 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_LOGIN_FIX_CAPTIVE_PORTAL" desc="An link text to fix Internet connection (captive portal) in guest mode.">
Start a Guest session
</message>
+ <message name="IDS_LOGIN_MAYBE_CAPTIVE_PORTAL" desc="An offline message shown when we suggest that user may be behind the captive portal.">
+ Connected to a network, but still can't sign in? You might be on a network that requires a web-based authentication. Start a guest browsing session (if available) and see if a network log-in page appears. Once you're logged in to the network and are able to visit different web pages, exit the guest session and try signing in again.
+ </message>
<message name="IDS_LOGIN_ERROR_CAPTIVE_PORTAL_NO_GUEST_MODE" desc="An error message shown when we suggest that user may be behind the captive portal but Guest mode is disabled.">
Your password cannot be verified on this current network. Please select another network.
</message>
diff --git a/chrome/browser/chromeos/login/webui_login_view.cc b/chrome/browser/chromeos/login/webui_login_view.cc
index 33c549c..97f7429 100644
--- a/chrome/browser/chromeos/login/webui_login_view.cc
+++ b/chrome/browser/chromeos/login/webui_login_view.cc
@@ -5,6 +5,8 @@
#include "chrome/browser/chromeos/login/webui_login_view.h"
#include "base/i18n/rtl.h"
+#include "base/utf_string_conversions.h"
+#include "base/values.h"
#include "chrome/browser/chromeos/accessibility_util.h"
#include "chrome/browser/chromeos/login/proxy_settings_dialog.h"
#include "chrome/browser/chromeos/login/webui_login_display.h"
@@ -15,6 +17,8 @@
#include "chrome/browser/chromeos/wm_ipc.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/views/dom_view.h"
+#include "chrome/common/render_messages.h"
+#include "content/browser/renderer_host/render_view_host_observer.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
@@ -33,6 +37,39 @@ const char kViewClassName[] = "browser/chromeos/login/WebUILoginView";
const char kAccelNameAccessibility[] = "accessibility";
const char kAccelNameEnrollment[] = "enrollment";
+// Observes IPC messages from the FrameSniffer and notifies JS if error
+// appears.
+class SnifferObserver : public RenderViewHostObserver {
+ public:
+ SnifferObserver(RenderViewHost* host, WebUI* webui)
+ : RenderViewHostObserver(host), webui_(webui) {
+ DCHECK(webui_);
+ Send(new ChromeViewMsg_StartFrameSniffer(routing_id(),
+ UTF8ToUTF16("gaia-frame")));
+ }
+
+ virtual ~SnifferObserver() {}
+
+ // IPC::Channel::Listener implementation.
+ virtual bool OnMessageReceived(const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(SnifferObserver, message)
+ IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FrameLoadingError, OnError)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+ }
+
+ private:
+ void OnError(int error) {
+ base::FundamentalValue error_value(error);
+ webui_->CallJavascriptFunction("login.OfflineMessageScreen.onFrameError",
+ error_value);
+ }
+
+ WebUI* webui_;
+};
+
// A View class which places its first child at the right most position.
class RightAlignedView : public views::View {
public:
@@ -53,7 +90,6 @@ void RightAlignedView::ChildPreferredSizeChanged(View* child) {
Layout();
}
-
} // namespace
namespace chromeos {
@@ -226,6 +262,10 @@ void WebUILoginView::OnLocaleChanged() {
SchedulePaint();
}
+void WebUILoginView::OnRenderHostCreated(RenderViewHost* host) {
+ new SnifferObserver(host, GetWebUI());
+}
+
void WebUILoginView::OnTabMainFrameLoaded() {
}
diff --git a/chrome/browser/chromeos/login/webui_login_view.h b/chrome/browser/chromeos/login/webui_login_view.h
index 38912d3..76090e9 100644
--- a/chrome/browser/chromeos/login/webui_login_view.h
+++ b/chrome/browser/chromeos/login/webui_login_view.h
@@ -91,6 +91,7 @@ class WebUILoginView : public views::View,
virtual void OnLocaleChanged() OVERRIDE;
// TabFirstRenderWatcher::Delegate implementation.
+ virtual void OnRenderHostCreated(RenderViewHost* host) OVERRIDE;
virtual void OnTabMainFrameLoaded() OVERRIDE;
virtual void OnTabMainFrameFirstRender() OVERRIDE;
diff --git a/chrome/browser/chromeos/tab_first_render_watcher.cc b/chrome/browser/chromeos/tab_first_render_watcher.cc
index fecb253..9768377 100644
--- a/chrome/browser/chromeos/tab_first_render_watcher.cc
+++ b/chrome/browser/chromeos/tab_first_render_watcher.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/chromeos/tab_first_render_watcher.h"
#include "content/browser/renderer_host/render_widget_host.h"
+#include "content/browser/renderer_host/render_view_host.h"
#include "content/common/content_notification_types.h"
#include "content/common/notification_details.h"
#include "content/common/notification_source.h"
@@ -32,6 +33,7 @@ void TabFirstRenderWatcher::Observe(int type,
registrar_.Add(this,
content::NOTIFICATION_RENDER_WIDGET_HOST_DID_PAINT,
Source<RenderWidgetHost>(rwh));
+ delegate_->OnRenderHostCreated(Details<RenderViewHost>(details).ptr());
break;
}
case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME:
diff --git a/chrome/browser/chromeos/tab_first_render_watcher.h b/chrome/browser/chromeos/tab_first_render_watcher.h
index 9f87051..2fde9b0 100644
--- a/chrome/browser/chromeos/tab_first_render_watcher.h
+++ b/chrome/browser/chromeos/tab_first_render_watcher.h
@@ -10,6 +10,7 @@
#include "content/common/notification_observer.h"
#include "content/common/notification_registrar.h"
+class RenderViewHost;
class TabContents;
namespace chromeos {
@@ -20,6 +21,7 @@ class TabFirstRenderWatcher : public NotificationObserver {
public:
class Delegate {
public:
+ virtual void OnRenderHostCreated(RenderViewHost* host) = 0;
virtual void OnTabMainFrameLoaded() = 0;
virtual void OnTabMainFrameFirstRender() = 0;
};
diff --git a/chrome/browser/resources/chromeos/login/oobe.js b/chrome/browser/resources/chromeos/login/oobe.js
index e301085..8ff5b2c 100644
--- a/chrome/browser/resources/chromeos/login/oobe.js
+++ b/chrome/browser/resources/chromeos/login/oobe.js
@@ -225,7 +225,6 @@ cr.define('cr.ui', function() {
prepareForLoginDisplay_ : function() {
for (var i = 0, screenId; screenId = this.screens_[i]; ++i) {
var screen = $(screenId);
-
screen.classList.add('faded');
screen.classList.remove('right');
screen.classList.remove('left');
diff --git a/chrome/browser/resources/chromeos/login/screen_gaia_signin.js b/chrome/browser/resources/chromeos/login/screen_gaia_signin.js
index 3532ac8..fe95a81 100644
--- a/chrome/browser/resources/chromeos/login/screen_gaia_signin.js
+++ b/chrome/browser/resources/chromeos/login/screen_gaia_signin.js
@@ -144,6 +144,7 @@ cr.define('login', function() {
chrome.send('completeLogin', [msg.email, msg.password] );
this.loading = true;
} else if (msg.method == 'loginUILoaded' && this.isAuthExtMessage_(e)) {
+ $('offline-message').update();
this.loading = false;
chrome.send('loginWebuiReady');
}
diff --git a/chrome/browser/resources/chromeos/login/screen_offline_message.html b/chrome/browser/resources/chromeos/login/screen_offline_message.html
index 0cdc58c..3167a7e 100644
--- a/chrome/browser/resources/chromeos/login/screen_offline_message.html
+++ b/chrome/browser/resources/chromeos/login/screen_offline_message.html
@@ -1,4 +1,8 @@
<div id="offline-message" class="step faded hidden">
<span id="offline-message-title" i18n-content="offlineMessageTitle"></span>
- <span id="offline-message-body" i18n-content="offlineMessageBody"></span>
+ <div id="offline-message-body">
+ <span id="offline-message-text" i18n-content="offlineMessageBody"></span>
+ <span id="captive-portal-message-text" hidden
+ i18n-content="captivePortalMessage"></span>
+ </div>
</div>
diff --git a/chrome/browser/resources/chromeos/login/screen_offline_message.js b/chrome/browser/resources/chromeos/login/screen_offline_message.js
index c557bb0..ee34328 100644
--- a/chrome/browser/resources/chromeos/login/screen_offline_message.js
+++ b/chrome/browser/resources/chromeos/login/screen_offline_message.js
@@ -49,15 +49,20 @@ cr.define('login', function() {
var shouldOverlay = MANAGED_SCREENS.indexOf(currentScreen.id) != -1;
if (isOffline && shouldOverlay) {
+ $('offline-message-text').hidden = false;
+ $('captive-portal-message-text').hidden = true;
+
offlineMessage.classList.remove('hidden');
offlineMessage.classList.remove('faded');
- currentScreen.classList.add('faded');
- currentScreen.addEventListener('webkitTransitionEnd',
- function f(e) {
- currentScreen.removeEventListener('webkitTransitionEnd', f);
- currentScreen.classList.add('hidden');
- });
+ if (!currentScreen.classList.contains('faded')) {
+ currentScreen.classList.add('faded');
+ currentScreen.addEventListener('webkitTransitionEnd',
+ function f(e) {
+ currentScreen.removeEventListener('webkitTransitionEnd', f);
+ currentScreen.classList.add('hidden');
+ });
+ }
} else {
if (!offlineMessage.classList.contains('faded')) {
offlineMessage.classList.add('faded');
@@ -85,6 +90,38 @@ cr.define('login', function() {
}
};
+ /**
+ * Handler for iframe's error notification coming from the outside.
+ * For more info see C++ class 'SnifferObserver' which calls this method.
+ * @param {number} error Error code.
+ */
+ OfflineMessageScreen.onFrameError = function(error) {
+ var currentScreen = Oobe.getInstance().currentScreen;
+ var offlineMessage = $('offline-message');
+ var isOffline = !window.navigator.onLine;
+ var shouldOverlay = MANAGED_SCREENS.indexOf(currentScreen.id) != -1;
+
+ if (!shouldOverlay)
+ return;
+
+ if (!isOffline) {
+ $('offline-message-text').hidden = true;
+ $('captive-portal-message-text').hidden = false;
+ }
+
+ if (!currentScreen.classList.contains('faded')) {
+ offlineMessage.classList.remove('hidden');
+ offlineMessage.classList.remove('faded');
+
+ currentScreen.classList.add('faded');
+ currentScreen.addEventListener('webkitTransitionEnd',
+ function f(e) {
+ currentScreen.removeEventListener('webkitTransitionEnd', f);
+ currentScreen.classList.add('hidden');
+ });
+ }
+ };
+
return {
OfflineMessageScreen: OfflineMessageScreen
};
diff --git a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
index d442b77..69ddddb5 100644
--- a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
+++ b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
@@ -160,6 +160,8 @@ void SigninScreenHandler::GetLocalizedStrings(
l10n_util::GetStringUTF16(IDS_LOGIN_OFFLINE_TITLE));
localized_strings->SetString("offlineMessageBody",
l10n_util::GetStringUTF16(IDS_LOGIN_OFFLINE_MESSAGE));
+ localized_strings->SetString("captivePortalMessage",
+ l10n_util::GetStringUTF16(IDS_LOGIN_MAYBE_CAPTIVE_PORTAL));
localized_strings->SetString("createAccount",
l10n_util::GetStringUTF16(IDS_CREATE_ACCOUNT_HTML));
localized_strings->SetString("guestSignin",
diff --git a/chrome/chrome_renderer.gypi b/chrome/chrome_renderer.gypi
index 116e33f..1eb70de 100644
--- a/chrome/chrome_renderer.gypi
+++ b/chrome/chrome_renderer.gypi
@@ -82,6 +82,8 @@
'renderer/extensions/user_script_idle_scheduler.h',
'renderer/extensions/user_script_slave.cc',
'renderer/extensions/user_script_slave.h',
+ 'renderer/frame_sniffer.cc',
+ 'renderer/frame_sniffer.h',
'renderer/loadtimes_extension_bindings.h',
'renderer/loadtimes_extension_bindings.cc',
'renderer/net/predictor_queue.cc',
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index f28e17d..e10e191 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -289,6 +289,10 @@ IPC_MESSAGE_ROUTED1(ChromeViewMsg_SetAllowRunningInsecureContent,
IPC_MESSAGE_ROUTED1(ChromeViewMsg_SetClientSidePhishingDetection,
bool /* enable_phishing_detection */)
+// This message asks frame sniffer start.
+IPC_MESSAGE_ROUTED1(ChromeViewMsg_StartFrameSniffer,
+ string16 /* frame-name */)
+
// JavaScript related messages -----------------------------------------------
// Notify the JavaScript engine in the render to change its parameters
@@ -532,6 +536,10 @@ IPC_MESSAGE_ROUTED2(ChromeViewHostMsg_InstantSupportDetermined,
// The currently displayed PDF has an unsupported feature.
IPC_MESSAGE_ROUTED0(ChromeViewHostMsg_PDFHasUnsupportedFeature)
+// This message indicates the error appeared in the frame.
+IPC_MESSAGE_ROUTED1(ChromeViewHostMsg_FrameLoadingError,
+ int /* error */)
+
// The following messages are used to set and get cookies for ChromeFrame
// processes.
// Used to set a cookie. The cookie is set asynchronously, but will be
@@ -547,4 +555,3 @@ IPC_SYNC_MESSAGE_ROUTED2_1(ChromeViewHostMsg_GetCookies,
GURL /* url */,
GURL /* first_party_for_cookies */,
std::string /* cookies */)
-
diff --git a/chrome/renderer/chrome_render_view_observer.cc b/chrome/renderer/chrome_render_view_observer.cc
index 6e7c1e5..d263e1e 100644
--- a/chrome/renderer/chrome_render_view_observer.cc
+++ b/chrome/renderer/chrome_render_view_observer.cc
@@ -15,10 +15,11 @@
#include "chrome/common/thumbnail_score.h"
#include "chrome/common/url_constants.h"
#include "chrome/renderer/about_handler.h"
-#include "chrome/renderer/content_settings_observer.h"
#include "chrome/renderer/automation/dom_automation_controller.h"
+#include "chrome/renderer/content_settings_observer.h"
#include "chrome/renderer/extensions/extension_renderer_context.h"
#include "chrome/renderer/external_host_bindings.h"
+#include "chrome/renderer/frame_sniffer.h"
#include "chrome/renderer/prerender/prerender_helper.h"
#include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h"
#include "chrome/renderer/translate_helper.h"
@@ -238,6 +239,9 @@ bool ChromeRenderViewObserver::OnMessageReceived(const IPC::Message& message) {
OnSetAllowRunningInsecureContent)
IPC_MESSAGE_HANDLER(ChromeViewMsg_SetClientSidePhishingDetection,
OnSetClientSidePhishingDetection)
+#if defined(OS_CHROMEOS)
+ IPC_MESSAGE_HANDLER(ChromeViewMsg_StartFrameSniffer, OnStartFrameSniffer)
+#endif
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -341,6 +345,10 @@ void ChromeRenderViewObserver::OnSetClientSidePhishingDetection(
#endif
}
+void ChromeRenderViewObserver::OnStartFrameSniffer(const string16& frame_name) {
+ new FrameSniffer(render_view(), frame_name);
+}
+
bool ChromeRenderViewObserver::allowDatabase(
WebFrame* frame,
const WebString& name,
diff --git a/chrome/renderer/chrome_render_view_observer.h b/chrome/renderer/chrome_render_view_observer.h
index baba525..9797ffd 100644
--- a/chrome/renderer/chrome_render_view_observer.h
+++ b/chrome/renderer/chrome_render_view_observer.h
@@ -118,6 +118,7 @@ class ChromeRenderViewObserver : public RenderViewObserver,
void OnSetAllowDisplayingInsecureContent(bool allow);
void OnSetAllowRunningInsecureContent(bool allow);
void OnSetClientSidePhishingDetection(bool enable_phishing_detection);
+ void OnStartFrameSniffer(const string16& frame_name);
// Captures the thumbnail and text contents for indexing for the given load
// ID. If the view's load ID is different than the parameter, this call is
diff --git a/chrome/renderer/frame_sniffer.cc b/chrome/renderer/frame_sniffer.cc
new file mode 100644
index 0000000..e026b39
--- /dev/null
+++ b/chrome/renderer/frame_sniffer.cc
@@ -0,0 +1,30 @@
+// 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/renderer/frame_sniffer.h"
+
+#include "base/logging.h"
+#include "chrome/common/render_messages.h"
+#include "content/common/view_messages.h"
+#include "content/renderer/navigation_state.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h"
+
+FrameSniffer::FrameSniffer(RenderView* render_view, const string16 &frame_name)
+ : RenderViewObserver(render_view), frame_name_(frame_name) {
+}
+
+FrameSniffer::~FrameSniffer() {
+}
+
+void FrameSniffer::DidFailProvisionalLoad(WebKit::WebFrame* frame,
+ const WebKit::WebURLError& error) {
+ if (!ShouldSniffFrame(frame))
+ return;
+ Send(new ChromeViewHostMsg_FrameLoadingError(routing_id(), -error.reason));
+}
+
+bool FrameSniffer::ShouldSniffFrame(WebKit::WebFrame* frame) {
+ return frame->name() == frame_name_;
+}
diff --git a/chrome/renderer/frame_sniffer.h b/chrome/renderer/frame_sniffer.h
new file mode 100644
index 0000000..ae022ba
--- /dev/null
+++ b/chrome/renderer/frame_sniffer.h
@@ -0,0 +1,32 @@
+// 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_RENDERER_FRAME_SNIFFER_H_
+#define CHROME_RENDERER_FRAME_SNIFFER_H_
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "content/renderer/render_view_observer.h"
+
+// Class which observes events from the frame with specific name and sends IPC
+// messages to be handled by RenderViewHostObserver.
+class FrameSniffer : public RenderViewObserver {
+ public:
+ FrameSniffer(RenderView* render_view, const string16 &frame_name);
+ virtual ~FrameSniffer();
+
+ // Implements RenderViewObserver.
+ virtual void DidFailProvisionalLoad(
+ WebKit::WebFrame* frame, const WebKit::WebURLError& error) OVERRIDE;
+
+ private:
+ bool ShouldSniffFrame(WebKit::WebFrame* frame);
+
+ // Name of the frame to be monitored.
+ string16 frame_name_;
+
+ DISALLOW_COPY_AND_ASSIGN(FrameSniffer);
+};
+
+#endif // CHROME_RENDERER_FRAME_SNIFFER_H_