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/webstore_install_helper.h" | 5 #include "chrome/browser/extensions/webstore_install_helper.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" | 9 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" |
10 #include "chrome/browser/safe_json_parser.h" | 10 #include "components/safe_json_parser/safe_json_parser.h" |
11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
12 #include "net/base/load_flags.h" | 12 #include "net/base/load_flags.h" |
13 #include "net/url_request/url_request.h" | 13 #include "net/url_request/url_request.h" |
14 | 14 |
15 using content::BrowserThread; | 15 using content::BrowserThread; |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 const char kImageDecodeError[] = "Image decode failed"; | 19 const char kImageDecodeError[] = "Image decode failed"; |
20 | 20 |
(...skipping 21 matching lines...) Expand all Loading... |
42 | 42 |
43 void WebstoreInstallHelper::Start() { | 43 void WebstoreInstallHelper::Start() { |
44 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 44 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
45 | 45 |
46 // No existing |json_parser_| to avoid unbalanced AddRef(). | 46 // No existing |json_parser_| to avoid unbalanced AddRef(). |
47 CHECK(!json_parser_.get()); | 47 CHECK(!json_parser_.get()); |
48 AddRef(); // Balanced in OnJSONParseSucceeded()/OnJSONParseFailed(). | 48 AddRef(); // Balanced in OnJSONParseSucceeded()/OnJSONParseFailed(). |
49 // Use base::Unretained so that base::Bind won't AddRef() on us. Otherwise, | 49 // Use base::Unretained so that base::Bind won't AddRef() on us. Otherwise, |
50 // we'll have two callbacks holding references to us, only one of which will | 50 // we'll have two callbacks holding references to us, only one of which will |
51 // ever be called. | 51 // ever be called. |
52 json_parser_ = new SafeJsonParser( | 52 json_parser_ = new safe_json_parser::SafeJsonParser( |
53 manifest_, | 53 manifest_, |
54 base::Bind(&WebstoreInstallHelper::OnJSONParseSucceeded, | 54 base::Bind(&WebstoreInstallHelper::OnJSONParseSucceeded, |
55 base::Unretained(this)), | 55 base::Unretained(this)), |
56 base::Bind(&WebstoreInstallHelper::OnJSONParseFailed, | 56 base::Bind(&WebstoreInstallHelper::OnJSONParseFailed, |
57 base::Unretained(this))); | 57 base::Unretained(this))); |
58 json_parser_->Start(); | 58 json_parser_->Start(); |
59 | 59 |
60 if (icon_url_.is_empty()) { | 60 if (icon_url_.is_empty()) { |
61 icon_decode_complete_ = true; | 61 icon_decode_complete_ = true; |
62 } else { | 62 } else { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 if (!icon_decode_complete_ || !manifest_parse_complete_) | 121 if (!icon_decode_complete_ || !manifest_parse_complete_) |
122 return; | 122 return; |
123 | 123 |
124 if (error_.empty() && parsed_manifest_) | 124 if (error_.empty() && parsed_manifest_) |
125 delegate_->OnWebstoreParseSuccess(id_, icon_, parsed_manifest_.release()); | 125 delegate_->OnWebstoreParseSuccess(id_, icon_, parsed_manifest_.release()); |
126 else | 126 else |
127 delegate_->OnWebstoreParseFailure(id_, parse_error_, error_); | 127 delegate_->OnWebstoreParseFailure(id_, parse_error_, error_); |
128 } | 128 } |
129 | 129 |
130 } // namespace extensions | 130 } // namespace extensions |
OLD | NEW |