| 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 #include "chrome/browser/extensions/extension_preference_api.h" | 5 #include "chrome/browser/extensions/extension_preference_api.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 std::string extension_id = (*it)->id(); | 314 std::string extension_id = (*it)->id(); |
| 315 // TODO(bauerb): Only iterate over registered event listeners. | 315 // TODO(bauerb): Only iterate over registered event listeners. |
| 316 if (router->ExtensionHasEventListener(extension_id, event_name) && | 316 if (router->ExtensionHasEventListener(extension_id, event_name) && |
| 317 (*it)->HasAPIPermission(permission) && | 317 (*it)->HasAPIPermission(permission) && |
| 318 (!incognito || extension_service->CanCrossIncognito(*it))) { | 318 (!incognito || extension_service->CanCrossIncognito(*it))) { |
| 319 std::string level_of_control = | 319 std::string level_of_control = |
| 320 GetLevelOfControl(profile_, extension_id, browser_pref, incognito); | 320 GetLevelOfControl(profile_, extension_id, browser_pref, incognito); |
| 321 dict->SetString(keys::kLevelOfControl, level_of_control); | 321 dict->SetString(keys::kLevelOfControl, level_of_control); |
| 322 | 322 |
| 323 std::string json_args; | 323 std::string json_args; |
| 324 base::JSONWriter::Write(&args, false, &json_args); | 324 base::JSONWriter::Write(&args, &json_args); |
| 325 | 325 |
| 326 DispatchEvent(extension_id, event_name, json_args); | 326 DispatchEvent(extension_id, event_name, json_args); |
| 327 } | 327 } |
| 328 } | 328 } |
| 329 } | 329 } |
| 330 | 330 |
| 331 void ExtensionPreferenceEventRouter::DispatchEvent( | 331 void ExtensionPreferenceEventRouter::DispatchEvent( |
| 332 const std::string& extension_id, | 332 const std::string& extension_id, |
| 333 const std::string& event_name, | 333 const std::string& event_name, |
| 334 const std::string& json_args) { | 334 const std::string& json_args) { |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 } | 513 } |
| 514 | 514 |
| 515 std::string browser_pref; | 515 std::string browser_pref; |
| 516 if (!ValidateBrowserPref(pref_key, &browser_pref)) | 516 if (!ValidateBrowserPref(pref_key, &browser_pref)) |
| 517 return false; | 517 return false; |
| 518 | 518 |
| 519 ExtensionPrefs* prefs = profile_->GetExtensionService()->extension_prefs(); | 519 ExtensionPrefs* prefs = profile_->GetExtensionService()->extension_prefs(); |
| 520 prefs->RemoveExtensionControlledPref(extension_id(), browser_pref, scope); | 520 prefs->RemoveExtensionControlledPref(extension_id(), browser_pref, scope); |
| 521 return true; | 521 return true; |
| 522 } | 522 } |
| OLD | NEW |