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

Side by Side Diff: chrome/browser/extensions/api/runtime/runtime_api.cc

Issue 16915006: Convert most of extensions and some other random stuff to using the base namespace for Values. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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/api/runtime/runtime_api.h" 5 #include "chrome/browser/extensions/api/runtime/runtime_api.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/extensions/event_router.h" 9 #include "chrome/browser/extensions/event_router.h"
10 #include "chrome/browser/extensions/extension_host.h" 10 #include "chrome/browser/extensions/extension_host.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 first_call && 93 first_call &&
94 system->lazy_background_task_queue()-> 94 system->lazy_background_task_queue()->
95 ShouldEnqueueTask(profile, extension)) { 95 ShouldEnqueueTask(profile, extension)) {
96 system->lazy_background_task_queue()->AddPendingTask( 96 system->lazy_background_task_queue()->AddPendingTask(
97 profile, extension_id, 97 profile, extension_id,
98 base::Bind(&DispatchOnStartupEventImpl, 98 base::Bind(&DispatchOnStartupEventImpl,
99 profile, extension_id, false)); 99 profile, extension_id, false));
100 return; 100 return;
101 } 101 }
102 102
103 scoped_ptr<base::ListValue> event_args(new ListValue()); 103 scoped_ptr<base::ListValue> event_args(new base::ListValue());
104 scoped_ptr<Event> event(new Event(kOnStartupEvent, event_args.Pass())); 104 scoped_ptr<Event> event(new Event(kOnStartupEvent, event_args.Pass()));
105 system->event_router()->DispatchEventToExtension(extension_id, event.Pass()); 105 system->event_router()->DispatchEventToExtension(extension_id, event.Pass());
106 } 106 }
107 107
108 void SetUninstallUrl(ExtensionPrefs* prefs, 108 void SetUninstallUrl(ExtensionPrefs* prefs,
109 const std::string& extension_id, 109 const std::string& extension_id,
110 const std::string& url_string) { 110 const std::string& url_string) {
111 prefs->UpdateExtensionPref(extension_id, 111 prefs->UpdateExtensionPref(extension_id,
112 kUninstallUrl, 112 kUninstallUrl,
113 base::Value::CreateStringValue(url_string)); 113 base::Value::CreateStringValue(url_string));
(...skipping 22 matching lines...) Expand all
136 bool chrome_updated) { 136 bool chrome_updated) {
137 ExtensionSystem* system = ExtensionSystem::Get(profile); 137 ExtensionSystem* system = ExtensionSystem::Get(profile);
138 if (!system) 138 if (!system)
139 return; 139 return;
140 140
141 // Special case: normally, extensions add their own lazy event listeners. 141 // Special case: normally, extensions add their own lazy event listeners.
142 // However, since the extension has just been installed, it hasn't had a 142 // However, since the extension has just been installed, it hasn't had a
143 // chance to register for events. So we register on its behalf. If the 143 // chance to register for events. So we register on its behalf. If the
144 // extension does not actually have a listener, the event will just be 144 // extension does not actually have a listener, the event will just be
145 // ignored. 145 // ignored.
146 scoped_ptr<base::ListValue> event_args(new ListValue()); 146 scoped_ptr<base::ListValue> event_args(new base::ListValue());
147 base::DictionaryValue* info = new base::DictionaryValue(); 147 base::DictionaryValue* info = new base::DictionaryValue();
148 event_args->Append(info); 148 event_args->Append(info);
149 if (old_version.IsValid()) { 149 if (old_version.IsValid()) {
150 info->SetString(kInstallReason, kInstallReasonUpdate); 150 info->SetString(kInstallReason, kInstallReasonUpdate);
151 info->SetString(kInstallPreviousVersion, old_version.GetString()); 151 info->SetString(kInstallPreviousVersion, old_version.GetString());
152 } else if (chrome_updated) { 152 } else if (chrome_updated) {
153 info->SetString(kInstallReason, kInstallReasonChromeUpdate); 153 info->SetString(kInstallReason, kInstallReasonChromeUpdate);
154 } else { 154 } else {
155 info->SetString(kInstallReason, kInstallReasonInstall); 155 info->SetString(kInstallReason, kInstallReasonInstall);
156 } 156 }
157 DCHECK(system->event_router()); 157 DCHECK(system->event_router());
158 system->event_router()->AddLazyEventListener(kOnInstalledEvent, extension_id); 158 system->event_router()->AddLazyEventListener(kOnInstalledEvent, extension_id);
159 scoped_ptr<Event> event(new Event(kOnInstalledEvent, event_args.Pass())); 159 scoped_ptr<Event> event(new Event(kOnInstalledEvent, event_args.Pass()));
160 system->event_router()->DispatchEventToExtension(extension_id, event.Pass()); 160 system->event_router()->DispatchEventToExtension(extension_id, event.Pass());
161 system->event_router()->RemoveLazyEventListener(kOnInstalledEvent, 161 system->event_router()->RemoveLazyEventListener(kOnInstalledEvent,
162 extension_id); 162 extension_id);
163 } 163 }
164 164
165 // static 165 // static
166 void RuntimeEventRouter::DispatchOnUpdateAvailableEvent( 166 void RuntimeEventRouter::DispatchOnUpdateAvailableEvent(
167 Profile* profile, 167 Profile* profile,
168 const std::string& extension_id, 168 const std::string& extension_id,
169 const DictionaryValue* manifest) { 169 const base::DictionaryValue* manifest) {
170 ExtensionSystem* system = ExtensionSystem::Get(profile); 170 ExtensionSystem* system = ExtensionSystem::Get(profile);
171 if (!system) 171 if (!system)
172 return; 172 return;
173 173
174 scoped_ptr<ListValue> args(new ListValue); 174 scoped_ptr<base::ListValue> args(new base::ListValue);
175 args->Append(manifest->DeepCopy()); 175 args->Append(manifest->DeepCopy());
176 DCHECK(system->event_router()); 176 DCHECK(system->event_router());
177 scoped_ptr<Event> event(new Event(kOnUpdateAvailableEvent, args.Pass())); 177 scoped_ptr<Event> event(new Event(kOnUpdateAvailableEvent, args.Pass()));
178 system->event_router()->DispatchEventToExtension(extension_id, event.Pass()); 178 system->event_router()->DispatchEventToExtension(extension_id, event.Pass());
179 } 179 }
180 180
181 // static 181 // static
182 void RuntimeEventRouter::DispatchOnBrowserUpdateAvailableEvent( 182 void RuntimeEventRouter::DispatchOnBrowserUpdateAvailableEvent(
183 Profile* profile) { 183 Profile* profile) {
184 ExtensionSystem* system = ExtensionSystem::Get(profile); 184 ExtensionSystem* system = ExtensionSystem::Get(profile);
185 if (!system) 185 if (!system)
186 return; 186 return;
187 187
188 scoped_ptr<ListValue> args(new ListValue); 188 scoped_ptr<base::ListValue> args(new base::ListValue);
189 DCHECK(system->event_router()); 189 DCHECK(system->event_router());
190 scoped_ptr<Event> event(new Event(kOnBrowserUpdateAvailableEvent, 190 scoped_ptr<Event> event(new Event(kOnBrowserUpdateAvailableEvent,
191 args.Pass())); 191 args.Pass()));
192 system->event_router()->BroadcastEvent(event.Pass()); 192 system->event_router()->BroadcastEvent(event.Pass());
193 } 193 }
194 194
195 // static 195 // static
196 void RuntimeEventRouter::OnExtensionUninstalled( 196 void RuntimeEventRouter::OnExtensionUninstalled(
197 Profile *profile, 197 Profile *profile,
198 const std::string& extension_id) { 198 const std::string& extension_id) {
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 fileapi::kFileSystemTypeNativeLocal, path, &relative_path); 402 fileapi::kFileSystemTypeNativeLocal, path, &relative_path);
403 403
404 int renderer_id = render_view_host_->GetProcess()->GetID(); 404 int renderer_id = render_view_host_->GetProcess()->GetID();
405 content::ChildProcessSecurityPolicy* policy = 405 content::ChildProcessSecurityPolicy* policy =
406 content::ChildProcessSecurityPolicy::GetInstance(); 406 content::ChildProcessSecurityPolicy::GetInstance();
407 policy->GrantReadFileSystem(renderer_id, filesystem_id); 407 policy->GrantReadFileSystem(renderer_id, filesystem_id);
408 408
409 if (!policy->CanReadFile(renderer_id, path)) 409 if (!policy->CanReadFile(renderer_id, path))
410 policy->GrantReadFile(renderer_id, path); 410 policy->GrantReadFile(renderer_id, path);
411 411
412 DictionaryValue* dict = new DictionaryValue(); 412 base::DictionaryValue* dict = new base::DictionaryValue();
413 SetResult(dict); 413 SetResult(dict);
414 dict->SetString("fileSystemId", filesystem_id); 414 dict->SetString("fileSystemId", filesystem_id);
415 dict->SetString("baseName", relative_path); 415 dict->SetString("baseName", relative_path);
416 return true; 416 return true;
417 } 417 }
418 418
419 } // namespace extensions 419 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698