| 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" |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 if (!tab_close_start_time_.is_null()) { | 284 if (!tab_close_start_time_.is_null()) { |
| 285 UMA_HISTOGRAM_TIMES("Tab.Close", | 285 UMA_HISTOGRAM_TIMES("Tab.Close", |
| 286 base::TimeTicks::Now() - tab_close_start_time_); | 286 base::TimeTicks::Now() - tab_close_start_time_); |
| 287 } | 287 } |
| 288 | 288 |
| 289 FOR_EACH_OBSERVER(WebContentsObserver, observers_, TabContentsDestroyed()); | 289 FOR_EACH_OBSERVER(WebContentsObserver, observers_, TabContentsDestroyed()); |
| 290 | 290 |
| 291 SetDelegate(NULL); | 291 SetDelegate(NULL); |
| 292 } | 292 } |
| 293 | 293 |
| 294 NavigationController& TabContents::GetControllerImpl() { |
| 295 return controller_; |
| 296 } |
| 297 |
| 294 bool TabContents::OnMessageReceived(const IPC::Message& message) { | 298 bool TabContents::OnMessageReceived(const IPC::Message& message) { |
| 295 if (GetWebUI() && GetWebUI()->OnMessageReceived(message)) | 299 if (GetWebUI() && GetWebUI()->OnMessageReceived(message)) |
| 296 return true; | 300 return true; |
| 297 | 301 |
| 298 ObserverListBase<WebContentsObserver>::Iterator it(observers_); | 302 ObserverListBase<WebContentsObserver>::Iterator it(observers_); |
| 299 WebContentsObserver* observer; | 303 WebContentsObserver* observer; |
| 300 while ((observer = it.GetNext()) != NULL) | 304 while ((observer = it.GetNext()) != NULL) |
| 301 if (observer->OnMessageReceived(message)) | 305 if (observer->OnMessageReceived(message)) |
| 302 return true; | 306 return true; |
| 303 | 307 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 | 349 |
| 346 return handled; | 350 return handled; |
| 347 } | 351 } |
| 348 | 352 |
| 349 void TabContents::RunFileChooser( | 353 void TabContents::RunFileChooser( |
| 350 RenderViewHost* render_view_host, | 354 RenderViewHost* render_view_host, |
| 351 const content::FileChooserParams& params) { | 355 const content::FileChooserParams& params) { |
| 352 delegate_->RunFileChooser(this, params); | 356 delegate_->RunFileChooser(this, params); |
| 353 } | 357 } |
| 354 | 358 |
| 355 NavigationController& TabContents::GetController() { | 359 content::NavigationController& TabContents::GetController() { |
| 356 return controller_; | 360 return controller_; |
| 357 } | 361 } |
| 358 | 362 |
| 359 const NavigationController& TabContents::GetController() const { | 363 const content::NavigationController& TabContents::GetController() const { |
| 360 return controller_; | 364 return controller_; |
| 361 } | 365 } |
| 362 | 366 |
| 363 content::BrowserContext* TabContents::GetBrowserContext() const { | 367 content::BrowserContext* TabContents::GetBrowserContext() const { |
| 364 return controller_.GetBrowserContext(); | 368 return controller_.GetBrowserContext(); |
| 365 } | 369 } |
| 366 | 370 |
| 367 void TabContents::SetViewType(content::ViewType type) { | 371 void TabContents::SetViewType(content::ViewType type) { |
| 368 view_type_ = type; | 372 view_type_ = type; |
| 369 } | 373 } |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 } | 639 } |
| 636 | 640 |
| 637 TabContents* TabContents::Clone() { | 641 TabContents* TabContents::Clone() { |
| 638 // We create a new SiteInstance so that the new tab won't share processes | 642 // We create a new SiteInstance so that the new tab won't share processes |
| 639 // with the old one. This can be changed in the future if we need it to share | 643 // with the old one. This can be changed in the future if we need it to share |
| 640 // processes for some reason. | 644 // processes for some reason. |
| 641 TabContents* tc = new TabContents( | 645 TabContents* tc = new TabContents( |
| 642 GetBrowserContext(), | 646 GetBrowserContext(), |
| 643 SiteInstance::CreateSiteInstance(GetBrowserContext()), | 647 SiteInstance::CreateSiteInstance(GetBrowserContext()), |
| 644 MSG_ROUTING_NONE, this, NULL); | 648 MSG_ROUTING_NONE, this, NULL); |
| 645 tc->GetController().CopyStateFrom(controller_); | 649 tc->GetControllerImpl().CopyStateFrom(controller_); |
| 646 return tc; | 650 return tc; |
| 647 } | 651 } |
| 648 | 652 |
| 649 void TabContents::ShowPageInfo(const GURL& url, | 653 void TabContents::ShowPageInfo(const GURL& url, |
| 650 const SSLStatus& ssl, | 654 const SSLStatus& ssl, |
| 651 bool show_history) { | 655 bool show_history) { |
| 652 if (!delegate_) | 656 if (!delegate_) |
| 653 return; | 657 return; |
| 654 | 658 |
| 655 delegate_->ShowPageInfo(GetBrowserContext(), url, ssl, show_history); | 659 delegate_->ShowPageInfo(GetBrowserContext(), url, ssl, show_history); |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1276 | 1280 |
| 1277 content::NotificationService::current()->Notify( | 1281 content::NotificationService::current()->Notify( |
| 1278 content::NOTIFICATION_LOAD_FROM_MEMORY_CACHE, | 1282 content::NOTIFICATION_LOAD_FROM_MEMORY_CACHE, |
| 1279 content::Source<content::NavigationController>(&controller_), | 1283 content::Source<content::NavigationController>(&controller_), |
| 1280 content::Details<LoadFromMemoryCacheDetails>(&details)); | 1284 content::Details<LoadFromMemoryCacheDetails>(&details)); |
| 1281 } | 1285 } |
| 1282 | 1286 |
| 1283 void TabContents::OnDidDisplayInsecureContent() { | 1287 void TabContents::OnDidDisplayInsecureContent() { |
| 1284 content::RecordAction(UserMetricsAction("SSL.DisplayedInsecureContent")); | 1288 content::RecordAction(UserMetricsAction("SSL.DisplayedInsecureContent")); |
| 1285 displayed_insecure_content_ = true; | 1289 displayed_insecure_content_ = true; |
| 1286 SSLManager::NotifySSLInternalStateChanged(&GetController()); | 1290 SSLManager::NotifySSLInternalStateChanged(&GetControllerImpl()); |
| 1287 } | 1291 } |
| 1288 | 1292 |
| 1289 void TabContents::OnDidRunInsecureContent( | 1293 void TabContents::OnDidRunInsecureContent( |
| 1290 const std::string& security_origin, const GURL& target_url) { | 1294 const std::string& security_origin, const GURL& target_url) { |
| 1291 LOG(INFO) << security_origin << " ran insecure content from " | 1295 LOG(INFO) << security_origin << " ran insecure content from " |
| 1292 << target_url.possibly_invalid_spec(); | 1296 << target_url.possibly_invalid_spec(); |
| 1293 content::RecordAction(UserMetricsAction("SSL.RanInsecureContent")); | 1297 content::RecordAction(UserMetricsAction("SSL.RanInsecureContent")); |
| 1294 if (EndsWith(security_origin, kDotGoogleDotCom, false)) { | 1298 if (EndsWith(security_origin, kDotGoogleDotCom, false)) { |
| 1295 content::RecordAction( | 1299 content::RecordAction( |
| 1296 UserMetricsAction("SSL.RanInsecureContentGoogle")); | 1300 UserMetricsAction("SSL.RanInsecureContentGoogle")); |
| 1297 } | 1301 } |
| 1298 controller_.GetSSLManager()->DidRunInsecureContent(security_origin); | 1302 controller_.GetSSLManager()->DidRunInsecureContent(security_origin); |
| 1299 displayed_insecure_content_ = true; | 1303 displayed_insecure_content_ = true; |
| 1300 SSLManager::NotifySSLInternalStateChanged(&GetController()); | 1304 SSLManager::NotifySSLInternalStateChanged(&GetControllerImpl()); |
| 1301 } | 1305 } |
| 1302 | 1306 |
| 1303 void TabContents::OnDocumentLoadedInFrame(int64 frame_id) { | 1307 void TabContents::OnDocumentLoadedInFrame(int64 frame_id) { |
| 1304 controller_.DocumentLoadedInFrame(); | 1308 controller_.DocumentLoadedInFrame(); |
| 1305 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1309 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 1306 DocumentLoadedInFrame(frame_id)); | 1310 DocumentLoadedInFrame(frame_id)); |
| 1307 } | 1311 } |
| 1308 | 1312 |
| 1309 void TabContents::OnDidFinishLoad( | 1313 void TabContents::OnDidFinishLoad( |
| 1310 int64 frame_id, | 1314 int64 frame_id, |
| (...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2151 // normal size later so just ignore it. | 2155 // normal size later so just ignore it. |
| 2152 if (!size.IsEmpty()) | 2156 if (!size.IsEmpty()) |
| 2153 view_->SizeContents(size); | 2157 view_->SizeContents(size); |
| 2154 } | 2158 } |
| 2155 | 2159 |
| 2156 void TabContents::NotifySwappedFromRenderManager() { | 2160 void TabContents::NotifySwappedFromRenderManager() { |
| 2157 NotifySwapped(); | 2161 NotifySwapped(); |
| 2158 } | 2162 } |
| 2159 | 2163 |
| 2160 NavigationController& TabContents::GetControllerForRenderManager() { | 2164 NavigationController& TabContents::GetControllerForRenderManager() { |
| 2161 return GetController(); | 2165 return GetControllerImpl(); |
| 2162 } | 2166 } |
| 2163 | 2167 |
| 2164 WebUI* TabContents::CreateWebUIForRenderManager(const GURL& url) { | 2168 WebUI* TabContents::CreateWebUIForRenderManager(const GURL& url) { |
| 2165 return content::WebUIFactory::Get()->CreateWebUIForURL(this, url); | 2169 return content::WebUIFactory::Get()->CreateWebUIForURL(this, url); |
| 2166 } | 2170 } |
| 2167 | 2171 |
| 2168 NavigationEntry* | 2172 NavigationEntry* |
| 2169 TabContents::GetLastCommittedNavigationEntryForRenderManager() { | 2173 TabContents::GetLastCommittedNavigationEntryForRenderManager() { |
| 2170 return controller_.GetLastCommittedEntry(); | 2174 return controller_.GetLastCommittedEntry(); |
| 2171 } | 2175 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2225 encoding_ = content::GetContentClient()->browser()-> | 2229 encoding_ = content::GetContentClient()->browser()-> |
| 2226 GetCanonicalEncodingNameByAliasName(encoding); | 2230 GetCanonicalEncodingNameByAliasName(encoding); |
| 2227 } | 2231 } |
| 2228 | 2232 |
| 2229 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 2233 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
| 2230 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); | 2234 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); |
| 2231 // Can be NULL during tests. | 2235 // Can be NULL during tests. |
| 2232 if (rwh_view) | 2236 if (rwh_view) |
| 2233 rwh_view->SetSize(GetView()->GetContainerSize()); | 2237 rwh_view->SetSize(GetView()->GetContainerSize()); |
| 2234 } | 2238 } |
| OLD | NEW |