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

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

Issue 15950011: content: Move kViewSourceScheme constant into content namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months 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
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"
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 if (params->disposition != CURRENT_TAB) { 633 if (params->disposition != CURRENT_TAB) {
634 content::NotificationService::current()->Notify( 634 content::NotificationService::current()->Notify(
635 chrome::NOTIFICATION_TAB_ADDED, 635 chrome::NOTIFICATION_TAB_ADDED,
636 content::Source<content::WebContentsDelegate>(params->browser), 636 content::Source<content::WebContentsDelegate>(params->browser),
637 content::Details<WebContents>(params->target_contents)); 637 content::Details<WebContents>(params->target_contents));
638 } 638 }
639 } 639 }
640 640
641 bool IsURLAllowedInIncognito(const GURL& url, 641 bool IsURLAllowedInIncognito(const GURL& url,
642 content::BrowserContext* browser_context) { 642 content::BrowserContext* browser_context) {
643 if (url.scheme() == chrome::kViewSourceScheme) { 643 if (url.scheme() == content::kViewSourceScheme) {
644 // A view-source URL is allowed in incognito mode only if the URL itself 644 // A view-source URL is allowed in incognito mode only if the URL itself
645 // is allowed in incognito mode. Remove the "view-source:" from the start 645 // is allowed in incognito mode. Remove the "view-source:" from the start
646 // of the URL and validate the rest. 646 // of the URL and validate the rest.
647 std::string stripped_spec = url.spec(); 647 std::string stripped_spec = url.spec();
648 DCHECK_GT(stripped_spec.size(), strlen(kViewSourceScheme)); 648 DCHECK_GT(stripped_spec.size(), strlen(content::kViewSourceScheme));
649 stripped_spec.erase(0, strlen(kViewSourceScheme)+1); 649 stripped_spec.erase(0, strlen(content::kViewSourceScheme) + 1);
650 GURL stripped_url(stripped_spec); 650 GURL stripped_url(stripped_spec);
651 return stripped_url.is_valid() && 651 return stripped_url.is_valid() &&
652 IsURLAllowedInIncognito(stripped_url, browser_context); 652 IsURLAllowedInIncognito(stripped_url, browser_context);
653 } 653 }
654 // Most URLs are allowed in incognito; the following are exceptions. 654 // Most URLs are allowed in incognito; the following are exceptions.
655 // chrome://extensions is on the list because it redirects to 655 // chrome://extensions is on the list because it redirects to
656 // chrome://settings. 656 // chrome://settings.
657 if (url.scheme() == chrome::kChromeUIScheme && 657 if (url.scheme() == chrome::kChromeUIScheme &&
658 (url.host() == chrome::kChromeUISettingsHost || 658 (url.host() == chrome::kChromeUISettingsHost ||
659 url.host() == chrome::kChromeUISettingsFrameHost || 659 url.host() == chrome::kChromeUISettingsFrameHost ||
660 url.host() == chrome::kChromeUIExtensionsHost || 660 url.host() == chrome::kChromeUIExtensionsHost ||
661 url.host() == chrome::kChromeUIBookmarksHost || 661 url.host() == chrome::kChromeUIBookmarksHost ||
662 url.host() == chrome::kChromeUISyncPromoHost || 662 url.host() == chrome::kChromeUISyncPromoHost ||
663 url.host() == chrome::kChromeUIUberHost)) { 663 url.host() == chrome::kChromeUIUberHost)) {
664 return false; 664 return false;
665 } 665 }
666 666
667 GURL rewritten_url = url; 667 GURL rewritten_url = url;
668 bool reverse_on_redirect = false; 668 bool reverse_on_redirect = false;
669 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( 669 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary(
670 &rewritten_url, browser_context, &reverse_on_redirect); 670 &rewritten_url, browser_context, &reverse_on_redirect);
671 671
672 // Some URLs are mapped to uber subpages. Do not allow them in incognito. 672 // Some URLs are mapped to uber subpages. Do not allow them in incognito.
673 return !(rewritten_url.scheme() == chrome::kChromeUIScheme && 673 return !(rewritten_url.scheme() == chrome::kChromeUIScheme &&
674 rewritten_url.host() == chrome::kChromeUIUberHost); 674 rewritten_url.host() == chrome::kChromeUIUberHost);
675 } 675 }
676 676
677 } // namespace chrome 677 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_commands.cc ('k') | chrome/browser/ui/browser_navigator_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698