diff options
8 files changed, 0 insertions, 465 deletions
diff --git a/chrome/browser/extensions/api/managed_mode_private/managed_mode_apitest.cc b/chrome/browser/extensions/api/managed_mode_private/managed_mode_apitest.cc deleted file mode 100644 index f7c6e0a..0000000 --- a/chrome/browser/extensions/api/managed_mode_private/managed_mode_apitest.cc +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/managed_mode/managed_mode.h" -#include "chrome/browser/extensions/extension_apitest.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/common/chrome_switches.h" -#include "chrome/common/extensions/extension.h" -#include "chrome/test/base/ui_test_utils.h" - -// Tests enabling and querying managed mode. -IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ManagedModeGetAndEnable) { - ASSERT_FALSE(ManagedMode::IsInManagedMode()); - - ASSERT_TRUE(RunComponentExtensionTest("managed_mode/get_enter")) << message_; - - EXPECT_TRUE(ManagedMode::IsInManagedMode()); -} - -// Tests the event when entering or leaving managed mode. -IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ManagedModeOnChange) { - ASSERT_FALSE(ManagedMode::IsInManagedMode()); - - // We can't just call RunComponentExtension() like above, because we need to - // fire the event while the page is waiting. - base::FilePath extension_path = - test_data_dir_.AppendASCII("managed_mode/on_change"); - const extensions::Extension* extension = - LoadExtensionAsComponent(extension_path); - ASSERT_TRUE(extension) << "Failed to load extension."; - - ResultCatcher catcher; - // Tell the test what values for the |onChange| event to expect. - std::string page_url = "test.html?expect=true,false"; - ui_test_utils::NavigateToURL(browser(), - extension->GetResourceURL(page_url)); - - // Fire the extension event when entering managed mode. We directly call - // SetInManagedMode() to bypass any confirmation dialogs etc. - ManagedMode::GetInstance()->SetInManagedMode(browser()->profile()); - - // Fire the extension event when leaving managed mode. - ManagedMode::GetInstance()->SetInManagedMode(NULL); - - ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); -} diff --git a/chrome/browser/extensions/api/managed_mode_private/managed_mode_private_api.cc b/chrome/browser/extensions/api/managed_mode_private/managed_mode_private_api.cc deleted file mode 100644 index 926f6b1..0000000 --- a/chrome/browser/extensions/api/managed_mode_private/managed_mode_private_api.cc +++ /dev/null @@ -1,163 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Implementation of the Chrome Extensions Managed Mode API. - -#include "chrome/browser/extensions/api/managed_mode_private/managed_mode_private_api.h" - -#include <string> - -#include "base/bind.h" -#include "base/json/json_writer.h" -#include "base/lazy_instance.h" -#include "base/prefs/pref_service.h" -#include "chrome/browser/browser_process.h" -#include "chrome/browser/extensions/api/preference/preference_api_constants.h" -#include "chrome/browser/extensions/event_router.h" -#include "chrome/browser/extensions/extension_system.h" -#include "chrome/browser/managed_mode/managed_mode.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/common/chrome_notification_types.h" -#include "chrome/common/extensions/api/managed_mode_private.h" -#include "chrome/common/pref_names.h" -#include "content/public/browser/notification_details.h" - -#if defined(ENABLE_CONFIGURATION_POLICY) -#include "chrome/browser/policy/managed_mode_policy_provider.h" -#include "chrome/browser/policy/profile_policy_connector.h" -#include "chrome/browser/policy/profile_policy_connector_factory.h" -#endif - -namespace { - -// Event that is fired when we enter or leave managed mode. -const char kChangeEventName[] = "managedModePrivate.onChange"; - -// Key to report whether the attempt to enter managed mode succeeded. -const char kEnterSuccessKey[] = "success"; - -} // namespace - -namespace keys = extensions::preference_api_constants; - -namespace extensions { - -namespace GetPolicy = api::managed_mode_private::GetPolicy; -namespace SetPolicy = api::managed_mode_private::SetPolicy; - -ManagedModeEventRouter::ManagedModeEventRouter( - Profile* profile) : profile_(profile) { - registrar_.Init(g_browser_process->local_state()); - registrar_.Add( - prefs::kInManagedMode, - base::Bind(&ManagedModeEventRouter::OnInManagedModeChanged, - base::Unretained(this))); -} - -ManagedModeEventRouter::~ManagedModeEventRouter() { -} - -void ManagedModeEventRouter::OnInManagedModeChanged() { - DictionaryValue* dict = new DictionaryValue(); - dict->SetBoolean( - keys::kValue, - g_browser_process->local_state()->GetBoolean(prefs::kInManagedMode)); - scoped_ptr<ListValue> args(new ListValue()); - args->Set(0, dict); - - extensions::EventRouter* event_router = - extensions::ExtensionSystem::Get(profile_)->event_router(); - scoped_ptr<extensions::Event> event(new extensions::Event( - kChangeEventName, args.Pass())); - event_router->BroadcastEvent(event.Pass()); -} - -ManagedModePrivateGetFunction::~ManagedModePrivateGetFunction() { } - -bool ManagedModePrivateGetFunction::RunImpl() { - bool in_managed_mode = ManagedMode::IsInManagedMode(); - - scoped_ptr<DictionaryValue> result(new DictionaryValue); - result->SetBoolean(keys::kValue, in_managed_mode); - SetResult(result.release()); - return true; -} - -ManagedModePrivateEnterFunction::~ManagedModePrivateEnterFunction() { } - -bool ManagedModePrivateEnterFunction::RunImpl() { - ManagedMode::EnterManagedMode( - profile(), - base::Bind(&ManagedModePrivateEnterFunction::SendResult, this)); - return true; -} - -void ManagedModePrivateEnterFunction::SendResult(bool success) { - scoped_ptr<DictionaryValue> result(new DictionaryValue); - result->SetBoolean(kEnterSuccessKey, success); - SetResult(result.release()); - SendResponse(true); -} - -ManagedModePrivateGetPolicyFunction::~ManagedModePrivateGetPolicyFunction() { } - -bool ManagedModePrivateGetPolicyFunction::RunImpl() { - scoped_ptr<GetPolicy::Params> params(GetPolicy::Params::Create(*args_)); - EXTENSION_FUNCTION_VALIDATE(params.get()); -#if defined(ENABLE_CONFIGURATION_POLICY) - policy::ProfilePolicyConnector* connector = - policy::ProfilePolicyConnectorFactory::GetForProfile(profile_); - policy::ManagedModePolicyProvider* policy_provider = - connector->managed_mode_policy_provider(); - const base::Value* policy = policy_provider->GetPolicy(params->key); - if (policy) - SetResult(policy->DeepCopy()); -#endif - return true; -} - -ManagedModePrivateSetPolicyFunction::~ManagedModePrivateSetPolicyFunction() { } - -bool ManagedModePrivateSetPolicyFunction::RunImpl() { - scoped_ptr<SetPolicy::Params> params(SetPolicy::Params::Create(*args_)); - EXTENSION_FUNCTION_VALIDATE(params.get()); -#if defined(ENABLE_CONFIGURATION_POLICY) - policy::ProfilePolicyConnector* connector = - policy::ProfilePolicyConnectorFactory::GetForProfile(profile_); - policy::ManagedModePolicyProvider* policy_provider = - connector->managed_mode_policy_provider(); - policy_provider->SetPolicy(params->key, - make_scoped_ptr(params->value->DeepCopy())); -#endif - return true; -} - -ManagedModeAPI::ManagedModeAPI(Profile* profile) - : profile_(profile) { - ExtensionSystem::Get(profile_)->event_router()->RegisterObserver( - this, kChangeEventName); -} - -ManagedModeAPI::~ManagedModeAPI() { -} - -void ManagedModeAPI::Shutdown() { - ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); -} - -static base::LazyInstance<ProfileKeyedAPIFactory<ManagedModeAPI> > -g_factory = LAZY_INSTANCE_INITIALIZER; - -// static -ProfileKeyedAPIFactory<ManagedModeAPI>* ManagedModeAPI::GetFactoryInstance() { - return &g_factory.Get(); -} - -void ManagedModeAPI::OnListenerAdded( - const extensions::EventListenerInfo& details) { - managed_mode_event_router_.reset(new ManagedModeEventRouter(profile_)); - ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); -} - -} // namespace extensions diff --git a/chrome/browser/extensions/api/managed_mode_private/managed_mode_private_api.h b/chrome/browser/extensions/api/managed_mode_private/managed_mode_private_api.h deleted file mode 100644 index 2344dc9..0000000 --- a/chrome/browser/extensions/api/managed_mode_private/managed_mode_private_api.h +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Defines the Chrome Extensions Managed Mode API relevant classes to realize -// the API as specified in the extension API JSON. - -#ifndef CHROME_BROWSER_EXTENSIONS_API_MANAGED_MODE_PRIVATE_MANAGED_MODE_PRIVATE_API_H_ -#define CHROME_BROWSER_EXTENSIONS_API_MANAGED_MODE_PRIVATE_MANAGED_MODE_PRIVATE_API_H_ - -#include "base/prefs/pref_change_registrar.h" -#include "chrome/browser/extensions/api/profile_keyed_api_factory.h" -#include "chrome/browser/extensions/event_router.h" -#include "chrome/browser/extensions/extension_function.h" -#include "content/public/browser/notification_observer.h" - -class Profile; - -namespace extensions { - -class ManagedModeEventRouter { - public: - explicit ManagedModeEventRouter(Profile* profile); - virtual ~ManagedModeEventRouter(); - - private: - void OnInManagedModeChanged(); - - PrefChangeRegistrar registrar_; - Profile* profile_; - - DISALLOW_COPY_AND_ASSIGN(ManagedModeEventRouter); -}; - -class ManagedModePrivateGetFunction : public SyncExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION("managedModePrivate.get", MANAGEDMODEPRIVATE_GET) - - protected: - virtual ~ManagedModePrivateGetFunction(); - - // ExtensionFunction: - virtual bool RunImpl() OVERRIDE; -}; - -class ManagedModePrivateEnterFunction : public AsyncExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION("managedModePrivate.enter", - MANAGEDMODEPRIVATE_ENTER) - - protected: - virtual ~ManagedModePrivateEnterFunction(); - - // ExtensionFunction: - virtual bool RunImpl() OVERRIDE; - - private: - // Called when we have either successfully entered managed mode or failed. - void SendResult(bool success); -}; - - -class ManagedModePrivateGetPolicyFunction : public SyncExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION("managedModePrivate.getPolicy", - MANAGEDMODEPRIVATE_GETPOLICY) - - protected: - virtual ~ManagedModePrivateGetPolicyFunction(); - - // ExtensionFunction: - virtual bool RunImpl() OVERRIDE; -}; - -class ManagedModePrivateSetPolicyFunction : public SyncExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION("managedModePrivate.setPolicy", - MANAGEDMODEPRIVATE_SETPOLICY) - - protected: - virtual ~ManagedModePrivateSetPolicyFunction(); - - // ExtensionFunction: - virtual bool RunImpl() OVERRIDE; -}; - -class ManagedModeAPI : public ProfileKeyedAPI, - public extensions::EventRouter::Observer { - public: - explicit ManagedModeAPI(Profile* profile); - virtual ~ManagedModeAPI(); - - // BrowserContextKeyedService implementation. - virtual void Shutdown() OVERRIDE; - - // ProfileKeyedAPIFactory implementation. - static ProfileKeyedAPIFactory<ManagedModeAPI>* GetFactoryInstance(); - - // EventRouter::Observer implementation. - virtual void OnListenerAdded(const extensions::EventListenerInfo& details) - OVERRIDE; - - private: - friend class ProfileKeyedAPIFactory<ManagedModeAPI>; - - Profile* profile_; - - // ProfileKeyedAPI implementation. - static const char* service_name() { - return "ManagedModeAPI"; - } - static const bool kServiceIsNULLWhileTesting = true; - - // Created lazily upon OnListenerAdded. - scoped_ptr<ManagedModeEventRouter> managed_mode_event_router_; - - DISALLOW_COPY_AND_ASSIGN(ManagedModeAPI); -}; - -} // namespace extensions - -#endif // CHROME_BROWSER_EXTENSIONS_API_MANAGED_MODE_PRIVATE_MANAGED_MODE_PRIVATE_API_H_ diff --git a/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc b/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc index 41c3929..4ca3d0d 100644 --- a/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc +++ b/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc @@ -33,7 +33,6 @@ #include "chrome/browser/extensions/api/idle/idle_manager_factory.h" #include "chrome/browser/extensions/api/input/input.h" #include "chrome/browser/extensions/api/location/location_manager.h" -#include "chrome/browser/extensions/api/managed_mode_private/managed_mode_private_api.h" #include "chrome/browser/extensions/api/management/management_api.h" #include "chrome/browser/extensions/api/media_galleries_private/media_galleries_private_api.h" #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" @@ -209,7 +208,6 @@ EnsureBrowserContextKeyedServiceFactoriesBuilt() { extensions::InputMethodAPI::GetFactoryInstance(); #endif extensions::LocationManager::GetFactoryInstance(); - extensions::ManagedModeAPI::GetFactoryInstance(); extensions::ManagementAPI::GetFactoryInstance(); extensions::MediaGalleriesPrivateAPI::GetFactoryInstance(); #if defined(OS_CHROMEOS) diff --git a/chrome/chrome_browser_extensions.gypi b/chrome/chrome_browser_extensions.gypi index 100d5bc..e7cecae 100644 --- a/chrome/chrome_browser_extensions.gypi +++ b/chrome/chrome_browser_extensions.gypi @@ -267,8 +267,6 @@ 'browser/extensions/api/location/location_api.h', 'browser/extensions/api/location/location_manager.cc', 'browser/extensions/api/location/location_manager.h', - 'browser/extensions/api/managed_mode_private/managed_mode_private_api.cc', - 'browser/extensions/api/managed_mode_private/managed_mode_private_api.h', 'browser/extensions/api/management/management_api.cc', 'browser/extensions/api/management/management_api.h', 'browser/extensions/api/management/management_api_constants.cc', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 3283656..2be7a30 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -1324,7 +1324,6 @@ 'browser/extensions/api/idltest/idltest_apitest.cc', 'browser/extensions/api/input/input_apitest.cc', 'browser/extensions/api/input_ime/input_ime_apitest_chromeos.cc', - 'browser/extensions/api/managed_mode_private/managed_mode_apitest.cc', 'browser/extensions/api/management/management_api_browsertest.cc', 'browser/extensions/api/management/management_apitest.cc', 'browser/extensions/api/management/management_browsertest.cc', diff --git a/chrome/common/extensions/api/api.gyp b/chrome/common/extensions/api/api.gyp index 7317cd7..bee7f2a 100644 --- a/chrome/common/extensions/api/api.gyp +++ b/chrome/common/extensions/api/api.gyp @@ -64,7 +64,6 @@ 'identity.idl', 'identity_private.idl', 'idle.json', - 'managed_mode_private.json', 'management.json', 'manifest_types.json', 'media_galleries.idl', diff --git a/chrome/common/extensions/api/managed_mode_private.json b/chrome/common/extensions/api/managed_mode_private.json deleted file mode 100644 index 8c5a63b..0000000 --- a/chrome/common/extensions/api/managed_mode_private.json +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -[ - { - "namespace": "managedModePrivate", - "nodoc": true, - "functions": [ - { - "name": "enter", - "type": "function", - "description": "Shows a confirmation dialog, then puts the browser into managed mode. The callback parameter will be true if managed mode was entered successfully, false if the user cancelled the confirmation. If managed mode is already on, trying to enter it again will have no effect.", - "parameters": [ - { - "type": "function", - "name": "callback", - "optional": true, - "parameters": [ - { - "name": "result", - "type": "object", - "description": "The result of the attempt to enter managed mode.", - "properties": { - "success": { - "description": "True if managed mode was entered successfully, false if the user cancelled the confirmation.", - "type": "boolean" - } - } - } - ] - } - ] - }, - { - "name": "get", - "type": "function", - "description": "Gets the value of the setting describing whether managed mode is in effect.", - "parameters": [ - { - "type": "function", - "name": "callback", - "parameters": [ - { - "name": "details", - "type": "object", - "description": "Details of the currently effective value.", - "properties": { - "value": { - "description": "The value of the setting.", - "type": "boolean" - } - } - } - ] - } - ] - }, - { - "name": "setPolicy", - "type": "function", - "description": "Sets a policy.", - "parameters": [ - { - "name": "key", - "type": "string", - "description": "Policy key." - }, - { - "name": "value", - "type": "any", - "description": "Policy value." - }, - { - "type": "function", - "name": "callback", - "optional": true, - "parameters": [] - } - ] - }, - { - "name": "getPolicy", - "type": "function", - "description": "Gets a policy value.", - "parameters": [ - { - "name": "key", - "type": "string", - "description": "Policy key." - }, - { - "type": "function", - "name": "callback", - "optional": true, - "parameters": [ - { - "name": "value", - "type": "any", - "description": "Policy value or null if no policy is set.", - "optional": true - } - ] - } - ] - } - ], - "events": [ - { - "name": "onChange", - "description": "Fired when the value of the setting changes.", - "parameters": [ - { - "type": "object", - "name": "details", - "properties": { - "value": { - "description": "The value of the setting.", - "type": "any" - } - } - } - ] - } - ] - } -]
\ No newline at end of file |