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 21 matching lines...) Expand all Loading... | |
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/web_contents/web_contents_view_guest.h" | 39 #include "content/browser/web_contents/web_contents_view_guest.h" |
40 #include "content/browser/webui/web_ui_impl.h" | 40 #include "content/browser/webui/web_ui_impl.h" |
41 #include "content/common/browser_plugin_messages.h" | 41 #include "content/common/browser_plugin_messages.h" |
42 #include "content/common/icon_messages.h" | |
42 #include "content/common/intents_messages.h" | 43 #include "content/common/intents_messages.h" |
43 #include "content/common/ssl_status_serialization.h" | 44 #include "content/common/ssl_status_serialization.h" |
44 #include "content/common/view_messages.h" | 45 #include "content/common/view_messages.h" |
45 #include "content/port/browser/render_view_host_delegate_view.h" | 46 #include "content/port/browser/render_view_host_delegate_view.h" |
46 #include "content/port/browser/render_widget_host_view_port.h" | 47 #include "content/port/browser/render_widget_host_view_port.h" |
47 #include "content/public/browser/browser_context.h" | 48 #include "content/public/browser/browser_context.h" |
48 #include "content/public/browser/color_chooser.h" | 49 #include "content/public/browser/color_chooser.h" |
49 #include "content/public/browser/content_browser_client.h" | 50 #include "content/public/browser/content_browser_client.h" |
50 #include "content/public/browser/devtools_agent_host_registry.h" | 51 #include "content/public/browser/devtools_agent_host_registry.h" |
51 #include "content/public/browser/download_manager.h" | 52 #include "content/public/browser/download_manager.h" |
52 #include "content/public/browser/download_url_parameters.h" | 53 #include "content/public/browser/download_url_parameters.h" |
53 #include "content/public/browser/invalidate_type.h" | 54 #include "content/public/browser/invalidate_type.h" |
54 #include "content/public/browser/javascript_dialogs.h" | 55 #include "content/public/browser/javascript_dialogs.h" |
55 #include "content/public/browser/load_from_memory_cache_details.h" | 56 #include "content/public/browser/load_from_memory_cache_details.h" |
56 #include "content/public/browser/load_notification_details.h" | 57 #include "content/public/browser/load_notification_details.h" |
57 #include "content/public/browser/navigation_details.h" | 58 #include "content/public/browser/navigation_details.h" |
58 #include "content/public/browser/notification_details.h" | 59 #include "content/public/browser/notification_details.h" |
59 #include "content/public/browser/notification_service.h" | 60 #include "content/public/browser/notification_service.h" |
60 #include "content/public/browser/resource_request_details.h" | 61 #include "content/public/browser/resource_request_details.h" |
61 #include "content/public/browser/storage_partition.h" | 62 #include "content/public/browser/storage_partition.h" |
62 #include "content/public/browser/user_metrics.h" | 63 #include "content/public/browser/user_metrics.h" |
63 #include "content/public/browser/web_contents_delegate.h" | 64 #include "content/public/browser/web_contents_delegate.h" |
64 #include "content/public/browser/web_contents_observer.h" | 65 #include "content/public/browser/web_contents_observer.h" |
65 #include "content/public/browser/web_contents_view.h" | 66 #include "content/public/browser/web_contents_view.h" |
66 #include "content/public/browser/web_ui_controller_factory.h" | 67 #include "content/public/browser/web_ui_controller_factory.h" |
67 #include "content/public/common/bindings_policy.h" | 68 #include "content/public/common/bindings_policy.h" |
68 #include "content/public/common/content_constants.h" | 69 #include "content/public/common/content_constants.h" |
69 #include "content/public/common/content_restriction.h" | 70 #include "content/public/common/content_restriction.h" |
70 #include "content/public/common/content_switches.h" | 71 #include "content/public/common/content_switches.h" |
72 #include "content/public/common/favicon_url.h" | |
jam
2012/12/03 21:59:39
nit: redundant since by definition icon_messages.h
Cait (Slow)
2012/12/04 20:57:35
Done.
| |
71 #include "content/public/common/url_constants.h" | 73 #include "content/public/common/url_constants.h" |
72 #include "net/base/mime_util.h" | 74 #include "net/base/mime_util.h" |
73 #include "net/base/net_util.h" | 75 #include "net/base/net_util.h" |
74 #include "net/base/network_change_notifier.h" | 76 #include "net/base/network_change_notifier.h" |
75 #include "net/url_request/url_request_context_getter.h" | 77 #include "net/url_request/url_request_context_getter.h" |
76 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 78 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
77 #include "ui/base/layout.h" | 79 #include "ui/base/layout.h" |
78 #include "ui/base/touch/touch_device_win.h" | 80 #include "ui/base/touch/touch_device_win.h" |
79 #include "ui/base/ui_base_switches.h" | 81 #include "ui/base/ui_base_switches.h" |
80 #include "ui/gfx/display.h" | 82 #include "ui/gfx/display.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 namespace { | 143 namespace { |
142 | 144 |
143 // 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 |
144 // is queried for its state and pushed to the NavigationEntry. | 146 // is queried for its state and pushed to the NavigationEntry. |
145 const int kQueryStateDelay = 5000; | 147 const int kQueryStateDelay = 5000; |
146 | 148 |
147 const int kSyncWaitDelay = 40; | 149 const int kSyncWaitDelay = 40; |
148 | 150 |
149 const char kDotGoogleDotCom[] = ".google.com"; | 151 const char kDotGoogleDotCom[] = ".google.com"; |
150 | 152 |
153 static int StartDownload(content::RenderViewHost* rvh, | |
154 const GURL& url, | |
155 int image_size) { | |
156 static int g_next_favicon_download_id = 0; | |
157 rvh->Send(new IconMsg_DownloadFavicon(rvh->GetRoutingID(), | |
158 ++g_next_favicon_download_id, | |
159 url, | |
160 image_size)); | |
161 return g_next_favicon_download_id; | |
162 } | |
163 | |
151 #if defined(OS_WIN) | 164 #if defined(OS_WIN) |
152 | 165 |
153 BOOL CALLBACK InvalidateWindow(HWND hwnd, LPARAM lparam) { | 166 BOOL CALLBACK InvalidateWindow(HWND hwnd, LPARAM lparam) { |
154 // Note: erase is required to properly paint some widgets borders. This can | 167 // Note: erase is required to properly paint some widgets borders. This can |
155 // be seen with textfields. | 168 // be seen with textfields. |
156 InvalidateRect(hwnd, NULL, TRUE); | 169 InvalidateRect(hwnd, NULL, TRUE); |
157 return TRUE; | 170 return TRUE; |
158 } | 171 } |
159 #endif | 172 #endif |
160 | 173 |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
739 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenColorChooser, OnOpenColorChooser) | 752 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenColorChooser, OnOpenColorChooser) |
740 IPC_MESSAGE_HANDLER(ViewHostMsg_EndColorChooser, OnEndColorChooser) | 753 IPC_MESSAGE_HANDLER(ViewHostMsg_EndColorChooser, OnEndColorChooser) |
741 IPC_MESSAGE_HANDLER(ViewHostMsg_SetSelectedColorInColorChooser, | 754 IPC_MESSAGE_HANDLER(ViewHostMsg_SetSelectedColorInColorChooser, |
742 OnSetSelectedColorInColorChooser) | 755 OnSetSelectedColorInColorChooser) |
743 IPC_MESSAGE_HANDLER(ViewHostMsg_PepperPluginHung, OnPepperPluginHung) | 756 IPC_MESSAGE_HANDLER(ViewHostMsg_PepperPluginHung, OnPepperPluginHung) |
744 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend) | 757 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend) |
745 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission, | 758 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission, |
746 OnRequestPpapiBrokerPermission) | 759 OnRequestPpapiBrokerPermission) |
747 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CreateGuest, | 760 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CreateGuest, |
748 OnBrowserPluginCreateGuest) | 761 OnBrowserPluginCreateGuest) |
762 IPC_MESSAGE_HANDLER(IconHostMsg_DidDownloadFavicon, OnDidDownloadFavicon) | |
763 IPC_MESSAGE_HANDLER(IconHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) | |
749 IPC_MESSAGE_UNHANDLED(handled = false) | 764 IPC_MESSAGE_UNHANDLED(handled = false) |
750 IPC_END_MESSAGE_MAP_EX() | 765 IPC_END_MESSAGE_MAP_EX() |
751 message_source_ = NULL; | 766 message_source_ = NULL; |
752 | 767 |
753 if (!message_is_ok) { | 768 if (!message_is_ok) { |
754 RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); | 769 RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); |
755 GetRenderProcessHost()->ReceivedBadMessage(); | 770 GetRenderProcessHost()->ReceivedBadMessage(); |
756 } | 771 } |
757 | 772 |
758 return handled; | 773 return handled; |
(...skipping 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1943 GetRoutingID(), color_chooser_id, color)); | 1958 GetRoutingID(), color_chooser_id, color)); |
1944 } | 1959 } |
1945 | 1960 |
1946 void WebContentsImpl::DidEndColorChooser(int color_chooser_id) { | 1961 void WebContentsImpl::DidEndColorChooser(int color_chooser_id) { |
1947 Send(new ViewMsg_DidEndColorChooser(GetRoutingID(), color_chooser_id)); | 1962 Send(new ViewMsg_DidEndColorChooser(GetRoutingID(), color_chooser_id)); |
1948 if (delegate_) | 1963 if (delegate_) |
1949 delegate_->DidEndColorChooser(); | 1964 delegate_->DidEndColorChooser(); |
1950 color_chooser_ = NULL; | 1965 color_chooser_ = NULL; |
1951 } | 1966 } |
1952 | 1967 |
1968 int WebContentsImpl::DownloadFavicon(const GURL& url, int image_size, | |
1969 const FaviconDownloadCallback& callback) { | |
1970 RenderViewHost* host = GetRenderViewHost(); | |
1971 int id = StartDownload(host, url, image_size); | |
1972 favicon_download_map_[id] = callback; | |
1973 return id; | |
1974 } | |
1975 | |
1953 bool WebContentsImpl::FocusLocationBarByDefault() { | 1976 bool WebContentsImpl::FocusLocationBarByDefault() { |
1954 WebUI* web_ui = GetWebUIForCurrentState(); | 1977 WebUI* web_ui = GetWebUIForCurrentState(); |
1955 if (web_ui) | 1978 if (web_ui) |
1956 return web_ui->ShouldFocusLocationBarByDefault(); | 1979 return web_ui->ShouldFocusLocationBarByDefault(); |
1957 NavigationEntry* entry = controller_.GetActiveEntry(); | 1980 NavigationEntry* entry = controller_.GetActiveEntry(); |
1958 return (entry && entry->GetURL() == GURL(chrome::kAboutBlankURL)); | 1981 return (entry && entry->GetURL() == GURL(chrome::kAboutBlankURL)); |
1959 } | 1982 } |
1960 | 1983 |
1961 void WebContentsImpl::SetFocusToLocationBar(bool select_all) { | 1984 void WebContentsImpl::SetFocusToLocationBar(bool select_all) { |
1962 if (delegate_) | 1985 if (delegate_) |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2358 // BrowserPluginEmbedder. Thus, this code will not be executed if a | 2381 // BrowserPluginEmbedder. Thus, this code will not be executed if a |
2359 // BrowserPluginEmbedder exists for this WebContents. | 2382 // BrowserPluginEmbedder exists for this WebContents. |
2360 CHECK(!browser_plugin_embedder_.get()); | 2383 CHECK(!browser_plugin_embedder_.get()); |
2361 browser_plugin_embedder_.reset( | 2384 browser_plugin_embedder_.reset( |
2362 BrowserPluginEmbedder::Create(this, GetRenderViewHost())); | 2385 BrowserPluginEmbedder::Create(this, GetRenderViewHost())); |
2363 browser_plugin_embedder_->CreateGuest(GetRenderViewHost(), | 2386 browser_plugin_embedder_->CreateGuest(GetRenderViewHost(), |
2364 instance_id, | 2387 instance_id, |
2365 params); | 2388 params); |
2366 } | 2389 } |
2367 | 2390 |
2391 void WebContentsImpl::OnDidDownloadFavicon( | |
2392 int id, | |
2393 const GURL& image_url, | |
2394 bool errored, | |
2395 int requested_size, | |
2396 const std::vector<SkBitmap>& bitmaps) { | |
2397 FaviconDownloadMap::iterator iter = favicon_download_map_.find(id); | |
2398 if (iter == favicon_download_map_.end()) { | |
2399 // Currently WebContents notifies us of ANY downloads so that it is | |
2400 // possible to get here. | |
2401 return; | |
2402 } | |
2403 if (!iter->second.is_null()) { | |
2404 iter->second.Run(id, image_url, errored, requested_size, bitmaps); | |
2405 } | |
2406 favicon_download_map_.erase(id); | |
2407 } | |
2408 | |
2409 void WebContentsImpl::OnUpdateFaviconURL( | |
2410 int32 page_id, | |
2411 const std::vector<FaviconURL>& candidates) { | |
2412 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | |
2413 DidUpdateFaviconURL(page_id, candidates)); | |
2414 } | |
2415 | |
2368 void WebContentsImpl::DidBlock3DAPIs(const GURL& url, | 2416 void WebContentsImpl::DidBlock3DAPIs(const GURL& url, |
2369 ThreeDAPIType requester) { | 2417 ThreeDAPIType requester) { |
2370 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2418 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
2371 DidBlock3DAPIs(url, requester)); | 2419 DidBlock3DAPIs(url, requester)); |
2372 } | 2420 } |
2373 | 2421 |
2374 // Notifies the RenderWidgetHost instance about the fact that the page is | 2422 // Notifies the RenderWidgetHost instance about the fact that the page is |
2375 // loading, or done loading and calls the base implementation. | 2423 // loading, or done loading and calls the base implementation. |
2376 void WebContentsImpl::SetIsLoading(bool is_loading, | 2424 void WebContentsImpl::SetIsLoading(bool is_loading, |
2377 LoadNotificationDetails* details) { | 2425 LoadNotificationDetails* details) { |
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3359 | 3407 |
3360 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { | 3408 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { |
3361 return browser_plugin_guest_.get(); | 3409 return browser_plugin_guest_.get(); |
3362 } | 3410 } |
3363 | 3411 |
3364 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { | 3412 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { |
3365 return browser_plugin_embedder_.get(); | 3413 return browser_plugin_embedder_.get(); |
3366 } | 3414 } |
3367 | 3415 |
3368 } // namespace content | 3416 } // namespace content |
OLD | NEW |