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

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 1085783002: Replace image_messages.h with Mojo service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix review comments on set7 Created 5 years, 5 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
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/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 #include "content/browser/renderer_host/render_widget_host_view_base.h" 55 #include "content/browser/renderer_host/render_widget_host_view_base.h"
56 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host_ impl.h" 56 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host_ impl.h"
57 #include "content/browser/site_instance_impl.h" 57 #include "content/browser/site_instance_impl.h"
58 #include "content/browser/web_contents/web_contents_view_guest.h" 58 #include "content/browser/web_contents/web_contents_view_guest.h"
59 #include "content/browser/webui/generic_handler.h" 59 #include "content/browser/webui/generic_handler.h"
60 #include "content/browser/webui/web_ui_controller_factory_registry.h" 60 #include "content/browser/webui/web_ui_controller_factory_registry.h"
61 #include "content/browser/webui/web_ui_impl.h" 61 #include "content/browser/webui/web_ui_impl.h"
62 #include "content/common/browser_plugin/browser_plugin_constants.h" 62 #include "content/common/browser_plugin/browser_plugin_constants.h"
63 #include "content/common/browser_plugin/browser_plugin_messages.h" 63 #include "content/common/browser_plugin/browser_plugin_messages.h"
64 #include "content/common/frame_messages.h" 64 #include "content/common/frame_messages.h"
65 #include "content/common/image_messages.h"
66 #include "content/common/input_messages.h" 65 #include "content/common/input_messages.h"
67 #include "content/common/ssl_status_serialization.h" 66 #include "content/common/ssl_status_serialization.h"
68 #include "content/common/view_messages.h" 67 #include "content/common/view_messages.h"
69 #include "content/public/browser/ax_event_notification_details.h" 68 #include "content/public/browser/ax_event_notification_details.h"
70 #include "content/public/browser/browser_context.h" 69 #include "content/public/browser/browser_context.h"
71 #include "content/public/browser/browser_plugin_guest_manager.h" 70 #include "content/public/browser/browser_plugin_guest_manager.h"
72 #include "content/public/browser/content_browser_client.h" 71 #include "content/public/browser/content_browser_client.h"
73 #include "content/public/browser/devtools_agent_host.h" 72 #include "content/public/browser/devtools_agent_host.h"
74 #include "content/public/browser/download_manager.h" 73 #include "content/public/browser/download_manager.h"
75 #include "content/public/browser/download_url_parameters.h" 74 #include "content/public/browser/download_url_parameters.h"
(...skipping 14 matching lines...) Expand all
90 #include "content/public/browser/web_contents_observer.h" 89 #include "content/public/browser/web_contents_observer.h"
91 #include "content/public/common/bindings_policy.h" 90 #include "content/public/common/bindings_policy.h"
92 #include "content/public/common/content_constants.h" 91 #include "content/public/common/content_constants.h"
93 #include "content/public/common/content_switches.h" 92 #include "content/public/common/content_switches.h"
94 #include "content/public/common/page_zoom.h" 93 #include "content/public/common/page_zoom.h"
95 #include "content/public/common/result_codes.h" 94 #include "content/public/common/result_codes.h"
96 #include "content/public/common/security_style.h" 95 #include "content/public/common/security_style.h"
97 #include "content/public/common/url_constants.h" 96 #include "content/public/common/url_constants.h"
98 #include "content/public/common/url_utils.h" 97 #include "content/public/common/url_utils.h"
99 #include "content/public/common/web_preferences.h" 98 #include "content/public/common/web_preferences.h"
99 #include "mojo/common/url_type_converters.h"
100 #include "mojo/converters/geometry/geometry_type_converters.h"
100 #include "net/base/net_util.h" 101 #include "net/base/net_util.h"
101 #include "net/http/http_cache.h" 102 #include "net/http/http_cache.h"
102 #include "net/http/http_transaction_factory.h" 103 #include "net/http/http_transaction_factory.h"
103 #include "net/url_request/url_request_context.h" 104 #include "net/url_request/url_request_context.h"
104 #include "net/url_request/url_request_context_getter.h" 105 #include "net/url_request/url_request_context_getter.h"
106 #include "skia/public/type_converters.h"
107 #include "third_party/skia/include/core/SkBitmap.h"
105 #include "ui/base/layout.h" 108 #include "ui/base/layout.h"
106 #include "ui/gfx/display.h" 109 #include "ui/gfx/display.h"
107 #include "ui/gfx/screen.h" 110 #include "ui/gfx/screen.h"
108 #include "ui/gl/gl_switches.h" 111 #include "ui/gl/gl_switches.h"
109 112
110 #if defined(ENABLE_BROWSER_CDMS) 113 #if defined(ENABLE_BROWSER_CDMS)
111 #include "content/browser/media/media_web_contents_observer.h" 114 #include "content/browser/media/media_web_contents_observer.h"
112 #endif 115 #endif
113 116
114 #if defined(OS_ANDROID) 117 #if defined(OS_ANDROID)
(...skipping 13 matching lines...) Expand all
128 const int kMinimumDelayBetweenLoadingUpdatesMS = 100; 131 const int kMinimumDelayBetweenLoadingUpdatesMS = 100;
129 const char kDotGoogleDotCom[] = ".google.com"; 132 const char kDotGoogleDotCom[] = ".google.com";
130 133
131 #if defined(OS_ANDROID) 134 #if defined(OS_ANDROID)
132 const char kWebContentsAndroidKey[] = "web_contents_android"; 135 const char kWebContentsAndroidKey[] = "web_contents_android";
133 #endif // OS_ANDROID 136 #endif // OS_ANDROID
134 137
135 base::LazyInstance<std::vector<WebContentsImpl::CreatedCallback> > 138 base::LazyInstance<std::vector<WebContentsImpl::CreatedCallback> >
136 g_created_callbacks = LAZY_INSTANCE_INITIALIZER; 139 g_created_callbacks = LAZY_INSTANCE_INITIALIZER;
137 140
138 static int StartDownload(RenderFrameHost* rfh, 141 static void DidDownloadImage(const WebContents::ImageDownloadCallback& callback,
139 const GURL& url, 142 int id,
140 bool is_favicon, 143 const GURL& image_url,
141 uint32_t max_bitmap_size, 144 image_downloader::DownloadResultPtr result) {
142 bool bypass_cache) { 145 DCHECK(result);
143 static int g_next_image_download_id = 0; 146
144 rfh->Send(new ImageMsg_DownloadImage(rfh->GetRoutingID(), 147 const std::vector<SkBitmap> images =
145 ++g_next_image_download_id, 148 result->images.To<std::vector<SkBitmap>>();
146 url, 149 const std::vector<gfx::Size> original_image_sizes =
147 is_favicon, 150 result->original_image_sizes.To<std::vector<gfx::Size>>();
148 max_bitmap_size, 151
149 bypass_cache)); 152 callback.Run(id, result->http_status_code, image_url, images,
150 return g_next_image_download_id; 153 original_image_sizes);
151 } 154 }
152 155
153 void NotifyCacheOnIO( 156 void NotifyCacheOnIO(
154 scoped_refptr<net::URLRequestContextGetter> request_context, 157 scoped_refptr<net::URLRequestContextGetter> request_context,
155 const GURL& url, 158 const GURL& url,
156 const std::string& http_method) { 159 const std::string& http_method) {
157 net::HttpCache* cache = request_context->GetURLRequestContext()-> 160 net::HttpCache* cache = request_context->GetURLRequestContext()->
158 http_transaction_factory()->GetCache(); 161 http_transaction_factory()->GetCache();
159 if (cache) 162 if (cache)
160 cache->OnExternalCacheHit(url, http_method); 163 cache->OnExternalCacheHit(url, http_method);
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperInstanceDeleted, 607 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperInstanceDeleted,
605 OnPepperInstanceDeleted) 608 OnPepperInstanceDeleted)
606 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperPluginHung, OnPepperPluginHung) 609 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperPluginHung, OnPepperPluginHung)
607 IPC_MESSAGE_HANDLER(FrameHostMsg_PluginCrashed, OnPluginCrashed) 610 IPC_MESSAGE_HANDLER(FrameHostMsg_PluginCrashed, OnPluginCrashed)
608 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission, 611 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission,
609 OnRequestPpapiBrokerPermission) 612 OnRequestPpapiBrokerPermission)
610 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_Attach, 613 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_Attach,
611 OnBrowserPluginMessage(render_frame_host, 614 OnBrowserPluginMessage(render_frame_host,
612 message)) 615 message))
613 #endif 616 #endif
614 IPC_MESSAGE_HANDLER(ImageHostMsg_DidDownloadImage, OnDidDownloadImage)
615 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) 617 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL)
616 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowValidationMessage, 618 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowValidationMessage,
617 OnShowValidationMessage) 619 OnShowValidationMessage)
618 IPC_MESSAGE_HANDLER(ViewHostMsg_HideValidationMessage, 620 IPC_MESSAGE_HANDLER(ViewHostMsg_HideValidationMessage,
619 OnHideValidationMessage) 621 OnHideValidationMessage)
620 IPC_MESSAGE_HANDLER(ViewHostMsg_MoveValidationMessage, 622 IPC_MESSAGE_HANDLER(ViewHostMsg_MoveValidationMessage,
621 OnMoveValidationMessage) 623 OnMoveValidationMessage)
622 #if defined(OS_ANDROID) 624 #if defined(OS_ANDROID)
623 IPC_MESSAGE_HANDLER(ViewHostMsg_FindMatchRects_Reply, 625 IPC_MESSAGE_HANDLER(ViewHostMsg_FindMatchRects_Reply,
624 OnFindMatchRectsReply) 626 OnFindMatchRectsReply)
(...skipping 1942 matching lines...) Expand 10 before | Expand all | Expand 10 after
2567 color_chooser_info_->render_process_id, 2569 color_chooser_info_->render_process_id,
2568 color_chooser_info_->render_frame_id); 2570 color_chooser_info_->render_frame_id);
2569 if (!rfh) 2571 if (!rfh)
2570 return; 2572 return;
2571 2573
2572 rfh->Send(new FrameMsg_DidEndColorChooser( 2574 rfh->Send(new FrameMsg_DidEndColorChooser(
2573 rfh->GetRoutingID(), color_chooser_info_->identifier)); 2575 rfh->GetRoutingID(), color_chooser_info_->identifier));
2574 color_chooser_info_.reset(); 2576 color_chooser_info_.reset();
2575 } 2577 }
2576 2578
2577 int WebContentsImpl::DownloadImage(const GURL& url, 2579 int WebContentsImpl::DownloadImage(
2578 bool is_favicon, 2580 const GURL& url,
2579 uint32_t max_bitmap_size, 2581 bool is_favicon,
2580 bool bypass_cache, 2582 uint32_t max_bitmap_size,
2581 const ImageDownloadCallback& callback) { 2583 bool bypass_cache,
2582 int id = StartDownload(GetMainFrame(), url, is_favicon, max_bitmap_size, 2584 const WebContents::ImageDownloadCallback& callback) {
2583 bypass_cache); 2585 static int next_image_download_id = 0;
2584 image_download_map_[id] = callback; 2586 const image_downloader::ImageDownloaderPtr& mojo_image_downloader =
2585 return id; 2587 GetMainFrame()->GetMojoImageDownloader();
2588 image_downloader::DownloadRequestPtr req =
2589 image_downloader::DownloadRequest::New();
2590
2591 req->url = mojo::String::From(url);
2592 req->is_favicon = is_favicon;
2593 req->max_bitmap_size = max_bitmap_size;
2594 req->bypass_cache = bypass_cache;
2595
2596 mojo_image_downloader->DownloadImage(
2597 req.Pass(),
2598 base::Bind(&DidDownloadImage, callback, ++next_image_download_id, url));
2599 return next_image_download_id;
2586 } 2600 }
2587 2601
2588 bool WebContentsImpl::IsSubframe() const { 2602 bool WebContentsImpl::IsSubframe() const {
2589 return is_subframe_; 2603 return is_subframe_;
2590 } 2604 }
2591 2605
2592 void WebContentsImpl::Find(int request_id, 2606 void WebContentsImpl::Find(int request_id,
2593 const base::string16& search_text, 2607 const base::string16& search_text,
2594 const blink::WebFindOptions& options) { 2608 const blink::WebFindOptions& options) {
2595 // See if a top level browser plugin handles the find request first. 2609 // See if a top level browser plugin handles the find request first.
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
3150 } 3164 }
3151 3165
3152 void WebContentsImpl::OnBrowserPluginMessage(RenderFrameHost* render_frame_host, 3166 void WebContentsImpl::OnBrowserPluginMessage(RenderFrameHost* render_frame_host,
3153 const IPC::Message& message) { 3167 const IPC::Message& message) {
3154 CHECK(!browser_plugin_embedder_.get()); 3168 CHECK(!browser_plugin_embedder_.get());
3155 CreateBrowserPluginEmbedderIfNecessary(); 3169 CreateBrowserPluginEmbedderIfNecessary();
3156 browser_plugin_embedder_->OnMessageReceived(message, render_frame_host); 3170 browser_plugin_embedder_->OnMessageReceived(message, render_frame_host);
3157 } 3171 }
3158 #endif // defined(ENABLE_PLUGINS) 3172 #endif // defined(ENABLE_PLUGINS)
3159 3173
3160 void WebContentsImpl::OnDidDownloadImage(
3161 int id,
3162 int http_status_code,
3163 const GURL& image_url,
3164 const std::vector<SkBitmap>& bitmaps,
3165 const std::vector<gfx::Size>& original_bitmap_sizes) {
3166 if (bitmaps.size() != original_bitmap_sizes.size())
3167 return;
3168
3169 ImageDownloadMap::iterator iter = image_download_map_.find(id);
3170 if (iter == image_download_map_.end()) {
3171 // Currently WebContents notifies us of ANY downloads so that it is
3172 // possible to get here.
3173 return;
3174 }
3175 if (!iter->second.is_null()) {
3176 iter->second.Run(
3177 id, http_status_code, image_url, bitmaps, original_bitmap_sizes);
3178 }
3179 image_download_map_.erase(id);
3180 }
3181
3182 void WebContentsImpl::OnUpdateFaviconURL( 3174 void WebContentsImpl::OnUpdateFaviconURL(
3183 const std::vector<FaviconURL>& candidates) { 3175 const std::vector<FaviconURL>& candidates) {
3184 // We get updated favicon URLs after the page stops loading. If a cross-site 3176 // We get updated favicon URLs after the page stops loading. If a cross-site
3185 // navigation occurs while a page is still loading, the initial page 3177 // navigation occurs while a page is still loading, the initial page
3186 // may stop loading and send us updated favicon URLs after the navigation 3178 // may stop loading and send us updated favicon URLs after the navigation
3187 // for the new page has committed. 3179 // for the new page has committed.
3188 RenderViewHostImpl* rvhi = 3180 RenderViewHostImpl* rvhi =
3189 static_cast<RenderViewHostImpl*>(render_view_message_source_); 3181 static_cast<RenderViewHostImpl*>(render_view_message_source_);
3190 if (!rvhi->is_active()) 3182 if (!rvhi->is_active())
3191 return; 3183 return;
(...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after
4484 player_map->erase(it); 4476 player_map->erase(it);
4485 } 4477 }
4486 4478
4487 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { 4479 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) {
4488 force_disable_overscroll_content_ = force_disable; 4480 force_disable_overscroll_content_ = force_disable;
4489 if (view_) 4481 if (view_)
4490 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); 4482 view_->SetOverscrollControllerEnabled(CanOverscrollContent());
4491 } 4483 }
4492 4484
4493 } // namespace content 4485 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698