Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: chrome/browser/automation/automation_provider.cc

Issue 3030042: New translate tests for pyauto.py (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Adding corpora Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/test/data/translate/ar/google.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/automation/automation_provider.h" 5 #include "chrome/browser/automation/automation_provider.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "app/message_box_flags.h" 9 #include "app/message_box_flags.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 2857 matching lines...) Expand 10 before | Expand all | Expand 10 after
2868 void AutomationProvider::WaitUntilTranslateComplete( 2868 void AutomationProvider::WaitUntilTranslateComplete(
2869 Browser* browser, DictionaryValue* args, IPC::Message* reply_message) { 2869 Browser* browser, DictionaryValue* args, IPC::Message* reply_message) {
2870 std::string error_message; 2870 std::string error_message;
2871 TabContents* tab_contents = GetTabContentsFromDict(browser, args, 2871 TabContents* tab_contents = GetTabContentsFromDict(browser, args,
2872 &error_message); 2872 &error_message);
2873 if (!tab_contents) { 2873 if (!tab_contents) {
2874 AutomationJSONReply(this, reply_message).SendError(error_message); 2874 AutomationJSONReply(this, reply_message).SendError(error_message);
2875 return; 2875 return;
2876 } 2876 }
2877 2877
2878 TranslateInfoBarDelegate* translate_bar =
2879 GetTranslateInfoBarDelegate(tab_contents);
2880 scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
2881
2882 if (!translate_bar) {
2883 return_value->SetBoolean(L"translation_success", false);
2884 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get());
2885 return;
2886 }
2887
2878 // If the translation is still pending, the observer will wait 2888 // If the translation is still pending, the observer will wait
2879 // for it to finish and then reply. 2889 // for it to finish and then reply.
2880 if (tab_contents->language_state().translation_pending()) { 2890 if (translate_bar->type() == TranslateInfoBarDelegate::TRANSLATING) {
2881 new PageTranslatedObserver(this, reply_message, tab_contents); 2891 new PageTranslatedObserver(this, reply_message, tab_contents);
2882 return; 2892 return;
2883 } 2893 }
2884 // Otherwise send back the success or failure of the attempted translation 2894
2885 // based on the translate bar state. 2895 // Otherwise send back the success or failure of the attempted translation.
2886 AutomationJSONReply reply(this, reply_message); 2896 return_value->SetBoolean(
2887 TranslateInfoBarDelegate* translate_bar = 2897 L"translation_success",
2888 GetTranslateInfoBarDelegate(tab_contents); 2898 translate_bar->type() == TranslateInfoBarDelegate::AFTER_TRANSLATE);
2889 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); 2899 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get());
2890 if (!translate_bar) {
2891 return_value->SetBoolean(L"translation_success", false);
2892 } else {
2893 return_value->SetBoolean(
2894 L"translation_success",
2895 translate_bar->type() == TranslateInfoBarDelegate::AFTER_TRANSLATE);
2896 }
2897 reply.SendSuccess(return_value.get());
2898 } 2900 }
2899 2901
2900 // Sample json input: { "command": "GetThemeInfo" } 2902 // Sample json input: { "command": "GetThemeInfo" }
2901 // Refer GetThemeInfo() in chrome/test/pyautolib/pyauto.py for sample output. 2903 // Refer GetThemeInfo() in chrome/test/pyautolib/pyauto.py for sample output.
2902 void AutomationProvider::GetThemeInfo(Browser* browser, 2904 void AutomationProvider::GetThemeInfo(Browser* browser,
2903 DictionaryValue* args, 2905 DictionaryValue* args,
2904 IPC::Message* reply_message) { 2906 IPC::Message* reply_message) {
2905 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); 2907 scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
2906 Extension* theme = browser->profile()->GetTheme(); 2908 Extension* theme = browser->profile()->GetTheme();
2907 if (theme) { 2909 if (theme) {
(...skipping 1577 matching lines...) Expand 10 before | Expand all | Expand 10 after
4485 } 4487 }
4486 4488
4487 void AutomationProvider::WaitForPopupMenuToOpen(IPC::Message* reply_message) { 4489 void AutomationProvider::WaitForPopupMenuToOpen(IPC::Message* reply_message) {
4488 NOTIMPLEMENTED(); 4490 NOTIMPLEMENTED();
4489 } 4491 }
4490 #endif // !defined(TOOLKIT_VIEWS) 4492 #endif // !defined(TOOLKIT_VIEWS)
4491 4493
4492 void AutomationProvider::ResetToDefaultTheme() { 4494 void AutomationProvider::ResetToDefaultTheme() {
4493 profile_->ClearTheme(); 4495 profile_->ClearTheme();
4494 } 4496 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/translate/ar/google.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698