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

Side by Side Diff: content/browser/loader/buffered_resource_handler.cc

Issue 263513004: Forward MIME types to BrowserPlugin when a viewer is specified. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code review fixes Created 6 years, 7 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 "content/browser/loader/buffered_resource_handler.h" 5 #include "content/browser/loader/buffered_resource_handler.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "content/browser/download/download_resource_handler.h" 13 #include "content/browser/download/download_resource_handler.h"
14 #include "content/browser/download/download_stats.h" 14 #include "content/browser/download/download_stats.h"
15 #include "content/browser/loader/certificate_resource_handler.h" 15 #include "content/browser/loader/certificate_resource_handler.h"
16 #include "content/browser/loader/resource_dispatcher_host_impl.h" 16 #include "content/browser/loader/resource_dispatcher_host_impl.h"
17 #include "content/browser/loader/resource_request_info_impl.h" 17 #include "content/browser/loader/resource_request_info_impl.h"
18 #include "content/browser/loader/stream_resource_handler.h"
18 #include "content/browser/plugin_service_impl.h" 19 #include "content/browser/plugin_service_impl.h"
19 #include "content/public/browser/content_browser_client.h" 20 #include "content/public/browser/content_browser_client.h"
20 #include "content/public/browser/download_item.h" 21 #include "content/public/browser/download_item.h"
21 #include "content/public/browser/download_save_info.h" 22 #include "content/public/browser/download_save_info.h"
22 #include "content/public/browser/download_url_parameters.h" 23 #include "content/public/browser/download_url_parameters.h"
23 #include "content/public/browser/resource_context.h" 24 #include "content/public/browser/resource_context.h"
24 #include "content/public/browser/resource_dispatcher_host_delegate.h" 25 #include "content/public/browser/resource_dispatcher_host_delegate.h"
25 #include "content/public/common/resource_response.h" 26 #include "content/public/common/resource_response.h"
26 #include "content/public/common/webplugininfo.h" 27 #include "content/public/common/webplugininfo.h"
27 #include "net/base/io_buffer.h" 28 #include "net/base/io_buffer.h"
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 } 315 }
315 316
316 if (!info->allow_download()) 317 if (!info->allow_download())
317 return true; 318 return true;
318 319
319 bool must_download = MustDownload(); 320 bool must_download = MustDownload();
320 if (!must_download) { 321 if (!must_download) {
321 if (net::IsSupportedMimeType(mime_type)) 322 if (net::IsSupportedMimeType(mime_type))
322 return true; 323 return true;
323 324
324 scoped_ptr<ResourceHandler> handler( 325 scoped_ptr<StreamResourceHandler> handler(
325 host_->MaybeInterceptAsStream(request(), response_.get())); 326 host_->MaybeInterceptAsStream(request(), response_.get()));
326 if (handler) 327 if (handler) {
327 return UseAlternateNextHandler(handler.Pass()); 328 if (handler->HasPayload()) {
329 handler->SetNextHandler(next_handler_.Pass());
330
331 next_handler_ = handler.Pass();
332 next_handler_->SetController(this);
333
334 int request_id =
335 ResourceRequestInfo::ForRequest(request())->GetRequestID();
336 return CopyReadBufferToNextHandler(request_id);
337 } else {
338 UseAlternateNextHandler(handler.PassAs<ResourceHandler>());
339 }
340 }
328 341
329 #if defined(ENABLE_PLUGINS) 342 #if defined(ENABLE_PLUGINS)
330 bool stale; 343 bool stale;
331 bool has_plugin = HasSupportingPlugin(&stale); 344 bool has_plugin = HasSupportingPlugin(&stale);
332 if (stale) { 345 if (stale) {
333 // Refresh the plugins asynchronously. 346 // Refresh the plugins asynchronously.
334 PluginServiceImpl::GetInstance()->GetPlugins( 347 PluginServiceImpl::GetInstance()->GetPlugins(
335 base::Bind(&BufferedResourceHandler::OnPluginsLoaded, 348 base::Bind(&BufferedResourceHandler::OnPluginsLoaded,
336 weak_ptr_factory_.GetWeakPtr())); 349 weak_ptr_factory_.GetWeakPtr()));
337 request()->LogBlockedBy("BufferedResourceHandler"); 350 request()->LogBlockedBy("BufferedResourceHandler");
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 request()->LogUnblocked(); 490 request()->LogUnblocked();
478 bool defer = false; 491 bool defer = false;
479 if (!ProcessResponse(&defer)) { 492 if (!ProcessResponse(&defer)) {
480 controller()->Cancel(); 493 controller()->Cancel();
481 } else if (!defer) { 494 } else if (!defer) {
482 controller()->Resume(); 495 controller()->Resume();
483 } 496 }
484 } 497 }
485 498
486 } // namespace content 499 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698