| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/tab_contents/tab_contents.h" | 5 #include "chrome/browser/tab_contents/tab_contents.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/file_version_info.h" | 9 #include "base/file_version_info.h" |
| 10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 const std::wstring TabContents::GetDefaultTitle() const { | 490 const std::wstring TabContents::GetDefaultTitle() const { |
| 491 return l10n_util::GetString(IDS_DEFAULT_TAB_TITLE); | 491 return l10n_util::GetString(IDS_DEFAULT_TAB_TITLE); |
| 492 } | 492 } |
| 493 | 493 |
| 494 bool TabContents::ShouldDisplayURL() { | 494 bool TabContents::ShouldDisplayURL() { |
| 495 // Don't hide the url in view source mode. | 495 // Don't hide the url in view source mode. |
| 496 NavigationEntry* entry = controller_.GetActiveEntry(); | 496 NavigationEntry* entry = controller_.GetActiveEntry(); |
| 497 if (entry && entry->IsViewSourceMode()) | 497 if (entry && entry->IsViewSourceMode()) |
| 498 return true; | 498 return true; |
| 499 | 499 |
| 500 // Hide the URL in chrome-extension://. | |
| 501 if (GetURL().SchemeIs(chrome::kExtensionScheme)) | |
| 502 return false; | |
| 503 | |
| 504 DOMUI* dom_ui = GetDOMUIForCurrentState(); | 500 DOMUI* dom_ui = GetDOMUIForCurrentState(); |
| 505 if (dom_ui) | 501 if (dom_ui) |
| 506 return !dom_ui->should_hide_url(); | 502 return !dom_ui->should_hide_url(); |
| 507 return true; | 503 return true; |
| 508 } | 504 } |
| 509 | 505 |
| 510 SkBitmap TabContents::GetFavIcon() const { | 506 SkBitmap TabContents::GetFavIcon() const { |
| 511 // Like GetTitle(), we also want to use the favicon for the last committed | 507 // Like GetTitle(), we also want to use the favicon for the last committed |
| 512 // entry rather than a pending navigation entry. | 508 // entry rather than a pending navigation entry. |
| 513 NavigationEntry* entry = controller_.GetTransientEntry(); | 509 NavigationEntry* entry = controller_.GetTransientEntry(); |
| (...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1496 return save_package_.get(); // May be NULL, but we can return NULL. | 1492 return save_package_.get(); // May be NULL, but we can return NULL. |
| 1497 } | 1493 } |
| 1498 | 1494 |
| 1499 RendererPreferences TabContents::GetRendererPrefs() const { | 1495 RendererPreferences TabContents::GetRendererPrefs() const { |
| 1500 if (delegate()) | 1496 if (delegate()) |
| 1501 return delegate()->GetRendererPrefs(); | 1497 return delegate()->GetRendererPrefs(); |
| 1502 else | 1498 else |
| 1503 return RendererPreferences(); | 1499 return RendererPreferences(); |
| 1504 } | 1500 } |
| 1505 | 1501 |
| 1506 ExtensionFunctionDispatcher* TabContents::CreateExtensionFunctionDispatcher( | |
| 1507 RenderViewHost* render_view_host, | |
| 1508 const std::string& extension_id) { | |
| 1509 return delegate()->CreateExtensionFunctionDispatcher(render_view_host, | |
| 1510 extension_id); | |
| 1511 } | |
| 1512 | |
| 1513 TabContents* TabContents::GetAsTabContents() { | 1502 TabContents* TabContents::GetAsTabContents() { |
| 1514 return this; | 1503 return this; |
| 1515 } | 1504 } |
| 1516 | 1505 |
| 1517 void TabContents::RenderViewCreated(RenderViewHost* render_view_host) { | 1506 void TabContents::RenderViewCreated(RenderViewHost* render_view_host) { |
| 1518 NavigationEntry* entry = controller_.GetActiveEntry(); | 1507 NavigationEntry* entry = controller_.GetActiveEntry(); |
| 1519 if (!entry) | 1508 if (!entry) |
| 1520 return; | 1509 return; |
| 1521 | 1510 |
| 1522 // When we're creating views, we're still doing initial setup, so we always | 1511 // When we're creating views, we're still doing initial setup, so we always |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1857 | 1846 |
| 1858 void TabContents::DomOperationResponse(const std::string& json_string, | 1847 void TabContents::DomOperationResponse(const std::string& json_string, |
| 1859 int automation_id) { | 1848 int automation_id) { |
| 1860 DomOperationNotificationDetails details(json_string, automation_id); | 1849 DomOperationNotificationDetails details(json_string, automation_id); |
| 1861 NotificationService::current()->Notify( | 1850 NotificationService::current()->Notify( |
| 1862 NotificationType::DOM_OPERATION_RESPONSE, Source<TabContents>(this), | 1851 NotificationType::DOM_OPERATION_RESPONSE, Source<TabContents>(this), |
| 1863 Details<DomOperationNotificationDetails>(&details)); | 1852 Details<DomOperationNotificationDetails>(&details)); |
| 1864 } | 1853 } |
| 1865 | 1854 |
| 1866 void TabContents::ProcessDOMUIMessage(const std::string& message, | 1855 void TabContents::ProcessDOMUIMessage(const std::string& message, |
| 1867 const std::string& content) { | 1856 const std::string& content, |
| 1857 int request_id, |
| 1858 bool has_callback) { |
| 1868 if (!render_manager_.dom_ui()) { | 1859 if (!render_manager_.dom_ui()) { |
| 1869 // We shouldn't get a DOM UI message when we haven't enabled the DOM UI. | 1860 // We shouldn't get a DOM UI message when we haven't enabled the DOM UI. |
| 1870 // Because the renderer might be owned and sending random messages, we need | 1861 // Because the renderer might be owned and sending random messages, we need |
| 1871 // to ignore these inproper ones. | 1862 // to ignore these inproper ones. |
| 1872 NOTREACHED(); | 1863 NOTREACHED(); |
| 1873 return; | 1864 return; |
| 1874 } | 1865 } |
| 1875 render_manager_.dom_ui()->ProcessDOMUIMessage(message, content); | 1866 render_manager_.dom_ui()->ProcessDOMUIMessage(message, content, request_id, |
| 1867 has_callback); |
| 1876 } | 1868 } |
| 1877 | 1869 |
| 1878 void TabContents::DocumentLoadedInFrame() { | 1870 void TabContents::DocumentLoadedInFrame() { |
| 1879 controller_.DocumentLoadedInFrame(); | 1871 controller_.DocumentLoadedInFrame(); |
| 1880 } | 1872 } |
| 1881 | 1873 |
| 1882 void TabContents::ProcessExternalHostMessage(const std::string& message, | 1874 void TabContents::ProcessExternalHostMessage(const std::string& message, |
| 1883 const std::string& origin, | 1875 const std::string& origin, |
| 1884 const std::string& target) { | 1876 const std::string& target) { |
| 1885 if (delegate()) | 1877 if (delegate()) |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2273 return DOMUIFactory::CreateDOMUIForURL(this, url); | 2265 return DOMUIFactory::CreateDOMUIForURL(this, url); |
| 2274 } | 2266 } |
| 2275 | 2267 |
| 2276 NavigationEntry* | 2268 NavigationEntry* |
| 2277 TabContents::GetLastCommittedNavigationEntryForRenderManager() { | 2269 TabContents::GetLastCommittedNavigationEntryForRenderManager() { |
| 2278 return controller_.GetLastCommittedEntry(); | 2270 return controller_.GetLastCommittedEntry(); |
| 2279 } | 2271 } |
| 2280 | 2272 |
| 2281 bool TabContents::CreateRenderViewForRenderManager( | 2273 bool TabContents::CreateRenderViewForRenderManager( |
| 2282 RenderViewHost* render_view_host) { | 2274 RenderViewHost* render_view_host) { |
| 2283 // When we're running a DOM UI, the RenderViewHost needs to be put in DOM UI | 2275 // If the pending navigation is to a DOMUI, tell the RenderView about any |
| 2284 // mode before CreateRenderView is called. When we're asked to create a | 2276 // bindings it will need enabled. |
| 2285 // RenderView, that means it's for the pending entry, so we have to use the | |
| 2286 // pending DOM UI. | |
| 2287 if (render_manager_.pending_dom_ui()) | 2277 if (render_manager_.pending_dom_ui()) |
| 2288 render_view_host->AllowDOMUIBindings(); | 2278 render_view_host->AllowBindings( |
| 2289 | 2279 render_manager_.pending_dom_ui()->bindings()); |
| 2290 // Ditto for extension bindings. | |
| 2291 if (controller().pending_entry()->url().SchemeIs(chrome::kExtensionScheme)) | |
| 2292 render_view_host->AllowExtensionBindings(); | |
| 2293 | 2280 |
| 2294 RenderWidgetHostView* rwh_view = view_->CreateViewForWidget(render_view_host); | 2281 RenderWidgetHostView* rwh_view = view_->CreateViewForWidget(render_view_host); |
| 2295 if (!render_view_host->CreateRenderView()) | 2282 if (!render_view_host->CreateRenderView()) |
| 2296 return false; | 2283 return false; |
| 2297 | 2284 |
| 2298 // Now that the RenderView has been created, we need to tell it its size. | 2285 // Now that the RenderView has been created, we need to tell it its size. |
| 2299 rwh_view->SetSize(view_->GetContainerSize()); | 2286 rwh_view->SetSize(view_->GetContainerSize()); |
| 2300 | 2287 |
| 2301 UpdateMaxPageIDIfNecessary(render_view_host->site_instance(), | 2288 UpdateMaxPageIDIfNecessary(render_view_host->site_instance(), |
| 2302 render_view_host); | 2289 render_view_host); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2343 NavigationController::LoadCommittedDetails& committed_details = | 2330 NavigationController::LoadCommittedDetails& committed_details = |
| 2344 *(Details<NavigationController::LoadCommittedDetails>(details).ptr()); | 2331 *(Details<NavigationController::LoadCommittedDetails>(details).ptr()); |
| 2345 ExpireInfoBars(committed_details); | 2332 ExpireInfoBars(committed_details); |
| 2346 break; | 2333 break; |
| 2347 } | 2334 } |
| 2348 | 2335 |
| 2349 default: | 2336 default: |
| 2350 NOTREACHED(); | 2337 NOTREACHED(); |
| 2351 } | 2338 } |
| 2352 } | 2339 } |
| OLD | NEW |