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 "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/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 20 matching lines...) Expand all Loading... | |
31 #include "content/browser/intents/web_intents_dispatcher_impl.h" | 31 #include "content/browser/intents/web_intents_dispatcher_impl.h" |
32 #include "content/browser/renderer_host/render_process_host_impl.h" | 32 #include "content/browser/renderer_host/render_process_host_impl.h" |
33 #include "content/browser/renderer_host/render_view_host_impl.h" | 33 #include "content/browser/renderer_host/render_view_host_impl.h" |
34 #include "content/browser/renderer_host/render_widget_host_impl.h" | 34 #include "content/browser/renderer_host/render_widget_host_impl.h" |
35 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" | 35 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" |
36 #include "content/browser/site_instance_impl.h" | 36 #include "content/browser/site_instance_impl.h" |
37 #include "content/browser/web_contents/interstitial_page_impl.h" | 37 #include "content/browser/web_contents/interstitial_page_impl.h" |
38 #include "content/browser/web_contents/navigation_entry_impl.h" | 38 #include "content/browser/web_contents/navigation_entry_impl.h" |
39 #include "content/browser/webui/web_ui_impl.h" | 39 #include "content/browser/webui/web_ui_impl.h" |
40 #include "content/common/browser_plugin_messages.h" | 40 #include "content/common/browser_plugin_messages.h" |
41 #include "content/common/icon_messages.h" | |
41 #include "content/common/intents_messages.h" | 42 #include "content/common/intents_messages.h" |
42 #include "content/common/ssl_status_serialization.h" | 43 #include "content/common/ssl_status_serialization.h" |
43 #include "content/common/view_messages.h" | 44 #include "content/common/view_messages.h" |
44 #include "content/port/browser/render_view_host_delegate_view.h" | 45 #include "content/port/browser/render_view_host_delegate_view.h" |
45 #include "content/port/browser/render_widget_host_view_port.h" | 46 #include "content/port/browser/render_widget_host_view_port.h" |
46 #include "content/public/browser/browser_context.h" | 47 #include "content/public/browser/browser_context.h" |
47 #include "content/public/browser/color_chooser.h" | 48 #include "content/public/browser/color_chooser.h" |
48 #include "content/public/browser/content_browser_client.h" | 49 #include "content/public/browser/content_browser_client.h" |
49 #include "content/public/browser/devtools_agent_host_registry.h" | 50 #include "content/public/browser/devtools_agent_host_registry.h" |
50 #include "content/public/browser/download_manager.h" | 51 #include "content/public/browser/download_manager.h" |
51 #include "content/public/browser/download_url_parameters.h" | 52 #include "content/public/browser/download_url_parameters.h" |
53 #include "content/public/browser/favicon_download_delegate.h" | |
52 #include "content/public/browser/invalidate_type.h" | 54 #include "content/public/browser/invalidate_type.h" |
53 #include "content/public/browser/javascript_dialogs.h" | 55 #include "content/public/browser/javascript_dialogs.h" |
54 #include "content/public/browser/load_from_memory_cache_details.h" | 56 #include "content/public/browser/load_from_memory_cache_details.h" |
55 #include "content/public/browser/load_notification_details.h" | 57 #include "content/public/browser/load_notification_details.h" |
56 #include "content/public/browser/navigation_details.h" | 58 #include "content/public/browser/navigation_details.h" |
57 #include "content/public/browser/notification_details.h" | 59 #include "content/public/browser/notification_details.h" |
58 #include "content/public/browser/notification_service.h" | 60 #include "content/public/browser/notification_service.h" |
59 #include "content/public/browser/resource_request_details.h" | 61 #include "content/public/browser/resource_request_details.h" |
60 #include "content/public/browser/storage_partition.h" | 62 #include "content/public/browser/storage_partition.h" |
61 #include "content/public/browser/user_metrics.h" | 63 #include "content/public/browser/user_metrics.h" |
62 #include "content/public/browser/web_contents_delegate.h" | 64 #include "content/public/browser/web_contents_delegate.h" |
63 #include "content/public/browser/web_contents_observer.h" | 65 #include "content/public/browser/web_contents_observer.h" |
64 #include "content/public/browser/web_contents_view.h" | 66 #include "content/public/browser/web_contents_view.h" |
65 #include "content/public/browser/web_ui_controller_factory.h" | 67 #include "content/public/browser/web_ui_controller_factory.h" |
66 #include "content/public/common/bindings_policy.h" | 68 #include "content/public/common/bindings_policy.h" |
67 #include "content/public/common/content_constants.h" | 69 #include "content/public/common/content_constants.h" |
68 #include "content/public/common/content_restriction.h" | 70 #include "content/public/common/content_restriction.h" |
69 #include "content/public/common/content_switches.h" | 71 #include "content/public/common/content_switches.h" |
72 #include "content/public/common/favicon_url.h" | |
70 #include "content/public/common/url_constants.h" | 73 #include "content/public/common/url_constants.h" |
71 #include "net/base/mime_util.h" | 74 #include "net/base/mime_util.h" |
72 #include "net/base/net_util.h" | 75 #include "net/base/net_util.h" |
73 #include "net/base/network_change_notifier.h" | 76 #include "net/base/network_change_notifier.h" |
74 #include "net/url_request/url_request_context_getter.h" | 77 #include "net/url_request/url_request_context_getter.h" |
75 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 78 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
76 #include "ui/base/layout.h" | 79 #include "ui/base/layout.h" |
77 #include "ui/base/touch/touch_device_win.h" | 80 #include "ui/base/touch/touch_device_win.h" |
78 #include "ui/base/ui_base_switches.h" | 81 #include "ui/base/ui_base_switches.h" |
79 #include "ui/gfx/display.h" | 82 #include "ui/gfx/display.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
140 namespace { | 143 namespace { |
141 | 144 |
142 // Amount of time we wait between when a key event is received and the renderer | 145 // Amount of time we wait between when a key event is received and the renderer |
143 // is queried for its state and pushed to the NavigationEntry. | 146 // is queried for its state and pushed to the NavigationEntry. |
144 const int kQueryStateDelay = 5000; | 147 const int kQueryStateDelay = 5000; |
145 | 148 |
146 const int kSyncWaitDelay = 40; | 149 const int kSyncWaitDelay = 40; |
147 | 150 |
148 const char kDotGoogleDotCom[] = ".google.com"; | 151 const char kDotGoogleDotCom[] = ".google.com"; |
149 | 152 |
153 static int current_favicon_download_id = 0; | |
jam
2012/11/27 01:16:31
nit: prefix with "g_" to make it clear that this i
Cait (Slow)
2012/11/28 00:11:45
Done.
| |
154 | |
150 #if defined(OS_WIN) | 155 #if defined(OS_WIN) |
151 | 156 |
152 BOOL CALLBACK InvalidateWindow(HWND hwnd, LPARAM lparam) { | 157 BOOL CALLBACK InvalidateWindow(HWND hwnd, LPARAM lparam) { |
153 // Note: erase is required to properly paint some widgets borders. This can | 158 // Note: erase is required to properly paint some widgets borders. This can |
154 // be seen with textfields. | 159 // be seen with textfields. |
155 InvalidateRect(hwnd, NULL, TRUE); | 160 InvalidateRect(hwnd, NULL, TRUE); |
156 return TRUE; | 161 return TRUE; |
157 } | 162 } |
158 #endif | 163 #endif |
159 | 164 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
310 #if defined(OS_WIN) | 315 #if defined(OS_WIN) |
311 message_box_active_(CreateEvent(NULL, TRUE, FALSE, NULL)), | 316 message_box_active_(CreateEvent(NULL, TRUE, FALSE, NULL)), |
312 #endif | 317 #endif |
313 is_showing_before_unload_dialog_(false), | 318 is_showing_before_unload_dialog_(false), |
314 opener_web_ui_type_(WebUI::kNoWebUI), | 319 opener_web_ui_type_(WebUI::kNoWebUI), |
315 closed_by_user_gesture_(false), | 320 closed_by_user_gesture_(false), |
316 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)), | 321 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)), |
317 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), | 322 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), |
318 temporary_zoom_settings_(false), | 323 temporary_zoom_settings_(false), |
319 content_restrictions_(0), | 324 content_restrictions_(0), |
320 color_chooser_(NULL) { | 325 color_chooser_(NULL), |
326 favicon_download_delegate_(NULL) { | |
321 } | 327 } |
322 | 328 |
323 WebContentsImpl::~WebContentsImpl() { | 329 WebContentsImpl::~WebContentsImpl() { |
324 is_being_destroyed_ = true; | 330 is_being_destroyed_ = true; |
325 | 331 |
326 for (std::set<RenderWidgetHostImpl*>::iterator iter = | 332 for (std::set<RenderWidgetHostImpl*>::iterator iter = |
327 created_widgets_.begin(); iter != created_widgets_.end(); ++iter) { | 333 created_widgets_.begin(); iter != created_widgets_.end(); ++iter) { |
328 (*iter)->DetachDelegate(); | 334 (*iter)->DetachDelegate(); |
329 } | 335 } |
330 created_widgets_.clear(); | 336 created_widgets_.clear(); |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
736 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenColorChooser, OnOpenColorChooser) | 742 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenColorChooser, OnOpenColorChooser) |
737 IPC_MESSAGE_HANDLER(ViewHostMsg_EndColorChooser, OnEndColorChooser) | 743 IPC_MESSAGE_HANDLER(ViewHostMsg_EndColorChooser, OnEndColorChooser) |
738 IPC_MESSAGE_HANDLER(ViewHostMsg_SetSelectedColorInColorChooser, | 744 IPC_MESSAGE_HANDLER(ViewHostMsg_SetSelectedColorInColorChooser, |
739 OnSetSelectedColorInColorChooser) | 745 OnSetSelectedColorInColorChooser) |
740 IPC_MESSAGE_HANDLER(ViewHostMsg_PepperPluginHung, OnPepperPluginHung) | 746 IPC_MESSAGE_HANDLER(ViewHostMsg_PepperPluginHung, OnPepperPluginHung) |
741 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend) | 747 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend) |
742 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission, | 748 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission, |
743 OnRequestPpapiBrokerPermission) | 749 OnRequestPpapiBrokerPermission) |
744 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CreateGuest, | 750 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CreateGuest, |
745 OnBrowserPluginCreateGuest) | 751 OnBrowserPluginCreateGuest) |
752 IPC_MESSAGE_HANDLER(IconHostMsg_DidDownloadFavicon, OnDidDownloadFavicon) | |
753 IPC_MESSAGE_HANDLER(IconHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) | |
746 IPC_MESSAGE_UNHANDLED(handled = false) | 754 IPC_MESSAGE_UNHANDLED(handled = false) |
747 IPC_END_MESSAGE_MAP_EX() | 755 IPC_END_MESSAGE_MAP_EX() |
748 message_source_ = NULL; | 756 message_source_ = NULL; |
749 | 757 |
750 if (!message_is_ok) { | 758 if (!message_is_ok) { |
751 RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); | 759 RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); |
752 GetRenderProcessHost()->ReceivedBadMessage(); | 760 GetRenderProcessHost()->ReceivedBadMessage(); |
753 } | 761 } |
754 | 762 |
755 return handled; | 763 return handled; |
(...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1931 GetRoutingID(), color_chooser_id, color)); | 1939 GetRoutingID(), color_chooser_id, color)); |
1932 } | 1940 } |
1933 | 1941 |
1934 void WebContentsImpl::DidEndColorChooser(int color_chooser_id) { | 1942 void WebContentsImpl::DidEndColorChooser(int color_chooser_id) { |
1935 Send(new ViewMsg_DidEndColorChooser(GetRoutingID(), color_chooser_id)); | 1943 Send(new ViewMsg_DidEndColorChooser(GetRoutingID(), color_chooser_id)); |
1936 if (delegate_) | 1944 if (delegate_) |
1937 delegate_->DidEndColorChooser(); | 1945 delegate_->DidEndColorChooser(); |
1938 color_chooser_ = NULL; | 1946 color_chooser_ = NULL; |
1939 } | 1947 } |
1940 | 1948 |
1949 int WebContentsImpl::DownloadFavicon(const GURL& url, int image_size) { | |
1950 RenderViewHost* host = GetRenderViewHost(); | |
1951 int id = ++current_favicon_download_id; | |
1952 host->Send(new IconMsg_DownloadFavicon(host->GetRoutingID(), id, url, | |
1953 image_size)); | |
1954 DownloadIdList::iterator i = | |
1955 std::find(favicon_download_ids_.begin(), favicon_download_ids_.end(), id); | |
1956 DCHECK(i == favicon_download_ids_.end()); | |
jam
2012/11/27 01:16:31
this check seems unnecessary given that you have a
Cait (Slow)
2012/11/28 00:11:45
Done.
| |
1957 favicon_download_ids_.insert(id); | |
1958 return id; | |
1959 } | |
1960 | |
1961 void WebContentsImpl::RegisterFaviconDelegate( | |
1962 FaviconDownloadDelegate* delegate) { | |
1963 favicon_download_delegate_ = delegate; | |
1964 } | |
1965 | |
1941 bool WebContentsImpl::FocusLocationBarByDefault() { | 1966 bool WebContentsImpl::FocusLocationBarByDefault() { |
1942 WebUI* web_ui = GetWebUIForCurrentState(); | 1967 WebUI* web_ui = GetWebUIForCurrentState(); |
1943 if (web_ui) | 1968 if (web_ui) |
1944 return web_ui->ShouldFocusLocationBarByDefault(); | 1969 return web_ui->ShouldFocusLocationBarByDefault(); |
1945 NavigationEntry* entry = controller_.GetActiveEntry(); | 1970 NavigationEntry* entry = controller_.GetActiveEntry(); |
1946 return (entry && entry->GetURL() == GURL(chrome::kAboutBlankURL)); | 1971 return (entry && entry->GetURL() == GURL(chrome::kAboutBlankURL)); |
1947 } | 1972 } |
1948 | 1973 |
1949 void WebContentsImpl::SetFocusToLocationBar(bool select_all) { | 1974 void WebContentsImpl::SetFocusToLocationBar(bool select_all) { |
1950 if (delegate_) | 1975 if (delegate_) |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2354 // BrowserPluginEmbedder. Thus, this code will not be executed if a | 2379 // BrowserPluginEmbedder. Thus, this code will not be executed if a |
2355 // BrowserPluginEmbedder exists for this WebContents. | 2380 // BrowserPluginEmbedder exists for this WebContents. |
2356 CHECK(!browser_plugin_embedder_.get()); | 2381 CHECK(!browser_plugin_embedder_.get()); |
2357 browser_plugin_embedder_.reset( | 2382 browser_plugin_embedder_.reset( |
2358 BrowserPluginEmbedder::Create(this, GetRenderViewHost())); | 2383 BrowserPluginEmbedder::Create(this, GetRenderViewHost())); |
2359 browser_plugin_embedder_->CreateGuest(GetRenderViewHost(), | 2384 browser_plugin_embedder_->CreateGuest(GetRenderViewHost(), |
2360 instance_id, | 2385 instance_id, |
2361 params); | 2386 params); |
2362 } | 2387 } |
2363 | 2388 |
2389 void WebContentsImpl::OnDidDownloadFavicon( | |
2390 int id, | |
2391 const GURL& image_url, | |
2392 bool errored, | |
2393 int requested_size, | |
2394 const std::vector<SkBitmap>& bitmaps) { | |
2395 DownloadIdList::iterator i = | |
2396 std::find(favicon_download_ids_.begin(), favicon_download_ids_.end(), id); | |
2397 if (i == favicon_download_ids_.end()) { | |
2398 // Currently WebContents notifies us of ANY downloads so that it is | |
jam
2012/11/27 01:16:31
I'm not sure I understand this comment. This is an
Cait (Slow)
2012/11/28 00:11:45
Done.
| |
2399 // possible to get here. | |
2400 return; | |
2401 } | |
2402 if (favicon_download_delegate_) { | |
2403 favicon_download_delegate_->DidDownloadFavicon( | |
2404 id, image_url, errored, requested_size, bitmaps); | |
2405 } | |
2406 favicon_download_ids_.erase(i); | |
2407 | |
2408 } | |
2409 | |
2410 void WebContentsImpl::OnUpdateFaviconURL( | |
2411 int32 page_id, | |
2412 const std::vector<FaviconURL>& candidates) { | |
2413 if (favicon_download_delegate_) | |
2414 favicon_download_delegate_->UpdateFaviconURL(page_id, candidates); | |
2415 } | |
2416 | |
2364 void WebContentsImpl::DidBlock3DAPIs(const GURL& url, | 2417 void WebContentsImpl::DidBlock3DAPIs(const GURL& url, |
2365 ThreeDAPIType requester) { | 2418 ThreeDAPIType requester) { |
2366 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2419 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
2367 DidBlock3DAPIs(url, requester)); | 2420 DidBlock3DAPIs(url, requester)); |
2368 } | 2421 } |
2369 | 2422 |
2370 // Notifies the RenderWidgetHost instance about the fact that the page is | 2423 // Notifies the RenderWidgetHost instance about the fact that the page is |
2371 // loading, or done loading and calls the base implementation. | 2424 // loading, or done loading and calls the base implementation. |
2372 void WebContentsImpl::SetIsLoading(bool is_loading, | 2425 void WebContentsImpl::SetIsLoading(bool is_loading, |
2373 LoadNotificationDetails* details) { | 2426 LoadNotificationDetails* details) { |
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3355 | 3408 |
3356 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { | 3409 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { |
3357 return browser_plugin_guest_.get(); | 3410 return browser_plugin_guest_.get(); |
3358 } | 3411 } |
3359 | 3412 |
3360 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { | 3413 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { |
3361 return browser_plugin_embedder_.get(); | 3414 return browser_plugin_embedder_.get(); |
3362 } | 3415 } |
3363 | 3416 |
3364 } // namespace content | 3417 } // namespace content |
OLD | NEW |