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 "apps/url_redirector.h" |
9 #include "base/command_line.h" | 10 #include "base/command_line.h" |
10 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
11 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.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" |
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 = |
| 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 // TODO(sergeygs): Remove this and update includes once url_handlers are |
| 492 // moved out of experimental. |
| 493 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 494 extensions::switches::kEnableExperimentalExtensionApis)) { |
| 495 if (apps::UrlRedirector::MaybeLaunchAppWithUrl( |
| 496 params->initiating_profile, |
| 497 params->url, |
| 498 params->referrer.url)) { |
| 499 // An app has intercepted the navigation: cancel it here. |
| 500 return; |
| 501 } |
| 502 } |
| 503 } |
| 504 } |
481 | 505 |
482 // The browser window may want to adjust the disposition. | 506 // The browser window may want to adjust the disposition. |
483 if (params->disposition == NEW_POPUP && | 507 if (params->disposition == NEW_POPUP && |
484 source_browser && | 508 source_browser && |
485 source_browser->window()) { | 509 source_browser->window()) { |
486 params->disposition = | 510 params->disposition = |
487 source_browser->window()->GetDispositionForPopupBounds( | 511 source_browser->window()->GetDispositionForPopupBounds( |
488 params->window_bounds); | 512 params->window_bounds); |
489 } | 513 } |
490 | 514 |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 bool reverse_on_redirect = false; | 709 bool reverse_on_redirect = false; |
686 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( | 710 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( |
687 &rewritten_url, browser_context, &reverse_on_redirect); | 711 &rewritten_url, browser_context, &reverse_on_redirect); |
688 | 712 |
689 // Some URLs are mapped to uber subpages. Do not allow them in incognito. | 713 // Some URLs are mapped to uber subpages. Do not allow them in incognito. |
690 return !(rewritten_url.scheme() == chrome::kChromeUIScheme && | 714 return !(rewritten_url.scheme() == chrome::kChromeUIScheme && |
691 rewritten_url.host() == chrome::kChromeUIUberHost); | 715 rewritten_url.host() == chrome::kChromeUIUberHost); |
692 } | 716 } |
693 | 717 |
694 } // namespace chrome | 718 } // namespace chrome |
OLD | NEW |