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

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

Issue 10826199: Properly propagate the current Chrome channel into the Feature system on the (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make the default stable Created 8 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 (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/dispatcher.h" 5 #include "chrome/renderer/extensions/dispatcher.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/string_piece.h" 10 #include "base/string_piece.h"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 return v8::Integer::New(manifest_version_); 212 return v8::Integer::New(manifest_version_);
213 } 213 }
214 214
215 private: 215 private:
216 std::string extension_id_; 216 std::string extension_id_;
217 std::string context_type_; 217 std::string context_type_;
218 bool is_incognito_context_; 218 bool is_incognito_context_;
219 int manifest_version_; 219 int manifest_version_;
220 }; 220 };
221 221
222 class ChannelNativeHandler : public NativeHandler {
223 public:
224 explicit ChannelNativeHandler(chrome::VersionInfo::Channel channel)
225 : channel_(channel) {
226 RouteFunction("IsDevChannel",
227 base::Bind(&ChannelNativeHandler::IsDevChannel,
228 base::Unretained(this)));
229 }
230
231 v8::Handle<v8::Value> IsDevChannel(const v8::Arguments& args) {
232 return v8::Boolean::New(channel_ <= chrome::VersionInfo::CHANNEL_DEV);
233 }
234
235 chrome::VersionInfo::Channel channel_;
236 };
237
238 class LoggingNativeHandler : public NativeHandler { 222 class LoggingNativeHandler : public NativeHandler {
239 public: 223 public:
240 LoggingNativeHandler() { 224 LoggingNativeHandler() {
241 RouteFunction("DCHECK", 225 RouteFunction("DCHECK",
242 base::Bind(&LoggingNativeHandler::Dcheck, 226 base::Bind(&LoggingNativeHandler::Dcheck,
243 base::Unretained(this))); 227 base::Unretained(this)));
244 } 228 }
245 229
246 v8::Handle<v8::Value> Dcheck(const v8::Arguments& args) { 230 v8::Handle<v8::Value> Dcheck(const v8::Arguments& args) {
247 CHECK_LE(args.Length(), 2); 231 CHECK_LE(args.Length(), 2);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 return chrome->ToObject(); 280 return chrome->ToObject();
297 } 281 }
298 282
299 } // namespace 283 } // namespace
300 284
301 Dispatcher::Dispatcher() 285 Dispatcher::Dispatcher()
302 : is_webkit_initialized_(false), 286 : is_webkit_initialized_(false),
303 webrequest_adblock_(false), 287 webrequest_adblock_(false),
304 webrequest_adblock_plus_(false), 288 webrequest_adblock_plus_(false),
305 webrequest_other_(false), 289 webrequest_other_(false),
306 source_map_(&ResourceBundle::GetSharedInstance()), 290 source_map_(&ResourceBundle::GetSharedInstance()) {
307 chrome_channel_(chrome::VersionInfo::CHANNEL_UNKNOWN) {
308 const CommandLine& command_line = *(CommandLine::ForCurrentProcess()); 291 const CommandLine& command_line = *(CommandLine::ForCurrentProcess());
309 is_extension_process_ = 292 is_extension_process_ =
310 command_line.HasSwitch(switches::kExtensionProcess) || 293 command_line.HasSwitch(switches::kExtensionProcess) ||
311 command_line.HasSwitch(switches::kSingleProcess); 294 command_line.HasSwitch(switches::kSingleProcess);
312 295
313 if (is_extension_process_) { 296 if (is_extension_process_) {
314 RenderThread::Get()->SetIdleNotificationDelayInMs( 297 RenderThread::Get()->SetIdleNotificationDelayInMs(
315 kInitialExtensionIdleHandlerDelayMs); 298 kInitialExtensionIdleHandlerDelayMs);
316 } 299 }
317 300
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 } 374 }
392 375
393 void Dispatcher::OnSetFunctionNames( 376 void Dispatcher::OnSetFunctionNames(
394 const std::vector<std::string>& names) { 377 const std::vector<std::string>& names) {
395 function_names_.clear(); 378 function_names_.clear();
396 for (size_t i = 0; i < names.size(); ++i) 379 for (size_t i = 0; i < names.size(); ++i)
397 function_names_.insert(names[i]); 380 function_names_.insert(names[i]);
398 } 381 }
399 382
400 void Dispatcher::OnSetChannel(int channel) { 383 void Dispatcher::OnSetChannel(int channel) {
401 chrome_channel_ = channel; 384 extensions::Feature::SetCurrentChannel(
385 static_cast<chrome::VersionInfo::Channel>(channel));
402 } 386 }
403 387
404 void Dispatcher::OnMessageInvoke(const std::string& extension_id, 388 void Dispatcher::OnMessageInvoke(const std::string& extension_id,
405 const std::string& function_name, 389 const std::string& function_name,
406 const ListValue& args, 390 const ListValue& args,
407 const GURL& event_url, 391 const GURL& event_url,
408 bool user_gesture) { 392 bool user_gesture) {
409 scoped_ptr<WebScopedUserGesture> web_user_gesture; 393 scoped_ptr<WebScopedUserGesture> web_user_gesture;
410 if (user_gesture) { 394 if (user_gesture) {
411 web_user_gesture.reset(new WebScopedUserGesture); 395 web_user_gesture.reset(new WebScopedUserGesture);
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 ModuleSystem::NativesEnabledScope natives_enabled_scope(module_system.get()); 732 ModuleSystem::NativesEnabledScope natives_enabled_scope(module_system.get());
749 733
750 RegisterNativeHandlers(module_system.get(), context); 734 RegisterNativeHandlers(module_system.get(), context);
751 735
752 module_system->RegisterNativeHandler("chrome_hidden", 736 module_system->RegisterNativeHandler("chrome_hidden",
753 scoped_ptr<NativeHandler>(new ChromeHiddenNativeHandler())); 737 scoped_ptr<NativeHandler>(new ChromeHiddenNativeHandler()));
754 module_system->RegisterNativeHandler("print", 738 module_system->RegisterNativeHandler("print",
755 scoped_ptr<NativeHandler>(new PrintNativeHandler())); 739 scoped_ptr<NativeHandler>(new PrintNativeHandler()));
756 module_system->RegisterNativeHandler("lazy_background_page", 740 module_system->RegisterNativeHandler("lazy_background_page",
757 scoped_ptr<NativeHandler>(new LazyBackgroundPageNativeHandler(this))); 741 scoped_ptr<NativeHandler>(new LazyBackgroundPageNativeHandler(this)));
758 module_system->RegisterNativeHandler("channel",
759 scoped_ptr<NativeHandler>(new ChannelNativeHandler(
760 static_cast<chrome::VersionInfo::Channel>(chrome_channel_))));
761 module_system->RegisterNativeHandler("logging", 742 module_system->RegisterNativeHandler("logging",
762 scoped_ptr<NativeHandler>(new LoggingNativeHandler())); 743 scoped_ptr<NativeHandler>(new LoggingNativeHandler()));
763 744
764
765 int manifest_version = extension ? extension->manifest_version() : 1; 745 int manifest_version = extension ? extension->manifest_version() : 1;
766 module_system->RegisterNativeHandler("process", 746 module_system->RegisterNativeHandler("process",
767 scoped_ptr<NativeHandler>(new ProcessInfoNativeHandler( 747 scoped_ptr<NativeHandler>(new ProcessInfoNativeHandler(
768 this, context->GetExtensionID(), 748 this, context->GetExtensionID(),
769 context->GetContextTypeDescription(), 749 context->GetContextTypeDescription(),
770 ChromeRenderProcessObserver::is_incognito_process(), 750 ChromeRenderProcessObserver::is_incognito_process(),
771 manifest_version))); 751 manifest_version)));
772 752
773 GetOrCreateChrome(v8_context); 753 GetOrCreateChrome(v8_context);
774 754
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 // we should abort. 1108 // we should abort.
1129 WebKit::WebFrame* frame = context->web_frame(); 1109 WebKit::WebFrame* frame = context->web_frame();
1130 ExtensionURLInfo url_info(frame->document().securityOrigin(), 1110 ExtensionURLInfo url_info(frame->document().securityOrigin(),
1131 UserScriptSlave::GetDataSourceURLForFrame(frame)); 1111 UserScriptSlave::GetDataSourceURLForFrame(frame));
1132 CHECK(!extensions_.IsSandboxedPage(url_info)); 1112 CHECK(!extensions_.IsSandboxedPage(url_info));
1133 1113
1134 return true; 1114 return true;
1135 } 1115 }
1136 1116
1137 } // namespace extensions 1117 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/dispatcher.h ('k') | chrome/renderer/resources/extensions/schema_generated_bindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698