| Index: chrome/browser/guest_view/extension_options/extension_options_guest.cc
|
| diff --git a/chrome/browser/guest_view/extension_options/extension_options_guest.cc b/chrome/browser/guest_view/extension_options/extension_options_guest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c2cd04d768792c3769f37523b9462dfcc8250784
|
| --- /dev/null
|
| +++ b/chrome/browser/guest_view/extension_options/extension_options_guest.cc
|
| @@ -0,0 +1,58 @@
|
| +// 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/guest_view/extension_options/extension_options_guest.h"
|
| +
|
| +#include "chrome/browser/guest_view/extension_options/extension_options_constants.h"
|
| +#include "chrome/common/extensions/manifest_url_handler.h"
|
| +#include "content/public/browser/render_process_host.h"
|
| +#include "content/public/browser/site_instance.h"
|
| +#include "content/public/browser/web_contents.h"
|
| +#include "extensions/browser/extension_registry.h"
|
| +#include "extensions/common/extension.h"
|
| +
|
| +using content::WebContents;
|
| +
|
| +// static
|
| +const char ExtensionOptionsGuest::Type[] = "extensionoptions";
|
| +
|
| +ExtensionOptionsGuest::ExtensionOptionsGuest(
|
| + content::BrowserContext* browser_context,
|
| + int guest_instance_id)
|
| + : GuestView<ExtensionOptionsGuest>(browser_context, guest_instance_id) {}
|
| +
|
| +ExtensionOptionsGuest::~ExtensionOptionsGuest() {}
|
| +
|
| +void ExtensionOptionsGuest::CreateWebContents(
|
| + const std::string& embedder_extension_id,
|
| + int embedder_render_process_id,
|
| + const base::DictionaryValue& create_params,
|
| + const WebContentsCreatedCallback& callback) {
|
| + content::RenderProcessHost* embedder_render_process_host =
|
| + content::RenderProcessHost::FromID(embedder_render_process_id);
|
| + content::BrowserContext* browser_context =
|
| + embedder_render_process_host->GetBrowserContext();
|
| +
|
| + // Get the extension id from create_params
|
| + std::string extension_id;
|
| + create_params.GetString(extensionoptions::kExtensionId, &extension_id);
|
| + DCHECK(!extension_id.empty());
|
| +
|
| + extensions::ExtensionRegistry* registry =
|
| + extensions::ExtensionRegistry::Get(browser_context);
|
| +
|
| + // Get the extension and its options page
|
| + const extensions::Extension* extension =
|
| + registry->GetExtensionById(extension_id,
|
| + extensions::ExtensionRegistry::ENABLED);
|
| + GURL options_page = extensions::ManifestURL::GetOptionsPage(extension);
|
| + content::SiteInstance* options_site_instance =
|
| + content::SiteInstance::CreateForURL(browser_context, options_page);
|
| +
|
| + // Create a webcontents containing the options page
|
| + WebContents::CreateParams params(browser_context,
|
| + options_site_instance);
|
| + params.guest_delegate = this;
|
| + callback.Run(WebContents::Create(params));
|
| +}
|
|
|