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

Side by Side Diff: chrome/browser/extensions/api/managed_mode/managed_mode_api.cc

Issue 11377131: Removing PrefObserver usage, batch 4. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to review comments. Created 8 years, 1 month 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/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
(...skipping 24 matching lines...) Expand all
35 35
36 } // namespace 36 } // namespace
37 37
38 namespace keys = extensions::preference_api_constants; 38 namespace keys = extensions::preference_api_constants;
39 39
40 namespace extensions { 40 namespace extensions {
41 41
42 ExtensionManagedModeEventRouter::ExtensionManagedModeEventRouter( 42 ExtensionManagedModeEventRouter::ExtensionManagedModeEventRouter(
43 Profile* profile) : profile_(profile) { 43 Profile* profile) : profile_(profile) {
44 registrar_.Init(g_browser_process->local_state()); 44 registrar_.Init(g_browser_process->local_state());
45 registrar_.Add(prefs::kInManagedMode, this); 45 registrar_.Add(
46 prefs::kInManagedMode,
47 base::Bind(&ExtensionManagedModeEventRouter::OnInManagedModeChanged,
48 base::Unretained(this)));
46 } 49 }
47 50
48 ExtensionManagedModeEventRouter::~ExtensionManagedModeEventRouter() { 51 ExtensionManagedModeEventRouter::~ExtensionManagedModeEventRouter() {
49 } 52 }
50 53
51 void ExtensionManagedModeEventRouter::OnPreferenceChanged( 54 void ExtensionManagedModeEventRouter::OnInManagedModeChanged() {
52 PrefServiceBase* service,
53 const std::string& pref_name) {
54 DCHECK_EQ(std::string(prefs::kInManagedMode), pref_name);
55
56 DictionaryValue* dict = new DictionaryValue(); 55 DictionaryValue* dict = new DictionaryValue();
57 dict->SetBoolean( 56 dict->SetBoolean(
58 keys::kValue, 57 keys::kValue,
59 g_browser_process->local_state()->GetBoolean(prefs::kInManagedMode)); 58 g_browser_process->local_state()->GetBoolean(prefs::kInManagedMode));
60 scoped_ptr<ListValue> args(new ListValue()); 59 scoped_ptr<ListValue> args(new ListValue());
61 args->Set(0, dict); 60 args->Set(0, dict);
62 61
63 extensions::EventRouter* event_router = 62 extensions::EventRouter* event_router =
64 extensions::ExtensionSystem::Get(profile_)->event_router(); 63 extensions::ExtensionSystem::Get(profile_)->event_router();
65 event_router->DispatchEventToRenderers(kChangeEventName, args.Pass(), NULL, 64 event_router->DispatchEventToRenderers(kChangeEventName, args.Pass(), NULL,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 EXTENSION_FUNCTION_VALIDATE(args_->Get(1, &value)); 117 EXTENSION_FUNCTION_VALIDATE(args_->Get(1, &value));
119 #if defined(ENABLE_CONFIGURATION_POLICY) 118 #if defined(ENABLE_CONFIGURATION_POLICY)
120 policy::ManagedModePolicyProvider* policy_provider = 119 policy::ManagedModePolicyProvider* policy_provider =
121 profile_->GetManagedModePolicyProvider(); 120 profile_->GetManagedModePolicyProvider();
122 policy_provider->SetPolicy(key, value); 121 policy_provider->SetPolicy(key, value);
123 #endif 122 #endif
124 return true; 123 return true;
125 } 124 }
126 125
127 } // namespace extensions 126 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698