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

Side by Side Diff: chrome/browser/extensions/extension_managed_mode_api.cc

Issue 10694085: Refactor extension event distribution to use Values instead of JSON strings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Build fix. Created 8 years, 5 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 // Implementation of the Chrome Extensions Managed Mode API. 5 // Implementation of the Chrome Extensions Managed Mode API.
6 6
7 #include "chrome/browser/extensions/extension_managed_mode_api.h" 7 #include "chrome/browser/extensions/extension_managed_mode_api.h"
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 void ExtensionManagedModeEventRouter::Observe( 52 void ExtensionManagedModeEventRouter::Observe(
53 int type, 53 int type,
54 const content::NotificationSource& source, 54 const content::NotificationSource& source,
55 const content::NotificationDetails& details) { 55 const content::NotificationDetails& details) {
56 DCHECK_EQ(chrome::NOTIFICATION_PREF_CHANGED, type); 56 DCHECK_EQ(chrome::NOTIFICATION_PREF_CHANGED, type);
57 const std::string& pref_name = 57 const std::string& pref_name =
58 *content::Details<std::string>(details).ptr(); 58 *content::Details<std::string>(details).ptr();
59 DCHECK_EQ(std::string(prefs::kInManagedMode), pref_name); 59 DCHECK_EQ(std::string(prefs::kInManagedMode), pref_name);
60 60
61 ListValue args;
62 DictionaryValue* dict = new DictionaryValue(); 61 DictionaryValue* dict = new DictionaryValue();
63 args.Append(dict);
64 dict->SetBoolean(extension_preference_api_constants::kValue, 62 dict->SetBoolean(extension_preference_api_constants::kValue,
65 g_browser_process->local_state()->GetBoolean(prefs::kInManagedMode)); 63 g_browser_process->local_state()->GetBoolean(prefs::kInManagedMode));
66 std::string json_args; 64 ListValue* arguments = new ListValue();
67 base::JSONWriter::Write(&args, &json_args); 65 arguments->Set(0, dict);
66
68 ExtensionEventRouter* event_router = profile_->GetExtensionEventRouter(); 67 ExtensionEventRouter* event_router = profile_->GetExtensionEventRouter();
69 event_router->DispatchEventToRenderers(kChangeEventName, json_args, 68 event_router->DispatchEventToRenderers(kChangeEventName, arguments,
70 NULL, GURL()); 69 NULL, GURL());
71 } 70 }
72 71
73 GetManagedModeFunction::~GetManagedModeFunction() { } 72 GetManagedModeFunction::~GetManagedModeFunction() { }
74 73
75 bool GetManagedModeFunction::RunImpl() { 74 bool GetManagedModeFunction::RunImpl() {
76 bool in_managed_mode = ManagedMode::IsInManagedMode(); 75 bool in_managed_mode = ManagedMode::IsInManagedMode();
77 76
78 scoped_ptr<DictionaryValue> result(new DictionaryValue); 77 scoped_ptr<DictionaryValue> result(new DictionaryValue);
79 result->SetBoolean(keys::kValue, in_managed_mode); 78 result->SetBoolean(keys::kValue, in_managed_mode);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &key)); 118 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &key));
120 base::Value* value = NULL; 119 base::Value* value = NULL;
121 EXTENSION_FUNCTION_VALIDATE(args_->Get(1, &value)); 120 EXTENSION_FUNCTION_VALIDATE(args_->Get(1, &value));
122 #if defined(ENABLE_CONFIGURATION_POLICY) 121 #if defined(ENABLE_CONFIGURATION_POLICY)
123 policy::ManagedModePolicyProvider* policy_provider = 122 policy::ManagedModePolicyProvider* policy_provider =
124 ManagedModePolicyProviderFactory::GetForProfile(profile_); 123 ManagedModePolicyProviderFactory::GetForProfile(profile_);
125 policy_provider->SetPolicy(key, value); 124 policy_provider->SetPolicy(key, value);
126 #endif 125 #endif
127 return true; 126 return true;
128 } 127 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698