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

Side by Side Diff: chrome/browser/extensions/api/guest_view/guest_view_internal_api.cc

Issue 345983002: Remove a hard CHECK when allocating instance ID would fail. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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_manager.h" 7 #include "chrome/browser/guest_view/guest_view_manager.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/common/extensions/api/guest_view_internal.h" 9 #include "chrome/common/extensions/api/guest_view_internal.h"
10 #include "extensions/common/permissions/permissions_data.h" 10 #include "extensions/common/permissions/permissions_data.h"
11 11
12 namespace {
13 const char* kWebViewPermissionRequiredError =
14 "\"webview\" permission is required for allocating instance ID.";
15 } // namespace
16
12 namespace extensions { 17 namespace extensions {
13 18
14 GuestViewInternalAllocateInstanceIdFunction:: 19 GuestViewInternalAllocateInstanceIdFunction::
15 GuestViewInternalAllocateInstanceIdFunction() { 20 GuestViewInternalAllocateInstanceIdFunction() {
16 } 21 }
17 22
18 bool GuestViewInternalAllocateInstanceIdFunction::RunAsync() { 23 bool GuestViewInternalAllocateInstanceIdFunction::RunAsync() {
19 EXTENSION_FUNCTION_VALIDATE(!args_->GetSize()); 24 EXTENSION_FUNCTION_VALIDATE(!args_->GetSize());
20 25
21 // Check if we have "webview" permission. 26
22 CHECK(GetExtension()->permissions_data()->HasAPIPermission( 27 if (!GetExtension()->permissions_data()->HasAPIPermission(
23 APIPermission::kWebView)); 28 APIPermission::kWebView)) {
29 LOG(ERROR) << kWebViewPermissionRequiredError;
30 error_ = kWebViewPermissionRequiredError;
31 SendResponse(false);
32 return false;
33 }
24 34
25 int instanceId = GuestViewManager::FromBrowserContext(browser_context()) 35 int instanceId = GuestViewManager::FromBrowserContext(browser_context())
26 ->GetNextInstanceID(); 36 ->GetNextInstanceID();
27 SetResult(base::Value::CreateIntegerValue(instanceId)); 37 SetResult(base::Value::CreateIntegerValue(instanceId));
28 SendResponse(true); 38 SendResponse(true);
29 return true; 39 return true;
30 } 40 }
31 41
32 } // namespace extensions 42 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698