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

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

Issue 10911300: Move ExtensionAction from common/ to browser/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: proof of concept Created 8 years, 3 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "chrome/browser/browser_shutdown.h" 43 #include "chrome/browser/browser_shutdown.h"
44 #include "chrome/browser/content_settings/host_content_settings_map.h" 44 #include "chrome/browser/content_settings/host_content_settings_map.h"
45 #include "chrome/browser/debugger/devtools_window.h" 45 #include "chrome/browser/debugger/devtools_window.h"
46 #include "chrome/browser/download/download_prefs.h" 46 #include "chrome/browser/download/download_prefs.h"
47 #include "chrome/browser/download/download_service.h" 47 #include "chrome/browser/download/download_service.h"
48 #include "chrome/browser/download/download_service_factory.h" 48 #include "chrome/browser/download/download_service_factory.h"
49 #include "chrome/browser/download/download_shelf.h" 49 #include "chrome/browser/download/download_shelf.h"
50 #include "chrome/browser/download/save_package_file_picker.h" 50 #include "chrome/browser/download/save_package_file_picker.h"
51 #include "chrome/browser/extensions/browser_action_test_util.h" 51 #include "chrome/browser/extensions/browser_action_test_util.h"
52 #include "chrome/browser/extensions/crx_installer.h" 52 #include "chrome/browser/extensions/crx_installer.h"
53 #include "chrome/browser/extensions/extension_action.h"
53 #include "chrome/browser/extensions/extension_host.h" 54 #include "chrome/browser/extensions/extension_host.h"
54 #include "chrome/browser/extensions/extension_process_manager.h" 55 #include "chrome/browser/extensions/extension_process_manager.h"
55 #include "chrome/browser/extensions/extension_service.h" 56 #include "chrome/browser/extensions/extension_service.h"
56 #include "chrome/browser/extensions/extension_tab_util.h" 57 #include "chrome/browser/extensions/extension_tab_util.h"
57 #include "chrome/browser/extensions/unpacked_installer.h" 58 #include "chrome/browser/extensions/unpacked_installer.h"
58 #include "chrome/browser/extensions/updater/extension_updater.h" 59 #include "chrome/browser/extensions/updater/extension_updater.h"
59 #include "chrome/browser/history/history_service_factory.h" 60 #include "chrome/browser/history/history_service_factory.h"
60 #include "chrome/browser/history/top_sites.h" 61 #include "chrome/browser/history/top_sites.h"
61 #include "chrome/browser/importer/importer_host.h" 62 #include "chrome/browser/importer/importer_host.h"
62 #include "chrome/browser/importer/importer_list.h" 63 #include "chrome/browser/importer/importer_list.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 #include "chrome/browser/view_type_utils.h" 117 #include "chrome/browser/view_type_utils.h"
117 #include "chrome/common/automation_constants.h" 118 #include "chrome/common/automation_constants.h"
118 #include "chrome/common/automation_events.h" 119 #include "chrome/common/automation_events.h"
119 #include "chrome/common/automation_id.h" 120 #include "chrome/common/automation_id.h"
120 #include "chrome/common/automation_messages.h" 121 #include "chrome/common/automation_messages.h"
121 #include "chrome/common/chrome_constants.h" 122 #include "chrome/common/chrome_constants.h"
122 #include "chrome/common/chrome_notification_types.h" 123 #include "chrome/common/chrome_notification_types.h"
123 #include "chrome/common/chrome_paths.h" 124 #include "chrome/common/chrome_paths.h"
124 #include "chrome/common/chrome_switches.h" 125 #include "chrome/common/chrome_switches.h"
125 #include "chrome/common/extensions/extension.h" 126 #include "chrome/common/extensions/extension.h"
126 #include "chrome/common/extensions/extension_action.h"
127 #include "chrome/common/extensions/permissions/permission_set.h" 127 #include "chrome/common/extensions/permissions/permission_set.h"
128 #include "chrome/common/extensions/url_pattern.h" 128 #include "chrome/common/extensions/url_pattern.h"
129 #include "chrome/common/extensions/url_pattern_set.h" 129 #include "chrome/common/extensions/url_pattern_set.h"
130 #include "chrome/common/pref_names.h" 130 #include "chrome/common/pref_names.h"
131 #include "chrome/common/render_messages.h" 131 #include "chrome/common/render_messages.h"
132 #include "chrome/common/url_constants.h" 132 #include "chrome/common/url_constants.h"
133 #include "content/public/browser/browser_child_process_host_iterator.h" 133 #include "content/public/browser/browser_child_process_host_iterator.h"
134 #include "content/public/browser/child_process_data.h" 134 #include "content/public/browser/child_process_data.h"
135 #include "content/public/browser/favicon_status.h" 135 #include "content/public/browser/favicon_status.h"
136 #include "content/public/browser/geolocation.h" 136 #include "content/public/browser/geolocation.h"
(...skipping 3841 matching lines...) Expand 10 before | Expand all | Expand 10 after
3978 if (!GetBrowserAndTabFromJSONArgs(args, &browser, &tab, &error)) { 3978 if (!GetBrowserAndTabFromJSONArgs(args, &browser, &tab, &error)) {
3979 AutomationJSONReply(this, reply_message).SendError(error); 3979 AutomationJSONReply(this, reply_message).SendError(error);
3980 return; 3980 return;
3981 } 3981 }
3982 const Extension* extension; 3982 const Extension* extension;
3983 if (!GetEnabledExtensionFromJSONArgs( 3983 if (!GetEnabledExtensionFromJSONArgs(
3984 args, "id", browser->profile(), &extension, &error)) { 3984 args, "id", browser->profile(), &extension, &error)) {
3985 AutomationJSONReply(this, reply_message).SendError(error); 3985 AutomationJSONReply(this, reply_message).SendError(error);
3986 return; 3986 return;
3987 } 3987 }
3988 ExtensionAction* page_action = extension->page_action(); 3988 ExtensionAction* page_action = GetPageAction(browser->profile(), *extension);
3989 if (!page_action) { 3989 if (!page_action) {
3990 AutomationJSONReply(this, reply_message).SendError( 3990 AutomationJSONReply(this, reply_message).SendError(
3991 "Extension doesn't have any page action."); 3991 "Extension doesn't have any page action.");
3992 return; 3992 return;
3993 } 3993 }
3994 EnsureTabSelected(browser, tab); 3994 EnsureTabSelected(browser, tab);
3995 3995
3996 bool pressed = false; 3996 bool pressed = false;
3997 LocationBarTesting* loc_bar = 3997 LocationBarTesting* loc_bar =
3998 browser->window()->GetLocationBar()->GetLocationBarForTesting(); 3998 browser->window()->GetLocationBar()->GetLocationBarForTesting();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
4031 if (!GetBrowserAndTabFromJSONArgs(args, &browser, &tab, &error)) { 4031 if (!GetBrowserAndTabFromJSONArgs(args, &browser, &tab, &error)) {
4032 AutomationJSONReply(this, reply_message).SendError(error); 4032 AutomationJSONReply(this, reply_message).SendError(error);
4033 return; 4033 return;
4034 } 4034 }
4035 const Extension* extension; 4035 const Extension* extension;
4036 if (!GetEnabledExtensionFromJSONArgs( 4036 if (!GetEnabledExtensionFromJSONArgs(
4037 args, "id", browser->profile(), &extension, &error)) { 4037 args, "id", browser->profile(), &extension, &error)) {
4038 AutomationJSONReply(this, reply_message).SendError(error); 4038 AutomationJSONReply(this, reply_message).SendError(error);
4039 return; 4039 return;
4040 } 4040 }
4041 ExtensionAction* action = extension->browser_action(); 4041 ExtensionAction* action = GetBrowserAction(browser->profile(), *extension);
4042 if (!action) { 4042 if (!action) {
4043 AutomationJSONReply(this, reply_message).SendError( 4043 AutomationJSONReply(this, reply_message).SendError(
4044 "Extension doesn't have any browser action."); 4044 "Extension doesn't have any browser action.");
4045 return; 4045 return;
4046 } 4046 }
4047 EnsureTabSelected(browser, tab); 4047 EnsureTabSelected(browser, tab);
4048 4048
4049 BrowserActionTestUtil browser_actions(browser); 4049 BrowserActionTestUtil browser_actions(browser);
4050 int num_browser_actions = browser_actions.NumberOfBrowserActions(); 4050 int num_browser_actions = browser_actions.NumberOfBrowserActions();
4051 int action_index = -1; 4051 int action_index = -1;
(...skipping 2258 matching lines...) Expand 10 before | Expand all | Expand 10 after
6310 reply.SendError(error); 6310 reply.SendError(error);
6311 return; 6311 return;
6312 } 6312 }
6313 Browser* browser = automation_util::GetBrowserForTab(tab); 6313 Browser* browser = automation_util::GetBrowserForTab(tab);
6314 const Extension* extension; 6314 const Extension* extension;
6315 if (!GetEnabledExtensionFromJSONArgs( 6315 if (!GetEnabledExtensionFromJSONArgs(
6316 args, "extension_id", browser->profile(), &extension, &error)) { 6316 args, "extension_id", browser->profile(), &extension, &error)) {
6317 reply.SendError(error); 6317 reply.SendError(error);
6318 return; 6318 return;
6319 } 6319 }
6320 ExtensionAction* page_action = extension->page_action(); 6320 ExtensionAction* page_action = GetPageAction(browser->profile(), *extension);
6321 if (!page_action) { 6321 if (!page_action) {
6322 reply.SendError("Extension doesn't have any page action"); 6322 reply.SendError("Extension doesn't have any page action");
6323 return; 6323 return;
6324 } 6324 }
6325 if (!browser) { 6325 if (!browser) {
6326 reply.SendError("Tab does not belong to an open browser"); 6326 reply.SendError("Tab does not belong to an open browser");
6327 return; 6327 return;
6328 } 6328 }
6329 EnsureTabSelected(browser, tab); 6329 EnsureTabSelected(browser, tab);
6330 6330
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
6425 void TestingAutomationProvider::OnRemoveProvider() { 6425 void TestingAutomationProvider::OnRemoveProvider() {
6426 if (g_browser_process) 6426 if (g_browser_process)
6427 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); 6427 g_browser_process->GetAutomationProviderList()->RemoveProvider(this);
6428 } 6428 }
6429 6429
6430 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, 6430 void TestingAutomationProvider::EnsureTabSelected(Browser* browser,
6431 WebContents* tab) { 6431 WebContents* tab) {
6432 if (chrome::GetActiveWebContents(browser) != tab) 6432 if (chrome::GetActiveWebContents(browser) != tab)
6433 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); 6433 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true);
6434 } 6434 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698