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

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

Powered by Google App Engine
This is Rietveld 408576698