summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authorkuan@chromium.org <kuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-29 16:41:53 +0000
committerkuan@chromium.org <kuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-29 16:41:53 +0000
commit8db841ac0528a7eba71e89260526da9ba33dbb54 (patch)
tree79501d52aa828b2bbaf87e91064f978851d702d2 /chrome/renderer
parent89e29d25efa776ed1f564e576d764fd3e9ddecfc (diff)
downloadchromium_src-8db841ac0528a7eba71e89260526da9ba33dbb54.zip
chromium_src-8db841ac0528a7eba71e89260526da9ba33dbb54.tar.gz
chromium_src-8db841ac0528a7eba71e89260526da9ba33dbb54.tar.bz2
implement error state for translate infobar
- this cl implements the UI on Windows and the partial backend of IPC messaging to include error type - implement error state - add translate error types - use a structure as details for IPC messaging between render view and browser so as to include error type (was using std::pair) - translate delegate handles error state and provides mapping to error messages - infobar handles visual error states - modify background painting to handle normal and error backgrounds, and animation of cross-fading between the 2 backgrounds - infobar now stores state (and translation_pending flag) that it's currently displaying to user, instead of just relying on TransateInfoBarDelegate's - if infobar receives PAGE_TRANSLAED notification before delegate does (possible because order is not fixed), delegate's state won't be updated to be used by infobar. - after all the observers have received the notification, both infobar and delegate will end up with matching states, so there's no worries of out-of-sync. - update unittests accordingly - update mac and linux code accordingly to make build pass - jay will implement the remaining backend to pass actual translate error types to the IPC message (tracked by bug 37778) BUG=38548 TEST=none yet, until bug 37778 is also fixed. Review URL: http://codereview.chromium.org/1321003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42953 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/render_view.cc6
-rw-r--r--chrome/renderer/render_view.h4
-rw-r--r--chrome/renderer/translate/page_translator.cc8
-rw-r--r--chrome/renderer/translate/page_translator.h4
4 files changed, 16 insertions, 6 deletions
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index dd0607d..11ee680 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -3079,9 +3079,11 @@ WebCookieJar* RenderView::GetCookieJar() {
void RenderView::PageTranslated(int page_id,
const std::string& original_lang,
- const std::string& target_lang) {
+ const std::string& target_lang,
+ TranslateErrors::Type error_type) {
Send(new ViewHostMsg_PageTranslated(routing_id_, page_id_,
- original_lang, target_lang));
+ original_lang, target_lang,
+ error_type));
}
void RenderView::SyncNavigationState() {
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 43605ef..e368bdc 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -28,6 +28,7 @@
#include "chrome/common/page_zoom.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/renderer_preferences.h"
+#include "chrome/common/translate_errors.h"
#include "chrome/common/view_types.h"
#include "chrome/renderer/automation/dom_automation_controller.h"
#include "chrome/renderer/dom_ui_bindings.h"
@@ -415,7 +416,8 @@ class RenderView : public RenderWidget,
// PageTranslator::PageTranslatorDelegate implementation:
virtual void PageTranslated(int page_id,
const std::string& original_lang,
- const std::string& target_lang);
+ const std::string& target_lang,
+ TranslateErrors::Type error_type);
// Do not delete directly. This class is reference counted.
virtual ~RenderView();
diff --git a/chrome/renderer/translate/page_translator.cc b/chrome/renderer/translate/page_translator.cc
index 22e24be..cba0001 100644
--- a/chrome/renderer/translate/page_translator.cc
+++ b/chrome/renderer/translate/page_translator.cc
@@ -231,8 +231,12 @@ void PageTranslator::TextTranslated(
ClearNodeZone(work_id);
- if (delegate_ && pending_translations_.empty())
- delegate_->PageTranslated(page_id_, original_language_, current_language_);
+ if (delegate_ && pending_translations_.empty()) {
+ // TODO(jcivelli): if there's error, pass in the actual error type.
+ TranslateErrors::Type error_type = TranslateErrors::NONE;
+ delegate_->PageTranslated(page_id_, original_language_, current_language_,
+ error_type);
+ }
}
void PageTranslator::TraverseNode(WebKit::WebNode node,
diff --git a/chrome/renderer/translate/page_translator.h b/chrome/renderer/translate/page_translator.h
index 2ec5401..2b1a9c3 100644
--- a/chrome/renderer/translate/page_translator.h
+++ b/chrome/renderer/translate/page_translator.h
@@ -14,6 +14,7 @@
#include "base/logging.h"
#include "base/scoped_ptr.h"
#include "base/string16.h"
+#include "chrome/common/translate_errors.h"
#include "chrome/renderer/translate/text_translator.h"
#include "third_party/WebKit/WebKit/chromium/public/WebElement.h"
@@ -40,7 +41,8 @@ class PageTranslator : public TextTranslator::Delegate {
virtual ~PageTranslatorDelegate() {}
virtual void PageTranslated(int page_id,
const std::string& original_lang,
- const std::string& target_lang) = 0;
+ const std::string& target_lang,
+ TranslateErrors::Type error_type) = 0;
};
// The caller remains the owner of |text_translator|.