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/api/management/management_api.h" | 5 #include "chrome/browser/extensions/api/management/management_api.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 void StartWorkOnIOThread() { | 292 void StartWorkOnIOThread() { |
293 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 293 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
294 UtilityProcessHost* host = | 294 UtilityProcessHost* host = |
295 UtilityProcessHost::Create( | 295 UtilityProcessHost::Create( |
296 this, | 296 this, |
297 base::MessageLoopProxy::current()); | 297 base::MessageLoopProxy::current()); |
298 host->EnableZygote(); | 298 host->EnableZygote(); |
299 host->Send(new ChromeUtilityMsg_ParseJSON(manifest_)); | 299 host->Send(new ChromeUtilityMsg_ParseJSON(manifest_)); |
300 } | 300 } |
301 | 301 |
302 virtual bool OnMessageReceived(const IPC::Message& message) { | 302 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { |
303 bool handled = true; | 303 bool handled = true; |
304 IPC_BEGIN_MESSAGE_MAP(SafeManifestJSONParser, message) | 304 IPC_BEGIN_MESSAGE_MAP(SafeManifestJSONParser, message) |
305 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParseJSON_Succeeded, | 305 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParseJSON_Succeeded, |
306 OnJSONParseSucceeded) | 306 OnJSONParseSucceeded) |
307 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParseJSON_Failed, | 307 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParseJSON_Failed, |
308 OnJSONParseFailed) | 308 OnJSONParseFailed) |
309 IPC_MESSAGE_UNHANDLED(handled = false) | 309 IPC_MESSAGE_UNHANDLED(handled = false) |
310 IPC_END_MESSAGE_MAP() | 310 IPC_END_MESSAGE_MAP() |
311 return handled; | 311 return handled; |
312 } | 312 } |
(...skipping 25 matching lines...) Expand all Loading... |
338 | 338 |
339 void ReportResultFromUIThread() { | 339 void ReportResultFromUIThread() { |
340 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 340 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
341 if (error_.empty() && parsed_manifest_.get()) | 341 if (error_.empty() && parsed_manifest_.get()) |
342 client_->OnParseSuccess(parsed_manifest_.release()); | 342 client_->OnParseSuccess(parsed_manifest_.release()); |
343 else | 343 else |
344 client_->OnParseFailure(error_); | 344 client_->OnParseFailure(error_); |
345 } | 345 } |
346 | 346 |
347 private: | 347 private: |
348 ~SafeManifestJSONParser() {} | 348 virtual ~SafeManifestJSONParser() {} |
349 | 349 |
350 // The client who we'll report results back to. | 350 // The client who we'll report results back to. |
351 ManagementGetPermissionWarningsByManifestFunction* client_; | 351 ManagementGetPermissionWarningsByManifestFunction* client_; |
352 | 352 |
353 // Data to parse. | 353 // Data to parse. |
354 std::string manifest_; | 354 std::string manifest_; |
355 | 355 |
356 // Results of parsing. | 356 // Results of parsing. |
357 scoped_ptr<DictionaryValue> parsed_manifest_; | 357 scoped_ptr<DictionaryValue> parsed_manifest_; |
358 | 358 |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 ProfileKeyedAPIFactory<ManagementAPI>* ManagementAPI::GetFactoryInstance() { | 709 ProfileKeyedAPIFactory<ManagementAPI>* ManagementAPI::GetFactoryInstance() { |
710 return &g_factory.Get(); | 710 return &g_factory.Get(); |
711 } | 711 } |
712 | 712 |
713 void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) { | 713 void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) { |
714 management_event_router_.reset(new ManagementEventRouter(profile_)); | 714 management_event_router_.reset(new ManagementEventRouter(profile_)); |
715 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); | 715 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); |
716 } | 716 } |
717 | 717 |
718 } // namespace extensions | 718 } // namespace extensions |
OLD | NEW |