OLD | NEW |
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" |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 ExtensionOptionsGuest::ExtensionOptionsGuest( | 30 ExtensionOptionsGuest::ExtensionOptionsGuest( |
31 content::BrowserContext* browser_context, | 31 content::BrowserContext* browser_context, |
32 int guest_instance_id) | 32 int guest_instance_id) |
33 : GuestView<ExtensionOptionsGuest>(browser_context, guest_instance_id) { | 33 : GuestView<ExtensionOptionsGuest>(browser_context, guest_instance_id) { |
34 } | 34 } |
35 | 35 |
36 ExtensionOptionsGuest::~ExtensionOptionsGuest() { | 36 ExtensionOptionsGuest::~ExtensionOptionsGuest() { |
37 } | 37 } |
38 | 38 |
39 bool ExtensionOptionsGuest::CanEmbedderUseGuestView( | 39 const char* ExtensionOptionsGuest::GetAPINamespace() { |
40 const std::string& embedder_extension_id) { | 40 return extensionoptions::kAPINamespace; |
41 const extensions::Extension* embedder_extension = | |
42 extensions::ExtensionRegistry::Get(browser_context()) | |
43 ->enabled_extensions() | |
44 .GetByID(embedder_extension_id); | |
45 if (!embedder_extension) | |
46 return false; | |
47 return embedder_extension->permissions_data()->HasAPIPermission( | |
48 extensions::APIPermission::kEmbeddedExtensionOptions); | |
49 } | 41 } |
50 | 42 |
51 // static | 43 // static |
52 GuestViewBase* ExtensionOptionsGuest::Create( | 44 GuestViewBase* ExtensionOptionsGuest::Create( |
53 content::BrowserContext* browser_context, | 45 content::BrowserContext* browser_context, |
54 int guest_instance_id) { | 46 int guest_instance_id) { |
55 if (!extensions::FeatureSwitch::embedded_extension_options()->IsEnabled()) { | 47 if (!extensions::FeatureSwitch::embedded_extension_options()->IsEnabled()) { |
56 return NULL; | 48 return NULL; |
57 } | 49 } |
58 return new ExtensionOptionsGuest(browser_context, guest_instance_id); | 50 return new ExtensionOptionsGuest(browser_context, guest_instance_id); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 int min_width = 0; | 168 int min_width = 0; |
177 extra_params()->GetInteger(extensionoptions::kAttributeMinHeight, | 169 extra_params()->GetInteger(extensionoptions::kAttributeMinHeight, |
178 &min_height); | 170 &min_height); |
179 extra_params()->GetInteger(extensionoptions::kAttributeMinWidth, &min_width); | 171 extra_params()->GetInteger(extensionoptions::kAttributeMinWidth, &min_width); |
180 | 172 |
181 // Call SetAutoSize to apply all the appropriate validation and clipping of | 173 // Call SetAutoSize to apply all the appropriate validation and clipping of |
182 // values. | 174 // values. |
183 SetAutoSize( | 175 SetAutoSize( |
184 true, gfx::Size(min_width, min_height), gfx::Size(max_width, max_height)); | 176 true, gfx::Size(min_width, min_height), gfx::Size(max_width, max_height)); |
185 } | 177 } |
OLD | NEW |