Chromium Code Reviews| 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..39c104254ae595f3a49734883b3f7b34b9f1f279 |
| --- /dev/null |
| +++ b/chrome/browser/guest_view/extension_options/extension_options_guest.cc |
| @@ -0,0 +1,57 @@ |
| +// 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/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("extensionId", &extension_id); |
|
Fady Samuel
2014/07/08 14:23:40
Make extensionId a constant.
ericzeng
2014/07/08 18:10:48
A constant just in this class or in some constants
Fady Samuel
2014/07/08 18:13:30
A constants file. See web_view_constants as an exa
ericzeng
2014/07/08 18:34:51
Done.
|
| + 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); |
|
Fady Samuel
2014/07/08 14:23:40
Does this end up in the same process as the app?
ericzeng
2014/07/08 18:10:48
I'm not exactly certain how this works and what pr
Fady Samuel
2014/07/08 18:13:30
Use the task manager built into Chrome. Does the o
|
| + |
| + // Create a webcontents containing the options page |
| + WebContents::CreateParams params(browser_context, |
| + options_site_instance); |
| + params.guest_delegate = this; |
| + callback.Run(WebContents::Create(params)); |
| +} |