OLD | NEW |
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/new_tab_page_url_handler.h" | 5 #include "chrome/browser/android/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/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
11 #include "content/public/common/url_constants.h" | 11 #include "content/public/common/url_constants.h" |
12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
13 | 13 |
14 namespace { | 14 namespace { |
15 const char kBookmarkFolderPath[] = "folder/"; | 15 const char kBookmarkFolderPath[] = "folder/"; |
| 16 const char kLegacyWelcomeHost[] = "welcome"; |
16 } | 17 } |
17 | 18 |
18 namespace chrome { | 19 namespace chrome { |
19 namespace android { | 20 namespace android { |
20 | 21 |
21 bool HandleAndroidNativePageURL(GURL* url, | 22 bool HandleAndroidNativePageURL(GURL* url, |
22 content::BrowserContext* browser_context) { | 23 content::BrowserContext* browser_context) { |
23 if (url->SchemeIs(content::kChromeUIScheme) && | 24 if (url->SchemeIs(content::kChromeUIScheme)) { |
24 url->host() == chrome::kChromeUINewTabHost) { | 25 // TODO(newt): stop redirecting chrome://welcome to chrome-native://newtab |
25 *url = GURL(chrome::kChromeUINativeNewTabURL); | 26 // when M39 is a distant memory. http://crbug.com/455427 |
26 return true; | 27 if (url->host() == chrome::kChromeUINewTabHost || |
| 28 url->host() == kLegacyWelcomeHost) { |
| 29 *url = GURL(chrome::kChromeUINativeNewTabURL); |
| 30 return true; |
| 31 } |
27 } | 32 } |
28 | 33 |
29 if (url->SchemeIs(chrome::kChromeNativeScheme) && | 34 if (url->SchemeIs(chrome::kChromeNativeScheme) && |
30 url->host() == kChromeUIBookmarksHost) { | 35 url->host() == kChromeUIBookmarksHost) { |
31 std::string ref = url->ref(); | 36 std::string ref = url->ref(); |
32 if (!ref.empty()) { | 37 if (!ref.empty()) { |
33 *url = GURL(std::string(kChromeUINativeBookmarksURL) | 38 *url = GURL(std::string(kChromeUINativeBookmarksURL) |
34 .append(kBookmarkFolderPath) | 39 .append(kBookmarkFolderPath) |
35 .append(ref)); | 40 .append(ref)); |
36 return true; | 41 return true; |
37 } | 42 } |
38 } | 43 } |
39 | 44 |
40 return false; | 45 return false; |
41 } | 46 } |
42 | 47 |
43 } // namespace android | 48 } // namespace android |
44 } // namespace chrome | 49 } // namespace chrome |
OLD | NEW |