| 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 1758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1769 // Create the save package and possibly prompt the user for the name to save | 1769 // Create the save package and possibly prompt the user for the name to save |
| 1770 // the page as. The user prompt is an asynchronous operation that runs on | 1770 // the page as. The user prompt is an asynchronous operation that runs on |
| 1771 // another thread. | 1771 // another thread. |
| 1772 save_package_ = new SavePackage(this); | 1772 save_package_ = new SavePackage(this); |
| 1773 save_package_->GetSaveInfo(); | 1773 save_package_->GetSaveInfo(); |
| 1774 } | 1774 } |
| 1775 | 1775 |
| 1776 // Used in automated testing to bypass prompting the user for file names. | 1776 // Used in automated testing to bypass prompting the user for file names. |
| 1777 // Instead, the names and paths are hard coded rather than running them through | 1777 // Instead, the names and paths are hard coded rather than running them through |
| 1778 // file name sanitation and extension / mime checking. | 1778 // file name sanitation and extension / mime checking. |
| 1779 bool WebContentsImpl::SavePage(const FilePath& main_file, | 1779 bool WebContentsImpl::SavePage(const base::FilePath& main_file, |
| 1780 const FilePath& dir_path, | 1780 const base::FilePath& dir_path, |
| 1781 SavePageType save_type) { | 1781 SavePageType save_type) { |
| 1782 // Stop the page from navigating. | 1782 // Stop the page from navigating. |
| 1783 Stop(); | 1783 Stop(); |
| 1784 | 1784 |
| 1785 save_package_ = new SavePackage(this, save_type, main_file, dir_path); | 1785 save_package_ = new SavePackage(this, save_type, main_file, dir_path); |
| 1786 return save_package_->Init(SavePackageDownloadCreatedCallback()); | 1786 return save_package_->Init(SavePackageDownloadCreatedCallback()); |
| 1787 } | 1787 } |
| 1788 | 1788 |
| 1789 void WebContentsImpl::GenerateMHTML( | 1789 void WebContentsImpl::GenerateMHTML( |
| 1790 const FilePath& file, | 1790 const base::FilePath& file, |
| 1791 const base::Callback<void(const FilePath&, int64)>& callback) { | 1791 const base::Callback<void(const base::FilePath&, int64)>& callback) { |
| 1792 MHTMLGenerationManager::GetInstance()->GenerateMHTML(this, file, callback); | 1792 MHTMLGenerationManager::GetInstance()->GenerateMHTML(this, file, callback); |
| 1793 } | 1793 } |
| 1794 | 1794 |
| 1795 bool WebContentsImpl::IsActiveEntry(int32 page_id) { | 1795 bool WebContentsImpl::IsActiveEntry(int32 page_id) { |
| 1796 NavigationEntryImpl* active_entry = | 1796 NavigationEntryImpl* active_entry = |
| 1797 NavigationEntryImpl::FromNavigationEntry(controller_.GetActiveEntry()); | 1797 NavigationEntryImpl::FromNavigationEntry(controller_.GetActiveEntry()); |
| 1798 return (active_entry != NULL && | 1798 return (active_entry != NULL && |
| 1799 active_entry->site_instance() == GetSiteInstance() && | 1799 active_entry->site_instance() == GetSiteInstance() && |
| 1800 active_entry->GetPageID() == page_id); | 1800 active_entry->GetPageID() == page_id); |
| 1801 } | 1801 } |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2285 // message originates from Pepper plugins, it may not be the case if the | 2285 // message originates from Pepper plugins, it may not be the case if the |
| 2286 // plugin is an embedded element. | 2286 // plugin is an embedded element. |
| 2287 GURL main_frame_url = GetURL(); | 2287 GURL main_frame_url = GetURL(); |
| 2288 if (!main_frame_url.is_valid()) | 2288 if (!main_frame_url.is_valid()) |
| 2289 return; | 2289 return; |
| 2290 bool is_main_frame = (url == main_frame_url); | 2290 bool is_main_frame = (url == main_frame_url); |
| 2291 SaveURL(url, referrer, is_main_frame); | 2291 SaveURL(url, referrer, is_main_frame); |
| 2292 } | 2292 } |
| 2293 | 2293 |
| 2294 void WebContentsImpl::OnEnumerateDirectory(int request_id, | 2294 void WebContentsImpl::OnEnumerateDirectory(int request_id, |
| 2295 const FilePath& path) { | 2295 const base::FilePath& path) { |
| 2296 if (!delegate_) | 2296 if (!delegate_) |
| 2297 return; | 2297 return; |
| 2298 | 2298 |
| 2299 ChildProcessSecurityPolicyImpl* policy = | 2299 ChildProcessSecurityPolicyImpl* policy = |
| 2300 ChildProcessSecurityPolicyImpl::GetInstance(); | 2300 ChildProcessSecurityPolicyImpl::GetInstance(); |
| 2301 if (policy->CanReadDirectory(GetRenderProcessHost()->GetID(), path)) | 2301 if (policy->CanReadDirectory(GetRenderProcessHost()->GetID(), path)) |
| 2302 delegate_->EnumerateDirectory(this, request_id, path); | 2302 delegate_->EnumerateDirectory(this, request_id, path); |
| 2303 } | 2303 } |
| 2304 | 2304 |
| 2305 void WebContentsImpl::OnJSOutOfMemory() { | 2305 void WebContentsImpl::OnJSOutOfMemory() { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2341 delegate_->FindMatchRectsReply(this, version, rects, active_rect); | 2341 delegate_->FindMatchRectsReply(this, version, rects, active_rect); |
| 2342 } | 2342 } |
| 2343 | 2343 |
| 2344 void WebContentsImpl::OnOpenDateTimeDialog(int type, const std::string& value) { | 2344 void WebContentsImpl::OnOpenDateTimeDialog(int type, const std::string& value) { |
| 2345 date_time_chooser_->ShowDialog( | 2345 date_time_chooser_->ShowDialog( |
| 2346 GetContentNativeView(), GetRenderViewHost(), type, value); | 2346 GetContentNativeView(), GetRenderViewHost(), type, value); |
| 2347 } | 2347 } |
| 2348 | 2348 |
| 2349 #endif | 2349 #endif |
| 2350 | 2350 |
| 2351 void WebContentsImpl::OnCrashedPlugin(const FilePath& plugin_path, | 2351 void WebContentsImpl::OnCrashedPlugin(const base::FilePath& plugin_path, |
| 2352 base::ProcessId plugin_pid) { | 2352 base::ProcessId plugin_pid) { |
| 2353 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2353 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2354 PluginCrashed(plugin_path, plugin_pid)); | 2354 PluginCrashed(plugin_path, plugin_pid)); |
| 2355 } | 2355 } |
| 2356 | 2356 |
| 2357 void WebContentsImpl::OnAppCacheAccessed(const GURL& manifest_url, | 2357 void WebContentsImpl::OnAppCacheAccessed(const GURL& manifest_url, |
| 2358 bool blocked_by_policy) { | 2358 bool blocked_by_policy) { |
| 2359 // Notify observers about navigation. | 2359 // Notify observers about navigation. |
| 2360 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2360 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2361 AppCacheAccessed(manifest_url, blocked_by_policy)); | 2361 AppCacheAccessed(manifest_url, blocked_by_policy)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2374 } | 2374 } |
| 2375 | 2375 |
| 2376 void WebContentsImpl::OnSetSelectedColorInColorChooser(int color_chooser_id, | 2376 void WebContentsImpl::OnSetSelectedColorInColorChooser(int color_chooser_id, |
| 2377 SkColor color) { | 2377 SkColor color) { |
| 2378 if (color_chooser_ && | 2378 if (color_chooser_ && |
| 2379 color_chooser_id == color_chooser_->identifier()) | 2379 color_chooser_id == color_chooser_->identifier()) |
| 2380 color_chooser_->SetSelectedColor(color); | 2380 color_chooser_->SetSelectedColor(color); |
| 2381 } | 2381 } |
| 2382 | 2382 |
| 2383 void WebContentsImpl::OnPepperPluginHung(int plugin_child_id, | 2383 void WebContentsImpl::OnPepperPluginHung(int plugin_child_id, |
| 2384 const FilePath& path, | 2384 const base::FilePath& path, |
| 2385 bool is_hung) { | 2385 bool is_hung) { |
| 2386 UMA_HISTOGRAM_COUNTS("Pepper.PluginHung", 1); | 2386 UMA_HISTOGRAM_COUNTS("Pepper.PluginHung", 1); |
| 2387 | 2387 |
| 2388 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2388 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2389 PluginHungStatusChanged(plugin_child_id, path, is_hung)); | 2389 PluginHungStatusChanged(plugin_child_id, path, is_hung)); |
| 2390 } | 2390 } |
| 2391 | 2391 |
| 2392 // This exists for render views that don't have a WebUI, but do have WebUI | 2392 // This exists for render views that don't have a WebUI, but do have WebUI |
| 2393 // bindings enabled. | 2393 // bindings enabled. |
| 2394 void WebContentsImpl::OnWebUISend(const GURL& source_url, | 2394 void WebContentsImpl::OnWebUISend(const GURL& source_url, |
| 2395 const std::string& name, | 2395 const std::string& name, |
| 2396 const base::ListValue& args) { | 2396 const base::ListValue& args) { |
| 2397 if (delegate_) | 2397 if (delegate_) |
| 2398 delegate_->WebUISend(this, source_url, name, args); | 2398 delegate_->WebUISend(this, source_url, name, args); |
| 2399 } | 2399 } |
| 2400 | 2400 |
| 2401 void WebContentsImpl::OnRequestPpapiBrokerPermission( | 2401 void WebContentsImpl::OnRequestPpapiBrokerPermission( |
| 2402 int request_id, | 2402 int request_id, |
| 2403 const GURL& url, | 2403 const GURL& url, |
| 2404 const FilePath& plugin_path) { | 2404 const base::FilePath& plugin_path) { |
| 2405 if (!delegate_) { | 2405 if (!delegate_) { |
| 2406 OnPpapiBrokerPermissionResult(request_id, false); | 2406 OnPpapiBrokerPermissionResult(request_id, false); |
| 2407 return; | 2407 return; |
| 2408 } | 2408 } |
| 2409 | 2409 |
| 2410 if (!delegate_->RequestPpapiBrokerPermission( | 2410 if (!delegate_->RequestPpapiBrokerPermission( |
| 2411 this, url, plugin_path, | 2411 this, url, plugin_path, |
| 2412 base::Bind(&WebContentsImpl::OnPpapiBrokerPermissionResult, | 2412 base::Bind(&WebContentsImpl::OnPpapiBrokerPermissionResult, |
| 2413 base::Unretained(this), request_id))) { | 2413 base::Unretained(this), request_id))) { |
| 2414 NOTIMPLEMENTED(); | 2414 NOTIMPLEMENTED(); |
| (...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3483 | 3483 |
| 3484 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() const { | 3484 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() const { |
| 3485 return browser_plugin_guest_.get(); | 3485 return browser_plugin_guest_.get(); |
| 3486 } | 3486 } |
| 3487 | 3487 |
| 3488 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() const { | 3488 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() const { |
| 3489 return browser_plugin_embedder_.get(); | 3489 return browser_plugin_embedder_.get(); |
| 3490 } | 3490 } |
| 3491 | 3491 |
| 3492 } // namespace content | 3492 } // namespace content |
| OLD | NEW |