| 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/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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 DCHECK_EQ(std::string(prefs::kInManagedMode), pref_name); | 54 DCHECK_EQ(std::string(prefs::kInManagedMode), pref_name); |
| 55 | 55 |
| 56 ListValue args; | 56 ListValue args; |
| 57 DictionaryValue* dict = new DictionaryValue(); | 57 DictionaryValue* dict = new DictionaryValue(); |
| 58 args.Append(dict); | 58 args.Append(dict); |
| 59 dict->SetBoolean(extension_preference_api_constants::kValue, | 59 dict->SetBoolean(extension_preference_api_constants::kValue, |
| 60 g_browser_process->local_state()->GetBoolean(prefs::kInManagedMode)); | 60 g_browser_process->local_state()->GetBoolean(prefs::kInManagedMode)); |
| 61 std::string json_args; | 61 std::string json_args; |
| 62 base::JSONWriter::Write(&args, &json_args); | 62 base::JSONWriter::Write(&args, &json_args); |
| 63 ExtensionEventRouter* event_router = profile_->GetExtensionEventRouter(); | 63 ExtensionEventRouter* event_router = profile_->GetExtensionEventRouter(); |
| 64 event_router->DispatchEventToRenderers(kChangeEventName, json_args, | 64 event_router->DispatchEventToRenderers(kChangeEventName, json_args, NULL, |
| 65 NULL, GURL()); | 65 GURL(), |
| 66 extensions::EventFilteringInfo()); |
| 66 } | 67 } |
| 67 | 68 |
| 68 GetManagedModeFunction::~GetManagedModeFunction() { } | 69 GetManagedModeFunction::~GetManagedModeFunction() { } |
| 69 | 70 |
| 70 bool GetManagedModeFunction::RunImpl() { | 71 bool GetManagedModeFunction::RunImpl() { |
| 71 bool in_managed_mode = ManagedMode::IsInManagedMode(); | 72 bool in_managed_mode = ManagedMode::IsInManagedMode(); |
| 72 | 73 |
| 73 scoped_ptr<DictionaryValue> result(new DictionaryValue); | 74 scoped_ptr<DictionaryValue> result(new DictionaryValue); |
| 74 result->SetBoolean(keys::kValue, in_managed_mode); | 75 result->SetBoolean(keys::kValue, in_managed_mode); |
| 75 result_.reset(result.release()); | 76 result_.reset(result.release()); |
| 76 return true; | 77 return true; |
| 77 } | 78 } |
| 78 | 79 |
| 79 EnterManagedModeFunction::~EnterManagedModeFunction() { } | 80 EnterManagedModeFunction::~EnterManagedModeFunction() { } |
| 80 | 81 |
| 81 bool EnterManagedModeFunction::RunImpl() { | 82 bool EnterManagedModeFunction::RunImpl() { |
| 82 ManagedMode::EnterManagedMode( | 83 ManagedMode::EnterManagedMode( |
| 83 profile(), | 84 profile(), |
| 84 base::Bind(&EnterManagedModeFunction::SendResult, this)); | 85 base::Bind(&EnterManagedModeFunction::SendResult, this)); |
| 85 return true; | 86 return true; |
| 86 } | 87 } |
| 87 | 88 |
| 88 void EnterManagedModeFunction::SendResult(bool success) { | 89 void EnterManagedModeFunction::SendResult(bool success) { |
| 89 scoped_ptr<DictionaryValue> result(new DictionaryValue); | 90 scoped_ptr<DictionaryValue> result(new DictionaryValue); |
| 90 result->SetBoolean(kEnterSuccessKey, success); | 91 result->SetBoolean(kEnterSuccessKey, success); |
| 91 result_.reset(result.release()); | 92 result_.reset(result.release()); |
| 92 SendResponse(true); | 93 SendResponse(true); |
| 93 } | 94 } |
| OLD | NEW |