OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #import "ios/web/webui/crw_web_ui_manager.h" | 5 #import "ios/web/webui/crw_web_ui_manager.h" |
6 | 6 |
7 #include "base/mac/bind_objc_block.h" | 7 #include "base/mac/bind_objc_block.h" |
8 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #import "base/strings/sys_string_conversions.h" | 10 #import "base/strings/sys_string_conversions.h" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 - (void)fetchResourceWithURL:(const GURL&)URL | 148 - (void)fetchResourceWithURL:(const GURL&)URL |
149 completionHandler:(void (^)(NSData*))completionHandler { | 149 completionHandler:(void (^)(NSData*))completionHandler { |
150 base::WeakNSObject<CRWWebUIManager> weakSelf(self); | 150 base::WeakNSObject<CRWWebUIManager> weakSelf(self); |
151 web::URLFetcherBlockAdapterCompletion fetcherCompletion = | 151 web::URLFetcherBlockAdapterCompletion fetcherCompletion = |
152 ^(NSData* data, web::URLFetcherBlockAdapter* fetcher) { | 152 ^(NSData* data, web::URLFetcherBlockAdapter* fetcher) { |
153 completionHandler(data); | 153 completionHandler(data); |
154 [weakSelf removeFetcher:fetcher]; | 154 [weakSelf removeFetcher:fetcher]; |
155 }; | 155 }; |
156 | 156 |
157 _fetchers.push_back( | 157 _fetchers.push_back( |
158 [self fetcherForURL:URL completionHandler:fetcherCompletion].Pass()); | 158 [self fetcherForURL:URL completionHandler:fetcherCompletion]); |
159 _fetchers.back()->Start(); | 159 _fetchers.back()->Start(); |
160 } | 160 } |
161 | 161 |
162 - (BOOL)handleWebUIJSMessage:(const base::DictionaryValue&)message { | 162 - (BOOL)handleWebUIJSMessage:(const base::DictionaryValue&)message { |
163 std::string command; | 163 std::string command; |
164 if (!message.GetString("message", &command) || | 164 if (!message.GetString("message", &command) || |
165 command != "webui.requestFavicon") { | 165 command != "webui.requestFavicon") { |
166 DLOG(WARNING) << "Unexpected message received" << command; | 166 DLOG(WARNING) << "Unexpected message received" << command; |
167 return NO; | 167 return NO; |
168 } | 168 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 | 214 |
215 - (scoped_ptr<web::URLFetcherBlockAdapter>) | 215 - (scoped_ptr<web::URLFetcherBlockAdapter>) |
216 fetcherForURL:(const GURL&)URL | 216 fetcherForURL:(const GURL&)URL |
217 completionHandler:(web::URLFetcherBlockAdapterCompletion)handler { | 217 completionHandler:(web::URLFetcherBlockAdapterCompletion)handler { |
218 return scoped_ptr<web::URLFetcherBlockAdapter>( | 218 return scoped_ptr<web::URLFetcherBlockAdapter>( |
219 new web::URLFetcherBlockAdapter( | 219 new web::URLFetcherBlockAdapter( |
220 URL, _webState->GetBrowserState()->GetRequestContext(), handler)); | 220 URL, _webState->GetBrowserState()->GetRequestContext(), handler)); |
221 } | 221 } |
222 | 222 |
223 @end | 223 @end |
OLD | NEW |