Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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, explicitly set the title to "New Tab" on the | |
| 277 // pending entry. | |
| 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( | |
|
Charlie Reis
2013/11/22 18:54:18
Hmm, this call happens for almost every URL. (Soo
samarth
2013/11/22 20:03:19
Agreed, this doesn't seem ideal. I don't know wher
Charlie Reis
2013/11/22 20:33:47
That sounds perfect-- thanks.
samarth
2013/11/22 21:54:41
Done.
| |
| 286 entry->GetURL(), | |
| 287 Profile::FromBrowserContext(target_contents->GetBrowserContext()))) { | |
| 288 entry->SetTitle(l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); | |
| 289 } | |
| 271 } | 290 } |
| 272 | 291 |
| 273 // This class makes sure the Browser object held in |params| is made visible | 292 // 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. | 293 // by the time it goes out of scope, provided |params| wants it to be shown. |
| 275 class ScopedBrowserShower { | 294 class ScopedBrowserShower { |
| 276 public: | 295 public: |
| 277 explicit ScopedBrowserShower(chrome::NavigateParams* params) | 296 explicit ScopedBrowserShower(chrome::NavigateParams* params) |
| 278 : params_(params) { | 297 : params_(params) { |
| 279 } | 298 } |
| 280 ~ScopedBrowserShower() { | 299 ~ScopedBrowserShower() { |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 706 bool reverse_on_redirect = false; | 725 bool reverse_on_redirect = false; |
| 707 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( | 726 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( |
| 708 &rewritten_url, browser_context, &reverse_on_redirect); | 727 &rewritten_url, browser_context, &reverse_on_redirect); |
| 709 | 728 |
| 710 // Some URLs are mapped to uber subpages. Do not allow them in incognito. | 729 // Some URLs are mapped to uber subpages. Do not allow them in incognito. |
| 711 return !(rewritten_url.scheme() == chrome::kChromeUIScheme && | 730 return !(rewritten_url.scheme() == chrome::kChromeUIScheme && |
| 712 rewritten_url.host() == chrome::kChromeUIUberHost); | 731 rewritten_url.host() == chrome::kChromeUIUberHost); |
| 713 } | 732 } |
| 714 | 733 |
| 715 } // namespace chrome | 734 } // namespace chrome |
| OLD | NEW |