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/apps/app_url_redirector.h" | |
| 13 #include "chrome/browser/browser_about_handler.h" | 14 #include "chrome/browser/browser_about_handler.h" |
| 14 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
| 15 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
| 17 #include "chrome/browser/extensions/extension_system.h" | |
| 16 #include "chrome/browser/extensions/tab_helper.h" | 18 #include "chrome/browser/extensions/tab_helper.h" |
| 17 #include "chrome/browser/google/google_url_tracker.h" | 19 #include "chrome/browser/google/google_url_tracker.h" |
| 18 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 20 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 19 #include "chrome/browser/prerender/prerender_manager.h" | 21 #include "chrome/browser/prerender/prerender_manager.h" |
| 20 #include "chrome/browser/prerender/prerender_manager_factory.h" | 22 #include "chrome/browser/prerender/prerender_manager_factory.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/tab_contents/tab_util.h" | 24 #include "chrome/browser/tab_contents/tab_util.h" |
| 23 #include "chrome/browser/ui/browser.h" | 25 #include "chrome/browser/ui/browser.h" |
| 24 #include "chrome/browser/ui/browser_finder.h" | 26 #include "chrome/browser/ui/browser_finder.h" |
| 25 #include "chrome/browser/ui/browser_instant_controller.h" | 27 #include "chrome/browser/ui/browser_instant_controller.h" |
| 26 #include "chrome/browser/ui/browser_tab_contents.h" | 28 #include "chrome/browser/ui/browser_tab_contents.h" |
| 27 #include "chrome/browser/ui/browser_window.h" | 29 #include "chrome/browser/ui/browser_window.h" |
| 28 #include "chrome/browser/ui/host_desktop.h" | 30 #include "chrome/browser/ui/host_desktop.h" |
| 29 #include "chrome/browser/ui/omnibox/location_bar.h" | 31 #include "chrome/browser/ui/omnibox/location_bar.h" |
| 30 #include "chrome/browser/ui/singleton_tabs.h" | 32 #include "chrome/browser/ui/singleton_tabs.h" |
| 31 #include "chrome/browser/ui/status_bubble.h" | 33 #include "chrome/browser/ui/status_bubble.h" |
| 32 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 34 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 33 #include "chrome/browser/web_applications/web_app.h" | 35 #include "chrome/browser/web_applications/web_app.h" |
| 34 #include "chrome/common/extensions/extension.h" | 36 #include "chrome/common/extensions/extension.h" |
| 35 #include "chrome/common/pref_names.h" | 37 #include "chrome/common/pref_names.h" |
| 36 #include "chrome/common/url_constants.h" | 38 #include "chrome/common/url_constants.h" |
| 37 #include "content/public/browser/browser_url_handler.h" | 39 #include "content/public/browser/browser_url_handler.h" |
| 38 #include "content/public/browser/notification_service.h" | 40 #include "content/public/browser/notification_service.h" |
| 39 #include "content/public/browser/render_view_host.h" | 41 #include "content/public/browser/render_view_host.h" |
| 40 #include "content/public/browser/web_contents.h" | 42 #include "content/public/browser/web_contents.h" |
| 41 #include "content/public/browser/web_contents_view.h" | 43 #include "content/public/browser/web_contents_view.h" |
| 44 #include "extensions/common/switches.h" | |
|
not at google - send to devlin
2013/09/04 15:37:21
unused?
sergeygs
2013/09/05 09:19:03
Done.
| |
| 42 | 45 |
| 43 #if defined(USE_AURA) | 46 #if defined(USE_AURA) |
| 44 #include "ui/aura/window.h" | 47 #include "ui/aura/window.h" |
| 45 #endif | 48 #endif |
| 46 | 49 |
| 47 using content::GlobalRequestID; | 50 using content::GlobalRequestID; |
| 48 using content::NavigationController; | 51 using content::NavigationController; |
| 49 using content::WebContents; | 52 using content::WebContents; |
| 50 | 53 |
| 51 class BrowserNavigatorWebContentsAdoption { | 54 class BrowserNavigatorWebContentsAdoption { |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 468 | 471 |
| 469 void Navigate(NavigateParams* params) { | 472 void Navigate(NavigateParams* params) { |
| 470 Browser* source_browser = params->browser; | 473 Browser* source_browser = params->browser; |
| 471 if (source_browser) | 474 if (source_browser) |
| 472 params->initiating_profile = source_browser->profile(); | 475 params->initiating_profile = source_browser->profile(); |
| 473 DCHECK(params->initiating_profile); | 476 DCHECK(params->initiating_profile); |
| 474 | 477 |
| 475 if (!AdjustNavigateParamsForURL(params)) | 478 if (!AdjustNavigateParamsForURL(params)) |
| 476 return; | 479 return; |
| 477 | 480 |
| 478 ExtensionService* service = params->initiating_profile->GetExtensionService(); | 481 // See if the extension service wants to block this navigation or some |
| 479 if (service) | 482 // platform app wants to intercept it. |
| 480 service->ShouldBlockUrlInBrowserTab(¶ms->url); | 483 extensions::ExtensionSystem* system = |
|
benwells
2013/09/04 23:54:20
It's unfortunate this code has to be here. This fu
sergeygs
2013/09/05 09:19:03
To answer the last question: because this deals on
| |
| 484 extensions::ExtensionSystem::Get(params->initiating_profile); | |
| 485 if (system) { | |
| 486 ExtensionService* service = system->extension_service(); | |
| 487 if (service && service->ShouldBlockUrlInBrowserTab(¶ms->url)) { | |
| 488 // Proceed. The call just rewrites the URL to the error page: we still | |
| 489 // have to display it. | |
| 490 } else { | |
| 491 if (AppUrlRedirector::MaybeLaunchAppWithUrl( | |
| 492 params->initiating_profile, | |
|
not at google - send to devlin
2013/09/04 15:37:21
Just grab the AppUrlRedirector from the initiating
benwells
2013/09/04 23:54:20
At the moment the redirector is a tab helper (or w
not at google - send to devlin
2013/09/05 00:01:52
Yes, realised this later after chatting to Sergey.
sergeygs
2013/09/05 09:19:03
Obsolete.
| |
| 493 params->url, | |
| 494 params->referrer.url)) { | |
| 495 // An app has intercepted the navigation: cancel it here. | |
| 496 return; | |
| 497 } | |
| 498 } | |
| 499 } | |
| 481 | 500 |
| 482 // The browser window may want to adjust the disposition. | 501 // The browser window may want to adjust the disposition. |
| 483 if (params->disposition == NEW_POPUP && | 502 if (params->disposition == NEW_POPUP && |
| 484 source_browser && | 503 source_browser && |
| 485 source_browser->window()) { | 504 source_browser->window()) { |
| 486 params->disposition = | 505 params->disposition = |
| 487 source_browser->window()->GetDispositionForPopupBounds( | 506 source_browser->window()->GetDispositionForPopupBounds( |
| 488 params->window_bounds); | 507 params->window_bounds); |
| 489 } | 508 } |
| 490 | 509 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 685 bool reverse_on_redirect = false; | 704 bool reverse_on_redirect = false; |
| 686 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( | 705 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( |
| 687 &rewritten_url, browser_context, &reverse_on_redirect); | 706 &rewritten_url, browser_context, &reverse_on_redirect); |
| 688 | 707 |
| 689 // Some URLs are mapped to uber subpages. Do not allow them in incognito. | 708 // Some URLs are mapped to uber subpages. Do not allow them in incognito. |
| 690 return !(rewritten_url.scheme() == chrome::kChromeUIScheme && | 709 return !(rewritten_url.scheme() == chrome::kChromeUIScheme && |
| 691 rewritten_url.host() == chrome::kChromeUIUberHost); | 710 rewritten_url.host() == chrome::kChromeUIUberHost); |
| 692 } | 711 } |
| 693 | 712 |
| 694 } // namespace chrome | 713 } // namespace chrome |
| OLD | NEW |