OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chrome/browser/ui/search/instant_loader.h" | 5 #include "chrome/browser/ui/search/instant_loader.h" |
6 | 6 |
7 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 7 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
8 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" | 8 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" |
9 #include "chrome/browser/favicon/favicon_tab_helper.h" | 9 #include "chrome/browser/favicon/favicon_tab_helper.h" |
10 #include "chrome/browser/history/history_tab_helper.h" | 10 #include "chrome/browser/history/history_tab_helper.h" |
11 #include "chrome/browser/safe_browsing/safe_browsing_tab_observer.h" | 11 #include "chrome/browser/safe_browsing/safe_browsing_tab_observer.h" |
12 #include "chrome/browser/search/search.h" | 12 #include "chrome/browser/search/search.h" |
13 #include "chrome/browser/tab_contents/tab_util.h" | 13 #include "chrome/browser/tab_contents/tab_util.h" |
14 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" | 14 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" |
15 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" | 15 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" |
16 #include "chrome/browser/ui/search/search_tab_helper.h" | 16 #include "chrome/browser/ui/search/search_tab_helper.h" |
17 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 17 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
18 #include "content/public/browser/navigation_entry.h" | 18 #include "content/public/browser/navigation_entry.h" |
19 #include "content/public/browser/notification_source.h" | 19 #include "content/public/browser/notification_source.h" |
20 #include "content/public/browser/notification_types.h" | 20 #include "content/public/browser/notification_types.h" |
21 #include "content/public/browser/render_widget_host_view.h" | 21 #include "content/public/browser/render_widget_host_view.h" |
22 #include "content/public/browser/site_instance.h" | 22 #include "content/public/browser/site_instance.h" |
23 #include "content/public/browser/web_contents_view.h" | 23 #include "content/public/browser/web_contents_view.h" |
| 24 #include "grit/generated_resources.h" |
| 25 #include "ui/base/l10n/l10n_util.h" |
24 | 26 |
25 namespace { | 27 namespace { |
26 | 28 |
27 // This HTTP header and value are set on loads that originate from Instant. | 29 // This HTTP header and value are set on loads that originate from Instant. |
28 const char kInstantHeader[] = "X-Purpose: Instant"; | 30 const char kInstantHeader[] = "X-Purpose: Instant"; |
29 | 31 |
30 } // namespace | 32 } // namespace |
31 | 33 |
32 InstantLoader::Delegate::~Delegate() { | 34 InstantLoader::Delegate::~Delegate() { |
33 } | 35 } |
(...skipping 15 matching lines...) Expand all Loading... |
49 content::WebContents::Create(create_params))); | 51 content::WebContents::Create(create_params))); |
50 instant_url_ = instant_url; | 52 instant_url_ = instant_url; |
51 on_stale_callback_ = on_stale_callback; | 53 on_stale_callback_ = on_stale_callback; |
52 } | 54 } |
53 | 55 |
54 void InstantLoader::Load() { | 56 void InstantLoader::Load() { |
55 DVLOG(1) << "LoadURL: " << instant_url_; | 57 DVLOG(1) << "LoadURL: " << instant_url_; |
56 contents_->GetController().LoadURL( | 58 contents_->GetController().LoadURL( |
57 instant_url_, content::Referrer(), | 59 instant_url_, content::Referrer(), |
58 content::PAGE_TRANSITION_GENERATED, kInstantHeader); | 60 content::PAGE_TRANSITION_GENERATED, kInstantHeader); |
| 61 |
| 62 // Explicitly set the new tab title and virtual URL. |
| 63 // |
| 64 // This ensures that the title is set even before we get a title from the |
| 65 // page, preventing a potential flicker of the URL, and also ensures that |
| 66 // (unless overridden by the page) the new tab title matches the browser UI |
| 67 // locale. |
| 68 content::NavigationEntry* entry = contents_->GetController().GetActiveEntry(); |
| 69 if (entry) |
| 70 entry->SetTitle(l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); |
| 71 |
59 contents_->WasHidden(); | 72 contents_->WasHidden(); |
60 | 73 |
61 int staleness_timeout_ms = chrome::GetInstantLoaderStalenessTimeoutSec() * | 74 int staleness_timeout_ms = chrome::GetInstantLoaderStalenessTimeoutSec() * |
62 1000; | 75 1000; |
63 if (staleness_timeout_ms > 0) { | 76 if (staleness_timeout_ms > 0) { |
64 stale_page_timer_.Start( | 77 stale_page_timer_.Start( |
65 FROM_HERE, | 78 FROM_HERE, |
66 base::TimeDelta::FromMilliseconds(staleness_timeout_ms), | 79 base::TimeDelta::FromMilliseconds(staleness_timeout_ms), |
67 on_stale_callback_); | 80 on_stale_callback_); |
68 } | 81 } |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 | 243 |
231 bool InstantLoader::OnGoToEntryOffset(int /* offset */) { | 244 bool InstantLoader::OnGoToEntryOffset(int /* offset */) { |
232 return false; | 245 return false; |
233 } | 246 } |
234 | 247 |
235 content::WebContents* InstantLoader::OpenURLFromTab( | 248 content::WebContents* InstantLoader::OpenURLFromTab( |
236 content::WebContents* source, | 249 content::WebContents* source, |
237 const content::OpenURLParams& params) { | 250 const content::OpenURLParams& params) { |
238 return delegate_->OpenURLFromTab(source, params); | 251 return delegate_->OpenURLFromTab(source, params); |
239 } | 252 } |
OLD | NEW |