OLD | NEW |
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 // Implementation of the Chrome Extensions Managed Mode API. | 5 // Implementation of the Chrome Extensions Managed Mode API. |
6 | 6 |
7 #include "chrome/browser/extensions/api/managed_mode/managed_mode_api.h" | 7 #include "chrome/browser/extensions/api/managed_mode/managed_mode_api.h" |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/extensions/extension_event_router.h" | 14 #include "chrome/browser/extensions/event_router.h" |
15 #include "chrome/browser/extensions/extension_preference_api_constants.h" | 15 #include "chrome/browser/extensions/extension_preference_api_constants.h" |
16 #include "chrome/browser/managed_mode.h" | 16 #include "chrome/browser/managed_mode.h" |
17 #include "chrome/browser/prefs/pref_service.h" | 17 #include "chrome/browser/prefs/pref_service.h" |
18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/common/chrome_notification_types.h" | 19 #include "chrome/common/chrome_notification_types.h" |
20 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
21 #include "content/public/browser/notification_details.h" | 21 #include "content/public/browser/notification_details.h" |
22 | 22 |
23 #if defined(ENABLE_CONFIGURATION_POLICY) | 23 #if defined(ENABLE_CONFIGURATION_POLICY) |
24 #include "chrome/browser/policy/managed_mode_policy_provider.h" | 24 #include "chrome/browser/policy/managed_mode_policy_provider.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 *content::Details<std::string>(details).ptr(); | 60 *content::Details<std::string>(details).ptr(); |
61 DCHECK_EQ(std::string(prefs::kInManagedMode), pref_name); | 61 DCHECK_EQ(std::string(prefs::kInManagedMode), pref_name); |
62 | 62 |
63 ListValue args; | 63 ListValue args; |
64 DictionaryValue* dict = new DictionaryValue(); | 64 DictionaryValue* dict = new DictionaryValue(); |
65 args.Append(dict); | 65 args.Append(dict); |
66 dict->SetBoolean(extension_preference_api_constants::kValue, | 66 dict->SetBoolean(extension_preference_api_constants::kValue, |
67 g_browser_process->local_state()->GetBoolean(prefs::kInManagedMode)); | 67 g_browser_process->local_state()->GetBoolean(prefs::kInManagedMode)); |
68 std::string json_args; | 68 std::string json_args; |
69 base::JSONWriter::Write(&args, &json_args); | 69 base::JSONWriter::Write(&args, &json_args); |
70 ExtensionEventRouter* event_router = profile_->GetExtensionEventRouter(); | 70 extensions::EventRouter* event_router = profile_->GetExtensionEventRouter(); |
71 event_router->DispatchEventToRenderers(kChangeEventName, json_args, NULL, | 71 event_router->DispatchEventToRenderers(kChangeEventName, json_args, NULL, |
72 GURL(), | 72 GURL(), |
73 extensions::EventFilteringInfo()); | 73 extensions::EventFilteringInfo()); |
74 } | 74 } |
75 | 75 |
76 GetManagedModeFunction::~GetManagedModeFunction() { } | 76 GetManagedModeFunction::~GetManagedModeFunction() { } |
77 | 77 |
78 bool GetManagedModeFunction::RunImpl() { | 78 bool GetManagedModeFunction::RunImpl() { |
79 bool in_managed_mode = ManagedMode::IsInManagedMode(); | 79 bool in_managed_mode = ManagedMode::IsInManagedMode(); |
80 | 80 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 EXTENSION_FUNCTION_VALIDATE(args_->Get(1, &value)); | 124 EXTENSION_FUNCTION_VALIDATE(args_->Get(1, &value)); |
125 #if defined(ENABLE_CONFIGURATION_POLICY) | 125 #if defined(ENABLE_CONFIGURATION_POLICY) |
126 policy::ManagedModePolicyProvider* policy_provider = | 126 policy::ManagedModePolicyProvider* policy_provider = |
127 ManagedModePolicyProviderFactory::GetForProfile(profile_); | 127 ManagedModePolicyProviderFactory::GetForProfile(profile_); |
128 policy_provider->SetPolicy(key, value); | 128 policy_provider->SetPolicy(key, value); |
129 #endif | 129 #endif |
130 return true; | 130 return true; |
131 } | 131 } |
132 | 132 |
133 } // namespace extensions | 133 } // namespace extensions |
OLD | NEW |