summaryrefslogtreecommitdiffstats
path: root/ios/chrome/browser/history/history_utils.cc
blob: 1fe8fde5baa267a4c10257fe09259667a4dacfd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright 2015 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 "ios/chrome/browser/history/history_utils.h"

#include "components/dom_distiller/core/url_constants.h"
#include "ios/chrome/browser/chrome_url_constants.h"
#include "url/gurl.h"
#include "url/url_constants.h"

namespace ios {

// Returns true if this looks like the type of URL that should be added to the
// history. This filters out URLs such a JavaScript.
bool CanAddURLToHistory(const GURL& url) {
  if (!url.is_valid())
    return false;

  // TODO: We should allow ChromeUIScheme URLs if they have been explicitly
  // typed.  Right now, however, these are marked as typed even when triggered
  // by a shortcut or menu action.
  if (url.SchemeIs(url::kJavaScriptScheme) ||
      url.SchemeIs(dom_distiller::kDomDistillerScheme) ||
      url.SchemeIs(kChromeUIScheme))
    return false;

  // Allow all about: and chrome: URLs except about:blank, since the user may
  // like to see "chrome://memory/", etc. in their history and autocomplete.
  if (url == GURL(url::kAboutBlankURL))
    return false;

  return true;
}

}  // namespace ios