[Android] Delete local java reference every loop.
[chromium-blink-merge.git] / chrome / browser / android / new_tab_page_url_handler.cc
blob7ea759360aed16d050b293b01bb1795a250ab567
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
3 // found in the LICENSE file.
5 #include "chrome/browser/android/new_tab_page_url_handler.h"
7 #include <string>
9 #include "base/strings/string_util.h"
10 #include "chrome/common/url_constants.h"
11 #include "content/public/common/url_constants.h"
12 #include "url/gurl.h"
14 namespace {
15 const char kLegacyBookmarksFragment[] = "bookmarks";
16 const char kLegacyOpenTabsFragment[] = "open_tabs";
17 const char kLegacyRecentTabsHost[] = "recent_tabs";
20 namespace chrome {
21 namespace android {
23 bool HandleAndroidNewTabURL(GURL* url,
24 content::BrowserContext* browser_context) {
25 if (url->SchemeIs(content::kChromeUIScheme) &&
26 url->host() == chrome::kChromeUINewTabHost) {
27 std::string ref = url->ref();
28 if (StartsWithASCII(ref, kLegacyBookmarksFragment, true)) {
29 *url = GURL(chrome::kChromeUINativeBookmarksURL);
30 } else if (ref == kLegacyOpenTabsFragment) {
31 *url = GURL(chrome::kChromeUINativeRecentTabsURL);
32 } else {
33 *url = GURL(chrome::kChromeUINativeNewTabURL);
35 return true;
38 if (url->SchemeIs(chrome::kChromeNativeScheme) &&
39 url->host() == kLegacyRecentTabsHost) {
40 *url = GURL(chrome::kChromeUINativeRecentTabsURL);
41 return true;
44 return false;
47 } // namespace android
48 } // namespace chrome