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

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

Issue 426593007: Refactor guest view availability to be API not permission based. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: app view Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/guest_view/extension_options/extension_options_guest.h" 5 #include "chrome/browser/guest_view/extension_options/extension_options_guest.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" 8 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
9 #include "chrome/browser/guest_view/extension_options/extension_options_constant s.h" 9 #include "chrome/browser/guest_view/extension_options/extension_options_constant s.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/common/extensions/api/extension_options_internal.h" 11 #include "chrome/common/extensions/api/extension_options_internal.h"
12 #include "chrome/common/extensions/manifest_url_handler.h" 12 #include "chrome/common/extensions/manifest_url_handler.h"
13 #include "content/public/browser/render_process_host.h" 13 #include "content/public/browser/render_process_host.h"
14 #include "content/public/browser/site_instance.h" 14 #include "content/public/browser/site_instance.h"
15 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
16 #include "extensions/browser/extension_function_dispatcher.h" 16 #include "extensions/browser/extension_function_dispatcher.h"
17 #include "extensions/browser/extension_registry.h" 17 #include "extensions/browser/extension_registry.h"
18 #include "extensions/common/extension.h" 18 #include "extensions/common/extension.h"
19 #include "extensions/common/extension_messages.h" 19 #include "extensions/common/extension_messages.h"
20 #include "extensions/common/feature_switch.h" 20 #include "extensions/common/feature_switch.h"
21 #include "extensions/common/features/feature.h"
22 #include "extensions/common/features/feature_provider.h"
21 #include "extensions/common/permissions/permissions_data.h" 23 #include "extensions/common/permissions/permissions_data.h"
22 #include "ipc/ipc_message_macros.h" 24 #include "ipc/ipc_message_macros.h"
23 25
24 using content::WebContents; 26 using content::WebContents;
25 27
26 // static 28 // static
27 const char ExtensionOptionsGuest::Type[] = "extensionoptions"; 29 const char ExtensionOptionsGuest::Type[] = "extensionoptions";
28 30
29 ExtensionOptionsGuest::ExtensionOptionsGuest( 31 ExtensionOptionsGuest::ExtensionOptionsGuest(
30 content::BrowserContext* browser_context, 32 content::BrowserContext* browser_context,
31 int guest_instance_id) 33 int guest_instance_id)
32 : GuestView<ExtensionOptionsGuest>(browser_context, guest_instance_id) { 34 : GuestView<ExtensionOptionsGuest>(browser_context, guest_instance_id) {
33 } 35 }
34 36
35 ExtensionOptionsGuest::~ExtensionOptionsGuest() { 37 ExtensionOptionsGuest::~ExtensionOptionsGuest() {
36 } 38 }
37 39
38 bool ExtensionOptionsGuest::CanEmbedderUseGuestView( 40 extensions::Feature* ExtensionOptionsGuest::GetFeature() {
39 const std::string& embedder_extension_id) { 41 return extensions::FeatureProvider::GetAPIFeatures()->GetFeature(
40 const extensions::Extension* embedder_extension = 42 "guestViewInternal");
41 extensions::ExtensionRegistry::Get(browser_context())
42 ->enabled_extensions()
43 .GetByID(embedder_extension_id);
44 if (!embedder_extension)
45 return false;
46 return embedder_extension->permissions_data()->HasAPIPermission(
47 extensions::APIPermission::kEmbeddedExtensionOptions);
48 } 43 }
49 44
50 // static 45 // static
51 GuestViewBase* ExtensionOptionsGuest::Create( 46 GuestViewBase* ExtensionOptionsGuest::Create(
52 content::BrowserContext* browser_context, 47 content::BrowserContext* browser_context,
53 int guest_instance_id) { 48 int guest_instance_id) {
54 if (!extensions::FeatureSwitch::embedded_extension_options()->IsEnabled()) { 49 if (!extensions::FeatureSwitch::embedded_extension_options()->IsEnabled()) {
55 return NULL; 50 return NULL;
56 } 51 }
57 return new ExtensionOptionsGuest(browser_context, guest_instance_id); 52 return new ExtensionOptionsGuest(browser_context, guest_instance_id);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 IPC_MESSAGE_UNHANDLED(handled = false) 126 IPC_MESSAGE_UNHANDLED(handled = false)
132 IPC_END_MESSAGE_MAP() 127 IPC_END_MESSAGE_MAP()
133 return handled; 128 return handled;
134 } 129 }
135 130
136 void ExtensionOptionsGuest::OnRequest( 131 void ExtensionOptionsGuest::OnRequest(
137 const ExtensionHostMsg_Request_Params& params) { 132 const ExtensionHostMsg_Request_Params& params) {
138 extension_function_dispatcher_->Dispatch( 133 extension_function_dispatcher_->Dispatch(
139 params, guest_web_contents()->GetRenderViewHost()); 134 params, guest_web_contents()->GetRenderViewHost());
140 } 135 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698