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

Side by Side Diff: extensions/browser/updater/safe_manifest_parser.cc

Issue 464613002: Move SafeManifestParser to //extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge and update gn Created 6 years, 2 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/updater/safe_manifest_parser.h" 5 #include "extensions/browser/updater/safe_manifest_parser.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "chrome/common/extensions/chrome_utility_extensions_messages.h"
12 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/utility_process_host.h" 12 #include "content/public/browser/utility_process_host.h"
14 #include "content/public/common/content_switches.h" 13 #include "content/public/common/content_switches.h"
14 #include "extensions/common/extension_utility_messages.h"
15 #include "ipc/ipc_message_macros.h" 15 #include "ipc/ipc_message_macros.h"
16 16
17 using content::BrowserThread; 17 using content::BrowserThread;
18 18
19 namespace extensions { 19 namespace extensions {
20 20
21 SafeManifestParser::SafeManifestParser(const std::string& xml, 21 SafeManifestParser::SafeManifestParser(const std::string& xml,
22 ManifestFetchData* fetch_data, 22 ManifestFetchData* fetch_data,
23 const UpdateCallback& update_callback) 23 const UpdateCallback& update_callback)
24 : xml_(xml), 24 : xml_(xml), fetch_data_(fetch_data), update_callback_(update_callback) {
25 fetch_data_(fetch_data),
26 update_callback_(update_callback) {
27 DCHECK_CURRENTLY_ON(BrowserThread::UI); 25 DCHECK_CURRENTLY_ON(BrowserThread::UI);
28 } 26 }
29 27
30 void SafeManifestParser::Start() { 28 void SafeManifestParser::Start() {
31 DCHECK_CURRENTLY_ON(BrowserThread::UI); 29 DCHECK_CURRENTLY_ON(BrowserThread::UI);
32 if (!BrowserThread::PostTask( 30 if (!BrowserThread::PostTask(
33 BrowserThread::IO, FROM_HERE, 31 BrowserThread::IO,
32 FROM_HERE,
34 base::Bind(&SafeManifestParser::ParseInSandbox, this))) { 33 base::Bind(&SafeManifestParser::ParseInSandbox, this))) {
35 NOTREACHED(); 34 NOTREACHED();
36 } 35 }
37 } 36 }
38 37
39 SafeManifestParser::~SafeManifestParser() { 38 SafeManifestParser::~SafeManifestParser() {
40 // If we're using UtilityProcessHost, we may not be destroyed on 39 // If we're using UtilityProcessHost, we may not be destroyed on
41 // the UI or IO thread. 40 // the UI or IO thread.
42 } 41 }
43 42
44 void SafeManifestParser::ParseInSandbox() { 43 void SafeManifestParser::ParseInSandbox() {
45 DCHECK_CURRENTLY_ON(BrowserThread::IO); 44 DCHECK_CURRENTLY_ON(BrowserThread::IO);
46 45
47 content::UtilityProcessHost* host = content::UtilityProcessHost::Create( 46 content::UtilityProcessHost* host = content::UtilityProcessHost::Create(
48 this, 47 this,
49 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI).get()); 48 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI).get());
50 host->Send(new ChromeUtilityMsg_ParseUpdateManifest(xml_)); 49 host->Send(new ExtensionUtilityMsg_ParseUpdateManifest(xml_));
51 } 50 }
52 51
53 bool SafeManifestParser::OnMessageReceived(const IPC::Message& message) { 52 bool SafeManifestParser::OnMessageReceived(const IPC::Message& message) {
54 bool handled = true; 53 bool handled = true;
55 IPC_BEGIN_MESSAGE_MAP(SafeManifestParser, message) 54 IPC_BEGIN_MESSAGE_MAP(SafeManifestParser, message)
56 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParseUpdateManifest_Succeeded, 55 IPC_MESSAGE_HANDLER(ExtensionUtilityHostMsg_ParseUpdateManifest_Succeeded,
57 OnParseUpdateManifestSucceeded) 56 OnParseUpdateManifestSucceeded)
58 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParseUpdateManifest_Failed, 57 IPC_MESSAGE_HANDLER(ExtensionUtilityHostMsg_ParseUpdateManifest_Failed,
59 OnParseUpdateManifestFailed) 58 OnParseUpdateManifestFailed)
60 IPC_MESSAGE_UNHANDLED(handled = false) 59 IPC_MESSAGE_UNHANDLED(handled = false)
61 IPC_END_MESSAGE_MAP() 60 IPC_END_MESSAGE_MAP()
62 return handled; 61 return handled;
63 } 62 }
64 63
65 void SafeManifestParser::OnParseUpdateManifestSucceeded( 64 void SafeManifestParser::OnParseUpdateManifestSucceeded(
66 const UpdateManifest::Results& results) { 65 const UpdateManifest::Results& results) {
67 VLOG(2) << "parsing manifest succeeded (" << fetch_data_->full_url() << ")"; 66 VLOG(2) << "parsing manifest succeeded (" << fetch_data_->full_url() << ")";
68 DCHECK_CURRENTLY_ON(BrowserThread::UI); 67 DCHECK_CURRENTLY_ON(BrowserThread::UI);
69 update_callback_.Run(*fetch_data_, &results); 68 update_callback_.Run(*fetch_data_, &results);
70 } 69 }
71 70
72 void SafeManifestParser::OnParseUpdateManifestFailed( 71 void SafeManifestParser::OnParseUpdateManifestFailed(
73 const std::string& error_message) { 72 const std::string& error_message) {
74 VLOG(2) << "parsing manifest failed (" << fetch_data_->full_url() << ")"; 73 VLOG(2) << "parsing manifest failed (" << fetch_data_->full_url() << ")";
75 DCHECK_CURRENTLY_ON(BrowserThread::UI); 74 DCHECK_CURRENTLY_ON(BrowserThread::UI);
76 LOG(WARNING) << "Error parsing update manifest:\n" << error_message; 75 LOG(WARNING) << "Error parsing update manifest:\n" << error_message;
77 update_callback_.Run(*fetch_data_, NULL); 76 update_callback_.Run(*fetch_data_, NULL);
78 } 77 }
79 78
80 } // namespace extensions 79 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/updater/safe_manifest_parser.h ('k') | extensions/common/extension_message_generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698