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

Side by Side Diff: chrome/browser/android/ntp/new_tab_page_url_handler.cc

Issue 2676893002: [Android History] Fix chrome://history redirect (Closed)
Patch Set: [Android History] Fix chrome://history redirect Created 3 years, 10 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/android/ntp/new_tab_page_url_handler.h" 5 #include "chrome/browser/android/ntp/new_tab_page_url_handler.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "chrome/browser/android/chrome_feature_list.h" 10 #include "chrome/browser/android/chrome_feature_list.h"
11 #include "chrome/common/url_constants.h" 11 #include "chrome/common/url_constants.h"
12 #include "content/public/common/content_features.h"
12 #include "content/public/common/url_constants.h" 13 #include "content/public/common/url_constants.h"
13 #include "url/gurl.h" 14 #include "url/gurl.h"
14 15
15 namespace { 16 namespace {
16 const char kBookmarkFolderPath[] = "folder/"; 17 const char kBookmarkFolderPath[] = "folder/";
17 const char kLegacyWelcomeHost[] = "welcome"; 18 const char kLegacyWelcomeHost[] = "welcome";
18 } 19 }
19 20
20 namespace chrome { 21 namespace chrome {
21 namespace android { 22 namespace android {
22 23
23 bool HandleAndroidNativePageURL(GURL* url, 24 bool HandleAndroidNativePageURL(GURL* url,
24 content::BrowserContext* browser_context) { 25 content::BrowserContext* browser_context) {
25 if (url->SchemeIs(content::kChromeUIScheme)) { 26 if (url->SchemeIs(content::kChromeUIScheme)) {
26 // TODO(newt): stop redirecting chrome://welcome to chrome-native://newtab 27 // TODO(newt): stop redirecting chrome://welcome to chrome-native://newtab
27 // when M39 is a distant memory. http://crbug.com/455427 28 // when M39 is a distant memory. http://crbug.com/455427
28 if (url->host() == chrome::kChromeUINewTabHost || 29 if (url->host() == chrome::kChromeUINewTabHost ||
29 url->host() == kLegacyWelcomeHost) { 30 url->host() == kLegacyWelcomeHost) {
30 *url = GURL(chrome::kChromeUINativeNewTabURL); 31 *url = GURL(chrome::kChromeUINativeNewTabURL);
31 return true; 32 return true;
32 } 33 }
33 34
34 // TODO(twellington): stop redirecting chrome://bookmarks to 35 // TODO(twellington): stop redirecting chrome://history to
35 // chrome-native://bookmarks when M57 is a distant memory. 36 // chrome-native://history when M57 is a distant memory.
36 // See http://crbug.com/654071. 37 // See http://crbug.com/654071.
37 if (base::FeatureList::IsEnabled( 38 if (base::FeatureList::IsEnabled(features::kNativeAndroidHistoryManager) &&
38 chrome::android::kNativeAndroidHistoryManager) &&
39 (url->host() == kChromeUIHistoryHost || 39 (url->host() == kChromeUIHistoryHost ||
40 url->host() == kChromeUIHistoryFrameHost)) { 40 url->host() == kChromeUIHistoryFrameHost)) {
41 *url = GURL(kChromeUINativeHistoryURL); 41 *url = GURL(content::kChromeUINativeHistoryURL);
42 return true; 42 return true;
43 } 43 }
44 44
45 if (url->host() == kChromeUIPhysicalWebDiagnosticsHost) { 45 if (url->host() == kChromeUIPhysicalWebDiagnosticsHost) {
46 *url = GURL(kChromeUINativePhysicalWebDiagnosticsURL); 46 *url = GURL(kChromeUINativePhysicalWebDiagnosticsURL);
47 return true; 47 return true;
48 } 48 }
49 } 49 }
50 50
51 if (url->SchemeIs(chrome::kChromeNativeScheme) && 51 if (url->SchemeIs(chrome::kChromeNativeScheme) &&
52 url->host() == kChromeUIBookmarksHost) { 52 url->host() == kChromeUIBookmarksHost) {
53 std::string ref = url->ref(); 53 std::string ref = url->ref();
54 if (!ref.empty()) { 54 if (!ref.empty()) {
55 *url = GURL(std::string(kChromeUINativeBookmarksURL) 55 *url = GURL(std::string(kChromeUINativeBookmarksURL)
56 .append(kBookmarkFolderPath) 56 .append(kBookmarkFolderPath)
57 .append(ref)); 57 .append(ref));
58 return true; 58 return true;
59 } 59 }
60 } 60 }
61 61
62 return false; 62 return false;
63 } 63 }
64 64
65 } // namespace android 65 } // namespace android
66 } // namespace chrome 66 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698