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/stringprintf.h" | 11 #include "base/stringprintf.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "chrome/browser/browser_about_handler.h" | 13 #include "chrome/browser/browser_about_handler.h" |
14 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
| 15 #include "chrome/browser/extensions/extension_system.h" |
| 16 #include "chrome/browser/extensions/platform_app_redirector.h" |
15 #include "chrome/browser/extensions/tab_helper.h" | 17 #include "chrome/browser/extensions/tab_helper.h" |
16 #include "chrome/browser/google/google_url_tracker.h" | 18 #include "chrome/browser/google/google_url_tracker.h" |
17 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 19 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
18 #include "chrome/browser/prerender/prerender_manager.h" | 20 #include "chrome/browser/prerender/prerender_manager.h" |
19 #include "chrome/browser/prerender/prerender_manager_factory.h" | 21 #include "chrome/browser/prerender/prerender_manager_factory.h" |
20 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/tab_contents/tab_util.h" | 23 #include "chrome/browser/tab_contents/tab_util.h" |
22 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
23 #include "chrome/browser/ui/browser_finder.h" | 25 #include "chrome/browser/ui/browser_finder.h" |
24 #include "chrome/browser/ui/browser_instant_controller.h" | 26 #include "chrome/browser/ui/browser_instant_controller.h" |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 | 452 |
451 void Navigate(NavigateParams* params) { | 453 void Navigate(NavigateParams* params) { |
452 Browser* source_browser = params->browser; | 454 Browser* source_browser = params->browser; |
453 if (source_browser) | 455 if (source_browser) |
454 params->initiating_profile = source_browser->profile(); | 456 params->initiating_profile = source_browser->profile(); |
455 DCHECK(params->initiating_profile); | 457 DCHECK(params->initiating_profile); |
456 | 458 |
457 if (!AdjustNavigateParamsForURL(params)) | 459 if (!AdjustNavigateParamsForURL(params)) |
458 return; | 460 return; |
459 | 461 |
460 ExtensionService* service = params->initiating_profile->GetExtensionService(); | 462 // See if the extension service wants to block this navigation or some |
461 if (service) | 463 // platform app wants to intercept it. |
462 service->ShouldBlockUrlInBrowserTab(¶ms->url); | 464 extensions::ExtensionSystem* system = |
| 465 extensions::ExtensionSystem::Get(params->initiating_profile); |
| 466 if (system) { |
| 467 ExtensionService* service = system->extension_service(); |
| 468 if (service && service->ShouldBlockUrlInBrowserTab(¶ms->url)) { |
| 469 // Proceed. The call just rewrites the URL to an error page: we still |
| 470 // have to display it. |
| 471 } else { |
| 472 extensions::PlatformAppRedirector* redirector = |
| 473 system->platform_app_redirector(); |
| 474 if (redirector && redirector->MaybeLaunchPlatformAppWithUrl( |
| 475 params->url, params->referrer.url)) { |
| 476 // An app has intercepted the navigation: cancel it here. |
| 477 return; |
| 478 } |
| 479 } |
| 480 } |
463 | 481 |
464 // The browser window may want to adjust the disposition. | 482 // The browser window may want to adjust the disposition. |
465 if (params->disposition == NEW_POPUP && | 483 if (params->disposition == NEW_POPUP && |
466 source_browser && | 484 source_browser && |
467 source_browser->window()) { | 485 source_browser->window()) { |
468 params->disposition = | 486 params->disposition = |
469 source_browser->window()->GetDispositionForPopupBounds( | 487 source_browser->window()->GetDispositionForPopupBounds( |
470 params->window_bounds); | 488 params->window_bounds); |
471 } | 489 } |
472 | 490 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 bool reverse_on_redirect = false; | 675 bool reverse_on_redirect = false; |
658 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( | 676 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( |
659 &rewritten_url, browser_context, &reverse_on_redirect); | 677 &rewritten_url, browser_context, &reverse_on_redirect); |
660 | 678 |
661 // Some URLs are mapped to uber subpages. Do not allow them in incognito. | 679 // Some URLs are mapped to uber subpages. Do not allow them in incognito. |
662 return !(rewritten_url.scheme() == chrome::kChromeUIScheme && | 680 return !(rewritten_url.scheme() == chrome::kChromeUIScheme && |
663 rewritten_url.host() == chrome::kChromeUIUberHost); | 681 rewritten_url.host() == chrome::kChromeUIUberHost); |
664 } | 682 } |
665 | 683 |
666 } // namespace chrome | 684 } // namespace chrome |
OLD | NEW |