Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Side by Side Diff: chrome/browser/ui/browser_navigator.cc

Issue 78443005: New Tab: fix tab title flickering. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/ui/browser_navigator.h" 5 #include "chrome/browser/ui/browser_navigator.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "chrome/browser/browser_about_handler.h" 13 #include "chrome/browser/browser_about_handler.h"
14 #include "chrome/browser/chrome_notification_types.h" 14 #include "chrome/browser/chrome_notification_types.h"
15 #include "chrome/browser/extensions/extension_service.h" 15 #include "chrome/browser/extensions/extension_service.h"
16 #include "chrome/browser/extensions/tab_helper.h" 16 #include "chrome/browser/extensions/tab_helper.h"
17 #include "chrome/browser/google/google_url_tracker.h" 17 #include "chrome/browser/google/google_url_tracker.h"
18 #include "chrome/browser/prefs/incognito_mode_prefs.h" 18 #include "chrome/browser/prefs/incognito_mode_prefs.h"
19 #include "chrome/browser/prerender/prerender_manager.h" 19 #include "chrome/browser/prerender/prerender_manager.h"
20 #include "chrome/browser/prerender/prerender_manager_factory.h" 20 #include "chrome/browser/prerender/prerender_manager_factory.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/search/search.h"
22 #include "chrome/browser/tab_contents/tab_util.h" 23 #include "chrome/browser/tab_contents/tab_util.h"
23 #include "chrome/browser/ui/browser.h" 24 #include "chrome/browser/ui/browser.h"
24 #include "chrome/browser/ui/browser_finder.h" 25 #include "chrome/browser/ui/browser_finder.h"
25 #include "chrome/browser/ui/browser_instant_controller.h" 26 #include "chrome/browser/ui/browser_instant_controller.h"
26 #include "chrome/browser/ui/browser_tab_contents.h" 27 #include "chrome/browser/ui/browser_tab_contents.h"
27 #include "chrome/browser/ui/browser_window.h" 28 #include "chrome/browser/ui/browser_window.h"
28 #include "chrome/browser/ui/host_desktop.h" 29 #include "chrome/browser/ui/host_desktop.h"
29 #include "chrome/browser/ui/omnibox/location_bar.h" 30 #include "chrome/browser/ui/omnibox/location_bar.h"
30 #include "chrome/browser/ui/singleton_tabs.h" 31 #include "chrome/browser/ui/singleton_tabs.h"
31 #include "chrome/browser/ui/status_bubble.h" 32 #include "chrome/browser/ui/status_bubble.h"
32 #include "chrome/browser/ui/tabs/tab_strip_model.h" 33 #include "chrome/browser/ui/tabs/tab_strip_model.h"
33 #include "chrome/browser/web_applications/web_app.h" 34 #include "chrome/browser/web_applications/web_app.h"
34 #include "chrome/common/pref_names.h" 35 #include "chrome/common/pref_names.h"
35 #include "chrome/common/url_constants.h" 36 #include "chrome/common/url_constants.h"
36 #include "content/public/browser/browser_url_handler.h" 37 #include "content/public/browser/browser_url_handler.h"
38 #include "content/public/browser/navigation_entry.h"
37 #include "content/public/browser/notification_service.h" 39 #include "content/public/browser/notification_service.h"
38 #include "content/public/browser/render_view_host.h" 40 #include "content/public/browser/render_view_host.h"
39 #include "content/public/browser/web_contents.h" 41 #include "content/public/browser/web_contents.h"
40 #include "content/public/browser/web_contents_view.h" 42 #include "content/public/browser/web_contents_view.h"
41 #include "extensions/common/extension.h" 43 #include "extensions/common/extension.h"
44 #include "grit/generated_resources.h"
45 #include "ui/base/l10n/l10n_util.h"
42 46
43 #if defined(USE_AURA) 47 #if defined(USE_AURA)
44 #include "ui/aura/window.h" 48 #include "ui/aura/window.h"
45 #endif 49 #endif
46 50
47 using content::GlobalRequestID; 51 using content::GlobalRequestID;
48 using content::NavigationController; 52 using content::NavigationController;
49 using content::WebContents; 53 using content::WebContents;
50 54
51 class BrowserNavigatorWebContentsAdoption { 55 class BrowserNavigatorWebContentsAdoption {
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 } 265 }
262 266
263 // Only allows the browser-initiated navigation to use POST. 267 // Only allows the browser-initiated navigation to use POST.
264 if (params->uses_post && !params->is_renderer_initiated) { 268 if (params->uses_post && !params->is_renderer_initiated) {
265 load_url_params.load_type = 269 load_url_params.load_type =
266 NavigationController::LOAD_TYPE_BROWSER_INITIATED_HTTP_POST; 270 NavigationController::LOAD_TYPE_BROWSER_INITIATED_HTTP_POST;
267 load_url_params.browser_initiated_post_data = 271 load_url_params.browser_initiated_post_data =
268 params->browser_initiated_post_data; 272 params->browser_initiated_post_data;
269 } 273 }
270 target_contents->GetController().LoadURLWithParams(load_url_params); 274 target_contents->GetController().LoadURLWithParams(load_url_params);
275
276 // For Instant Extended NTPs, add a transient entry and explicitly set the
sky 2013/11/21 23:16:31 This seems like a total hack to me. Isn't there a
samarth 2013/11/21 23:20:58 Yeah. I tried setting the title on the pending en
Charlie Reis 2013/11/21 23:23:57 It's worth understanding why IsInitialNavigation i
samarth 2013/11/21 23:44:06 Ah ok, so the problem is that the check is IsIniti
samarth 2013/11/22 00:29:03 I implemented this in PS2. Let me know what you th
277 // title to "New Tab".
278 //
279 // This ensures that the title is set even before we get a title from the
280 // page, preventing a potential flicker of the URL or "Loading...", and also
281 // ensures that (unless overridden by the page) the new tab title matches the
282 // browser UI locale.
283 content::NavigationController* controller = &target_contents->GetController();
284 content::NavigationEntry* entry = controller->GetVisibleEntry();
285 if (chrome::IsNTPURL(
286 entry->GetURL(),
287 Profile::FromBrowserContext(target_contents->GetBrowserContext()))) {
288 content::NavigationEntry* transient = controller->CreateNavigationEntry(
289 entry->GetURL(),
290 entry->GetReferrer(),
291 entry->GetTransitionType(),
292 false,
293 std::string(),
294 target_contents->GetBrowserContext());
295 transient->SetTitle(l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE));
296 controller->SetTransientEntry(transient);
297 }
271 } 298 }
272 299
273 // This class makes sure the Browser object held in |params| is made visible 300 // This class makes sure the Browser object held in |params| is made visible
274 // by the time it goes out of scope, provided |params| wants it to be shown. 301 // by the time it goes out of scope, provided |params| wants it to be shown.
275 class ScopedBrowserShower { 302 class ScopedBrowserShower {
276 public: 303 public:
277 explicit ScopedBrowserShower(chrome::NavigateParams* params) 304 explicit ScopedBrowserShower(chrome::NavigateParams* params)
278 : params_(params) { 305 : params_(params) {
279 } 306 }
280 ~ScopedBrowserShower() { 307 ~ScopedBrowserShower() {
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 bool reverse_on_redirect = false; 733 bool reverse_on_redirect = false;
707 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( 734 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary(
708 &rewritten_url, browser_context, &reverse_on_redirect); 735 &rewritten_url, browser_context, &reverse_on_redirect);
709 736
710 // Some URLs are mapped to uber subpages. Do not allow them in incognito. 737 // Some URLs are mapped to uber subpages. Do not allow them in incognito.
711 return !(rewritten_url.scheme() == chrome::kChromeUIScheme && 738 return !(rewritten_url.scheme() == chrome::kChromeUIScheme &&
712 rewritten_url.host() == chrome::kChromeUIUberHost); 739 rewritten_url.host() == chrome::kChromeUIUberHost);
713 } 740 }
714 741
715 } // namespace chrome 742 } // namespace chrome
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698