blob: c487a6a8cb1f581d1c882d3c4305e811f2ab0415 [file] [log] [blame]
// Copyright (c) 2012 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 <set>
#include "base/macros.h"
#include "extensions/common/extension_id.h"
#include "ui/base/page_transition_types.h"
class GURL;
namespace blink {
class WebLocalFrame;
namespace extensions {
class Dispatcher;
class Extension;
// Encapsulates the policy for when chrome-extension:// URLs can be requested.
class ResourceRequestPolicy {
explicit ResourceRequestPolicy(Dispatcher* dispatcher);
void OnExtensionLoaded(const Extension& extension);
void OnExtensionUnloaded(const ExtensionId& extension);
// Returns true if the chrome-extension:// |resource_url| can be requested
// from |frame_url|. In some cases this decision is made based upon how
// this request was generated. Web triggered transitions are more restrictive
// than those triggered through UI.
bool CanRequestResource(const GURL& resource_url,
blink::WebLocalFrame* frame,
ui::PageTransition transition_type);
Dispatcher* dispatcher_;
// The set of extension IDs with any potentially web- or webview-accessible
// resources.
std::set<ExtensionId> web_accessible_ids_;
} // namespace extensions