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_helpers.h" | 5 #include "chrome/browser/extensions/extension_preference_helpers.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/extensions/event_router.h" | 9 #include "chrome/browser/extensions/event_router.h" |
10 #include "chrome/browser/extensions/extension_prefs.h" | 10 #include "chrome/browser/extensions/extension_prefs.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 (*it)->HasAPIPermission(permission) && | 97 (*it)->HasAPIPermission(permission) && |
98 (!incognito || (*it)->incognito_split_mode() || | 98 (!incognito || (*it)->incognito_split_mode() || |
99 extension_service->CanCrossIncognito(*it))) { | 99 extension_service->CanCrossIncognito(*it))) { |
100 // Inject level of control key-value. | 100 // Inject level of control key-value. |
101 DictionaryValue* dict; | 101 DictionaryValue* dict; |
102 bool rv = args->GetDictionary(0, &dict); | 102 bool rv = args->GetDictionary(0, &dict); |
103 DCHECK(rv); | 103 DCHECK(rv); |
104 std::string level_of_control = | 104 std::string level_of_control = |
105 GetLevelOfControl(profile, extension_id, browser_pref, incognito); | 105 GetLevelOfControl(profile, extension_id, browser_pref, incognito); |
106 dict->SetString(kLevelOfControlKey, level_of_control); | 106 dict->SetString(kLevelOfControlKey, level_of_control); |
107 std::string json_args; | |
108 base::JSONWriter::Write(args, &json_args); | |
109 | 107 |
110 // If the extension is in incognito split mode, | 108 // If the extension is in incognito split mode, |
111 // a) incognito pref changes are visible only to the incognito tabs | 109 // a) incognito pref changes are visible only to the incognito tabs |
112 // b) regular pref changes are visible only to the incognito tabs if the | 110 // b) regular pref changes are visible only to the incognito tabs if the |
113 // incognito pref has not alredy been set | 111 // incognito pref has not alredy been set |
114 Profile* restrict_to_profile = NULL; | 112 Profile* restrict_to_profile = NULL; |
115 bool from_incognito = false; | 113 bool from_incognito = false; |
116 if ((*it)->incognito_split_mode()) { | 114 if ((*it)->incognito_split_mode()) { |
117 if (incognito && extension_service->IsIncognitoEnabled(extension_id)) { | 115 if (incognito && extension_service->IsIncognitoEnabled(extension_id)) { |
118 restrict_to_profile = profile->GetOffTheRecordProfile(); | 116 restrict_to_profile = profile->GetOffTheRecordProfile(); |
119 } else if (!incognito && | 117 } else if (!incognito && |
120 extension_prefs->DoesExtensionControlPref( | 118 extension_prefs->DoesExtensionControlPref( |
121 extension_id, | 119 extension_id, |
122 browser_pref, | 120 browser_pref, |
123 &from_incognito) && | 121 &from_incognito) && |
124 from_incognito) { | 122 from_incognito) { |
125 restrict_to_profile = profile; | 123 restrict_to_profile = profile; |
126 } | 124 } |
127 } | 125 } |
128 | 126 |
| 127 scoped_ptr<ListValue> args_copy(args->DeepCopy()); |
129 router->DispatchEventToExtension( | 128 router->DispatchEventToExtension( |
130 extension_id, event_name, json_args, restrict_to_profile, GURL()); | 129 extension_id, event_name, args_copy.Pass(), restrict_to_profile, |
| 130 GURL()); |
131 } | 131 } |
132 } | 132 } |
133 } | 133 } |
134 | 134 |
135 } // namespace extension_preference_helpers | 135 } // namespace extension_preference_helpers |
OLD | NEW |