#include "chrome/browser/extensions/extension_action_manager.h"
#include "chrome/browser/extensions/extension_host.h"
#include "chrome/browser/extensions/extension_service.h"
-#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/extensions/launch_util.h"
#include "chrome/browser/notifications/balloon.h"
#include "chrome/browser/notifications/balloon_collection.h"
#include "chrome/browser/notifications/notification.h"
-#include "chrome/browser/password_manager/password_store.h"
-#include "chrome/browser/password_manager/password_store_change.h"
#include "chrome/browser/password_manager/password_store_factory.h"
#include "chrome/browser/platform_util.h"
#include "chrome/browser/plugins/plugin_prefs.h"
#include "chrome/common/extensions/manifest_url_handler.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/render_messages.h"
+#include "components/password_manager/core/browser/password_store.h"
+#include "components/password_manager/core/browser/password_store_change.h"
#include "content/public/browser/browser_child_process_host_iterator.h"
#include "content/public/browser/child_process_data.h"
#include "content/public/browser/favicon_status.h"
#include "content/public/common/geoposition.h"
#include "content/public/common/ssl_status.h"
#include "content/public/common/webplugininfo.h"
+#include "extensions/browser/extension_registry.h"
+#include "extensions/browser/extension_system.h"
#include "extensions/browser/process_manager.h"
#include "extensions/browser/view_type_utils.h"
#include "extensions/common/extension.h"
using extensions::Extension;
using extensions::ExtensionActionManager;
using extensions::ExtensionList;
+using extensions::ExtensionRegistry;
using extensions::Manifest;
namespace {
browser_handler_map_["SaveTabContents"] =
&TestingAutomationProvider::SaveTabContents;
- browser_handler_map_["AddSavedPassword"] =
- &TestingAutomationProvider::AddSavedPassword;
- browser_handler_map_["RemoveSavedPassword"] =
- &TestingAutomationProvider::RemoveSavedPassword;
browser_handler_map_["GetSavedPasswords"] =
&TestingAutomationProvider::GetSavedPasswords;
this, reply_message);
}
-namespace {
-
-// Translates a dictionary password to a PasswordForm struct.
-autofill::PasswordForm GetPasswordFormFromDict(
- const base::DictionaryValue& password_dict) {
-
- // If the time is specified, change time to the specified time.
- base::Time time = base::Time::Now();
- int it;
- double dt;
- if (password_dict.GetInteger("time", &it))
- time = base::Time::FromTimeT(it);
- else if (password_dict.GetDouble("time", &dt))
- time = base::Time::FromDoubleT(dt);
-
- std::string signon_realm;
- base::string16 username_value;
- base::string16 password_value;
- base::string16 origin_url_text;
- base::string16 username_element;
- base::string16 password_element;
- base::string16 submit_element;
- base::string16 action_target_text;
- bool blacklist;
- base::string16 old_password_element;
- base::string16 old_password_value;
-
- // We don't care if any of these fail - they are either optional or checked
- // before this function is called.
- password_dict.GetString("signon_realm", &signon_realm);
- password_dict.GetString("username_value", &username_value);
- password_dict.GetString("password_value", &password_value);
- password_dict.GetString("origin_url", &origin_url_text);
- password_dict.GetString("username_element", &username_element);
- password_dict.GetString("password_element", &password_element);
- password_dict.GetString("submit_element", &submit_element);
- password_dict.GetString("action_target", &action_target_text);
- if (!password_dict.GetBoolean("blacklist", &blacklist))
- blacklist = false;
-
- GURL origin_gurl(origin_url_text);
- GURL action_target(action_target_text);
-
- autofill::PasswordForm password_form;
- password_form.signon_realm = signon_realm;
- password_form.username_value = username_value;
- password_form.password_value = password_value;
- password_form.origin = origin_gurl;
- password_form.username_element = username_element;
- password_form.password_element = password_element;
- password_form.submit_element = submit_element;
- password_form.action = action_target;
- password_form.blacklisted_by_user = blacklist;
- password_form.date_created = time;
-
- return password_form;
-}
-
-} // namespace
-
-// See AddSavedPassword() in chrome/test/functional/pyauto.py for sample json
-// input.
-// Sample json output: { "password_added": true }
-void TestingAutomationProvider::AddSavedPassword(
- Browser* browser,
- base::DictionaryValue* args,
- IPC::Message* reply_message) {
- base::DictionaryValue* password_dict = NULL;
- if (!args->GetDictionary("password", &password_dict)) {
- AutomationJSONReply(this, reply_message).SendError(
- "Must specify a password dictionary.");
- return;
- }
-
- // The "signon realm" is effectively the primary key and must be included.
- // Check here before calling GetPasswordFormFromDict.
- if (!password_dict->HasKey("signon_realm")) {
- AutomationJSONReply(this, reply_message).SendError(
- "Password must include a value for 'signon_realm.'");
- return;
- }
-
- autofill::PasswordForm new_password =
- GetPasswordFormFromDict(*password_dict);
-
- // Use IMPLICIT_ACCESS since new passwords aren't added in incognito mode.
- PasswordStore* password_store = PasswordStoreFactory::GetForProfile(
- browser->profile(), Profile::IMPLICIT_ACCESS).get();
-
- // The password store does not exist for an incognito window.
- if (password_store == NULL) {
- scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue);
- return_value->SetBoolean("password_added", false);
- AutomationJSONReply(this, reply_message).SendSuccess(return_value.get());
- return;
- }
-
- // This observer will delete itself.
- PasswordStoreLoginsChangedObserver* observer =
- new PasswordStoreLoginsChangedObserver(this, reply_message,
- PasswordStoreChange::ADD,
- "password_added");
- observer->Init();
- password_store->AddLogin(new_password);
-}
-
-// See RemoveSavedPassword() in chrome/test/functional/pyauto.py for sample
-// json input.
-// Sample json output: {}
-void TestingAutomationProvider::RemoveSavedPassword(
- Browser* browser,
- base::DictionaryValue* args,
- IPC::Message* reply_message) {
- base::DictionaryValue* password_dict = NULL;
-
- if (!args->GetDictionary("password", &password_dict)) {
- AutomationJSONReply(this, reply_message).SendError(
- "Must specify a password dictionary.");
- return;
- }
-
- // The "signon realm" is effectively the primary key and must be included.
- // Check here before calling GetPasswordFormFromDict.
- if (!password_dict->HasKey("signon_realm")) {
- AutomationJSONReply(this, reply_message).SendError(
- "Password must include a value for 'signon_realm.'");
- return;
- }
- autofill::PasswordForm to_remove =
- GetPasswordFormFromDict(*password_dict);
-
- // Use EXPLICIT_ACCESS since passwords can be removed in incognito mode.
- PasswordStore* password_store = PasswordStoreFactory::GetForProfile(
- browser->profile(), Profile::EXPLICIT_ACCESS).get();
- if (password_store == NULL) {
- AutomationJSONReply(this, reply_message).SendError(
- "Unable to get password store.");
- return;
- }
-
- // This observer will delete itself.
- PasswordStoreLoginsChangedObserver* observer =
- new PasswordStoreLoginsChangedObserver(
- this, reply_message, PasswordStoreChange::REMOVE, std::string());
- observer->Init();
-
- password_store->RemoveLogin(to_remove);
-}
-
// Sample json input: { "command": "GetSavedPasswords" }
// Refer to GetSavedPasswords() in chrome/test/pyautolib/pyauto.py for sample
// json output.
}
scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue);
base::ListValue* extensions_values = new base::ListValue;
- const extensions::ExtensionSet* extensions = service->extensions();
- const extensions::ExtensionSet* disabled_extensions =
- service->disabled_extensions();
+ ExtensionRegistry* registry = ExtensionRegistry::Get(browser->profile());
+ const extensions::ExtensionSet& extensions = registry->enabled_extensions();
+ const extensions::ExtensionSet& disabled_extensions =
+ registry->disabled_extensions();
ExtensionList all;
- all.insert(all.end(),
- extensions->begin(),
- extensions->end());
- all.insert(all.end(),
- disabled_extensions->begin(),
- disabled_extensions->end());
+ all.insert(all.end(), extensions.begin(), extensions.end());
+ all.insert(all.end(), disabled_extensions.begin(), disabled_extensions.end());
ExtensionActionManager* extension_action_manager =
ExtensionActionManager::Get(browser->profile());
for (ExtensionList::const_iterator it = all.begin();