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

Side by Side Diff: chrome/renderer/extensions/chrome_v8_context.cc

Issue 114803007: Register bindings for blessed web contexts (aka hosted app contexts) by hand (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: jeffrey Created 6 years, 11 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer/extensions/chrome_v8_context.h" 5 #include "chrome/renderer/extensions/chrome_v8_context.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/string_split.h" 9 #include "base/strings/string_split.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 bool ChromeV8Context::IsAnyFeatureAvailableToContext(const Feature& api) { 97 bool ChromeV8Context::IsAnyFeatureAvailableToContext(const Feature& api) {
98 return ExtensionAPI::GetSharedInstance()->IsAnyFeatureAvailableToContext( 98 return ExtensionAPI::GetSharedInstance()->IsAnyFeatureAvailableToContext(
99 api, 99 api,
100 extension_.get(), 100 extension_.get(),
101 context_type_, 101 context_type_,
102 UserScriptSlave::GetDataSourceURLForFrame(web_frame_)); 102 UserScriptSlave::GetDataSourceURLForFrame(web_frame_));
103 } 103 }
104 104
105 Feature::Availability ChromeV8Context::GetAvailability( 105 Feature::Availability ChromeV8Context::GetAvailability(
106 const std::string& api_name) { 106 const std::string& api_name) {
107 // Hack: Hosted apps should have the availability of messaging APIs based on
108 // the URL of the page (which might have access depending on some extension
109 // with externally_connectable), not whether the app has access to messaging
110 // (which it won't).
111 const Extension* extension = extension_.get();
112 if (extension && extension->is_hosted_app() &&
113 (api_name == "runtime.connect" || api_name == "runtime.sendMessage")) {
114 extension = NULL;
115 }
107 return ExtensionAPI::GetSharedInstance()->IsAvailable(api_name, 116 return ExtensionAPI::GetSharedInstance()->IsAvailable(api_name,
108 extension_.get(), 117 extension,
109 context_type_, 118 context_type_,
110 GetURL()); 119 GetURL());
111 } 120 }
112 121
113 void ChromeV8Context::DispatchOnUnloadEvent() { 122 void ChromeV8Context::DispatchOnUnloadEvent() {
114 module_system_->CallModuleMethod("unload_event", "dispatch"); 123 module_system_->CallModuleMethod("unload_event", "dispatch");
115 } 124 }
116 125
117 std::string ChromeV8Context::GetContextTypeDescription() { 126 std::string ChromeV8Context::GetContextTypeDescription() {
118 switch (context_type_) { 127 switch (context_type_) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 // string if a validation error has occured. 163 // string if a validation error has occured.
155 if (DCHECK_IS_ON()) { 164 if (DCHECK_IS_ON()) {
156 if (!retval.IsEmpty() && !retval->IsUndefined()) { 165 if (!retval.IsEmpty() && !retval->IsUndefined()) {
157 std::string error = *v8::String::Utf8Value(retval); 166 std::string error = *v8::String::Utf8Value(retval);
158 DCHECK(false) << error; 167 DCHECK(false) << error;
159 } 168 }
160 } 169 }
161 } 170 }
162 171
163 } // namespace extensions 172 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698