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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/testing_automation_provider.h" 5 #include "chrome/browser/automation/testing_automation_provider.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 #include "chrome/browser/ui/download/download_tab_helper.h" 80 #include "chrome/browser/ui/download/download_tab_helper.h"
81 #include "chrome/browser/ui/find_bar/find_bar.h" 81 #include "chrome/browser/ui/find_bar/find_bar.h"
82 #include "chrome/browser/ui/login/login_prompt.h" 82 #include "chrome/browser/ui/login/login_prompt.h"
83 #include "chrome/browser/ui/omnibox/location_bar.h" 83 #include "chrome/browser/ui/omnibox/location_bar.h"
84 #include "chrome/browser/ui/omnibox/omnibox_view.h" 84 #include "chrome/browser/ui/omnibox/omnibox_view.h"
85 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h" 85 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h"
86 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 86 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
87 #include "chrome/browser/ui/webui/ntp/shown_sections_handler.h" 87 #include "chrome/browser/ui/webui/ntp/shown_sections_handler.h"
88 #include "chrome/common/automation_messages.h" 88 #include "chrome/common/automation_messages.h"
89 #include "chrome/common/chrome_constants.h" 89 #include "chrome/common/chrome_constants.h"
90 #include "chrome/common/chrome_notification_types.h"
90 #include "chrome/common/chrome_paths.h" 91 #include "chrome/common/chrome_paths.h"
91 #include "chrome/common/chrome_switches.h" 92 #include "chrome/common/chrome_switches.h"
92 #include "chrome/common/extensions/extension.h" 93 #include "chrome/common/extensions/extension.h"
93 #include "chrome/common/extensions/url_pattern.h" 94 #include "chrome/common/extensions/url_pattern.h"
94 #include "chrome/common/extensions/url_pattern_set.h" 95 #include "chrome/common/extensions/url_pattern_set.h"
95 #include "chrome/common/pref_names.h" 96 #include "chrome/common/pref_names.h"
96 #include "chrome/common/render_messages.h" 97 #include "chrome/common/render_messages.h"
97 #include "chrome/common/url_constants.h" 98 #include "chrome/common/url_constants.h"
98 #include "content/browser/debugger/devtools_window.h" 99 #include "content/browser/debugger/devtools_window.h"
99 #include "content/browser/renderer_host/render_process_host.h" 100 #include "content/browser/renderer_host/render_process_host.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 155
155 } // namespace 156 } // namespace
156 157
157 TestingAutomationProvider::TestingAutomationProvider(Profile* profile) 158 TestingAutomationProvider::TestingAutomationProvider(Profile* profile)
158 : AutomationProvider(profile), 159 : AutomationProvider(profile),
159 #if defined(TOOLKIT_VIEWS) 160 #if defined(TOOLKIT_VIEWS)
160 popup_menu_waiter_(NULL), 161 popup_menu_waiter_(NULL),
161 #endif 162 #endif
162 redirect_query_(0) { 163 redirect_query_(0) {
163 BrowserList::AddObserver(this); 164 BrowserList::AddObserver(this);
164 registrar_.Add(this, NotificationType::SESSION_END, 165 registrar_.Add(this, chrome::NOTIFICATION_SESSION_END,
165 NotificationService::AllSources()); 166 NotificationService::AllSources());
166 } 167 }
167 168
168 TestingAutomationProvider::~TestingAutomationProvider() { 169 TestingAutomationProvider::~TestingAutomationProvider() {
169 BrowserList::RemoveObserver(this); 170 BrowserList::RemoveObserver(this);
170 } 171 }
171 172
172 IPC::Channel::Mode TestingAutomationProvider::GetChannelMode( 173 IPC::Channel::Mode TestingAutomationProvider::GetChannelMode(
173 bool use_named_interface) { 174 bool use_named_interface) {
174 if (use_named_interface) 175 if (use_named_interface)
175 #if defined(OS_POSIX) 176 #if defined(OS_POSIX)
176 return IPC::Channel::MODE_OPEN_NAMED_SERVER; 177 return IPC::Channel::MODE_OPEN_NAMED_SERVER;
177 #else 178 #else
178 return IPC::Channel::MODE_NAMED_SERVER; 179 return IPC::Channel::MODE_NAMED_SERVER;
179 #endif 180 #endif
180 else 181 else
181 return IPC::Channel::MODE_CLIENT; 182 return IPC::Channel::MODE_CLIENT;
182 } 183 }
183 184
184 void TestingAutomationProvider::OnBrowserAdded(const Browser* browser) { 185 void TestingAutomationProvider::OnBrowserAdded(const Browser* browser) {
185 } 186 }
186 187
187 void TestingAutomationProvider::OnBrowserRemoved(const Browser* browser) { 188 void TestingAutomationProvider::OnBrowserRemoved(const Browser* browser) {
188 // For backwards compatibility with the testing automation interface, we 189 // For backwards compatibility with the testing automation interface, we
189 // want the automation provider (and hence the process) to go away when the 190 // want the automation provider (and hence the process) to go away when the
190 // last browser goes away. 191 // last browser goes away.
191 if (BrowserList::empty() && !CommandLine::ForCurrentProcess()->HasSwitch( 192 if (BrowserList::empty() && !CommandLine::ForCurrentProcess()->HasSwitch(
192 switches::kKeepAliveForTest)) { 193 switches::kKeepAliveForTest)) {
193 // If you change this, update Observer for NotificationType::SESSION_END 194 // If you change this, update Observer for chrome::SESSION_END
194 // below. 195 // below.
195 MessageLoop::current()->PostTask(FROM_HERE, 196 MessageLoop::current()->PostTask(FROM_HERE,
196 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider)); 197 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider));
197 } 198 }
198 } 199 }
199 200
200 void TestingAutomationProvider::OnSourceProfilesLoaded() { 201 void TestingAutomationProvider::OnSourceProfilesLoaded() {
201 DCHECK_NE(static_cast<ImporterList*>(NULL), importer_list_.get()); 202 DCHECK_NE(static_cast<ImporterList*>(NULL), importer_list_.get());
202 203
203 // Get the correct profile based on the browser that the user provided. 204 // Get the correct profile based on the browser that the user provided.
(...skipping 20 matching lines...) Expand all
224 this, import_settings_data_.reply_message)); 225 this, import_settings_data_.reply_message));
225 226
226 Profile* target_profile = import_settings_data_.browser->profile(); 227 Profile* target_profile = import_settings_data_.browser->profile();
227 importer_host->StartImportSettings(source_profile, 228 importer_host->StartImportSettings(source_profile,
228 target_profile, 229 target_profile,
229 import_settings_data_.import_items, 230 import_settings_data_.import_items,
230 new ProfileWriter(target_profile), 231 new ProfileWriter(target_profile),
231 import_settings_data_.first_run); 232 import_settings_data_.first_run);
232 } 233 }
233 234
234 void TestingAutomationProvider::Observe(NotificationType type, 235 void TestingAutomationProvider::Observe(int type,
235 const NotificationSource& source, 236 const NotificationSource& source,
236 const NotificationDetails& details) { 237 const NotificationDetails& details) {
237 DCHECK(type == NotificationType::SESSION_END); 238 DCHECK(type == chrome::NOTIFICATION_SESSION_END);
238 // OnBrowserRemoved does a ReleaseLater. When session end is received we exit 239 // OnBrowserRemoved does a ReleaseLater. When session end is received we exit
239 // before the task runs resulting in this object not being deleted. This 240 // before the task runs resulting in this object not being deleted. This
240 // Release balance out the Release scheduled by OnBrowserRemoved. 241 // Release balance out the Release scheduled by OnBrowserRemoved.
241 Release(); 242 Release();
242 } 243 }
243 244
244 bool TestingAutomationProvider::OnMessageReceived( 245 bool TestingAutomationProvider::OnMessageReceived(
245 const IPC::Message& message) { 246 const IPC::Message& message) {
246 bool handled = true; 247 bool handled = true;
247 bool deserialize_success = true; 248 bool deserialize_success = true;
(...skipping 3614 matching lines...) Expand 10 before | Expand all | Expand 10 after
3862 GetTranslateInfoBarDelegate(tab_contents); 3863 GetTranslateInfoBarDelegate(tab_contents);
3863 3864
3864 TabLanguageDeterminedObserver* observer = new TabLanguageDeterminedObserver( 3865 TabLanguageDeterminedObserver* observer = new TabLanguageDeterminedObserver(
3865 this, reply_message, tab_contents, translate_bar); 3866 this, reply_message, tab_contents, translate_bar);
3866 // If the language for the page hasn't been loaded yet, then just make 3867 // If the language for the page hasn't been loaded yet, then just make
3867 // the observer, otherwise call observe directly. 3868 // the observer, otherwise call observe directly.
3868 TranslateTabHelper* helper = TabContentsWrapper::GetCurrentWrapperForContents( 3869 TranslateTabHelper* helper = TabContentsWrapper::GetCurrentWrapperForContents(
3869 tab_contents)->translate_tab_helper(); 3870 tab_contents)->translate_tab_helper();
3870 std::string language = helper->language_state().original_language(); 3871 std::string language = helper->language_state().original_language();
3871 if (!language.empty()) { 3872 if (!language.empty()) {
3872 observer->Observe(NotificationType::TAB_LANGUAGE_DETERMINED, 3873 observer->Observe(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED,
3873 Source<TabContents>(tab_contents), 3874 Source<TabContents>(tab_contents),
3874 Details<std::string>(&language)); 3875 Details<std::string>(&language));
3875 } 3876 }
3876 } 3877 }
3877 3878
3878 // See SelectTranslateOption() in chrome/test/pyautolib/pyauto.py for sample 3879 // See SelectTranslateOption() in chrome/test/pyautolib/pyauto.py for sample
3879 // json input. 3880 // json input.
3880 // Sample json output: {} 3881 // Sample json output: {}
3881 void TestingAutomationProvider::SelectTranslateOption( 3882 void TestingAutomationProvider::SelectTranslateOption(
3882 Browser* browser, 3883 Browser* browser,
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
4374 } 4375 }
4375 4376
4376 TabContents* tab_contents = browser->GetTabContentsAt(tab_index); 4377 TabContents* tab_contents = browser->GetTabContentsAt(tab_index);
4377 if (!tab_contents) { 4378 if (!tab_contents) {
4378 AutomationJSONReply(this, reply_message).SendError( 4379 AutomationJSONReply(this, reply_message).SendError(
4379 StringPrintf("No such tab at index %d", tab_index)); 4380 StringPrintf("No such tab at index %d", tab_index));
4380 return; 4381 return;
4381 } 4382 }
4382 4383
4383 new AutofillDisplayedObserver( 4384 new AutofillDisplayedObserver(
4384 NotificationType::AUTOFILL_DID_SHOW_SUGGESTIONS, 4385 chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS,
4385 tab_contents->render_view_host(), this, reply_message); 4386 tab_contents->render_view_host(), this, reply_message);
4386 SendWebKeyPressEventAsync(ui::VKEY_DOWN, tab_contents); 4387 SendWebKeyPressEventAsync(ui::VKEY_DOWN, tab_contents);
4387 } 4388 }
4388 4389
4389 void TestingAutomationProvider::AutofillHighlightSuggestion( 4390 void TestingAutomationProvider::AutofillHighlightSuggestion(
4390 Browser* browser, 4391 Browser* browser,
4391 DictionaryValue* args, 4392 DictionaryValue* args,
4392 IPC::Message* reply_message) { 4393 IPC::Message* reply_message) {
4393 int tab_index; 4394 int tab_index;
4394 if (!args->GetInteger("tab_index", &tab_index)) { 4395 if (!args->GetInteger("tab_index", &tab_index)) {
(...skipping 12 matching lines...) Expand all
4407 std::string direction; 4408 std::string direction;
4408 if (!args->GetString("direction", &direction) || (direction != "up" && 4409 if (!args->GetString("direction", &direction) || (direction != "up" &&
4409 direction != "down")) { 4410 direction != "down")) {
4410 AutomationJSONReply(this, reply_message).SendError( 4411 AutomationJSONReply(this, reply_message).SendError(
4411 "Must specify a direction of either 'up' or 'down'."); 4412 "Must specify a direction of either 'up' or 'down'.");
4412 return; 4413 return;
4413 } 4414 }
4414 int key_code = (direction == "up") ? ui::VKEY_UP : ui::VKEY_DOWN; 4415 int key_code = (direction == "up") ? ui::VKEY_UP : ui::VKEY_DOWN;
4415 4416
4416 new AutofillDisplayedObserver( 4417 new AutofillDisplayedObserver(
4417 NotificationType::AUTOFILL_DID_FILL_FORM_DATA, 4418 chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA,
4418 tab_contents->render_view_host(), this, reply_message); 4419 tab_contents->render_view_host(), this, reply_message);
4419 SendWebKeyPressEventAsync(key_code, tab_contents); 4420 SendWebKeyPressEventAsync(key_code, tab_contents);
4420 } 4421 }
4421 4422
4422 void TestingAutomationProvider::AutofillAcceptSelection( 4423 void TestingAutomationProvider::AutofillAcceptSelection(
4423 Browser* browser, 4424 Browser* browser,
4424 DictionaryValue* args, 4425 DictionaryValue* args,
4425 IPC::Message* reply_message) { 4426 IPC::Message* reply_message) {
4426 int tab_index; 4427 int tab_index;
4427 if (!args->GetInteger("tab_index", &tab_index)) { 4428 if (!args->GetInteger("tab_index", &tab_index)) {
4428 AutomationJSONReply(this, reply_message).SendError( 4429 AutomationJSONReply(this, reply_message).SendError(
4429 "Invalid or missing args"); 4430 "Invalid or missing args");
4430 return; 4431 return;
4431 } 4432 }
4432 4433
4433 TabContents* tab_contents = browser->GetTabContentsAt(tab_index); 4434 TabContents* tab_contents = browser->GetTabContentsAt(tab_index);
4434 if (!tab_contents) { 4435 if (!tab_contents) {
4435 AutomationJSONReply(this, reply_message).SendError( 4436 AutomationJSONReply(this, reply_message).SendError(
4436 StringPrintf("No such tab at index %d", tab_index)); 4437 StringPrintf("No such tab at index %d", tab_index));
4437 return; 4438 return;
4438 } 4439 }
4439 4440
4440 new AutofillDisplayedObserver( 4441 new AutofillDisplayedObserver(
4441 NotificationType::AUTOFILL_DID_FILL_FORM_DATA, 4442 chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA,
4442 tab_contents->render_view_host(), this, reply_message); 4443 tab_contents->render_view_host(), this, reply_message);
4443 SendWebKeyPressEventAsync(ui::VKEY_RETURN, tab_contents); 4444 SendWebKeyPressEventAsync(ui::VKEY_RETURN, tab_contents);
4444 } 4445 }
4445 4446
4446 // Sample json output: { "success": true } 4447 // Sample json output: { "success": true }
4447 void TestingAutomationProvider::SignInToSync(Browser* browser, 4448 void TestingAutomationProvider::SignInToSync(Browser* browser,
4448 DictionaryValue* args, 4449 DictionaryValue* args,
4449 IPC::Message* reply_message) { 4450 IPC::Message* reply_message) {
4450 AutomationJSONReply reply(this, reply_message); 4451 AutomationJSONReply reply(this, reply_message);
4451 std::string username; 4452 std::string username;
(...skipping 1597 matching lines...) Expand 10 before | Expand all | Expand 10 after
6049 IPC::ParamTraits<std::vector<GURL> >::Write(reply_message_, redirects_gurl); 6050 IPC::ParamTraits<std::vector<GURL> >::Write(reply_message_, redirects_gurl);
6050 6051
6051 Send(reply_message_); 6052 Send(reply_message_);
6052 redirect_query_ = 0; 6053 redirect_query_ = 0;
6053 reply_message_ = NULL; 6054 reply_message_ = NULL;
6054 } 6055 }
6055 6056
6056 void TestingAutomationProvider::OnRemoveProvider() { 6057 void TestingAutomationProvider::OnRemoveProvider() {
6057 AutomationProviderList::GetInstance()->RemoveProvider(this); 6058 AutomationProviderList::GetInstance()->RemoveProvider(this);
6058 } 6059 }
OLDNEW
« no previous file with comments | « chrome/browser/automation/testing_automation_provider.h ('k') | chrome/browser/background/background_application_list_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698