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/extensions/api/guest_view/guest_view_internal_api.h" | 5 #include "chrome/browser/extensions/api/guest_view/guest_view_internal_api.h" |
6 | 6 |
7 #include "chrome/browser/guest_view/guest_view_base.h" | 7 #include "chrome/browser/guest_view/guest_view_base.h" |
8 #include "chrome/browser/guest_view/guest_view_manager.h" | 8 #include "chrome/browser/guest_view/guest_view_manager.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/common/extensions/api/guest_view_internal.h" | 10 #include "chrome/common/extensions/api/guest_view_internal.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 base::DictionaryValue* create_params; | 31 base::DictionaryValue* create_params; |
32 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &create_params)); | 32 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &create_params)); |
33 | 33 |
34 const PermissionsData* permissions_data = GetExtension()->permissions_data(); | 34 const PermissionsData* permissions_data = GetExtension()->permissions_data(); |
35 if (!permissions_data->HasAPIPermission(APIPermission::kWebView) && | 35 if (!permissions_data->HasAPIPermission(APIPermission::kWebView) && |
36 !permissions_data->HasAPIPermission(APIPermission::kAppView)) { | 36 !permissions_data->HasAPIPermission(APIPermission::kAppView)) { |
37 LOG(ERROR) << kPermissionRequiredError; | 37 LOG(ERROR) << kPermissionRequiredError; |
38 error_ = kPermissionRequiredError; | 38 error_ = kPermissionRequiredError; |
39 SendResponse(false); | 39 SendResponse(false); |
| 40 return true; |
40 } | 41 } |
41 | 42 |
42 GuestViewManager* guest_view_manager = | 43 GuestViewManager* guest_view_manager = |
43 GuestViewManager::FromBrowserContext(browser_context()); | 44 GuestViewManager::FromBrowserContext(browser_context()); |
44 | 45 |
45 GuestViewManager::WebContentsCreatedCallback callback = | 46 GuestViewManager::WebContentsCreatedCallback callback = |
46 base::Bind(&GuestViewInternalCreateGuestFunction::CreateGuestCallback, | 47 base::Bind(&GuestViewInternalCreateGuestFunction::CreateGuestCallback, |
47 this); | 48 this); |
48 guest_view_manager->CreateGuest(view_type, | 49 guest_view_manager->CreateGuest(view_type, |
49 extension_id(), | 50 extension_id(), |
50 render_view_host()->GetProcess()->GetID(), | 51 render_view_host()->GetProcess()->GetID(), |
51 *create_params, | 52 *create_params, |
52 callback); | 53 callback); |
53 | 54 |
54 return true; | 55 return true; |
55 } | 56 } |
56 | 57 |
57 void GuestViewInternalCreateGuestFunction::CreateGuestCallback( | 58 void GuestViewInternalCreateGuestFunction::CreateGuestCallback( |
58 content::WebContents* guest_web_contents) { | 59 content::WebContents* guest_web_contents) { |
59 if (!guest_web_contents) | 60 int guest_instance_id = 0; |
60 return; | 61 if (guest_web_contents) { |
61 GuestViewBase* guest = GuestViewBase::FromWebContents(guest_web_contents); | 62 GuestViewBase* guest = GuestViewBase::FromWebContents(guest_web_contents); |
62 SetResult(base::Value::CreateIntegerValue(guest->GetGuestInstanceID())); | 63 guest_instance_id = guest->GetGuestInstanceID(); |
| 64 } |
| 65 SetResult(base::Value::CreateIntegerValue(guest_instance_id)); |
63 SendResponse(true); | 66 SendResponse(true); |
64 } | 67 } |
65 | 68 |
66 } // namespace extensions | 69 } // namespace extensions |
OLD | NEW |