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

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

Issue 10375021: Move Extension into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Take 2 Created 8 years, 7 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
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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 using content::DownloadManager; 176 using content::DownloadManager;
177 using content::InterstitialPage; 177 using content::InterstitialPage;
178 using content::NavigationController; 178 using content::NavigationController;
179 using content::NavigationEntry; 179 using content::NavigationEntry;
180 using content::PluginService; 180 using content::PluginService;
181 using content::OpenURLParams; 181 using content::OpenURLParams;
182 using content::Referrer; 182 using content::Referrer;
183 using content::RenderViewHost; 183 using content::RenderViewHost;
184 using content::SSLStatus; 184 using content::SSLStatus;
185 using content::WebContents; 185 using content::WebContents;
186 using extensions::Extension;
187 using extensions::ExtensionList;
186 188
187 namespace { 189 namespace {
188 190
189 // Helper to reply asynchronously if |automation| is still valid. 191 // Helper to reply asynchronously if |automation| is still valid.
190 void SendSuccessReply(base::WeakPtr<AutomationProvider> automation, 192 void SendSuccessReply(base::WeakPtr<AutomationProvider> automation,
191 IPC::Message* reply_message) { 193 IPC::Message* reply_message) {
192 if (automation) 194 if (automation)
193 AutomationJSONReply(automation.get(), reply_message).SendSuccess(NULL); 195 AutomationJSONReply(automation.get(), reply_message).SendSuccess(NULL);
194 } 196 }
195 197
(...skipping 4320 matching lines...) Expand 10 before | Expand all | Expand 10 after
4516 permissions->Append(new StringValue(perm->c_str())); 4518 permissions->Append(new StringValue(perm->c_str()));
4517 } 4519 }
4518 return permissions; 4520 return permissions;
4519 } 4521 }
4520 4522
4521 } // namespace 4523 } // namespace
4522 4524
4523 // Sample json input: { "command": "GetExtensionsInfo" } 4525 // Sample json input: { "command": "GetExtensionsInfo" }
4524 // See GetExtensionsInfo() in chrome/test/pyautolib/pyauto.py for sample json 4526 // See GetExtensionsInfo() in chrome/test/pyautolib/pyauto.py for sample json
4525 // output. 4527 // output.
4526 void TestingAutomationProvider::GetExtensionsInfo( 4528 void TestingAutomationProvider::GetExtensionsInfo(DictionaryValue* args,
4527 DictionaryValue* args, 4529 IPC::Message* reply_message) {
4528 IPC::Message* reply_message) {
4529 AutomationJSONReply reply(this, reply_message); 4530 AutomationJSONReply reply(this, reply_message);
4530 Browser* browser; 4531 Browser* browser;
4531 std::string error_msg; 4532 std::string error_msg;
4532 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { 4533 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) {
4533 reply.SendError(error_msg); 4534 reply.SendError(error_msg);
4534 return; 4535 return;
4535 } 4536 }
4536 ExtensionService* service = browser->profile()->GetExtensionService(); 4537 ExtensionService* service = browser->profile()->GetExtensionService();
4537 if (!service) { 4538 if (!service) {
4538 reply.SendError("No extensions service."); 4539 reply.SendError("No extensions service.");
(...skipping 25 matching lines...) Expand all
4564 extension_value->SetString("options_url", 4565 extension_value->SetString("options_url",
4565 extension->options_url().spec()); 4566 extension->options_url().spec());
4566 extension_value->Set("host_permissions", 4567 extension_value->Set("host_permissions",
4567 GetHostPermissions(extension, false)); 4568 GetHostPermissions(extension, false));
4568 extension_value->Set("effective_host_permissions", 4569 extension_value->Set("effective_host_permissions",
4569 GetHostPermissions(extension, true)); 4570 GetHostPermissions(extension, true));
4570 extension_value->Set("api_permissions", GetAPIPermissions(extension)); 4571 extension_value->Set("api_permissions", GetAPIPermissions(extension));
4571 Extension::Location location = extension->location(); 4572 Extension::Location location = extension->location();
4572 extension_value->SetBoolean("is_component", 4573 extension_value->SetBoolean("is_component",
4573 location == Extension::COMPONENT); 4574 location == Extension::COMPONENT);
4574 extension_value->SetBoolean("is_internal", location == Extension::INTERNAL); 4575 extension_value->SetBoolean("is_internal",
4576 location == Extension::INTERNAL);
4575 extension_value->SetBoolean("is_user_installed", 4577 extension_value->SetBoolean("is_user_installed",
4576 location == Extension::INTERNAL || location == Extension::LOAD); 4578 location == Extension::INTERNAL ||
4579 location == Extension::LOAD);
4577 extension_value->SetBoolean("is_enabled", service->IsExtensionEnabled(id)); 4580 extension_value->SetBoolean("is_enabled", service->IsExtensionEnabled(id));
4578 extension_value->SetBoolean("allowed_in_incognito", 4581 extension_value->SetBoolean("allowed_in_incognito",
4579 service->IsIncognitoEnabled(id)); 4582 service->IsIncognitoEnabled(id));
4580 extension_value->SetBoolean("has_page_action", 4583 extension_value->SetBoolean("has_page_action",
4581 extension->page_action() != NULL); 4584 extension->page_action() != NULL);
4582 extensions_values->Append(extension_value); 4585 extensions_values->Append(extension_value);
4583 } 4586 }
4584 return_value->Set("extensions", extensions_values); 4587 return_value->Set("extensions", extensions_values);
4585 reply.SendSuccess(return_value.get()); 4588 reply.SendSuccess(return_value.get());
4586 } 4589 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
4669 new ExtensionReadyNotificationObserver( 4672 new ExtensionReadyNotificationObserver(
4670 manager, 4673 manager,
4671 service, 4674 service,
4672 this, 4675 this,
4673 reply_message); 4676 reply_message);
4674 service->EnableExtension(extension->id()); 4677 service->EnableExtension(extension->id());
4675 } else { 4678 } else {
4676 AutomationJSONReply(this, reply_message).SendSuccess(NULL); 4679 AutomationJSONReply(this, reply_message).SendSuccess(NULL);
4677 } 4680 }
4678 } else { 4681 } else {
4679 service->DisableExtension(extension->id(), Extension::DISABLE_USER_ACTION); 4682 service->DisableExtension(extension->id(),
4683 Extension::DISABLE_USER_ACTION);
4680 AutomationJSONReply(this, reply_message).SendSuccess(NULL); 4684 AutomationJSONReply(this, reply_message).SendSuccess(NULL);
4681 } 4685 }
4682 4686
4683 service->SetIsIncognitoEnabled(extension->id(), allow_in_incognito); 4687 service->SetIsIncognitoEnabled(extension->id(), allow_in_incognito);
4684 } 4688 }
4685 4689
4686 namespace { 4690 namespace {
4687 4691
4688 // Selects the given |browser| and |tab| if not selected already. 4692 // Selects the given |browser| and |tab| if not selected already.
4689 void EnsureTabSelected(Browser* browser, WebContents* tab) { 4693 void EnsureTabSelected(Browser* browser, WebContents* tab) {
(...skipping 2468 matching lines...) Expand 10 before | Expand all | Expand 10 after
7158 *browser_handle = browser_tracker_->Add(browser); 7162 *browser_handle = browser_tracker_->Add(browser);
7159 *success = true; 7163 *success = true;
7160 } 7164 }
7161 } 7165 }
7162 } 7166 }
7163 7167
7164 void TestingAutomationProvider::OnRemoveProvider() { 7168 void TestingAutomationProvider::OnRemoveProvider() {
7165 if (g_browser_process) 7169 if (g_browser_process)
7166 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); 7170 g_browser_process->GetAutomationProviderList()->RemoveProvider(this);
7167 } 7171 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698