| OLD | NEW | 
|     1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |     1 // Copyright (c) 2011 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/tab_contents/tab_contents.h" |     5 #include "content/browser/tab_contents/tab_contents.h" | 
|     6  |     6  | 
|     7 #include <cmath> |     7 #include <cmath> | 
|     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" | 
|    11 #include "base/metrics/stats_counters.h" |    11 #include "base/metrics/stats_counters.h" | 
|    12 #include "base/string16.h" |    12 #include "base/string16.h" | 
|    13 #include "base/string_util.h" |    13 #include "base/string_util.h" | 
|    14 #include "base/time.h" |    14 #include "base/time.h" | 
|    15 #include "base/utf_string_conversions.h" |    15 #include "base/utf_string_conversions.h" | 
 |    16 #include "chrome/browser/browser_process.h" | 
|    16 #include "chrome/browser/browser_shutdown.h" |    17 #include "chrome/browser/browser_shutdown.h" | 
|    17 #include "chrome/browser/debugger/devtools_manager.h" |    18 #include "chrome/browser/debugger/devtools_manager.h" | 
|    18 #include "chrome/browser/defaults.h" |    19 #include "chrome/browser/defaults.h" | 
 |    20 #include "chrome/browser/download/download_request_limiter.h" | 
|    19 #include "chrome/browser/external_protocol_handler.h" |    21 #include "chrome/browser/external_protocol_handler.h" | 
|    20 #include "chrome/browser/history/history.h" |    22 #include "chrome/browser/history/history.h" | 
|    21 #include "chrome/browser/load_from_memory_cache_details.h" |    23 #include "chrome/browser/load_from_memory_cache_details.h" | 
|    22 #include "chrome/browser/load_notification_details.h" |    24 #include "chrome/browser/load_notification_details.h" | 
|    23 #include "chrome/browser/notifications/desktop_notification_service.h" |    25 #include "chrome/browser/notifications/desktop_notification_service.h" | 
|    24 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |    26 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 
|    25 #include "chrome/browser/platform_util.h" |    27 #include "chrome/browser/platform_util.h" | 
|    26 #include "chrome/browser/plugin_observer.h" |    28 #include "chrome/browser/plugin_observer.h" | 
|    27 #include "chrome/browser/prefs/pref_service.h" |    29 #include "chrome/browser/prefs/pref_service.h" | 
|    28 #include "chrome/browser/profiles/profile.h" |    30 #include "chrome/browser/profiles/profile.h" | 
| (...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   847  |   849  | 
|   848   // When it's the first load, we know either the pending one or the committed |   850   // When it's the first load, we know either the pending one or the committed | 
|   849   // one will have the Web UI in it (see GetWebUIForCurrentState), and only one |   851   // one will have the Web UI in it (see GetWebUIForCurrentState), and only one | 
|   850   // of them will be valid, so we can just check both. |   852   // of them will be valid, so we can just check both. | 
|   851   if (render_manager_.pending_web_ui()) |   853   if (render_manager_.pending_web_ui()) | 
|   852     return render_manager_.pending_web_ui()->force_bookmark_bar_visible(); |   854     return render_manager_.pending_web_ui()->force_bookmark_bar_visible(); | 
|   853   return (render_manager_.web_ui() == NULL) ? |   855   return (render_manager_.web_ui() == NULL) ? | 
|   854       false : render_manager_.web_ui()->force_bookmark_bar_visible(); |   856       false : render_manager_.web_ui()->force_bookmark_bar_visible(); | 
|   855 } |   857 } | 
|   856  |   858  | 
 |   859 bool TabContents::CanDownload(int request_id) { | 
 |   860   TabContentsDelegate* d = delegate(); | 
 |   861   if (d) | 
 |   862     return d->CanDownload(request_id); | 
 |   863   return true; | 
 |   864 } | 
 |   865  | 
 |   866 void TabContents::OnStartDownload(DownloadItem* download) { | 
 |   867   DCHECK(download); | 
 |   868  | 
 |   869   if (!delegate()) | 
 |   870     return; | 
 |   871  | 
 |   872   // Download in a constrained popup is shown in the tab that opened it. | 
 |   873   TabContents* tab_contents = delegate()->GetConstrainingContents(this); | 
 |   874  | 
 |   875   if (tab_contents && tab_contents->delegate()) | 
 |   876     tab_contents->delegate()->OnStartDownload(download, this); | 
 |   877 } | 
 |   878  | 
|   857 void TabContents::WillClose(ConstrainedWindow* window) { |   879 void TabContents::WillClose(ConstrainedWindow* window) { | 
|   858   ConstrainedWindowList::iterator i( |   880   ConstrainedWindowList::iterator i( | 
|   859       std::find(child_windows_.begin(), child_windows_.end(), window)); |   881       std::find(child_windows_.begin(), child_windows_.end(), window)); | 
|   860   bool removed_topmost_window = i == child_windows_.begin(); |   882   bool removed_topmost_window = i == child_windows_.begin(); | 
|   861   if (i != child_windows_.end()) |   883   if (i != child_windows_.end()) | 
|   862     child_windows_.erase(i); |   884     child_windows_.erase(i); | 
|   863   if (child_windows_.empty()) { |   885   if (child_windows_.empty()) { | 
|   864     BlockTabContent(false); |   886     BlockTabContent(false); | 
|   865   } else { |   887   } else { | 
|   866     if (removed_topmost_window) |   888     if (removed_topmost_window) | 
| (...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1925   // Disable accelerated compositing if IOSurface's are not supported, |  1947   // Disable accelerated compositing if IOSurface's are not supported, | 
|  1926   // as is the case in 10.5. |  1948   // as is the case in 10.5. | 
|  1927   if (!IOSurfaceSupport::Initialize()) |  1949   if (!IOSurfaceSupport::Initialize()) | 
|  1928       web_prefs.accelerated_compositing_enabled = false; |  1950       web_prefs.accelerated_compositing_enabled = false; | 
|  1929 #endif |  1951 #endif | 
|  1930  |  1952  | 
|  1931   return web_prefs; |  1953   return web_prefs; | 
|  1932 } |  1954 } | 
|  1933  |  1955  | 
|  1934 void TabContents::OnUserGesture() { |  1956 void TabContents::OnUserGesture() { | 
|  1935   // Notify observers. |  1957   // See comment in RenderViewHostDelegate::OnUserGesture as to why we do this. | 
|  1936   FOR_EACH_OBSERVER(TabContentsObserver, observers_, DidGetUserGesture()); |  1958   DownloadRequestLimiter* limiter = | 
 |  1959       g_browser_process->download_request_limiter(); | 
 |  1960   if (limiter) | 
 |  1961     limiter->OnUserGesture(this); | 
|  1937   ExternalProtocolHandler::PermitLaunchUrl(); |  1962   ExternalProtocolHandler::PermitLaunchUrl(); | 
|  1938 } |  1963 } | 
|  1939  |  1964  | 
|  1940 void TabContents::OnIgnoredUIEvent() { |  1965 void TabContents::OnIgnoredUIEvent() { | 
|  1941   if (constrained_window_count()) { |  1966   if (constrained_window_count()) { | 
|  1942     ConstrainedWindow* window = *constrained_window_begin(); |  1967     ConstrainedWindow* window = *constrained_window_begin(); | 
|  1943     window->FocusConstrainedWindow(); |  1968     window->FocusConstrainedWindow(); | 
|  1944   } |  1969   } | 
|  1945 } |  1970 } | 
|  1946  |  1971  | 
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2201  |  2226  | 
|  2202 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |  2227 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 
|  2203   RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); |  2228   RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); | 
|  2204   rwh_view->SetSize(view()->GetContainerSize()); |  2229   rwh_view->SetSize(view()->GetContainerSize()); | 
|  2205 } |  2230 } | 
|  2206  |  2231  | 
|  2207 void TabContents::OnOnlineStateChanged(bool online) { |  2232 void TabContents::OnOnlineStateChanged(bool online) { | 
|  2208   render_view_host()->Send(new ViewMsg_NetworkStateChanged( |  2233   render_view_host()->Send(new ViewMsg_NetworkStateChanged( | 
|  2209       render_view_host()->routing_id(), online)); |  2234       render_view_host()->routing_id(), online)); | 
|  2210 } |  2235 } | 
| OLD | NEW |