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

Unified Diff: chrome/browser/android/new_tab_page_url_handler.cc

Issue 205983005: [Android] Rewrite old-style NTP URLs to new-style URLs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: register chrome-native as standard scheme, add back recent_tabs handling Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/new_tab_page_url_handler.cc
diff --git a/chrome/browser/android/new_tab_page_url_handler.cc b/chrome/browser/android/new_tab_page_url_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7ea759360aed16d050b293b01bb1795a250ab567
--- /dev/null
+++ b/chrome/browser/android/new_tab_page_url_handler.cc
@@ -0,0 +1,48 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/android/new_tab_page_url_handler.h"
+
+#include <string>
+
+#include "base/strings/string_util.h"
+#include "chrome/common/url_constants.h"
+#include "content/public/common/url_constants.h"
+#include "url/gurl.h"
+
+namespace {
+const char kLegacyBookmarksFragment[] = "bookmarks";
+const char kLegacyOpenTabsFragment[] = "open_tabs";
+const char kLegacyRecentTabsHost[] = "recent_tabs";
+}
+
+namespace chrome {
+namespace android {
+
+bool HandleAndroidNewTabURL(GURL* url,
+ content::BrowserContext* browser_context) {
+ if (url->SchemeIs(content::kChromeUIScheme) &&
+ url->host() == chrome::kChromeUINewTabHost) {
+ std::string ref = url->ref();
+ if (StartsWithASCII(ref, kLegacyBookmarksFragment, true)) {
+ *url = GURL(chrome::kChromeUINativeBookmarksURL);
+ } else if (ref == kLegacyOpenTabsFragment) {
+ *url = GURL(chrome::kChromeUINativeRecentTabsURL);
+ } else {
+ *url = GURL(chrome::kChromeUINativeNewTabURL);
+ }
+ return true;
+ }
+
+ if (url->SchemeIs(chrome::kChromeNativeScheme) &&
+ url->host() == kLegacyRecentTabsHost) {
+ *url = GURL(chrome::kChromeUINativeRecentTabsURL);
+ return true;
+ }
+
+ return false;
+}
+
+} // namespace android
+} // namespace chrome

Powered by Google App Engine
This is Rietveld 408576698