Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: chrome/browser/guest_view/extension_options/extension_options_guest.cc

Issue 378783002: Initial implementation of the <extensionoptions> GuestView tag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add constants file Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/guest_view/extension_options/extension_options_guest.h"
6
7 #include "chrome/browser/guest_view/extension_options/extension_options_constant s.h"
8 #include "chrome/common/extensions/manifest_url_handler.h"
9 #include "content/public/browser/render_process_host.h"
10 #include "content/public/browser/site_instance.h"
11 #include "content/public/browser/web_contents.h"
12 #include "extensions/browser/extension_registry.h"
13 #include "extensions/common/extension.h"
14
15 using content::WebContents;
16
17 // static
18 const char ExtensionOptionsGuest::Type[] = "extensionoptions";
19
20 ExtensionOptionsGuest::ExtensionOptionsGuest(
21 content::BrowserContext* browser_context,
22 int guest_instance_id)
23 : GuestView<ExtensionOptionsGuest>(browser_context, guest_instance_id) {}
24
25 ExtensionOptionsGuest::~ExtensionOptionsGuest() {}
26
27 void ExtensionOptionsGuest::CreateWebContents(
28 const std::string& embedder_extension_id,
29 int embedder_render_process_id,
30 const base::DictionaryValue& create_params,
31 const WebContentsCreatedCallback& callback) {
32 content::RenderProcessHost* embedder_render_process_host =
33 content::RenderProcessHost::FromID(embedder_render_process_id);
34 content::BrowserContext* browser_context =
35 embedder_render_process_host->GetBrowserContext();
36
37 // Get the extension id from create_params
38 std::string extension_id;
39 create_params.GetString(extensionoptions::kExtensionId, &extension_id);
40 DCHECK(!extension_id.empty());
41
42 extensions::ExtensionRegistry* registry =
43 extensions::ExtensionRegistry::Get(browser_context);
44
45 // Get the extension and its options page
46 const extensions::Extension* extension =
47 registry->GetExtensionById(extension_id,
48 extensions::ExtensionRegistry::ENABLED);
49 GURL options_page = extensions::ManifestURL::GetOptionsPage(extension);
50 content::SiteInstance* options_site_instance =
51 content::SiteInstance::CreateForURL(browser_context, options_page);
52
53 // Create a webcontents containing the options page
54 WebContents::CreateParams params(browser_context,
55 options_site_instance);
56 params.guest_delegate = this;
57 callback.Run(WebContents::Create(params));
58 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698