blob: 5d7d53edc6845d50a988f986afb632bbab03eb3f [file] [log] [blame]
// Copyright 2016 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.
#ifndef IOS_CHROME_COMMON_X_CALLBACK_URL_H_
#define IOS_CHROME_COMMON_X_CALLBACK_URL_H_
#include <map>
#include <string>
#include "base/strings/string_piece.h"
#include "url/gurl.h"
// Returns true if |url| is compliant with the x-callback-url specs.
bool IsXCallbackURL(const GURL& url);
// Returns a GURL compliant with the x-callback-url specs (simple version with
// no parameters set, see XCallbackURLWithParameters for constructing complex
// URLs).
GURL CreateXCallbackURL(base::StringPiece scheme, base::StringPiece action);
// Returns a GURL compliant with the x-callback-url specs.
// See http://x-callback-url.com/specifications/ for specifications.
// |scheme| must not be empty, all other parameters may be.
GURL CreateXCallbackURLWithParameters(
base::StringPiece scheme,
base::StringPiece action,
const GURL& success_url,
const GURL& error_url,
const GURL& cancel_url,
const std::map<std::string, std::string>& parameters);
// Extract query parameters from an x-callback-url URL. |x_callback_url| must
// be compliant with the x-callback-url specs.
std::map<std::string, std::string> ExtractQueryParametersFromXCallbackURL(
const GURL& x_callback_url);
#endif // IOS_CHROME_COMMON_X_CALLBACK_URL_H_