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

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

Issue 10758025: Add IsEmpty() check to blind IsUndefined() check in ExtensionDispatcher. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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
« 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 (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/extension_dispatcher.h" 5 #include "chrome/renderer/extensions/extension_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 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 module_system->RegisterNativeHandler("lazy_background_page", 687 module_system->RegisterNativeHandler("lazy_background_page",
688 scoped_ptr<NativeHandler>(new LazyBackgroundPageNativeHandler(this))); 688 scoped_ptr<NativeHandler>(new LazyBackgroundPageNativeHandler(this)));
689 module_system->RegisterNativeHandler("channel", 689 module_system->RegisterNativeHandler("channel",
690 scoped_ptr<NativeHandler>(new ChannelNativeHandler( 690 scoped_ptr<NativeHandler>(new ChannelNativeHandler(
691 static_cast<chrome::VersionInfo::Channel>(chrome_channel_)))); 691 static_cast<chrome::VersionInfo::Channel>(chrome_channel_))));
692 // Create the 'chrome' variable if it doesn't already exist. 692 // Create the 'chrome' variable if it doesn't already exist.
693 { 693 {
694 v8::HandleScope handle_scope; 694 v8::HandleScope handle_scope;
695 v8::Handle<v8::String> chrome_string(v8::String::New("chrome")); 695 v8::Handle<v8::String> chrome_string(v8::String::New("chrome"));
696 v8::Handle<v8::Object> global(v8::Context::GetCurrent()->Global()); 696 v8::Handle<v8::Object> global(v8::Context::GetCurrent()->Global());
697 if (global->Get(chrome_string)->IsUndefined()) 697 v8::Handle<v8::Value> chrome(global->Get(chrome_string));
698 if (chrome.IsEmpty() || chrome->IsUndefined())
698 global->Set(chrome_string, v8::Object::New()); 699 global->Set(chrome_string, v8::Object::New());
699 } 700 }
700 701
701 // Loading JavaScript is expensive, so only run the full API bindings 702 // Loading JavaScript is expensive, so only run the full API bindings
702 // generation mechanisms in extension pages (NOT all web pages). 703 // generation mechanisms in extension pages (NOT all web pages).
703 switch (context_type) { 704 switch (context_type) {
704 case Feature::UNSPECIFIED_CONTEXT: 705 case Feature::UNSPECIFIED_CONTEXT:
705 case Feature::WEB_PAGE_CONTEXT: 706 case Feature::WEB_PAGE_CONTEXT:
706 // TODO(kalman): see comment below about ExtensionAPI. 707 // TODO(kalman): see comment below about ExtensionAPI.
707 InstallBindings(module_system.get(), v8_context, "app"); 708 InstallBindings(module_system.get(), v8_context, "app");
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 // APIs, they don't get extension bindings injected. If we end up here it 1031 // APIs, they don't get extension bindings injected. If we end up here it
1031 // means that a sandboxed page somehow managed to invoke an API anyway, so 1032 // means that a sandboxed page somehow managed to invoke an API anyway, so
1032 // we should abort. 1033 // we should abort.
1033 WebKit::WebFrame* frame = context->web_frame(); 1034 WebKit::WebFrame* frame = context->web_frame();
1034 ExtensionURLInfo url_info(frame->document().securityOrigin(), 1035 ExtensionURLInfo url_info(frame->document().securityOrigin(),
1035 UserScriptSlave::GetDataSourceURLForFrame(frame)); 1036 UserScriptSlave::GetDataSourceURLForFrame(frame));
1036 CHECK(!extensions_.IsSandboxedPage(url_info)); 1037 CHECK(!extensions_.IsSandboxedPage(url_info));
1037 1038
1038 return true; 1039 return true;
1039 } 1040 }
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