diff --git a/nw.gypi b/nw.gypi index 5cedde1553..7f1ba04bb3 100644 --- a/nw.gypi +++ b/nw.gypi @@ -37,7 +37,7 @@ '<(DEPTH)/base/base.gyp:base', '<(DEPTH)/base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations', '<(DEPTH)/components/components.gyp:autofill_content_renderer', - '<(DEPTH)/components/components.gyp:browser_context_keyed_service', + '<(DEPTH)/components/components.gyp:keyed_service_content', '<(DEPTH)/content/content.gyp:content_app_browser', '<(DEPTH)/content/content.gyp:content_browser', '<(DEPTH)/content/content.gyp:content_common', @@ -55,11 +55,10 @@ '<(DEPTH)/printing/printing.gyp:printing', '<(DEPTH)/skia/skia.gyp:skia', '<(DEPTH)/third_party/node/node.gyp:node', - '<(DEPTH)/ui/ui.gyp:ui', - '<(DEPTH)/ui/ui.gyp:ui_resources', + '<(DEPTH)/ui/base/ui_base.gyp:ui_base', + '<(DEPTH)/ui/resources/ui_resources.gyp:ui_resources', '<(DEPTH)/url/url.gyp:url_lib', '<(DEPTH)/v8/tools/gyp/v8.gyp:v8', - '<(DEPTH)/webkit/glue/webkit_glue.gyp:glue', '<(DEPTH)/third_party/zlib/zlib.gyp:minizip', '<(DEPTH)/third_party/WebKit/public/blink.gyp:blink', 'nw_resources', @@ -71,6 +70,7 @@ '<(DEPTH)/breakpad/src', '<(SHARED_INTERMEDIATE_DIR)/blink', '<(SHARED_INTERMEDIATE_DIR)/blink/bindings', + '<(SHARED_INTERMEDIATE_DIR)/chrome', ], 'cflags_cc': [ '-Wno-error=c++0x-compat', @@ -83,7 +83,6 @@ #'<(DEPTH)/chrome/common/child_process_logging_posix.cc', #'<(DEPTH)/chrome/common/child_process_logging_win.cc', '<(DEPTH)/chrome/common/crash_keys.cc', - '<(DEPTH)/chrome/common/dump_without_crashing.cc', '<(DEPTH)/chrome/common/env_vars.cc', '<(DEPTH)/chrome/browser/crash_upload_list.cc', '<(DEPTH)/chrome/browser/upload_list.cc', @@ -274,8 +273,8 @@ 'src/nw_version.h', 'src/paths_mac.h', 'src/paths_mac.mm', - 'src/renderer/autofill_agent.cc', - 'src/renderer/autofill_agent.h', + # 'src/renderer/autofill_agent.cc', + # 'src/renderer/autofill_agent.h', 'src/renderer/common/render_messages.cc', 'src/renderer/common/render_messages.h', 'src/renderer/prerenderer/prerenderer_client.cc', @@ -378,7 +377,7 @@ '<(SHARED_INTERMEDIATE_DIR)/webkit', ], 'dependencies': [ - '<(DEPTH)/ui/ui.gyp:ui_resources', + '<(DEPTH)/ui/resources/ui_resources.gyp:ui_resources', '<(DEPTH)/ui/views/controls/webview/webview.gyp:webview', '<(DEPTH)/ui/views/views.gyp:views', '<(DEPTH)/webkit/webkit_resources.gyp:webkit_resources', @@ -532,7 +531,7 @@ 'type': 'none', 'dependencies': [ '<(DEPTH)/content/browser/devtools/devtools_resources.gyp:devtools_resources', - '<(DEPTH)/ui/ui.gyp:ui_resources', + '<(DEPTH)/ui/resources/ui_resources.gyp:ui_resources', 'nw_resources', ], 'variables': { @@ -680,6 +679,10 @@ }, }, }], # OS=="win" + ['OS == "linux"', { + 'ldflags': [ + '-Wl,--whole-archive', 'obj/third_party/node/libnode.a', '-Wl,--no-whole-archive' ], + }], ['OS == "win" or toolkit_uses_gtk == 1', { 'dependencies': [ '<(DEPTH)/sandbox/sandbox.gyp:sandbox', diff --git a/src/api/api_messages.h b/src/api/api_messages.h index 88db56ae0b..e649074172 100644 --- a/src/api/api_messages.h +++ b/src/api/api_messages.h @@ -36,7 +36,7 @@ IPC_STRUCT_TRAITS_END() IPC_MESSAGE_ROUTED3(ShellViewHostMsg_Allocate_Object, int /* object id */, std::string /* type name */, - DictionaryValue /* option */) + base::DictionaryValue /* option */) IPC_MESSAGE_ROUTED1(ShellViewHostMsg_Deallocate_Object, int /* object id */) @@ -45,30 +45,30 @@ IPC_MESSAGE_ROUTED4(ShellViewHostMsg_Call_Object_Method, int /* object id */, std::string /* type name */, std::string /* method name */, - ListValue /* arguments */) + base::ListValue /* arguments */) IPC_SYNC_MESSAGE_ROUTED4_1(ShellViewHostMsg_Call_Object_Method_Sync, int /* object id */, std::string /* type name */, std::string /* method name */, - ListValue /* arguments */, - ListValue /* result */) + base::ListValue /* arguments */, + base::ListValue /* result */) IPC_MESSAGE_ROUTED3(ShellViewHostMsg_Call_Static_Method, std::string /* type name */, std::string /* method name */, - ListValue /* arguments */) + base::ListValue /* arguments */) IPC_SYNC_MESSAGE_ROUTED3_1(ShellViewHostMsg_Call_Static_Method_Sync, std::string /* type name */, std::string /* method name */, - ListValue /* arguments */, - ListValue /* result */) + base::ListValue /* arguments */, + base::ListValue /* result */) IPC_MESSAGE_ROUTED3(ShellViewMsg_Object_On_Event, int /* object id */, std::string /* event name */, - ListValue /* arguments */) + base::ListValue /* arguments */) // Request Shell's id for current render_view_host. IPC_SYNC_MESSAGE_ROUTED0_1(ShellViewHostMsg_GetShellId, @@ -77,7 +77,7 @@ IPC_SYNC_MESSAGE_ROUTED0_1(ShellViewHostMsg_GetShellId, // Create a Shell and returns its routing id. IPC_SYNC_MESSAGE_ROUTED2_1(ShellViewHostMsg_CreateShell, std::string /* url */, - DictionaryValue /* manifest */, + base::DictionaryValue /* manifest */, int /* result */) // Tell browser we have an uncaughtException from node. diff --git a/src/api/bindings_common.cc b/src/api/bindings_common.cc index be1e1c74c7..48db9777e7 100644 --- a/src/api/bindings_common.cc +++ b/src/api/bindings_common.cc @@ -33,8 +33,8 @@ using content::RenderView; using content::RenderThread; using content::V8ValueConverter; -using WebKit::WebFrame; -using WebKit::WebView; +using blink::WebFrame; +using blink::WebView; namespace { RenderView* GetRenderView(v8::Handle ctx) { @@ -53,12 +53,14 @@ RenderView* GetRenderView(v8::Handle ctx) { } RenderView* GetCurrentRenderView() { - v8::Local ctx = v8::Context::GetCurrent(); + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + v8::Local ctx = isolate->GetCurrentContext(); return GetRenderView(ctx); } RenderView* GetEnteredRenderView() { - v8::Local ctx = v8::Context::GetEntered(); + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + v8::Local ctx = isolate->GetEnteredContext(); return GetRenderView(ctx); } @@ -69,29 +71,31 @@ base::StringPiece GetStringResource(int resource_id) { namespace remote { v8::Handle AllocateId(int routing_id) { - v8::HandleScope scope; + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + v8::EscapableHandleScope scope(isolate); int result = 0; RenderThread::Get()->Send(new ShellViewHostMsg_AllocateId( routing_id, &result)); - return scope.Close(v8::Integer::New(result)); + return scope.Escape(v8::Integer::New(isolate, result)); } v8::Handle AllocateObject(int routing_id, int object_id, const std::string& type, v8::Handle options) { - v8::HandleScope handle_scope; + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + v8::EscapableHandleScope handle_scope(isolate); scoped_ptr converter(V8ValueConverter::create()); converter->SetStripNullFromObjects(true); scoped_ptr value_option( - converter->FromV8Value(options, v8::Context::GetCurrent())); + converter->FromV8Value(options, isolate->GetCurrentContext())); if (!value_option.get() || !value_option->IsType(base::Value::TYPE_DICTIONARY)) - return v8::ThrowException(v8::Exception::Error(v8::String::New( + return isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, "Unable to convert 'option' passed to AllocateObject"))); DVLOG(1) << "remote::AllocateObject(routing_id=" << routing_id << ", object_id=" << object_id << ")"; @@ -101,14 +105,15 @@ v8::Handle AllocateObject(int routing_id, object_id, type, *static_cast(value_option.get()))); - return v8::Undefined(); + return v8::Undefined(isolate); } v8::Handle DeallocateObject(int routing_id, int object_id) { RenderThread::Get()->Send(new ShellViewHostMsg_Deallocate_Object( routing_id, object_id)); - return v8::Undefined(); + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + return v8::Undefined(isolate); } v8::Handle CallObjectMethod(int routing_id, @@ -116,13 +121,14 @@ v8::Handle CallObjectMethod(int routing_id, const std::string& type, const std::string& method, v8::Handle args) { + v8::Isolate* isolate = v8::Isolate::GetCurrent(); scoped_ptr converter(V8ValueConverter::create()); scoped_ptr value_args( - converter->FromV8Value(args, v8::Context::GetCurrent())); + converter->FromV8Value(args, isolate->GetCurrentContext())); if (!value_args.get() || !value_args->IsType(base::Value::TYPE_LIST)) - return v8::ThrowException(v8::Exception::Error(v8::String::New( + return isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, "Unable to convert 'args' passed to CallObjectMethod"))); RenderThread::Get()->Send(new ShellViewHostMsg_Call_Object_Method( @@ -131,7 +137,7 @@ v8::Handle CallObjectMethod(int routing_id, type, method, *static_cast(value_args.get()))); - return v8::Undefined(); + return v8::Undefined(isolate); } v8::Handle CallObjectMethodSync(int routing_id, @@ -139,13 +145,14 @@ v8::Handle CallObjectMethodSync(int routing_id, const std::string& type, const std::string& method, v8::Handle args) { + v8::Isolate* isolate = v8::Isolate::GetCurrent(); scoped_ptr converter(V8ValueConverter::create()); scoped_ptr value_args( - converter->FromV8Value(args, v8::Context::GetCurrent())); + converter->FromV8Value(args, isolate->GetCurrentContext())); if (!value_args.get() || !value_args->IsType(base::Value::TYPE_LIST)) - return v8::ThrowException(v8::Exception::Error(v8::String::New( + return isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, "Unable to convert 'args' passed to CallObjectMethodSync"))); base::ListValue result; @@ -156,7 +163,7 @@ v8::Handle CallObjectMethodSync(int routing_id, method, *static_cast(value_args.get()), &result)); - return converter->ToV8Value(&result, v8::Context::GetCurrent()); + return converter->ToV8Value(&result, isolate->GetCurrentContext()); } } // namespace remote diff --git a/src/api/clipboard/clipboard.cc b/src/api/clipboard/clipboard.cc index 03ccd2d070..1102bbe0b3 100644 --- a/src/api/clipboard/clipboard.cc +++ b/src/api/clipboard/clipboard.cc @@ -73,7 +73,7 @@ void Clipboard::SetText(std::string& text) { std::string Clipboard::GetText() { ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); - string16 text; + base::string16 text; clipboard->ReadText(ui::CLIPBOARD_TYPE_COPY_PASTE, &text); return UTF16ToUTF8(text); } diff --git a/src/api/dispatcher.cc b/src/api/dispatcher.cc index 1e411a00b2..7722148fb3 100644 --- a/src/api/dispatcher.cc +++ b/src/api/dispatcher.cc @@ -35,6 +35,8 @@ #undef LOG #undef ASSERT +#undef FROM_HERE + #if defined(OS_WIN) #define _USE_MATH_DEFINES #include @@ -47,7 +49,8 @@ namespace nwapi { static inline v8::Local v8_str(const char* x) { - return v8::String::New(x); + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + return v8::String::NewFromUtf8(isolate, x); } Dispatcher::Dispatcher(content::RenderView* render_view) @@ -67,8 +70,8 @@ bool Dispatcher::OnMessageReceived(const IPC::Message& message) { return handled; } -void Dispatcher::DraggableRegionsChanged(WebKit::WebFrame* frame) { - WebKit::WebVector webregions = +void Dispatcher::DraggableRegionsChanged(blink::WebFrame* frame) { + blink::WebVector webregions = frame->document().draggableRegions(); std::vector regions; for (size_t i = 0; i < webregions.size(); ++i) { @@ -83,8 +86,9 @@ void Dispatcher::DraggableRegionsChanged(WebKit::WebFrame* frame) { void Dispatcher::OnEvent(int object_id, std::string event, const base::ListValue& arguments) { - v8::HandleScope scope; - WebKit::WebView* web_view = render_view()->GetWebView(); + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + v8::HandleScope scope(isolate); + blink::WebView* web_view = render_view()->GetWebView(); if (web_view == NULL) return; @@ -92,36 +96,40 @@ void Dispatcher::OnEvent(int object_id, content::V8ValueConverterImpl converter; v8::Local context = - v8::Local::New(node::g_context->GetIsolate(), node::g_context); + v8::Local::New(isolate, node::g_context); v8::Handle args = converter.ToV8Value(&arguments, context); DCHECK(!args.IsEmpty()) << "Invalid 'arguments' in Dispatcher::OnEvent"; v8::Handle argv[] = { - v8::Integer::New(object_id), v8_str(event.c_str()), args }; + v8::Integer::New(isolate, object_id), v8_str(event.c_str()), args }; // __nwObjectsRegistry.handleEvent(object_id, event, arguments); v8::Handle val = - node::g_context->Global()->Get(v8_str("__nwObjectsRegistry")); + context->Global()->Get(v8_str("__nwObjectsRegistry")); if (val->IsNull() || val->IsUndefined()) return; // need to find out why it's undefined here in debugger v8::Handle objects_registry = val->ToObject(); DVLOG(1) << "handleEvent(object_id=" << object_id << ", event=\"" << event << "\")"; - node::MakeCallback(objects_registry, "handleEvent", 3, argv); + node::MakeCallback(isolate, objects_registry, "handleEvent", 3, argv); } v8::Handle Dispatcher::GetObjectRegistry() { + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + v8::HandleScope scope(isolate); + v8::Local context = + v8::Local::New(isolate, node::g_context); // need to enter node context to access the registry in // some cases, e.g. normal frame in #1519 - node::g_context->Enter(); + context->Enter(); v8::Handle registry = - node::g_context->Global()->Get(v8_str("__nwObjectsRegistry")); - node::g_context->Exit(); + context->Global()->Get(v8_str("__nwObjectsRegistry")); + context->Exit(); // if (registry->IsNull() || registry->IsUndefined()) // return v8::Undefined(); return registry->ToObject(); } -v8::Handle Dispatcher::GetWindowId(WebKit::WebFrame* frame) { +v8::Handle Dispatcher::GetWindowId(blink::WebFrame* frame) { v8::Handle v8win = frame->mainWorldScriptContext()->Global(); v8::Handle val = v8win->ToObject()->Get(v8_str("__nwWindowId")); @@ -129,7 +137,8 @@ v8::Handle Dispatcher::GetWindowId(WebKit::WebFrame* frame) { } void Dispatcher::ZoomLevelChanged() { - WebKit::WebView* web_view = render_view()->GetWebView(); + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + blink::WebView* web_view = render_view()->GetWebView(); float zoom_level = web_view->zoomLevel(); v8::Handle val = GetWindowId(web_view->mainFrame()); @@ -141,23 +150,24 @@ void Dispatcher::ZoomLevelChanged() { if (objects_registry->IsUndefined()) return; - v8::Local args = v8::Array::New(); - args->Set(0, v8::Number::New(zoom_level)); + v8::Local args = v8::Array::New(isolate); + args->Set(0, v8::Number::New(isolate, zoom_level)); v8::Handle argv[] = {val, v8_str("zoom"), args }; - node::MakeCallback(objects_registry, "handleEvent", 3, argv); + node::MakeCallback(isolate, objects_registry, "handleEvent", 3, argv); } -void Dispatcher::DidCreateDocumentElement(WebKit::WebFrame* frame) { +void Dispatcher::DidCreateDocumentElement(blink::WebFrame* frame) { documentCallback("document-start", frame); } -void Dispatcher::DidFinishDocumentLoad(WebKit::WebFrame* frame) { +void Dispatcher::DidFinishDocumentLoad(blink::WebFrame* frame) { documentCallback("document-end", frame); } -void Dispatcher::documentCallback(const char* ev, WebKit::WebFrame* frame) { - WebKit::WebView* web_view = render_view()->GetWebView(); +void Dispatcher::documentCallback(const char* ev, blink::WebFrame* frame) { + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + blink::WebView* web_view = render_view()->GetWebView(); if (!web_view) return; @@ -171,9 +181,9 @@ void Dispatcher::documentCallback(const char* ev, WebKit::WebFrame* frame) { if (objects_registry->IsUndefined()) return; - v8::Local args = v8::Array::New(); - v8::Handle element = v8::Null(); - WebCore::Frame* core_frame = WebKit::toWebFrameImpl(frame)->frame(); + v8::Local args = v8::Array::New(isolate); + v8::Handle element = v8::Null(isolate); + WebCore::LocalFrame* core_frame = blink::toWebFrameImpl(frame)->frame(); if (core_frame->ownerElement()) { element = WebCore::toV8((WebCore::HTMLElement*)core_frame->ownerElement(), frame->mainWorldScriptContext()->Global(), @@ -182,20 +192,21 @@ void Dispatcher::documentCallback(const char* ev, WebKit::WebFrame* frame) { args->Set(0, element); v8::Handle argv[] = {val, v8_str(ev), args }; - node::MakeCallback(objects_registry, "handleEvent", 3, argv); + node::MakeCallback(isolate, objects_registry, "handleEvent", 3, argv); } void Dispatcher::willHandleNavigationPolicy( content::RenderView* rv, - WebKit::WebFrame* frame, - const WebKit::WebURLRequest& request, - WebKit::WebNavigationPolicy* policy) { + blink::WebFrame* frame, + const blink::WebURLRequest& request, + blink::WebNavigationPolicy* policy) { - WebKit::WebView* web_view = rv->GetWebView(); + blink::WebView* web_view = rv->GetWebView(); if (!web_view) return; + v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::Context::Scope cscope (web_view->mainFrame()->mainWorldScriptContext()); v8::Handle id_val = nwapi::Dispatcher::GetWindowId(web_view->mainFrame()); @@ -206,11 +217,11 @@ void Dispatcher::willHandleNavigationPolicy( if (objects_registry->IsUndefined()) return; - v8::Local args = v8::Array::New(); - v8::Handle element = v8::Null(); - v8::Handle policy_obj = v8::Object::New(); + v8::Local args = v8::Array::New(isolate); + v8::Handle element = v8::Null(isolate); + v8::Handle policy_obj = v8::Object::New(isolate); - WebCore::Frame* core_frame = WebKit::toWebFrameImpl(frame)->frame(); + WebCore::LocalFrame* core_frame = blink::toWebFrameImpl(frame)->frame(); if (core_frame->ownerElement()) { element = WebCore::toV8((WebCore::HTMLElement*)core_frame->ownerElement(), frame->mainWorldScriptContext()->Global(), @@ -222,21 +233,21 @@ void Dispatcher::willHandleNavigationPolicy( v8::Handle argv[] = {id_val, v8_str("new-win-policy"), args }; - node::MakeCallback(objects_registry, "handleEvent", 3, argv); + node::MakeCallback(isolate, objects_registry, "handleEvent", 3, argv); v8::Local val = policy_obj->Get(v8_str("val")); if (!val->IsString()) return; v8::String::Utf8Value policy_str(val); if (!strcmp(*policy_str, "ignore")) - *policy = WebKit::WebNavigationPolicyIgnore; + *policy = blink::WebNavigationPolicyIgnore; else if (!strcmp(*policy_str, "download")) - *policy = WebKit::WebNavigationPolicyDownload; + *policy = blink::WebNavigationPolicyDownload; else if (!strcmp(*policy_str, "current")) - *policy = WebKit::WebNavigationPolicyCurrentTab; + *policy = blink::WebNavigationPolicyCurrentTab; else if (!strcmp(*policy_str, "new-window")) - *policy = WebKit::WebNavigationPolicyNewWindow; + *policy = blink::WebNavigationPolicyNewWindow; else if (!strcmp(*policy_str, "new-popup")) - *policy = WebKit::WebNavigationPolicyNewPopup; + *policy = blink::WebNavigationPolicyNewPopup; } } // namespace nwapi diff --git a/src/api/dispatcher.h b/src/api/dispatcher.h index 4a59932d57..51be736156 100644 --- a/src/api/dispatcher.h +++ b/src/api/dispatcher.h @@ -34,7 +34,7 @@ namespace content { class RenderView; } -namespace WebKit { +namespace blink { class WebFrame; class WebURLRequest; } @@ -47,22 +47,22 @@ class Dispatcher : public content::RenderViewObserver { virtual ~Dispatcher(); static v8::Handle GetObjectRegistry(); - static v8::Handle GetWindowId(WebKit::WebFrame* frame); + static v8::Handle GetWindowId(blink::WebFrame* frame); static void willHandleNavigationPolicy( content::RenderView* rv, - WebKit::WebFrame* frame, - const WebKit::WebURLRequest& request, - WebKit::WebNavigationPolicy* policy); + blink::WebFrame* frame, + const blink::WebURLRequest& request, + blink::WebNavigationPolicy* policy); private: // RenderViewObserver implementation. virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; - virtual void DraggableRegionsChanged(WebKit::WebFrame* frame) OVERRIDE; + virtual void DraggableRegionsChanged(blink::WebFrame* frame) OVERRIDE; virtual void ZoomLevelChanged() OVERRIDE; - virtual void DidFinishDocumentLoad(WebKit::WebFrame* frame) OVERRIDE; - virtual void DidCreateDocumentElement(WebKit::WebFrame* frame) OVERRIDE; + virtual void DidFinishDocumentLoad(blink::WebFrame* frame) OVERRIDE; + virtual void DidCreateDocumentElement(blink::WebFrame* frame) OVERRIDE; - void documentCallback(const char* ev, WebKit::WebFrame* frame); + void documentCallback(const char* ev, blink::WebFrame* frame); void OnEvent(int object_id, std::string event, diff --git a/src/api/dispatcher_bindings.cc b/src/api/dispatcher_bindings.cc index 84697ce400..60858ba777 100644 --- a/src/api/dispatcher_bindings.cc +++ b/src/api/dispatcher_bindings.cc @@ -43,11 +43,12 @@ namespace nwapi { namespace { v8::Handle WrapSource(v8::Handle source) { - v8::HandleScope handle_scope; + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + v8::EscapableHandleScope handle_scope(isolate); v8::Handle left = - v8::String::New("(function(nw, exports) {"); - v8::Handle right = v8::String::New("\n})"); - return handle_scope.Close( + v8::String::NewFromUtf8(isolate, "(function(nw, exports) {"); + v8::Handle right = v8::String::NewFromUtf8(isolate, "\n})"); + return handle_scope.Escape( v8::String::Concat(left, v8::String::Concat(source, right))); } @@ -56,14 +57,15 @@ void RequireFromResource(v8::Handle root, v8::Handle gui, v8::Handle name, int resource_id) { - v8::HandleScope scope; + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + v8::HandleScope handle_scope(isolate); - v8::Handle source = v8::String::NewExternal( + v8::Handle source = v8::String::NewExternal(isolate, new StaticV8ExternalAsciiStringResource( GetStringResource(resource_id))); v8::Handle wrapped_source = WrapSource(source); - v8::Handle script(v8::Script::New(wrapped_source, name)); + v8::Handle script(v8::Script::Compile(wrapped_source, name)); v8::Handle func = v8::Handle::Cast(script->Run()); v8::Handle args[] = { root, gui }; func->Call(root, 2, args); @@ -73,7 +75,7 @@ bool MakePathAbsolute(FilePath* file_path) { DCHECK(file_path); FilePath current_directory; - if (!file_util::GetCurrentDirectory(¤t_directory)) + if (!base::GetCurrentDirectory(¤t_directory)) return false; if (file_path->IsAbsolute()) @@ -107,121 +109,128 @@ DispatcherBindings::~DispatcherBindings() { } v8::Handle -DispatcherBindings::GetNativeFunction(v8::Handle name) { - if (name->Equals(v8::String::New("RequireNwGui"))) - return v8::FunctionTemplate::New(RequireNwGui); - else if (name->Equals(v8::String::New("GetAbsolutePath"))) - return v8::FunctionTemplate::New(GetAbsolutePath); - else if (name->Equals(v8::String::New("GetShellIdForCurrentContext"))) - return v8::FunctionTemplate::New(GetShellIdForCurrentContext); - else if (name->Equals(v8::String::New("GetRoutingIDForCurrentContext"))) - return v8::FunctionTemplate::New(GetRoutingIDForCurrentContext); - else if (name->Equals(v8::String::New("CreateShell"))) - return v8::FunctionTemplate::New(CreateShell); - else if (name->Equals(v8::String::New("AllocateObject"))) - return v8::FunctionTemplate::New(AllocateObject); - else if (name->Equals(v8::String::New("DeallocateObject"))) - return v8::FunctionTemplate::New(DeallocateObject); - else if (name->Equals(v8::String::New("CallObjectMethod"))) - return v8::FunctionTemplate::New(CallObjectMethod); - else if (name->Equals(v8::String::New("CallObjectMethodSync"))) - return v8::FunctionTemplate::New(CallObjectMethodSync); - else if (name->Equals(v8::String::New("CallStaticMethod"))) - return v8::FunctionTemplate::New(CallStaticMethod); - else if (name->Equals(v8::String::New("CallStaticMethodSync"))) - return v8::FunctionTemplate::New(CallStaticMethodSync); - else if (name->Equals(v8::String::New("CrashRenderer"))) - return v8::FunctionTemplate::New(CrashRenderer); - else if (name->Equals(v8::String::New("SetCrashDumpDir"))) - return v8::FunctionTemplate::New(SetCrashDumpDir); - else if (name->Equals(v8::String::New("AllocateId"))) - return v8::FunctionTemplate::New(AllocateId); +DispatcherBindings::GetNativeFunctionTemplate( + v8::Isolate* isolate, + v8::Handle name) { + if (name->Equals(v8::String::NewFromUtf8(isolate, "RequireNwGui"))) + return v8::FunctionTemplate::New(isolate, RequireNwGui); + else if (name->Equals(v8::String::NewFromUtf8(isolate, "GetAbsolutePath"))) + return v8::FunctionTemplate::New(isolate, GetAbsolutePath); + else if (name->Equals(v8::String::NewFromUtf8(isolate, "GetShellIdForCurrentContext"))) + return v8::FunctionTemplate::New(isolate, GetShellIdForCurrentContext); + else if (name->Equals(v8::String::NewFromUtf8(isolate, "GetRoutingIDForCurrentContext"))) + return v8::FunctionTemplate::New(isolate, GetRoutingIDForCurrentContext); + else if (name->Equals(v8::String::NewFromUtf8(isolate, "CreateShell"))) + return v8::FunctionTemplate::New(isolate, CreateShell); + else if (name->Equals(v8::String::NewFromUtf8(isolate, "AllocateObject"))) + return v8::FunctionTemplate::New(isolate, AllocateObject); + else if (name->Equals(v8::String::NewFromUtf8(isolate, "DeallocateObject"))) + return v8::FunctionTemplate::New(isolate, DeallocateObject); + else if (name->Equals(v8::String::NewFromUtf8(isolate, "CallObjectMethod"))) + return v8::FunctionTemplate::New(isolate, CallObjectMethod); + else if (name->Equals(v8::String::NewFromUtf8(isolate, "CallObjectMethodSync"))) + return v8::FunctionTemplate::New(isolate, CallObjectMethodSync); + else if (name->Equals(v8::String::NewFromUtf8(isolate, "CallStaticMethod"))) + return v8::FunctionTemplate::New(isolate, CallStaticMethod); + else if (name->Equals(v8::String::NewFromUtf8(isolate, "CallStaticMethodSync"))) + return v8::FunctionTemplate::New(isolate, CallStaticMethodSync); + else if (name->Equals(v8::String::NewFromUtf8(isolate, "CrashRenderer"))) + return v8::FunctionTemplate::New(isolate, CrashRenderer); + else if (name->Equals(v8::String::NewFromUtf8(isolate, "SetCrashDumpDir"))) + return v8::FunctionTemplate::New(isolate, SetCrashDumpDir); + else if (name->Equals(v8::String::NewFromUtf8(isolate, "AllocateId"))) + return v8::FunctionTemplate::New(isolate, AllocateId); NOTREACHED() << "Trying to get an non-exist function in DispatcherBindings:" << *v8::String::Utf8Value(name); - return v8::FunctionTemplate::New(); + return v8::FunctionTemplate::New(isolate); } // static void DispatcherBindings::RequireNwGui(const v8::FunctionCallbackInfo& args) { - v8::HandleScope scope; + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + v8::EscapableHandleScope handle_scope(isolate); // Initialize lazily - v8::Local NwGuiSymbol = v8::String::NewSymbol("nwGui"); + v8::Local NwGuiSymbol = v8::String::NewFromUtf8(isolate, "nwGui", v8::String::kInternalizedString); v8::Local NwGuiHidden = args.This()->Get(NwGuiSymbol); if (NwGuiHidden->IsObject()) { - args.GetReturnValue().Set(scope.Close(NwGuiHidden)); + args.GetReturnValue().Set(handle_scope.Escape(NwGuiHidden)); return; } - v8::Local NwGui = v8::Object::New(); + v8::Local NwGui = v8::Object::New(isolate); args.This()->Set(NwGuiSymbol, NwGui); RequireFromResource(args.This(), - NwGui, v8::String::New("base.js"), IDR_NW_API_BASE_JS); + NwGui, v8::String::NewFromUtf8(isolate, "base.js"), IDR_NW_API_BASE_JS); RequireFromResource(args.This(), - NwGui, v8::String::New("menuitem.js"), IDR_NW_API_MENUITEM_JS); + NwGui, v8::String::NewFromUtf8(isolate, "menuitem.js"), IDR_NW_API_MENUITEM_JS); RequireFromResource(args.This(), - NwGui, v8::String::New("menu.js"), IDR_NW_API_MENU_JS); + NwGui, v8::String::NewFromUtf8(isolate, "menu.js"), IDR_NW_API_MENU_JS); RequireFromResource(args.This(), - NwGui, v8::String::New("tray.js"), IDR_NW_API_TRAY_JS); + NwGui, v8::String::NewFromUtf8(isolate, "tray.js"), IDR_NW_API_TRAY_JS); RequireFromResource(args.This(), - NwGui, v8::String::New("clipboard.js"), IDR_NW_API_CLIPBOARD_JS); + NwGui, v8::String::NewFromUtf8(isolate, "clipboard.js"), IDR_NW_API_CLIPBOARD_JS); RequireFromResource(args.This(), - NwGui, v8::String::New("window.js"), IDR_NW_API_WINDOW_JS); + NwGui, v8::String::NewFromUtf8(isolate, "window.js"), IDR_NW_API_WINDOW_JS); RequireFromResource(args.This(), - NwGui, v8::String::New("shell.js"), IDR_NW_API_SHELL_JS); + NwGui, v8::String::NewFromUtf8(isolate, "shell.js"), IDR_NW_API_SHELL_JS); RequireFromResource(args.This(), - NwGui, v8::String::New("app.js"), IDR_NW_API_APP_JS); + NwGui, v8::String::NewFromUtf8(isolate, "app.js"), IDR_NW_API_APP_JS); - args.GetReturnValue().Set(scope.Close(NwGui)); + args.GetReturnValue().Set(handle_scope.Escape(NwGui)); } // static void DispatcherBindings::GetAbsolutePath(const v8::FunctionCallbackInfo& args) { + v8::Isolate* isolate = v8::Isolate::GetCurrent(); FilePath path = FilePath::FromUTF8Unsafe(*v8::String::Utf8Value(args[0])); MakePathAbsolute(&path); #if defined(OS_POSIX) - args.GetReturnValue().Set(v8::String::New(path.value().c_str())); + args.GetReturnValue().Set(v8::String::NewFromUtf8(isolate, path.value().c_str())); #else - args.GetReturnValue().Set(v8::String::New(path.AsUTF8Unsafe().c_str())); + args.GetReturnValue().Set(v8::String::NewFromUtf8(isolate, path.AsUTF8Unsafe().c_str())); #endif } // static void DispatcherBindings::GetShellIdForCurrentContext(const v8::FunctionCallbackInfo& args) { + v8::Isolate* isolate = v8::Isolate::GetCurrent(); RenderView* render_view = GetCurrentRenderView(); if (!render_view) { - args.GetReturnValue().Set(v8::ThrowException(v8::Exception::Error(v8::String::New( + args.GetReturnValue().Set(isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, "Unable to get render view in CallStaticMethodSync")))); return; } int id = -1; render_view->Send(new ShellViewHostMsg_GetShellId(MSG_ROUTING_NONE, &id)); - args.GetReturnValue().Set(v8::Integer::New(id)); + args.GetReturnValue().Set(v8::Integer::New(isolate, id)); } // static void DispatcherBindings::GetRoutingIDForCurrentContext(const v8::FunctionCallbackInfo& args) { + v8::Isolate* isolate = v8::Isolate::GetCurrent(); RenderView* render_view = GetCurrentRenderView(); if (!render_view) { - args.GetReturnValue().Set(v8::ThrowException(v8::Exception::Error(v8::String::New( + args.GetReturnValue().Set(isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, "Unable to get render view in GetRoutingIDForCurrentContext")))); return; } - args.GetReturnValue().Set(v8::Integer::New(render_view->GetRoutingID())); + args.GetReturnValue().Set(v8::Integer::New(isolate, render_view->GetRoutingID())); } // static void DispatcherBindings::CreateShell(const v8::FunctionCallbackInfo& args) { + v8::Isolate* isolate = v8::Isolate::GetCurrent(); if (args.Length() < 2) { - args.GetReturnValue().Set(v8::ThrowException(v8::Exception::Error(v8::String::New( + args.GetReturnValue().Set(isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, "CreateShell requries 2 arguments")))); return; } @@ -231,17 +240,17 @@ DispatcherBindings::CreateShell(const v8::FunctionCallbackInfo& args) scoped_ptr converter(V8ValueConverter::create()); scoped_ptr value_manifest( - converter->FromV8Value(args[1], v8::Context::GetCurrent())); + converter->FromV8Value(args[1], isolate->GetCurrentContext())); if (!value_manifest.get() || !value_manifest->IsType(base::Value::TYPE_DICTIONARY)) { - args.GetReturnValue().Set(v8::ThrowException(v8::Exception::Error(v8::String::New( + args.GetReturnValue().Set(isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, "Unable to convert 'options' passed to CreateShell")))); return; } RenderView* render_view = GetCurrentRenderView(); if (!render_view) { - args.GetReturnValue().Set(v8::ThrowException(v8::Exception::Error(v8::String::New( + args.GetReturnValue().Set(isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, "Unable to get render view in CreateShell")))); return; } @@ -253,15 +262,16 @@ DispatcherBindings::CreateShell(const v8::FunctionCallbackInfo& args) *static_cast(value_manifest.get()), &routing_id)); - args.GetReturnValue().Set(v8::Integer::New(routing_id)); + args.GetReturnValue().Set(v8::Integer::New(isolate, routing_id)); } // static void DispatcherBindings::AllocateId(const v8::FunctionCallbackInfo& args) { + v8::Isolate* isolate = v8::Isolate::GetCurrent(); RenderView* render_view = GetCurrentRenderView(); if (!render_view) { - args.GetReturnValue().Set(v8::ThrowException(v8::Exception::Error(v8::String::New( + args.GetReturnValue().Set(isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, "Unable to get render view in AllocateId")))); return; } @@ -271,8 +281,9 @@ DispatcherBindings::AllocateId(const v8::FunctionCallbackInfo& args) void DispatcherBindings::AllocateObject(const v8::FunctionCallbackInfo& args) { + v8::Isolate* isolate = v8::Isolate::GetCurrent(); if (args.Length() < 3) { - args.GetReturnValue().Set(v8::ThrowException(v8::Exception::Error(v8::String::New( + args.GetReturnValue().Set(isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, "AllocateObject requries 3 arguments")))); return; } @@ -282,7 +293,7 @@ DispatcherBindings::AllocateObject(const v8::FunctionCallbackInfo& ar RenderView* render_view = GetCurrentRenderView(); if (!render_view) { - args.GetReturnValue().Set(v8::ThrowException(v8::Exception::Error(v8::String::New( + args.GetReturnValue().Set(isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, "Unable to get render view in AllocateObject")))); return; } @@ -293,15 +304,16 @@ DispatcherBindings::AllocateObject(const v8::FunctionCallbackInfo& ar // static void DispatcherBindings::DeallocateObject(const v8::FunctionCallbackInfo& args) { + v8::Isolate* isolate = v8::Isolate::GetCurrent(); RenderView* render_view = GetCurrentRenderView(); if (!render_view) { - args.GetReturnValue().Set(v8::ThrowException(v8::Exception::Error(v8::String::New( + args.GetReturnValue().Set(isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, "Unable to get render view in DeallocateObject")))); return; } if (args.Length() < 1) { - args.GetReturnValue().Set(v8::ThrowException(v8::Exception::Error(v8::String::New( + args.GetReturnValue().Set(isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, "DeallocateObject requries 1 arguments")))); return; } @@ -311,8 +323,9 @@ DispatcherBindings::DeallocateObject(const v8::FunctionCallbackInfo& // static void DispatcherBindings::CallObjectMethod(const v8::FunctionCallbackInfo& args) { + v8::Isolate* isolate = v8::Isolate::GetCurrent(); if (args.Length() < 4) { - args.GetReturnValue().Set(v8::ThrowException(v8::Exception::Error(v8::String::New( + args.GetReturnValue().Set(isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, "CallObjectMethod requries 4 arguments")))); return; } @@ -325,7 +338,7 @@ DispatcherBindings::CallObjectMethod(const v8::FunctionCallbackInfo& if (!render_view) render_view = GetEnteredRenderView(); if (!render_view) { - args.GetReturnValue().Set(v8::ThrowException(v8::Exception::Error(v8::String::New( + args.GetReturnValue().Set(isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, "Unable to get render view in CallObjectMethod")))); return; } @@ -336,8 +349,9 @@ DispatcherBindings::CallObjectMethod(const v8::FunctionCallbackInfo& // static void DispatcherBindings::CallObjectMethodSync( const v8::FunctionCallbackInfo& args) { + v8::Isolate* isolate = v8::Isolate::GetCurrent(); if (args.Length() < 4) { - args.GetReturnValue().Set(v8::ThrowException(v8::Exception::Error(v8::String::New( + args.GetReturnValue().Set(isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, "CallObjectMethodSync requries 4 arguments")))); return; } @@ -348,7 +362,7 @@ void DispatcherBindings::CallObjectMethodSync( RenderView* render_view = GetCurrentRenderView(); if (!render_view) { - args.GetReturnValue().Set(v8::ThrowException(v8::Exception::Error(v8::String::New( + args.GetReturnValue().Set(isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, "Unable to get render view in CallObjectMethod")))); return; } @@ -359,8 +373,9 @@ void DispatcherBindings::CallObjectMethodSync( // static void DispatcherBindings::CallStaticMethod( const v8::FunctionCallbackInfo& args) { + v8::Isolate* isolate = v8::Isolate::GetCurrent(); if (args.Length() < 3) { - args.GetReturnValue().Set(v8::ThrowException(v8::Exception::Error(v8::String::New( + args.GetReturnValue().Set(isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, "CallStaticMethod requries 3 arguments")))); return; } @@ -371,17 +386,17 @@ void DispatcherBindings::CallStaticMethod( scoped_ptr converter(V8ValueConverter::create()); scoped_ptr value_args( - converter->FromV8Value(args[2], v8::Context::GetCurrent())); + converter->FromV8Value(args[2], isolate->GetCurrentContext())); if (!value_args.get() || !value_args->IsType(base::Value::TYPE_LIST)) { - args.GetReturnValue().Set(v8::ThrowException(v8::Exception::Error(v8::String::New( + args.GetReturnValue().Set(isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, "Unable to convert 'args' passed to CallStaticMethod")))); return; } RenderView* render_view = GetCurrentRenderView(); if (!render_view) { - args.GetReturnValue().Set(v8::ThrowException(v8::Exception::Error(v8::String::New( + args.GetReturnValue().Set(isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, "Unable to get render view in CallStaticMethod")))); return; } @@ -391,7 +406,7 @@ void DispatcherBindings::CallStaticMethod( type, method, *static_cast(value_args.get()))); - args.GetReturnValue().Set(v8::Undefined()); + args.GetReturnValue().Set(v8::Undefined(isolate)); } // static @@ -413,8 +428,9 @@ void DispatcherBindings::SetCrashDumpDir( // static void DispatcherBindings::CallStaticMethodSync( const v8::FunctionCallbackInfo& args) { + v8::Isolate* isolate = v8::Isolate::GetCurrent(); if (args.Length() < 3) { - args.GetReturnValue().Set(v8::ThrowException(v8::Exception::Error(v8::String::New( + args.GetReturnValue().Set(isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, "CallStaticMethodSync requries 3 arguments")))); return; } @@ -426,7 +442,7 @@ void DispatcherBindings::CallStaticMethodSync( RenderView* render_view = GetEnteredRenderView(); if (!render_view) { - args.GetReturnValue().Set(v8::ThrowException(v8::Exception::Error(v8::String::New( + args.GetReturnValue().Set(isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, "Unable to get render view in CallStaticMethodSync")))); return; } @@ -435,25 +451,25 @@ void DispatcherBindings::CallStaticMethodSync( std::string url = *v8::String::Utf8Value(args[2]); GURL gurl(url); if (!gurl.is_valid()) { - args.GetReturnValue().Set(v8::ThrowException(v8::Exception::Error(v8::String::New( + args.GetReturnValue().Set(isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, "Invalid URL passed to App.getProxyForURL()")))); return; } std::string proxy; bool result = content::RenderThread::Get()->ResolveProxy(gurl, &proxy); if (!result) { - args.GetReturnValue().Set(v8::Undefined()); + args.GetReturnValue().Set(v8::Undefined(isolate)); return; } - args.GetReturnValue().Set(v8::String::New(proxy.c_str())); + args.GetReturnValue().Set(v8::String::NewFromUtf8(isolate, proxy.c_str())); return; } scoped_ptr value_args( - converter->FromV8Value(args[2], v8::Context::GetCurrent())); + converter->FromV8Value(args[2], isolate->GetCurrentContext())); if (!value_args.get() || !value_args->IsType(base::Value::TYPE_LIST)) { - args.GetReturnValue().Set(v8::ThrowException(v8::Exception::Error(v8::String::New( + args.GetReturnValue().Set(isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, "Unable to convert 'args' passed to CallStaticMethodSync")))); return; } @@ -465,7 +481,7 @@ void DispatcherBindings::CallStaticMethodSync( method, *static_cast(value_args.get()), &result)); - args.GetReturnValue().Set(converter->ToV8Value(&result, v8::Context::GetCurrent())); + args.GetReturnValue().Set(converter->ToV8Value(&result, isolate->GetCurrentContext())); } } // namespace nwapi diff --git a/src/api/dispatcher_bindings.h b/src/api/dispatcher_bindings.h index f20d600f09..ecdca424d5 100644 --- a/src/api/dispatcher_bindings.h +++ b/src/api/dispatcher_bindings.h @@ -34,7 +34,9 @@ class DispatcherBindings : public v8::Extension { // v8::Extension implementation. virtual v8::Handle - GetNativeFunction(v8::Handle name) OVERRIDE; + GetNativeFunctionTemplate( + v8::Isolate* isolate, + v8::Handle name) OVERRIDE; private: // Helper functions for bindings. diff --git a/src/api/shell/shell.cc b/src/api/shell/shell.cc index b393f7b1f0..ff00722667 100644 --- a/src/api/shell/shell.cc +++ b/src/api/shell/shell.cc @@ -36,15 +36,15 @@ void Shell::Call(const std::string& method, if (method == "OpenExternal") { std::string uri; arguments.GetString(0, &uri); - platform_util::OpenExternal(GURL(uri)); + platform_util::OpenExternal(NULL, GURL(uri)); } else if (method == "OpenItem") { std::string full_path; arguments.GetString(0, &full_path); - platform_util::OpenItem(FilePath::FromUTF8Unsafe(full_path)); + platform_util::OpenItem(NULL, FilePath::FromUTF8Unsafe(full_path)); } else if (method == "ShowItemInFolder") { std::string full_path; arguments.GetString(0, &full_path); - platform_util::ShowItemInFolder(FilePath::FromUTF8Unsafe(full_path)); + platform_util::ShowItemInFolder(NULL, FilePath::FromUTF8Unsafe(full_path)); } else { NOTREACHED() << "Calling unknown method " << method << " of Shell"; } diff --git a/src/api/window/window.cc b/src/api/window/window.cc index 0679c04e5a..d2c3160648 100644 --- a/src/api/window/window.cc +++ b/src/api/window/window.cc @@ -139,8 +139,8 @@ PopulateCookieObject(const net::CanonicalCookie& canonical_cookie) { base::DictionaryValue* result = new base::DictionaryValue(); // A cookie is a raw byte sequence. By explicitly parsing it as UTF-8, we // apply error correction, so the string can be safely passed to the renderer. - result->SetString("name", UTF16ToUTF8(UTF8ToUTF16(canonical_cookie.Name()))); - result->SetString("value", UTF16ToUTF8(UTF8ToUTF16(canonical_cookie.Value()))); + result->SetString("name", base::UTF16ToUTF8(base::UTF8ToUTF16(canonical_cookie.Name()))); + result->SetString("value", base::UTF16ToUTF8(base::UTF8ToUTF16(canonical_cookie.Value()))); result->SetString("domain", canonical_cookie.Domain()); result->SetBoolean("host_only", net::cookie_util::DomainIsHostOnly( canonical_cookie.Domain())); diff --git a/src/api/window_bindings.cc b/src/api/window_bindings.cc index 466a4eeca5..d6436623f1 100644 --- a/src/api/window_bindings.cc +++ b/src/api/window_bindings.cc @@ -32,6 +32,7 @@ using namespace WebCore; #include #endif +#undef FROM_HERE #include "third_party/WebKit/Source/config.h" #include "third_party/WebKit/Source/core/html/HTMLIFrameElement.h" @@ -43,8 +44,8 @@ using namespace WebCore; #undef CHECK #include "V8HTMLIFrameElement.h" -using WebKit::WebScriptSource; -using WebKit::WebFrame; +using blink::WebScriptSource; +using blink::WebFrame; namespace nwapi { @@ -62,30 +63,33 @@ WindowBindings::~WindowBindings() { } v8::Handle -WindowBindings::GetNativeFunction(v8::Handle name) { - if (name->Equals(v8::String::New("BindToShell"))) - return v8::FunctionTemplate::New(BindToShell); - else if (name->Equals(v8::String::New("CallObjectMethod"))) - return v8::FunctionTemplate::New(CallObjectMethod); - else if (name->Equals(v8::String::New("CallObjectMethodSync"))) - return v8::FunctionTemplate::New(CallObjectMethodSync); - else if (name->Equals(v8::String::New("GetWindowObject"))) - return v8::FunctionTemplate::New(GetWindowObject); - else if (name->Equals(v8::String::New("AllocateId"))) - return v8::FunctionTemplate::New(AllocateId); - - return v8::FunctionTemplate::New(); +WindowBindings::GetNativeFunctionTemplate( + v8::Isolate* isolate, + v8::Handle name) { + if (name->Equals(v8::String::NewFromUtf8(isolate, "BindToShell"))) + return v8::FunctionTemplate::New(isolate, BindToShell); + else if (name->Equals(v8::String::NewFromUtf8(isolate, "CallObjectMethod"))) + return v8::FunctionTemplate::New(isolate, CallObjectMethod); + else if (name->Equals(v8::String::NewFromUtf8(isolate, "CallObjectMethodSync"))) + return v8::FunctionTemplate::New(isolate, CallObjectMethodSync); + else if (name->Equals(v8::String::NewFromUtf8(isolate, "GetWindowObject"))) + return v8::FunctionTemplate::New(isolate, GetWindowObject); + else if (name->Equals(v8::String::NewFromUtf8(isolate, "AllocateId"))) + return v8::FunctionTemplate::New(isolate, AllocateId); + + return v8::FunctionTemplate::New(isolate); } // static void WindowBindings::BindToShell(const v8::FunctionCallbackInfo& args) { + v8::Isolate* isolate = v8::Isolate::GetCurrent(); int routing_id = args[0]->Int32Value(); int object_id = args[1]->Int32Value(); - remote::AllocateObject(routing_id, object_id, "Window", v8::Object::New()); + remote::AllocateObject(routing_id, object_id, "Window", v8::Object::New(isolate)); - args.GetReturnValue().Set(v8::Undefined()); + args.GetReturnValue().Set(v8::Undefined(isolate)); } void @@ -99,9 +103,10 @@ WindowBindings::AllocateId(const v8::FunctionCallbackInfo& args) { // static void WindowBindings::CallObjectMethod(const v8::FunctionCallbackInfo& args) { + v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::Local self = args[0]->ToObject(); - int routing_id = self->Get(v8::String::New("routing_id"))->Int32Value(); - int object_id = self->Get(v8::String::New("id"))->Int32Value(); + int routing_id = self->Get(v8::String::NewFromUtf8(isolate, "routing_id"))->Int32Value(); + int object_id = self->Get(v8::String::NewFromUtf8(isolate, "id"))->Int32Value(); std::string method = *v8::String::Utf8Value(args[1]); content::RenderViewImpl* render_view = static_cast( content::RenderViewImpl::FromRoutingID(routing_id)); @@ -110,7 +115,7 @@ WindowBindings::CallObjectMethod(const v8::FunctionCallbackInfo& args if (!render_view) { std::string msg = "Unable to get render view in " + method; - args.GetReturnValue().Set(v8::ThrowException(v8::Exception::Error(v8::String::New(msg.c_str())))); + args.GetReturnValue().Set(isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, msg.c_str())))); return; } @@ -123,7 +128,7 @@ WindowBindings::CallObjectMethod(const v8::FunctionCallbackInfo& args web_frame = main_frame; }else{ WebCore::HTMLIFrameElement* iframe = WebCore::V8HTMLIFrameElement::toNative(frm); - web_frame = WebKit::WebFrameImpl::fromFrame(iframe->contentFrame()); + web_frame = blink::WebFrameImpl::fromFrame(iframe->contentFrame()); } #if defined(OS_WIN) base::string16 jscript((WCHAR*)*v8::String::Value(args[3])); @@ -141,9 +146,9 @@ WindowBindings::CallObjectMethod(const v8::FunctionCallbackInfo& args main_frame->setDevtoolsJail(NULL); }else{ WebCore::HTMLIFrameElement* iframe = WebCore::V8HTMLIFrameElement::toNative(frm); - main_frame->setDevtoolsJail(WebKit::WebFrameImpl::fromFrame(iframe->contentFrame())); + main_frame->setDevtoolsJail(blink::WebFrameImpl::fromFrame(iframe->contentFrame())); } - args.GetReturnValue().Set(v8::Undefined()); + args.GetReturnValue().Set(v8::Undefined(isolate)); return; } @@ -155,31 +160,32 @@ WindowBindings::CallObjectMethod(const v8::FunctionCallbackInfo& args // static void WindowBindings::CallObjectMethodSync(const v8::FunctionCallbackInfo& args) { - v8::HandleScope scope; + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + v8::EscapableHandleScope scope(isolate); v8::Local self = args[0]->ToObject(); - int routing_id = self->Get(v8::String::New("routing_id"))->Int32Value(); - int object_id = self->Get(v8::String::New("id"))->Int32Value(); + int routing_id = self->Get(v8::String::NewFromUtf8(isolate, "routing_id"))->Int32Value(); + int object_id = self->Get(v8::String::NewFromUtf8(isolate, "id"))->Int32Value(); std::string method = *v8::String::Utf8Value(args[1]); content::RenderViewImpl* render_view = static_cast( content::RenderViewImpl::FromRoutingID(routing_id)); if (!render_view) { std::string msg = "Unable to get render view in " + method; - args.GetReturnValue().Set(v8::ThrowException(v8::Exception::Error(v8::String::New(msg.c_str())))); + args.GetReturnValue().Set(isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, msg.c_str())))); return; } if (method == "GetZoomLevel") { float zoom_level = render_view->GetWebView()->zoomLevel(); - v8::Local array = v8::Array::New(); - array->Set(0, v8::Number::New(zoom_level)); - args.GetReturnValue().Set(scope.Close(array)); + v8::Local array = v8::Array::New(isolate); + array->Set(0, v8::Number::New(isolate, zoom_level)); + args.GetReturnValue().Set(scope.Escape(array)); return; }else if (method == "SetZoomLevel") { double zoom_level = args[2]->ToNumber()->Value(); render_view->OnSetZoomLevel(zoom_level); - args.GetReturnValue().Set(v8::Undefined()); + args.GetReturnValue().Set(v8::Undefined(isolate)); return; } args.GetReturnValue().Set(remote::CallObjectMethodSync(routing_id, object_id, "Window", method, args[2])); @@ -188,13 +194,14 @@ WindowBindings::CallObjectMethodSync(const v8::FunctionCallbackInfo& // static void WindowBindings::GetWindowObject(const v8::FunctionCallbackInfo& args) { + v8::Isolate* isolate = v8::Isolate::GetCurrent(); int routing_id = args[0]->Int32Value(); // Dark magic to digg out the RenderView from its id. content::RenderViewImpl* render_view = static_cast( content::RenderViewImpl::FromRoutingID(routing_id)); if (!render_view) { - args.GetReturnValue().Set(v8::ThrowException(v8::Exception::Error(v8::String::New("Unable to get render view in GetWindowObject")))); + args.GetReturnValue().Set(isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, "Unable to get render view in GetWindowObject")))); return; } // Return the window object. diff --git a/src/api/window_bindings.h b/src/api/window_bindings.h index d141363944..4e2fddca32 100644 --- a/src/api/window_bindings.h +++ b/src/api/window_bindings.h @@ -34,7 +34,9 @@ class WindowBindings : public v8::Extension { // v8::Extension implementation. virtual v8::Handle - GetNativeFunction(v8::Handle name) OVERRIDE; + GetNativeFunctionTemplate( + v8::Isolate* isolate, + v8::Handle name) OVERRIDE; private: static void AllocateId(const v8::FunctionCallbackInfo& args); diff --git a/src/breakpad_linux.cc b/src/breakpad_linux.cc index 0d3d40d3d9..d9d7a3e339 100644 --- a/src/breakpad_linux.cc +++ b/src/breakpad_linux.cc @@ -25,6 +25,7 @@ #include "base/base_switches.h" #include "base/command_line.h" #include "base/debug/crash_logging.h" +#include "base/debug/dump_without_crashing.h" #include "base/files/file_path.h" #include "base/linux_util.h" #include "base/path_service.h" @@ -1384,7 +1385,7 @@ void InitCrashReporter() { SetProcessStartTime(); - breakpad::GetBreakpadClient()->SetDumpWithoutCrashingFunction(&DumpProcess); + base::debug::SetDumpWithoutCrashingFunction(&DumpProcess); #if defined(ADDRESS_SANITIZER) // Register the callback for AddressSanitizer error reporting. __asan_set_error_report_callback(AsanLinuxBreakpadCallback); diff --git a/src/browser/capture_page_helper.cc b/src/browser/capture_page_helper.cc index 3771d1200c..a62634c1a1 100644 --- a/src/browser/capture_page_helper.cc +++ b/src/browser/capture_page_helper.cc @@ -88,7 +88,7 @@ void CapturePageHelper::StartCapturePage(const std::string& image_format_str) { gfx::Rect(), view->GetViewBounds().size(), base::Bind(&CapturePageHelper::CopyFromBackingStoreComplete, - this)); + this), SkBitmap::kARGB_8888_Config); } void CapturePageHelper::CopyFromBackingStoreComplete( diff --git a/src/browser/file_select_helper.cc b/src/browser/file_select_helper.cc index 7b6edfa2f9..100495d741 100644 --- a/src/browser/file_select_helper.cc +++ b/src/browser/file_select_helper.cc @@ -241,7 +241,7 @@ void FileSelectHelper::OnListDone(int id, int error) { scoped_ptr FileSelectHelper::GetFileTypesFromAcceptType( - const std::vector& accept_types) { + const std::vector& accept_types) { scoped_ptr base_file_type( new ui::SelectFileDialog::FileTypeInfo()); if (accept_types.empty()) @@ -474,7 +474,7 @@ bool FileSelectHelper::IsAcceptTypeValid(const std::string& accept_type) { std::string unused; if (accept_type.length() <= 1 || StringToLowerASCII(accept_type) != accept_type || - TrimWhitespaceASCII(accept_type, TRIM_ALL, &unused) != TRIM_NONE) { + base::TrimWhitespaceASCII(accept_type, base::TRIM_ALL, &unused) != base::TRIM_NONE) { return false; } return true; diff --git a/src/browser/file_select_helper.h b/src/browser/file_select_helper.h index 6f1c977be2..e488a4ad1b 100644 --- a/src/browser/file_select_helper.h +++ b/src/browser/file_select_helper.h @@ -146,7 +146,7 @@ class FileSelectHelper // |accept_types| contains only valid lowercased MIME types or file extensions // beginning with a period (.). scoped_ptr GetFileTypesFromAcceptType( - const std::vector& accept_types); + const std::vector& accept_types); // Check the accept type is valid. It is expected to be all lower case with // no whitespace. diff --git a/src/browser/printing/print_dialog_gtk.cc b/src/browser/printing/print_dialog_gtk.cc index 11ca278c76..2d6cdf7c25 100644 --- a/src/browser/printing/print_dialog_gtk.cc +++ b/src/browser/printing/print_dialog_gtk.cc @@ -122,12 +122,12 @@ class GtkPrinterList { // static printing::PrintDialogGtkInterface* PrintDialogGtk::CreatePrintDialog( - PrintingContextGtk* context) { + PrintingContextLinux* context) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); return new PrintDialogGtk(context); } -PrintDialogGtk::PrintDialogGtk(PrintingContextGtk* context) +PrintDialogGtk::PrintDialogGtk(PrintingContextLinux* context) : context_(context), dialog_(NULL), gtk_settings_(NULL), @@ -232,7 +232,7 @@ bool PrintDialogGtk::UpdateSettings(printing::PrintSettings* settings) { void PrintDialogGtk::ShowDialog( gfx::NativeView parent_view, bool has_selection, - const PrintingContextGtk::PrintSettingsCallback& callback) { + const PrintingContextLinux::PrintSettingsCallback& callback) { callback_ = callback; GtkWindow* parent = GTK_WINDOW(gtk_widget_get_toplevel(parent_view)); @@ -266,7 +266,7 @@ void PrintDialogGtk::ShowDialog( } void PrintDialogGtk::PrintDocument(const printing::Metafile* metafile, - const string16& document_name) { + const base::string16& document_name) { // This runs on the print worker thread, does not block the UI thread. DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -275,7 +275,7 @@ void PrintDialogGtk::PrintDocument(const printing::Metafile* metafile, AddRef(); bool error = false; - if (!file_util::CreateTemporaryFile(&path_to_pdf_)) { + if (!base::CreateTemporaryFile(&path_to_pdf_)) { LOG(ERROR) << "Creating temporary file failed"; error = true; } @@ -365,13 +365,13 @@ void PrintDialogGtk::OnResponse(GtkWidget* dialog, int response_id) { printing::PrintSettingsInitializerGtk::InitPrintSettings( gtk_settings_, page_setup_, &settings); context_->InitWithSettings(settings); - callback_.Run(PrintingContextGtk::OK); + callback_.Run(PrintingContextLinux::OK); callback_.Reset(); return; } case GTK_RESPONSE_DELETE_EVENT: // Fall through. case GTK_RESPONSE_CANCEL: { - callback_.Run(PrintingContextGtk::CANCEL); + callback_.Run(PrintingContextLinux::CANCEL); callback_.Reset(); return; } @@ -382,7 +382,7 @@ void PrintDialogGtk::OnResponse(GtkWidget* dialog, int response_id) { } } -void PrintDialogGtk::SendDocumentToPrinter(const string16& document_name) { +void PrintDialogGtk::SendDocumentToPrinter(const base::string16& document_name) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); // If |printer_| is NULL then somehow the GTK printer list changed out under diff --git a/src/browser/printing/print_dialog_gtk.h b/src/browser/printing/print_dialog_gtk.h index 06a14c79be..1eb385cc30 100644 --- a/src/browser/printing/print_dialog_gtk.h +++ b/src/browser/printing/print_dialog_gtk.h @@ -14,7 +14,7 @@ #include "base/sequenced_task_runner_helpers.h" #include "content/public/browser/browser_thread.h" #include "printing/print_dialog_gtk_interface.h" -#include "printing/printing_context_gtk.h" +#include "printing/printing_context_linux.h" #include "ui/base/gtk/gtk_signal.h" namespace printing { @@ -22,7 +22,7 @@ class Metafile; class PrintSettings; } -using printing::PrintingContextGtk; +using printing::PrintingContextLinux; // Needs to be freed on the UI thread to clean up its GTK members variables. class PrintDialogGtk @@ -32,7 +32,7 @@ class PrintDialogGtk public: // Creates and returns a print dialog. static printing::PrintDialogGtkInterface* CreatePrintDialog( - PrintingContextGtk* context); + PrintingContextLinux* context); // printing::PrintDialogGtkInterface implementation. virtual void UseDefaultSettings() OVERRIDE; @@ -42,9 +42,9 @@ class PrintDialogGtk virtual void ShowDialog( gfx::NativeView parent_view, bool has_selection, - const PrintingContextGtk::PrintSettingsCallback& callback) OVERRIDE; + const PrintingContextLinux::PrintSettingsCallback& callback) OVERRIDE; virtual void PrintDocument(const printing::Metafile* metafile, - const string16& document_name) OVERRIDE; + const base::string16& document_name) OVERRIDE; virtual void AddRefToDialog() OVERRIDE; virtual void ReleaseDialog() OVERRIDE; @@ -53,14 +53,14 @@ class PrintDialogGtk content::BrowserThread::UI>; friend class base::DeleteHelper; - explicit PrintDialogGtk(PrintingContextGtk* context); + explicit PrintDialogGtk(PrintingContextLinux* context); virtual ~PrintDialogGtk(); // Handles dialog response. CHROMEGTK_CALLBACK_1(PrintDialogGtk, void, OnResponse, int); // Prints document named |document_name|. - void SendDocumentToPrinter(const string16& document_name); + void SendDocumentToPrinter(const base::string16& document_name); // Handles print job response. static void OnJobCompletedThunk(GtkPrintJob* print_job, @@ -74,8 +74,8 @@ class PrintDialogGtk printing::PrintSettings* settings); // Printing dialog callback. - PrintingContextGtk::PrintSettingsCallback callback_; - PrintingContextGtk* context_; + PrintingContextLinux::PrintSettingsCallback callback_; + PrintingContextLinux* context_; // Print dialog settings. PrintDialogGtk owns |dialog_| and holds references // to the other objects. diff --git a/src/browser/printing/print_job.cc b/src/browser/printing/print_job.cc index d8e5cb79bd..d7dfbedc2d 100644 --- a/src/browser/printing/print_job.cc +++ b/src/browser/printing/print_job.cc @@ -38,10 +38,7 @@ PrintJob::PrintJob() settings_(), is_job_pending_(false), is_canceling_(false), - is_stopping_(false), - is_stopped_(false), - quit_factory_(this), - weak_ptr_factory_(this) { + quit_factory_(this) { DCHECK(ui_message_loop_); // This is normally a UI message loop, but in unit tests, the message loop is // of the 'default' type. @@ -164,16 +161,12 @@ void PrintJob::Stop() { // Be sure to live long enough. scoped_refptr handle(this); - MessageLoop* worker_loop = worker_->message_loop(); - if (worker_loop) { + if (worker_->message_loop()) { ControlledWorkerShutdown(); - - is_job_pending_ = false; - registrar_.Remove(this, content::NOTIFICATION_PRINT_JOB_EVENT, - content::Source(this)); + } else { + // Flush the cached document. + UpdatePrintedDocument(NULL); } - // Flush the cached document. - UpdatePrintedDocument(NULL); } void PrintJob::Cancel() { @@ -225,14 +218,6 @@ bool PrintJob::is_job_pending() const { return is_job_pending_; } -bool PrintJob::is_stopping() const { - return is_stopping_; -} - -bool PrintJob::is_stopped() const { - return is_stopped_; -} - PrintedDocument* PrintJob::document() const { return document_.get(); } @@ -326,53 +311,32 @@ void PrintJob::ControlledWorkerShutdown() { // deadlock is eliminated. worker_->StopSoon(); - // Run a tight message loop until the worker terminates. It may seems like a - // hack but I see no other way to get it to work flawlessly. The issues here - // are: - // - We don't want to run tasks while the thread is quitting. - // - We want this code path to wait on the thread to quit before continuing. - MSG msg; - HANDLE thread_handle = worker_->thread_handle().platform_handle(); - for (; thread_handle;) { - // Note that we don't do any kind of message prioritization since we don't - // execute any pending task or timer. - DWORD result = MsgWaitForMultipleObjects(1, &thread_handle, - FALSE, INFINITE, QS_ALLINPUT); - if (result == WAIT_OBJECT_0 + 1) { - while (PeekMessage(&msg, NULL, 0, 0, TRUE) > 0) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - // Continue looping. - } else if (result == WAIT_OBJECT_0) { - // The thread quit. - break; - } else { - // An error occurred. Assume the thread quit. - NOTREACHED(); - break; - } + // Delay shutdown until the worker terminates. We want this code path + // to wait on the thread to quit before continuing. + if (worker_->IsRunning()) { + base::MessageLoop::current()->PostDelayedTask( + FROM_HERE, + base::Bind(&PrintJob::ControlledWorkerShutdown, this), + base::TimeDelta::FromMilliseconds(100)); + return; } #endif // Now make sure the thread object is cleaned up. Do this on a worker // thread because it may block. - is_stopping_ = true; - base::WorkerPool::PostTaskAndReply( FROM_HERE, - base::Bind(&PrintJobWorker::Stop, - base::Unretained(worker_.get())), - base::Bind(&PrintJob::HoldUntilStopIsCalled, - weak_ptr_factory_.GetWeakPtr(), - scoped_refptr(this)), + base::Bind(&PrintJobWorker::Stop, base::Unretained(worker_.get())), + base::Bind(&PrintJob::HoldUntilStopIsCalled, this), false); + + is_job_pending_ = false; + registrar_.RemoveAll(); + UpdatePrintedDocument(NULL); } -void PrintJob::HoldUntilStopIsCalled(const scoped_refptr&) { - is_stopped_ = true; - is_stopping_ = false; +void PrintJob::HoldUntilStopIsCalled() { } void PrintJob::Quit() { @@ -391,12 +355,8 @@ JobEventDetails::JobEventDetails(Type type, JobEventDetails::~JobEventDetails() { } -PrintedDocument* JobEventDetails::document() const { - return document_; -} +PrintedDocument* JobEventDetails::document() const { return document_.get(); } -PrintedPage* JobEventDetails::page() const { - return page_; -} +PrintedPage* JobEventDetails::page() const { return page_.get(); } } // namespace printing diff --git a/src/browser/printing/print_job.h b/src/browser/printing/print_job.h index 35c3f7bc35..6b20bf40ba 100644 --- a/src/browser/printing/print_job.h +++ b/src/browser/printing/print_job.h @@ -88,12 +88,6 @@ class PrintJob : public PrintJobWorkerOwner, // and the end of the spooling. bool is_job_pending() const; - // Returns true if the worker thread is in the process of stopping. - bool is_stopping() const; - - // Returns true if the worker thread has stopped. - bool is_stopped() const; - // Access the current printed document. Warning: may be NULL. PrintedDocument* document() const; @@ -118,7 +112,7 @@ class PrintJob : public PrintJobWorkerOwner, // Called at shutdown when running a nested message loop. void Quit(); - void HoldUntilStopIsCalled(const scoped_refptr& job); + void HoldUntilStopIsCalled(); content::NotificationRegistrar registrar_; @@ -148,17 +142,9 @@ class PrintJob : public PrintJobWorkerOwner, // the notified calls Cancel() again. bool is_canceling_; - // Is the worker thread stopping. - bool is_stopping_; - - // Is the worker thread stopped. - bool is_stopped_; - // Used at shutdown so that we can quit a nested message loop. base::WeakPtrFactory quit_factory_; - base::WeakPtrFactory weak_ptr_factory_; - DISALLOW_COPY_AND_ASSIGN(PrintJob); }; diff --git a/src/browser/printing/print_job_worker.cc b/src/browser/printing/print_job_worker.cc index 8f86529e68..5e4ed1ed15 100644 --- a/src/browser/printing/print_job_worker.cc +++ b/src/browser/printing/print_job_worker.cc @@ -22,6 +22,7 @@ #include "printing/print_job_constants.h" #include "printing/printed_document.h" #include "printing/printed_page.h" +#include "printing/printing_utils.h" #include "ui/base/l10n/l10n_util.h" using content::BrowserThread; @@ -117,7 +118,7 @@ void PrintJobWorker::GetSettings( } } -void PrintJobWorker::SetSettings(const DictionaryValue* const new_settings) { +void PrintJobWorker::SetSettings(const base::DictionaryValue* const new_settings) { DCHECK_EQ(message_loop(), MessageLoop::current()); BrowserThread::PostTask( @@ -128,13 +129,13 @@ void PrintJobWorker::SetSettings(const DictionaryValue* const new_settings) { } void PrintJobWorker::UpdatePrintSettings( - const DictionaryValue* const new_settings) { + const base::DictionaryValue* const new_settings) { // Create new PageRanges based on |new_settings|. PageRanges new_ranges; - const ListValue* page_range_array; + const base::ListValue* page_range_array; if (new_settings->GetList(kSettingPageRange, &page_range_array)) { for (size_t index = 0; index < page_range_array->GetSize(); ++index) { - const DictionaryValue* dict; + const base::DictionaryValue* dict; if (!page_range_array->GetDictionary(index, &dict)) continue; @@ -216,10 +217,10 @@ void PrintJobWorker::StartPrinting(PrintedDocument* new_document) { return; } - string16 document_name = - printing::PrintBackend::SimplifyDocumentTitle(document_->name()); + base::string16 document_name = + printing::SimplifyDocumentTitle(document_->name()); if (document_name.empty()) { - document_name = printing::PrintBackend::SimplifyDocumentTitle( + document_name = printing::SimplifyDocumentTitle( l10n_util::GetStringUTF16(IDS_DEFAULT_PRINT_DOCUMENT_TITLE)); } PrintingContext::Result result = diff --git a/src/browser/printing/print_view_manager.cc b/src/browser/printing/print_view_manager.cc index 3d71ec9513..8600e01c13 100644 --- a/src/browser/printing/print_view_manager.cc +++ b/src/browser/printing/print_view_manager.cc @@ -136,8 +136,8 @@ void PrintViewManager::RenderProcessGone(base::TerminationStatus status) { } } -string16 PrintViewManager::RenderSourceName() { - string16 name(web_contents()->GetTitle()); +base::string16 PrintViewManager::RenderSourceName() { + base::string16 name(web_contents()->GetTitle()); if (name.empty()) name = l10n_util::GetStringUTF16(IDS_DEFAULT_PRINT_DOCUMENT_TITLE); return name; diff --git a/src/browser/printing/print_view_manager.h b/src/browser/printing/print_view_manager.h index 1670573ba9..6d2898f060 100644 --- a/src/browser/printing/print_view_manager.h +++ b/src/browser/printing/print_view_manager.h @@ -59,7 +59,7 @@ class PrintViewManager : public content::NotificationObserver, void set_observer(PrintViewManagerObserver* observer); // PrintedPagesSource implementation. - virtual string16 RenderSourceName() OVERRIDE; + virtual base::string16 RenderSourceName() OVERRIDE; // content::NotificationObserver implementation. virtual void Observe(int type, diff --git a/src/browser/printing/printer_query.cc b/src/browser/printing/printer_query.cc index 425baaf29e..3bcfb8eb84 100644 --- a/src/browser/printing/printer_query.cc +++ b/src/browser/printing/printer_query.cc @@ -95,7 +95,7 @@ void PrinterQuery::GetSettings( margin_type)); } -void PrinterQuery::SetSettings(const DictionaryValue& new_settings, +void PrinterQuery::SetSettings(const base::DictionaryValue& new_settings, const base::Closure& callback) { StartWorker(callback); diff --git a/src/browser/printing/printing_message_filter.cc b/src/browser/printing/printing_message_filter.cc index 7a1a88f721..08606ac886 100644 --- a/src/browser/printing/printing_message_filter.cc +++ b/src/browser/printing/printing_message_filter.cc @@ -77,7 +77,7 @@ void RenderParamsFromPrintSettings(const printing::PrintSettings& settings, } // namespace PrintingMessageFilter::PrintingMessageFilter(int render_process_id) - : print_job_manager_(NULL), + : BrowserMessageFilter(PrintMsgStart), print_job_manager_(NULL), render_process_id_(render_process_id) { content::ShellContentBrowserClient* browser_client = @@ -344,8 +344,8 @@ void PrintingMessageFilter::OnScriptedPrintReply( } void PrintingMessageFilter::OnUpdatePrintSettings( - int document_cookie, const DictionaryValue& job_settings, - IPC::Message* reply_msg) { + int document_cookie, const base::DictionaryValue& job_settings, + IPC::Message* reply_msg) { scoped_refptr printer_query; print_job_manager_->PopPrinterQuery(document_cookie, &printer_query); diff --git a/src/browser/shell_devtools_delegate.cc b/src/browser/shell_devtools_delegate.cc index b0caa9d698..febfb0b9b5 100644 --- a/src/browser/shell_devtools_delegate.cc +++ b/src/browser/shell_devtools_delegate.cc @@ -114,7 +114,7 @@ Target::Target(WebContents* web_contents) { id_ = agent_host_->GetId(); title_ = UTF16ToUTF8(web_contents->GetTitle()); url_ = web_contents->GetURL(); - last_activity_time_ = web_contents->GetLastSelectedTime(); + last_activity_time_ = web_contents->GetLastActiveTime(); } bool Target::Activate() const { diff --git a/src/browser/shell_download_manager_delegate.cc b/src/browser/shell_download_manager_delegate.cc index 1b2910a31f..b40fd7924f 100644 --- a/src/browser/shell_download_manager_delegate.cc +++ b/src/browser/shell_download_manager_delegate.cc @@ -87,7 +87,7 @@ bool ShellDownloadManagerDelegate::DetermineDownloadTarget( FilePath generated_name = net::GenerateFileName( download->GetURL(), download->GetContentDisposition(), - EmptyString(), + base::EmptyString(), download->GetSuggestedFilename(), download->GetMimeType(), "download"); @@ -109,7 +109,7 @@ void ShellDownloadManagerDelegate::GenerateFilename( const FilePath& suggested_directory) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); if (!base::PathExists(suggested_directory)) - file_util::CreateDirectory(suggested_directory); + base::CreateDirectory(suggested_directory); FilePath suggested_path(suggested_directory.Append(generated_name)); BrowserThread::PostTask( diff --git a/src/browser/shell_javascript_dialog.h b/src/browser/shell_javascript_dialog.h index 2ed17fb235..1057f6526b 100644 --- a/src/browser/shell_javascript_dialog.h +++ b/src/browser/shell_javascript_dialog.h @@ -45,8 +45,8 @@ class ShellJavaScriptDialog { ShellJavaScriptDialogCreator* creator, gfx::NativeWindow parent_window, JavaScriptMessageType message_type, - const string16& message_text, - const string16& default_prompt_text, + const base::string16& message_text, + const base::string16& default_prompt_text, const JavaScriptDialogManager::DialogClosedCallback& callback); ~ShellJavaScriptDialog(); @@ -62,8 +62,8 @@ class ShellJavaScriptDialog { #elif defined(OS_WIN) JavaScriptMessageType message_type_; HWND dialog_win_; - string16 message_text_; - string16 default_prompt_text_; + base::string16 message_text_; + base::string16 default_prompt_text_; static INT_PTR CALLBACK DialogProc(HWND dialog, UINT message, WPARAM wparam, LPARAM lparam); #elif defined(TOOLKIT_GTK) diff --git a/src/browser/shell_javascript_dialog_creator.cc b/src/browser/shell_javascript_dialog_creator.cc index fe1235b42b..4c176b2a1e 100644 --- a/src/browser/shell_javascript_dialog_creator.cc +++ b/src/browser/shell_javascript_dialog_creator.cc @@ -42,13 +42,13 @@ void ShellJavaScriptDialogCreator::RunJavaScriptDialog( const GURL& origin_url, const std::string& accept_lang, JavaScriptMessageType javascript_message_type, - const string16& message_text, - const string16& default_prompt_text, + const base::string16& message_text, + const base::string16& default_prompt_text, const DialogClosedCallback& callback, bool* did_suppress_message) { if (!dialog_request_callback_.is_null()) { dialog_request_callback_.Run(); - callback.Run(true, string16()); + callback.Run(true, base::string16()); dialog_request_callback_.Reset(); return; } @@ -80,12 +80,12 @@ void ShellJavaScriptDialogCreator::RunJavaScriptDialog( void ShellJavaScriptDialogCreator::RunBeforeUnloadDialog( WebContents* web_contents, - const string16& message_text, + const base::string16& message_text, bool is_reload, const DialogClosedCallback& callback) { if (!dialog_request_callback_.is_null()) { dialog_request_callback_.Run(); - callback.Run(true, string16()); + callback.Run(true, base::string16()); dialog_request_callback_.Reset(); return; } @@ -93,13 +93,13 @@ void ShellJavaScriptDialogCreator::RunBeforeUnloadDialog( #if defined(OS_MACOSX) || defined(OS_WIN) || defined(TOOLKIT_GTK) if (dialog_.get()) { // Seriously!? - callback.Run(true, string16()); + callback.Run(true, base::string16()); return; } - string16 new_message_text = + base::string16 new_message_text = message_text + - ASCIIToUTF16("\n\nIs it OK to leave/reload this page?"); + base::ASCIIToUTF16("\n\nIs it OK to leave/reload this page?"); gfx::NativeWindow parent_window = web_contents->GetView()->GetTopLevelNativeWindow(); @@ -108,11 +108,11 @@ void ShellJavaScriptDialogCreator::RunBeforeUnloadDialog( parent_window, JAVASCRIPT_MESSAGE_TYPE_CONFIRM, new_message_text, - string16(), // default_prompt_text + base::string16(), // default_prompt_text callback)); #else // TODO: implement ShellJavaScriptDialog for other platforms, drop this #if - callback.Run(true, string16()); + callback.Run(true, base::string16()); return; #endif } diff --git a/src/browser/shell_javascript_dialog_creator.h b/src/browser/shell_javascript_dialog_creator.h index e22cb31ad9..cddf0510ad 100644 --- a/src/browser/shell_javascript_dialog_creator.h +++ b/src/browser/shell_javascript_dialog_creator.h @@ -25,14 +25,14 @@ class ShellJavaScriptDialogCreator : public JavaScriptDialogManager { const GURL& origin_url, const std::string& accept_lang, JavaScriptMessageType javascript_message_type, - const string16& message_text, - const string16& default_prompt_text, + const base::string16& message_text, + const base::string16& default_prompt_text, const DialogClosedCallback& callback, bool* did_suppress_message) OVERRIDE; virtual void RunBeforeUnloadDialog( WebContents* web_contents, - const string16& message_text, + const base::string16& message_text, bool is_reload, const DialogClosedCallback& callback) OVERRIDE; diff --git a/src/browser/shell_javascript_dialog_gtk.cc b/src/browser/shell_javascript_dialog_gtk.cc index cff5458515..133fc98e0d 100644 --- a/src/browser/shell_javascript_dialog_gtk.cc +++ b/src/browser/shell_javascript_dialog_gtk.cc @@ -35,12 +35,12 @@ const char kPromptTextId[] = "content_shell_prompt_text"; // If there's a text entry in the dialog, get the text from the first one and // return it. -string16 GetPromptText(GtkDialog* dialog) { +base::string16 GetPromptText(GtkDialog* dialog) { GtkWidget* widget = static_cast( g_object_get_data(G_OBJECT(dialog), kPromptTextId)); if (widget) - return UTF8ToUTF16(gtk_entry_get_text(GTK_ENTRY(widget))); - return string16(); + return base::UTF8ToUTF16(gtk_entry_get_text(GTK_ENTRY(widget))); + return base::string16(); } } // namespace @@ -52,8 +52,8 @@ ShellJavaScriptDialog::ShellJavaScriptDialog( ShellJavaScriptDialogCreator* creator, gfx::NativeWindow parent_window, JavaScriptMessageType message_type, - const string16& message_text, - const string16& default_prompt_text, + const base::string16& message_text, + const base::string16& default_prompt_text, const JavaScriptDialogManager::DialogClosedCallback& callback) : creator_(creator), callback_(callback), @@ -129,7 +129,7 @@ void ShellJavaScriptDialog::OnResponse(GtkWidget* dialog, int response_id) { break; case GTK_RESPONSE_CANCEL: case GTK_RESPONSE_DELETE_EVENT: - callback_.Run(false, string16()); + callback_.Run(false, base::string16()); break; default: NOTREACHED(); diff --git a/src/browser/shell_login_dialog.cc b/src/browser/shell_login_dialog.cc index b103c5efd0..b531b659a9 100644 --- a/src/browser/shell_login_dialog.cc +++ b/src/browser/shell_login_dialog.cc @@ -1,79 +1,30 @@ -// Copyright (c) 2012 Intel Corp -// Copyright (c) 2012 The Chromium Authors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell co -// pies of the Software, and to permit persons to whom the Software is furnished -// to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in al -// l copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM -// PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNES -// S FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -// OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WH -// ETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. -#include "content/nw/src/browser/shell_login_dialog.h" +#include "content/shell/browser/shell_login_dialog.h" #include "base/bind.h" #include "base/logging.h" #include "base/strings/utf_string_conversions.h" -#include "chrome/browser/chrome_notification_types.h" #include "content/public/browser/browser_thread.h" -#include "content/public/browser/notification_registrar.h" -#include "content/public/browser/notification_service.h" #include "content/public/browser/resource_dispatcher_host.h" -#include "content/public/browser/resource_request_info.h" #include "net/base/auth.h" #include "net/url_request/url_request.h" #include "ui/gfx/text_elider.h" -using content::BrowserThread; -using content::ResourceDispatcherHost; - -namespace { -// Helper to remove the ref from an net::URLRequest to the ShellLoginDialog. -// Should only be called from the IO thread, since it accesses an -// net::URLRequest. -void ResetShellLoginDialogForRequest(net::URLRequest* request) { - ResourceDispatcherHost::Get()->ClearLoginDelegateForRequest(request); -} - -} // namespace - namespace content { -ShellLoginDialog::ShellLoginDialogList ShellLoginDialog::dialog_queue_; - ShellLoginDialog::ShellLoginDialog( net::AuthChallengeInfo* auth_info, - net::URLRequest* request) - : render_process_id_(0), - render_view_id_(0), - auth_info_(auth_info), - request_(request), - handled_auth_(false) { + net::URLRequest* request) : auth_info_(auth_info), + request_(request) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - - if (!ResourceRequestInfo::ForRequest(request_)->GetAssociatedRenderView( - &render_process_id_, &render_view_id_)) { - NOTREACHED(); - } - - // prevent object destruction on wrong (IO) thread - // paired with ReleaseSoon() - AddRef(); - BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, base::Bind(&ShellLoginDialog::PrepDialog, this, - ASCIIToUTF16(auth_info->challenger.ToString()), - UTF8ToUTF16(auth_info->realm))); + base::ASCIIToUTF16(auth_info->challenger.ToString()), + base::UTF8ToUTF16(auth_info->realm))); } void ShellLoginDialog::OnRequestCancelled() { @@ -83,24 +34,9 @@ void ShellLoginDialog::OnRequestCancelled() { base::Bind(&ShellLoginDialog::PlatformRequestCancelled, this)); } -void ShellLoginDialog::UserAcceptedAuth(const string16& username, - const string16& password) { +void ShellLoginDialog::UserAcceptedAuth(const base::string16& username, + const base::string16& password) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - - if (TestAndSetAuthHandled()) - return; - - // Calling NotifyAuthSupplied() directly instead of posting a task - // allows other ShellLoginDialog instances to queue their - // CloseContentsDeferred() before ours. Closing dialogs in the - // opposite order as they were created avoids races where remaining - // dialogs in the same tab may be briefly displayed to the user - // before they are removed. - NotifyAuthSupplied(username, password); - - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, - base::Bind(&ShellLoginDialog::CloseContentsDeferred, this)); BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&ShellLoginDialog::SendAuthToRequester, this, @@ -109,25 +45,13 @@ void ShellLoginDialog::UserAcceptedAuth(const string16& username, void ShellLoginDialog::UserCancelledAuth() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (TestAndSetAuthHandled()) - return; - - // Similar to how we deal with notifications above in SetAuth() - if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { - NotifyAuthCancelled(); - } else { - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, - base::Bind(&ShellLoginDialog::NotifyAuthCancelled, this)); - } - BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&ShellLoginDialog::SendAuthToRequester, this, - false, string16(), string16())); + false, base::string16(), base::string16())); BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind(&ShellLoginDialog::CloseContentsDeferred, this)); + base::Bind(&ShellLoginDialog::PlatformCleanUp, this)); } ShellLoginDialog::~ShellLoginDialog() { @@ -135,203 +59,49 @@ ShellLoginDialog::~ShellLoginDialog() { // referenced/dereferenced. } -void ShellLoginDialog::PrepDialog(const string16& host, - const string16& realm) { +#if !defined(OS_MACOSX) && !defined(TOOLKIT_GTK) +// Bogus implementations for linking. They are never called because +// ResourceDispatcherHostDelegate::CreateLoginDelegate returns NULL. +// TODO: implement ShellLoginDialog for other platforms, drop this #if +void ShellLoginDialog::PlatformCreateDialog(const base::string16& message) {} +void ShellLoginDialog::PlatformCleanUp() {} +void ShellLoginDialog::PlatformRequestCancelled() {} +#endif + +void ShellLoginDialog::PrepDialog(const base::string16& host, + const base::string16& realm) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); // The realm is controlled by the remote server, so there is no reason to // believe it is of a reasonable length. - string16 elided_realm; + base::string16 elided_realm; gfx::ElideString(realm, 120, &elided_realm); - string16 explanation = - ASCIIToUTF16("The server ") + host + - ASCIIToUTF16(" requires a username and password."); + base::string16 explanation = + base::ASCIIToUTF16("The server ") + host + + base::ASCIIToUTF16(" requires a username and password."); if (!elided_realm.empty()) { - explanation += ASCIIToUTF16(" The server says: "); + explanation += base::ASCIIToUTF16(" The server says: "); explanation += elided_realm; - explanation += ASCIIToUTF16("."); + explanation += base::ASCIIToUTF16("."); } - AddObservers(); - dialog_queue_.push_back(this); PlatformCreateDialog(explanation); - if (dialog_queue_.size() == 1) - PlatformShowDialog(); -} - -void ShellLoginDialog::HandleQueueOnClose() -{ - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - ShellLoginDialogList::iterator i( - std::find(dialog_queue_.begin(), dialog_queue_.end(), this)); - - // Ignore the second invocation. - if (i == dialog_queue_.end()) - return; - - bool removed_topmost_dialog = i == dialog_queue_.begin(); - dialog_queue_.erase(i); - if (!dialog_queue_.empty() && removed_topmost_dialog) { - ShellLoginDialog* next_dlg = dialog_queue_.front(); - next_dlg->PlatformShowDialog(); - } } void ShellLoginDialog::SendAuthToRequester(bool success, - const string16& username, - const string16& password) { + const base::string16& username, + const base::string16& password) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - if (success) { + if (success) request_->SetAuth(net::AuthCredentials(username, password)); - } else + else request_->CancelAuth(); ResourceDispatcherHost::Get()->ClearLoginDelegateForRequest(request_); -} - -void ShellLoginDialog::NotifyAuthSupplied(const string16& username, - const string16& password) { - - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - - content::NotificationService* service = - content::NotificationService::current(); - - AuthSuppliedLoginNotificationDetails details(this, username, password); - - service->Notify(chrome::NOTIFICATION_AUTH_SUPPLIED, - content::Source(this), - content::Details(&details)); -} - -void ShellLoginDialog::NotifyAuthCancelled() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - DCHECK(WasAuthHandled()); - - content::NotificationService* service = - content::NotificationService::current(); - - AuthSuppliedLoginNotificationDetails details(this, string16(), string16()); - - service->Notify(chrome::NOTIFICATION_AUTH_CANCELLED, - content::Source(this), - content::Details(&details)); -} - - -void ShellLoginDialog::Observe(int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - DCHECK(type == chrome::NOTIFICATION_AUTH_SUPPLIED || - type == chrome::NOTIFICATION_AUTH_CANCELLED); - - // Break out early if we aren't interested in the notification. - if (WasAuthHandled()) - return; - - LoginNotificationDetails* login_details = - content::Details(details).ptr(); - - // WasAuthHandled() should always test positive before we publish - // AUTH_SUPPLIED or AUTH_CANCELLED notifications. - DCHECK(login_details->handler() != this); - - // Only handle notification for the identical auth info. - if (!login_details->handler()->auth_info()->Equals(*auth_info())) - return; - - // Set or cancel the auth in this handler. - if (type == chrome::NOTIFICATION_AUTH_SUPPLIED) { - AuthSuppliedLoginNotificationDetails* supplied_details = - content::Details(details).ptr(); - UserAcceptedAuth(supplied_details->username(), supplied_details->password()); - } else { - DCHECK(type == chrome::NOTIFICATION_AUTH_CANCELLED); - UserCancelledAuth(); - } -} - -// Returns whether authentication had been handled (SetAuth or CancelAuth). -bool ShellLoginDialog::WasAuthHandled() const { - base::AutoLock lock(handled_auth_lock_); - bool was_handled = handled_auth_; - return was_handled; -} - -// Marks authentication as handled and returns the previous handled state. -bool ShellLoginDialog::TestAndSetAuthHandled() { - base::AutoLock lock(handled_auth_lock_); - bool was_handled = handled_auth_; - handled_auth_ = true; - return was_handled; -} - -// Closes the view_contents from the UI loop. -void ShellLoginDialog::CloseContentsDeferred() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - - HandleQueueOnClose(); - PlatformCleanUp(); -} - -void ShellLoginDialog::AddObservers() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - - // This is probably OK; we need to listen to everything and we break out of - // the Observe() if we aren't handling the same auth_info(). - registrar_.reset(new content::NotificationRegistrar); - registrar_->Add(this, chrome::NOTIFICATION_AUTH_SUPPLIED, - content::NotificationService::AllBrowserContextsAndSources()); - registrar_->Add(this, chrome::NOTIFICATION_AUTH_CANCELLED, - content::NotificationService::AllBrowserContextsAndSources()); -} - -void ShellLoginDialog::RemoveObservers() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - - registrar_.reset(); -} - -void ShellLoginDialog::ReleaseSoon() { - if (!TestAndSetAuthHandled()) { - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, - base::Bind(&ShellLoginDialog::CancelAuthDeferred, this)); - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, - base::Bind(&ShellLoginDialog::NotifyAuthCancelled, this)); - } BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, - base::Bind(&ShellLoginDialog::RemoveObservers, this)); - - // Delete this object once all InvokeLaters have been called. - BrowserThread::ReleaseSoon(BrowserThread::IO, FROM_HERE, this); -} - -// Calls SetAuth from the IO loop. -void ShellLoginDialog::SetAuthDeferred(const string16& username, - const string16& password) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - - if (request_) { - request_->SetAuth(net::AuthCredentials(username, password)); - ResetShellLoginDialogForRequest(request_); - } -} - -// Calls CancelAuth from the IO loop. -void ShellLoginDialog::CancelAuthDeferred() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - - if (request_) { - request_->CancelAuth(); - // Verify that CancelAuth doesn't destroy the request via our delegate. - DCHECK(request_ != NULL); - ResetShellLoginDialogForRequest(request_); - } + BrowserThread::UI, FROM_HERE, + base::Bind(&ShellLoginDialog::PlatformCleanUp, this)); } } // namespace content diff --git a/src/browser/shell_login_dialog.h b/src/browser/shell_login_dialog.h index 48f0e617b3..db70cb6e3d 100644 --- a/src/browser/shell_login_dialog.h +++ b/src/browser/shell_login_dialog.h @@ -1,33 +1,12 @@ -// Copyright (c) 2012 Intel Corp -// Copyright (c) 2012 The Chromium Authors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell co -// pies of the Software, and to permit persons to whom the Software is furnished -// to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in al -// l copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM -// PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNES -// S FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -// OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WH -// ETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -#ifndef CONTENT_NW_SRC_BROWSER_SHELL_LOGIN_DIALOG_H_ -#define CONTENT_NW_SRC_BROWSER_SHELL_LOGIN_DIALOG_H_ - -#include -#include "base/basictypes.h" +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_SHELL_BROWSER_SHELL_LOGIN_DIALOG_H_ +#define CONTENT_SHELL_BROWSER_SHELL_LOGIN_DIALOG_H_ + #include "base/compiler_specific.h" -#include "base/memory/scoped_ptr.h" #include "base/strings/string16.h" -#include "base/synchronization/lock.h" -#include "content/public/browser/notification_observer.h" #include "content/public/browser/resource_dispatcher_host_login_delegate.h" #if defined(TOOLKIT_GTK) @@ -42,11 +21,6 @@ class ShellLoginDialogHelper; #endif // __OBJC__ #endif // defined(OS_MACOSX) -namespace content { -class RenderViewHostDelegate; -class NotificationRegistrar; -} // namespace content - namespace net { class AuthChallengeInfo; class URLRequest; @@ -56,9 +30,7 @@ namespace content { // This class provides a dialog box to ask the user for credentials. Useful in // ResourceDispatcherHostDelegate::CreateLoginDelegate. -class ShellLoginDialog : public ResourceDispatcherHostLoginDelegate, - public content::NotificationObserver -{ +class ShellLoginDialog : public ResourceDispatcherHostLoginDelegate { public: // Threading: IO thread. ShellLoginDialog(net::AuthChallengeInfo* auth_info, net::URLRequest* request); @@ -71,64 +43,20 @@ class ShellLoginDialog : public ResourceDispatcherHostLoginDelegate, // the aforementioned platform specific code may not have access to private // members. Not to be called from client code. // Threading: UI thread. - void UserAcceptedAuth(const string16& username, const string16& password); + void UserAcceptedAuth(const base::string16& username, + const base::string16& password); void UserCancelledAuth(); - // Implements the content::NotificationObserver interface. - // Listens for AUTH_SUPPLIED and AUTH_CANCELLED notifications from other - // LoginHandlers so that this LoginHandler has the chance to dismiss itself - // if it was waiting for the same authentication. - virtual void Observe(int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) OVERRIDE; - - // Who/where/what asked for the authentication. - const net::AuthChallengeInfo* auth_info() const { return auth_info_.get(); } - - // Returns whether authentication had been handled (SetAuth or CancelAuth). - bool WasAuthHandled() const; - - // Performs necessary cleanup before deletion. - void ReleaseSoon(); - protected: // Threading: any virtual ~ShellLoginDialog(); - int render_process_id_; - int render_view_id_; - private: - - // popup next dialog in queue on closing of this dialog - void HandleQueueOnClose(); - - // Calls SetAuth from the IO loop. - void SetAuthDeferred(const string16& username, - const string16& password); - - // Calls CancelAuth from the IO loop. - void CancelAuthDeferred(); - - // Closes the view_contents from the UI loop. - void CloseContentsDeferred(); - - // Marks authentication as handled and returns the previous handled - // state. - bool TestAndSetAuthHandled(); - - // Notify observers that authentication is supplied. - void NotifyAuthSupplied(const string16& username, - const string16& password); - - void NotifyAuthCancelled(); // All the methods that begin with Platform need to be implemented by the // platform specific LoginDialog implementation. // Creates the dialog. // Threading: UI thread. - void PlatformCreateDialog(const string16& message); - - void PlatformShowDialog(); + void PlatformCreateDialog(const base::string16& message); // Called from the destructor to let each platform do any necessary cleanup. // Threading: UI thread. void PlatformCleanUp(); @@ -138,19 +66,13 @@ class ShellLoginDialog : public ResourceDispatcherHostLoginDelegate, // Sets up dialog creation. // Threading: UI thread. - void PrepDialog(const string16& host, const string16& realm); + void PrepDialog(const base::string16& host, const base::string16& realm); // Sends the authentication to the requester. // Threading: IO thread. void SendAuthToRequester(bool success, - const string16& username, - const string16& password); - - // Starts observing notifications from other LoginHandlers. - void AddObservers(); - - // Stops observing notifications from other LoginHandlers. - void RemoveObservers(); + const base::string16& username, + const base::string16& password); // Who/where/what asked for the authentication. // Threading: IO thread. @@ -160,77 +82,17 @@ class ShellLoginDialog : public ResourceDispatcherHostLoginDelegate, // Threading: IO thread. net::URLRequest* request_; - // True if we've handled auth (SetAuth or CancelAuth has been called). - bool handled_auth_; - mutable base::Lock handled_auth_lock_; - - // Observes other login handlers so this login handler can respond. - // This is only accessed on the UI thread. - scoped_ptr registrar_; - - typedef std::deque ShellLoginDialogList; - - static ShellLoginDialogList dialog_queue_; - #if defined(OS_MACOSX) // Threading: UI thread. ShellLoginDialogHelper* helper_; // owned - base::string16 message_; -#elif defined(OS_WIN) - HWND dialog_win_; - string16 message_text_; - static INT_PTR CALLBACK DialogProc(HWND dialog, UINT message, WPARAM wparam, - LPARAM lparam); #elif defined(TOOLKIT_GTK) GtkWidget* username_entry_; GtkWidget* password_entry_; GtkWidget* root_; CHROMEGTK_CALLBACK_1(ShellLoginDialog, void, OnResponse, int); - CHROMEGTK_CALLBACK_0(ShellLoginDialog, void, OnDestroy); #endif }; -// Details to provide the content::NotificationObserver. Used by the automation -// proxy for testing. -class LoginNotificationDetails { - public: - explicit LoginNotificationDetails(ShellLoginDialog* handler) - : handler_(handler) {} - ShellLoginDialog* handler() const { return handler_; } - - private: - LoginNotificationDetails() {} - - ShellLoginDialog* handler_; // Where to send the response. - - DISALLOW_COPY_AND_ASSIGN(LoginNotificationDetails); -}; - - -// Details to provide the NotificationObserver. Used by the automation proxy -// for testing and by other LoginHandlers to dismiss themselves when an -// identical auth is supplied. -class AuthSuppliedLoginNotificationDetails : public LoginNotificationDetails { - public: - AuthSuppliedLoginNotificationDetails(ShellLoginDialog* handler, - const string16& username, - const string16& password) - : LoginNotificationDetails(handler), - username_(username), - password_(password) {} - const string16& username() const { return username_; } - const string16& password() const { return password_; } - - private: - // The username that was used for the authentication. - const string16 username_; - - // The password that was used for the authentication. - const string16 password_; - - DISALLOW_COPY_AND_ASSIGN(AuthSuppliedLoginNotificationDetails); -}; - } // namespace content -#endif // CONTENT_NW_SRC_BROWSER_SHELL_LOGIN_DIALOG_H_ +#endif // CONTENT_SHELL_BROWSER_SHELL_LOGIN_DIALOG_H_ diff --git a/src/browser/shell_login_dialog_gtk.cc b/src/browser/shell_login_dialog_gtk.cc index e2a6447966..7ac1f583a0 100644 --- a/src/browser/shell_login_dialog_gtk.cc +++ b/src/browser/shell_login_dialog_gtk.cc @@ -1,24 +1,8 @@ -// Copyright (c) 2012 Intel Corp -// Copyright (c) 2012 The Chromium Authors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell co -// pies of the Software, and to permit persons to whom the Software is furnished -// to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in al -// l copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM -// PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNES -// S FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -// OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WH -// ETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -#include "content/nw/src/browser/shell_login_dialog.h" +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/shell/browser/shell_login_dialog.h" #include @@ -26,7 +10,7 @@ #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "content/public/browser/browser_thread.h" -#include "content/public/browser/render_view_host.h" +#include "content/public/browser/render_frame_host.h" #include "content/public/browser/resource_dispatcher_host.h" #include "content/public/browser/resource_request_info.h" #include "content/public/browser/web_contents.h" @@ -35,21 +19,20 @@ namespace content { -void ShellLoginDialog::PlatformCreateDialog(const string16& message) { +void ShellLoginDialog::PlatformCreateDialog(const base::string16& message) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); int render_process_id; - int render_view_id; - if (!ResourceRequestInfo::ForRequest(request_)->GetAssociatedRenderView( - &render_process_id, &render_view_id)) { + int render_frame_id; + if (!ResourceRequestInfo::ForRequest(request_)->GetAssociatedRenderFrame( + &render_process_id, &render_frame_id)) { NOTREACHED(); } WebContents* web_contents = NULL; - RenderViewHost* render_view_host = - RenderViewHost::FromID(render_process_id, render_view_id); - if (render_view_host) - web_contents = WebContents::FromRenderViewHost(render_view_host); + RenderFrameHost* render_frame_host = + RenderFrameHost::FromID(render_process_id, render_frame_id); + web_contents = WebContents::FromRenderFrameHost(render_frame_host); DCHECK(web_contents); gfx::NativeWindow parent_window = @@ -62,7 +45,7 @@ void ShellLoginDialog::PlatformCreateDialog(const string16& message) { "Please log in."); GtkWidget* content_area = gtk_dialog_get_content_area(GTK_DIALOG(root_)); - GtkWidget* label = gtk_label_new(UTF16ToUTF8(message).c_str()); + GtkWidget* label = gtk_label_new(base::UTF16ToUTF8(message).c_str()); gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); gtk_box_pack_start(GTK_BOX(content_area), label, FALSE, FALSE, 0); @@ -94,34 +77,24 @@ void ShellLoginDialog::PlatformCreateDialog(const string16& message) { gtk_box_pack_start(GTK_BOX(content_area), table, FALSE, FALSE, 0); g_signal_connect(root_, "response", G_CALLBACK(OnResponseThunk), this); - g_signal_connect(root_, "destroy", G_CALLBACK(OnDestroyThunk), this); - gtk_widget_grab_focus(username_entry_); + gtk_widget_show_all(GTK_WIDGET(root_)); } void ShellLoginDialog::PlatformCleanUp() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (root_) { - gtk_widget_destroy(root_); - root_ = NULL; - } } void ShellLoginDialog::PlatformRequestCancelled() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); } -void ShellLoginDialog::PlatformShowDialog() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - gtk_widget_show_all(GTK_WIDGET(root_)); -} - void ShellLoginDialog::OnResponse(GtkWidget* sender, int response_id) { switch (response_id) { case GTK_RESPONSE_OK: UserAcceptedAuth( - UTF8ToUTF16(gtk_entry_get_text(GTK_ENTRY(username_entry_))), - UTF8ToUTF16(gtk_entry_get_text(GTK_ENTRY(password_entry_)))); + base::UTF8ToUTF16(gtk_entry_get_text(GTK_ENTRY(username_entry_))), + base::UTF8ToUTF16(gtk_entry_get_text(GTK_ENTRY(password_entry_)))); break; case GTK_RESPONSE_CANCEL: case GTK_RESPONSE_DELETE_EVENT: @@ -131,15 +104,7 @@ void ShellLoginDialog::OnResponse(GtkWidget* sender, int response_id) { NOTREACHED(); } -} - -void ShellLoginDialog::OnDestroy(GtkWidget* widget) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - - // The web contents modal dialog is going to delete itself; clear our pointer. - root_ = NULL; - - ReleaseSoon(); + gtk_widget_destroy(root_); } } // namespace content diff --git a/src/browser/shell_login_dialog_mac.mm b/src/browser/shell_login_dialog_mac.mm index eb4ae0ec0d..3e014e8791 100644 --- a/src/browser/shell_login_dialog_mac.mm +++ b/src/browser/shell_login_dialog_mac.mm @@ -1,24 +1,8 @@ -// Copyright (c) 2012 Intel Corp -// Copyright (c) 2012 The Chromium Authors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell co -// pies of the Software, and to permit persons to whom the Software is furnished -// to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in al -// l copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM -// PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNES -// S FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -// OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WH -// ETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -#include "content/nw/src/browser/shell_login_dialog.h" +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/shell/browser/shell_login_dialog.h" #import @@ -80,14 +64,11 @@ - (void)focus { - (void)alertDidEnd:(NSAlert*)alert returnCode:(int)returnCode contextInfo:(void*)contextInfo { + if (returnCode == NSRunStoppedResponse) + return; content::ShellLoginDialog* this_dialog = reinterpret_cast(contextInfo); - if (returnCode == NSRunStoppedResponse) { - this_dialog->ReleaseSoon(); - return; - } - if (returnCode == NSAlertFirstButtonReturn) { this_dialog->UserAcceptedAuth( base::SysNSStringToUTF16([usernameField_ stringValue]), @@ -106,17 +87,14 @@ - (void)cancel { namespace content { -void ShellLoginDialog::PlatformCreateDialog(const string16& message) { +void ShellLoginDialog::PlatformCreateDialog(const base::string16& message) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); helper_ = [[ShellLoginDialogHelper alloc] init]; - message_ = message; -} -void ShellLoginDialog::PlatformShowDialog() { // Show the modal dialog. NSAlert* alert = [helper_ alert]; [alert setDelegate:helper_]; - [alert setInformativeText:base::SysUTF16ToNSString(message_)]; + [alert setInformativeText:base::SysUTF16ToNSString(message)]; [alert setMessageText:@"Please log in."]; [alert addButtonWithTitle:@"OK"]; NSButton* other = [alert addButtonWithTitle:@"Cancel"]; @@ -134,7 +112,6 @@ - (void)cancel { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); [helper_ release]; helper_ = nil; - ReleaseSoon(); } void ShellLoginDialog::PlatformRequestCancelled() { diff --git a/src/browser/shell_resource_dispatcher_host_delegate.cc b/src/browser/shell_resource_dispatcher_host_delegate.cc index 2bc22885aa..918df3340b 100644 --- a/src/browser/shell_resource_dispatcher_host_delegate.cc +++ b/src/browser/shell_resource_dispatcher_host_delegate.cc @@ -63,7 +63,7 @@ bool ShellResourceDispatcherHostDelegate::HandleExternalProtocol( BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, - base::Bind(&platform_util::OpenExternal, url)); + base::Bind(&platform_util::OpenExternal2, url)); #endif return true; diff --git a/src/chrome_breakpad_client.cc b/src/chrome_breakpad_client.cc index f73a28203b..3dff5afbd0 100644 --- a/src/chrome_breakpad_client.cc +++ b/src/chrome_breakpad_client.cc @@ -37,7 +37,7 @@ #endif #if defined(OS_POSIX) -#include "chrome/common/dump_without_crashing.h" +#include "base/debug/dump_without_crashing.h" #endif #if defined(OS_WIN) || defined(OS_MACOSX) @@ -306,12 +306,6 @@ bool ChromeBreakpadClient::GetCrashDumpLocation(base::FilePath* crash_dir) { return PathService::Get(chrome::DIR_CRASH_DUMPS, crash_dir); } -#if defined(OS_POSIX) -void ChromeBreakpadClient::SetDumpWithoutCrashingFunction(void (*function)()) { - logging::SetDumpWithoutCrashingFunction(function); -} -#endif - size_t ChromeBreakpadClient::RegisterCrashKeys() { return crash_keys::RegisterChromeCrashKeys(); } @@ -332,4 +326,13 @@ int ChromeBreakpadClient::GetAndroidMinidumpDescriptor() { } #endif +bool ChromeBreakpadClient::EnableBreakpadForProcess( + const std::string& process_type) { + return process_type == switches::kRendererProcess || + process_type == switches::kPluginProcess || + process_type == switches::kPpapiPluginProcess || + process_type == switches::kZygoteProcess || + process_type == switches::kGpuProcess; +} + } // namespace chrome diff --git a/src/chrome_breakpad_client.h b/src/chrome_breakpad_client.h index 10d09805df..7e79a092e6 100644 --- a/src/chrome_breakpad_client.h +++ b/src/chrome_breakpad_client.h @@ -68,6 +68,9 @@ class ChromeBreakpadClient : public breakpad::BreakpadClient { virtual void InstallAdditionalFilters(BreakpadRef breakpad) OVERRIDE; #endif + virtual bool EnableBreakpadForProcess( + const std::string& process_type) OVERRIDE; + private: DISALLOW_COPY_AND_ASSIGN(ChromeBreakpadClient); }; diff --git a/src/common/print_messages.cc b/src/common/print_messages.cc index d829fb54cd..f4fae5cc88 100644 --- a/src/common/print_messages.cc +++ b/src/common/print_messages.cc @@ -24,7 +24,7 @@ PrintMsg_Print_Params::PrintMsg_Print_Params() preview_ui_id(-1), preview_request_id(0), is_first_request(false), - print_scaling_option(WebKit::WebPrintScalingOptionSourceSize), + print_scaling_option(blink::WebPrintScalingOptionSourceSize), print_to_pdf(false), display_header_footer(false), title(), @@ -50,11 +50,11 @@ void PrintMsg_Print_Params::Reset() { preview_ui_id = -1; preview_request_id = 0; is_first_request = false; - print_scaling_option = WebKit::WebPrintScalingOptionSourceSize; + print_scaling_option = blink::WebPrintScalingOptionSourceSize; print_to_pdf = false; display_header_footer = false; - title = string16(); - url = string16(); + title = base::string16(); + url = base::string16(); should_print_backgrounds = false; } diff --git a/src/common/print_messages.h b/src/common/print_messages.h index d154bff752..4e3f99fab5 100644 --- a/src/common/print_messages.h +++ b/src/common/print_messages.h @@ -42,11 +42,11 @@ struct PrintMsg_Print_Params { int32 preview_ui_id; int preview_request_id; bool is_first_request; - WebKit::WebPrintScalingOption print_scaling_option; + blink::WebPrintScalingOption print_scaling_option; bool print_to_pdf; bool display_header_footer; - string16 title; - string16 url; + base::string16 title; + base::string16 url; bool should_print_backgrounds; }; @@ -75,7 +75,7 @@ struct PrintHostMsg_RequestPrintPreview_Params { #define IPC_MESSAGE_START PrintMsgStart IPC_ENUM_TRAITS(printing::MarginType) -IPC_ENUM_TRAITS(WebKit::WebPrintScalingOption) +IPC_ENUM_TRAITS(blink::WebPrintScalingOption) // Parameters for a render request. IPC_STRUCT_TRAITS_BEGIN(PrintMsg_Print_Params) @@ -287,7 +287,7 @@ IPC_MESSAGE_ROUTED0(PrintMsg_PrintNodeUnderContextMenu) // showing the print dialog. (This is the final step in the print preview // workflow.) IPC_MESSAGE_ROUTED1(PrintMsg_PrintForPrintPreview, - DictionaryValue /* settings */) + base::DictionaryValue /* settings */) // Tells the render view to switch the CSS to print media type, renders every // requested pages and switch back the CSS to display media type. @@ -305,7 +305,7 @@ IPC_MESSAGE_ROUTED1(PrintMsg_SetScriptedPrintingBlocked, // requested pages for print preview using the given |settings|. This gets // called multiple times as the user updates settings. IPC_MESSAGE_ROUTED1(PrintMsg_PrintPreview, - DictionaryValue /* settings */) + base::DictionaryValue /* settings */) // Like PrintMsg_PrintPages, but using the print preview document's frame/node. IPC_MESSAGE_ROUTED0(PrintMsg_PrintForSystemDialog) @@ -350,7 +350,7 @@ IPC_SYNC_MESSAGE_ROUTED0_1(PrintHostMsg_GetDefaultPrintSettings, // |job_settings|. IPC_SYNC_MESSAGE_ROUTED2_1(PrintHostMsg_UpdatePrintSettings, int /* document_cookie */, - DictionaryValue /* job_settings */, + base::DictionaryValue /* job_settings */, PrintMsg_PrintPages_Params /* current_settings */) // It's the renderer that controls the printing process when it is generated diff --git a/src/geolocation/shell_access_token_store.cc b/src/geolocation/shell_access_token_store.cc index 35e39e1a03..d1c53dc8b7 100644 --- a/src/geolocation/shell_access_token_store.cc +++ b/src/geolocation/shell_access_token_store.cc @@ -44,12 +44,12 @@ void ShellAccessTokenStore::RespondOnOriginatingThread( // Since content_shell is a test executable, rather than an end user program, // we provide a dummy access_token set to avoid hitting the server. AccessTokenSet access_token_set; - access_token_set[GURL()] = ASCIIToUTF16("chromium_content_shell"); + access_token_set[GURL()] = base::ASCIIToUTF16("chromium_content_shell"); callback.Run(access_token_set, system_request_context_); } void ShellAccessTokenStore::SaveAccessToken( - const GURL& server_url, const string16& access_token) { + const GURL& server_url, const base::string16& access_token) { } } // namespace content diff --git a/src/geolocation/shell_access_token_store.h b/src/geolocation/shell_access_token_store.h index 82ee0f888e..205d89ffc9 100644 --- a/src/geolocation/shell_access_token_store.h +++ b/src/geolocation/shell_access_token_store.h @@ -28,7 +28,7 @@ class ShellAccessTokenStore : public content::AccessTokenStore { const LoadAccessTokensCallbackType& callback) OVERRIDE; virtual void SaveAccessToken( - const GURL& server_url, const string16& access_token) OVERRIDE; + const GURL& server_url, const base::string16& access_token) OVERRIDE; content::ShellBrowserContext* shell_browser_context_; net::URLRequestContextGetter* system_request_context_; diff --git a/src/media/media_capture_devices_dispatcher.cc b/src/media/media_capture_devices_dispatcher.cc index 0a4d02ae7e..5e697f6732 100644 --- a/src/media/media_capture_devices_dispatcher.cc +++ b/src/media/media_capture_devices_dispatcher.cc @@ -4,14 +4,16 @@ #include "base/memory/singleton.h" +#include "content/public/browser/media_observer.h" #include "content/nw/src/media/media_capture_devices_dispatcher.h" #include "content/public/browser/browser_thread.h" -#include "content/public/browser/media_devices_monitor.h" +#include "content/public/browser/media_capture_devices.h" #include "content/public/common/media_stream_request.h" using content::BrowserThread; using content::MediaStreamDevices; +using content::MediaCaptureDevices; namespace { @@ -31,28 +33,26 @@ const content::MediaStreamDevice* FindDeviceWithId( } MediaCaptureDevicesDispatcher::MediaCaptureDevicesDispatcher() - : devices_enumerated_(false) {} +{} MediaCaptureDevicesDispatcher::~MediaCaptureDevicesDispatcher() {} -void MediaCaptureDevicesDispatcher::AudioCaptureDevicesChanged( - const MediaStreamDevices& devices) { +void MediaCaptureDevicesDispatcher::OnAudioCaptureDevicesChanged() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind(&MediaCaptureDevicesDispatcher::UpdateAudioDevicesOnUIThread, - this, devices)); + base::Bind( + &MediaCaptureDevicesDispatcher::NotifyAudioDevicesChangedOnUIThread, + base::Unretained(this))); } -void MediaCaptureDevicesDispatcher::VideoCaptureDevicesChanged( - const MediaStreamDevices& devices) { +void MediaCaptureDevicesDispatcher::OnVideoCaptureDevicesChanged() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind(&MediaCaptureDevicesDispatcher::UpdateVideoDevicesOnUIThread, - this, devices)); + base::Bind( + &MediaCaptureDevicesDispatcher::NotifyVideoDevicesChangedOnUIThread, + base::Unretained(this))); } void MediaCaptureDevicesDispatcher::AddObserver(Observer* observer) { @@ -69,25 +69,13 @@ void MediaCaptureDevicesDispatcher::RemoveObserver(Observer* observer) { const MediaStreamDevices& MediaCaptureDevicesDispatcher::GetAudioCaptureDevices() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (!devices_enumerated_) { - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, - base::Bind(&content::EnsureMonitorCaptureDevices)); - devices_enumerated_ = true; - } - return audio_devices_; + return MediaCaptureDevices::GetInstance()->GetAudioCaptureDevices(); } const MediaStreamDevices& MediaCaptureDevicesDispatcher::GetVideoCaptureDevices() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (!devices_enumerated_) { - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, - base::Bind(&content::EnsureMonitorCaptureDevices)); - devices_enumerated_ = true; - } - return video_devices_; + return MediaCaptureDevices::GetInstance()->GetVideoCaptureDevices(); } void MediaCaptureDevicesDispatcher::OnCreatingAudioStream( @@ -101,22 +89,16 @@ void MediaCaptureDevicesDispatcher::OnCreatingAudioStream( base::Unretained(this), render_process_id, render_view_id)); } -void MediaCaptureDevicesDispatcher::UpdateAudioDevicesOnUIThread( - const content::MediaStreamDevices& devices) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - devices_enumerated_ = true; - audio_devices_ = devices; +void MediaCaptureDevicesDispatcher::NotifyAudioDevicesChangedOnUIThread() { + MediaStreamDevices devices = GetAudioCaptureDevices(); FOR_EACH_OBSERVER(Observer, observers_, - OnUpdateAudioDevices(audio_devices_)); + OnUpdateAudioDevices(devices)); } -void MediaCaptureDevicesDispatcher::UpdateVideoDevicesOnUIThread( - const content::MediaStreamDevices& devices){ - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - devices_enumerated_ = true; - video_devices_ = devices; +void MediaCaptureDevicesDispatcher::NotifyVideoDevicesChangedOnUIThread() { + MediaStreamDevices devices = GetVideoCaptureDevices(); FOR_EACH_OBSERVER(Observer, observers_, - OnUpdateVideoDevices(video_devices_)); + OnUpdateVideoDevices(devices)); } void MediaCaptureDevicesDispatcher::OnCreatingAudioStreamOnUIThread( @@ -165,3 +147,9 @@ MediaCaptureDevicesDispatcher::GetFirstAvailableVideoDevice() { return &(*video_devices.begin()); } +void MediaCaptureDevicesDispatcher::Observe( + int type, + const content::NotificationSource& source, + const content::NotificationDetails& details) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); +} diff --git a/src/media/media_capture_devices_dispatcher.h b/src/media/media_capture_devices_dispatcher.h index 18c6fd0d03..2e707570a2 100644 --- a/src/media/media_capture_devices_dispatcher.h +++ b/src/media/media_capture_devices_dispatcher.h @@ -8,12 +8,16 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/observer_list.h" +#include "content/public/browser/media_observer.h" +#include "content/public/browser/notification_observer.h" +#include "content/public/browser/notification_registrar.h" +#include "content/public/browser/web_contents_delegate.h" #include "content/public/common/media_stream_request.h" // This observer is owned by MediaInternals and deleted when MediaInternals // is deleted. -class MediaCaptureDevicesDispatcher - : public base::RefCountedThreadSafe { +class MediaCaptureDevicesDispatcher : public content::MediaObserver, + public content::NotificationObserver { public: class Observer { public: @@ -27,6 +31,13 @@ class MediaCaptureDevicesDispatcher virtual void OnUpdateVideoDevices( const content::MediaStreamDevices& devices) {} + // Handle an information update related to a media stream request. + virtual void OnRequestUpdate( + int render_process_id, + int render_view_id, + const content::MediaStreamDevice& device, + const content::MediaRequestState state) {} + virtual void OnCreatingAudioStream(int render_process_id, int render_view_id) {} @@ -36,15 +47,29 @@ class MediaCaptureDevicesDispatcher MediaCaptureDevicesDispatcher(); virtual ~MediaCaptureDevicesDispatcher(); - // Called on IO thread when one audio device is plugged in or unplugged. - void AudioCaptureDevicesChanged(const content::MediaStreamDevices& devices); - - // Called on IO thread when one video device is plugged in or unplugged. - void VideoCaptureDevicesChanged(const content::MediaStreamDevices& devices); + void NotifyAudioDevicesChangedOnUIThread(); + void NotifyVideoDevicesChangedOnUIThread(); + // Overridden from content::MediaObserver: + virtual void OnAudioCaptureDevicesChanged() OVERRIDE; + virtual void OnVideoCaptureDevicesChanged() OVERRIDE; void OnCreatingAudioStream(int render_process_id, - int render_view_id); - - + int render_view_id) OVERRIDE; + + // content::NotificationObserver implementation. + virtual void Observe(int type, + const content::NotificationSource& source, + const content::NotificationDetails& details) OVERRIDE; + + + virtual void OnAudioStreamPlaying( + int render_process_id, + int render_frame_id, + int stream_id, + const ReadPowerAndClipCallback& power_read_callback) OVERRIDE {} + virtual void OnAudioStreamStopped( + int render_process_id, + int render_frame_id, + int stream_id) OVERRIDE {} // Methods for observers. Called on UI thread. // Observers should add themselves on construction and remove themselves // on destruction. @@ -60,6 +85,15 @@ class MediaCaptureDevicesDispatcher const content::MediaStreamDevice* GetRequestedVideoDevice(const std::string& requested_video_device_id); + + virtual void OnMediaRequestStateChanged( + int render_process_id, + int render_view_id, + int page_request_id, + const GURL& security_origin, + const content::MediaStreamDevice& device, + content::MediaRequestState state) {} + // Returns the first available audio or video device, or NULL if no devices // are available. const content::MediaStreamDevice* GetFirstAvailableAudioDevice(); diff --git a/src/media/media_internals.cc b/src/media/media_internals.cc index 56ed21b09d..ee171558c1 100644 --- a/src/media/media_internals.cc +++ b/src/media/media_internals.cc @@ -89,22 +89,21 @@ MediaInternals* MediaInternals::GetInstance() { MediaInternals::~MediaInternals() {} -void MediaInternals::OnAudioCaptureDevicesChanged( - const content::MediaStreamDevices& devices) { +void MediaInternals::OnAudioCaptureDevicesChanged() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - media_devices_dispatcher_->AudioCaptureDevicesChanged(devices); + media_devices_dispatcher_->OnAudioCaptureDevicesChanged(); } -void MediaInternals::OnVideoCaptureDevicesChanged( - const content::MediaStreamDevices& devices) { +void MediaInternals::OnVideoCaptureDevicesChanged() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - media_devices_dispatcher_->VideoCaptureDevicesChanged(devices); + media_devices_dispatcher_->OnVideoCaptureDevicesChanged(); } void MediaInternals::OnMediaRequestStateChanged( int render_process_id, int render_view_id, int page_request_id, + const GURL& security_origin, const content::MediaStreamDevice& device, content::MediaRequestState state) { } @@ -119,7 +118,7 @@ void MediaInternals::OnCreatingAudioStream( media_devices_dispatcher_->OnCreatingAudioStream(render_process_id, render_view_id); } -scoped_refptr +MediaCaptureDevicesDispatcher* MediaInternals::GetMediaCaptureDevicesDispatcher() { return media_devices_dispatcher_; } diff --git a/src/media/media_internals.h b/src/media/media_internals.h index b4e7af4ffb..3a2f79bcff 100644 --- a/src/media/media_internals.h +++ b/src/media/media_internals.h @@ -42,14 +42,13 @@ class MediaInternals : public content::MediaObserver { static MediaInternals* GetInstance(); // Overridden from content::MediaObserver: - virtual void OnAudioCaptureDevicesChanged( - const content::MediaStreamDevices& devices) OVERRIDE; - virtual void OnVideoCaptureDevicesChanged( - const content::MediaStreamDevices& devices) OVERRIDE; + virtual void OnAudioCaptureDevicesChanged() OVERRIDE; + virtual void OnVideoCaptureDevicesChanged() OVERRIDE; virtual void OnMediaRequestStateChanged( int render_process_id, int render_view_id, int page_request_id, + const GURL& security_origin, const content::MediaStreamDevice& device, content::MediaRequestState state) OVERRIDE; virtual void OnAudioStreamPlayingChanged( @@ -62,6 +61,15 @@ class MediaInternals : public content::MediaObserver { virtual void OnCreatingAudioStream(int render_process_id, int render_view_id) OVERRIDE; + virtual void OnAudioStreamPlaying( + int render_process_id, + int render_frame_id, + int stream_id, + const ReadPowerAndClipCallback& power_read_callback) OVERRIDE {} + virtual void OnAudioStreamStopped( + int render_process_id, + int render_frame_id, + int stream_id) OVERRIDE {} // Methods for observers. // Observers should add themselves on construction and remove themselves // on destruction. @@ -70,8 +78,7 @@ class MediaInternals : public content::MediaObserver { void SendEverything(); scoped_refptr GetMediaStreamCaptureIndicator(); - scoped_refptr - GetMediaCaptureDevicesDispatcher(); + MediaCaptureDevicesDispatcher* GetMediaCaptureDevicesDispatcher(); private: friend class MediaInternalsTest; @@ -83,7 +90,7 @@ class MediaInternals : public content::MediaObserver { // (host, stream_id) is a unique id for the audio stream. // |host| will never be dereferenced. void UpdateAudioStream(void* host, int stream_id, - const std::string& property, Value* value); + const std::string& property, base::Value* value); // Removes |item| from |data_|. void DeleteItem(const std::string& item); @@ -91,14 +98,14 @@ class MediaInternals : public content::MediaObserver { // Sets data_.id.property = value and notifies attached UIs using update_fn. // id may be any depth, e.g. "video.decoders.1.2.3" void UpdateItem(const std::string& update_fn, const std::string& id, - const std::string& property, Value* value); + const std::string& property, base::Value* value); // Calls javascript |function|(|value|) on each attached UI. - void SendUpdate(const std::string& function, Value* value); + void SendUpdate(const std::string& function, base::Value* value); - DictionaryValue data_; + base::DictionaryValue data_; ObserverList observers_; - scoped_refptr media_devices_dispatcher_; + MediaCaptureDevicesDispatcher* media_devices_dispatcher_; DISALLOW_COPY_AND_ASSIGN(MediaInternals); }; diff --git a/src/media/media_stream_devices_controller.cc b/src/media/media_stream_devices_controller.cc index 866c080876..29942a0300 100644 --- a/src/media/media_stream_devices_controller.cc +++ b/src/media/media_stream_devices_controller.cc @@ -8,7 +8,7 @@ #include "content/nw/src/media/media_capture_devices_dispatcher.h" #include "content/nw/src/media/media_internals.h" #include "content/public/browser/browser_thread.h" -#include "content/public/common/desktop_media_id.h" +#include "content/public/browser/desktop_media_id.h" #include "content/public/common/media_stream_request.h" using content::BrowserThread; @@ -185,11 +185,14 @@ void MediaStreamDevicesController::Accept(bool update_content_setting) { break; } - callback_.Run(devices, scoped_ptr()); + callback_.Run(devices, + devices.empty() ? + content::MEDIA_DEVICE_NO_HARDWARE : content::MEDIA_DEVICE_OK, + scoped_ptr()); } void MediaStreamDevicesController::Deny(bool update_content_setting) { - callback_.Run(content::MediaStreamDevices(), scoped_ptr()); + callback_.Run(content::MediaStreamDevices(), content::MEDIA_DEVICE_NO_HARDWARE, scoped_ptr()); } bool MediaStreamDevicesController::IsAudioDeviceBlockedByPolicy() const { @@ -233,7 +236,10 @@ void MediaStreamDevicesController::HandleTapMediaRequest() { content::MEDIA_DESKTOP_VIDEO_CAPTURE, media_id.ToString(), "Screen")); } - callback_.Run(devices, scoped_ptr()); + callback_.Run(devices, + devices.empty() ? + content::MEDIA_DEVICE_NO_HARDWARE : content::MEDIA_DEVICE_OK, + scoped_ptr()); } bool MediaStreamDevicesController::IsSchemeSecure() const { diff --git a/src/net/app_protocol_handler.cc b/src/net/app_protocol_handler.cc index da867b8644..2b61c4be16 100644 --- a/src/net/app_protocol_handler.cc +++ b/src/net/app_protocol_handler.cc @@ -51,15 +51,14 @@ net::HttpResponseHeaders* BuildHttpHeaders( last_modified_time.ToInternalValue()); hash = base::SHA1HashString(hash); std::string etag; - if (base::Base64Encode(hash, &etag)) { - raw_headers.append(1, '\0'); - raw_headers.append("ETag: \""); - raw_headers.append(etag); - raw_headers.append("\""); - // Also force revalidation. - raw_headers.append(1, '\0'); - raw_headers.append("cache-control: no-cache"); - } + base::Base64Encode(hash, &etag); + raw_headers.append(1, '\0'); + raw_headers.append("ETag: \""); + raw_headers.append(etag); + raw_headers.append("\""); + // Also force revalidation. + raw_headers.append(1, '\0'); + raw_headers.append("cache-control: no-cache"); } raw_headers.append(2, '\0'); @@ -74,8 +73,8 @@ void ReadMimeTypeFromFile(const base::FilePath& filename, base::Time GetFileLastModifiedTime(const base::FilePath& filename) { if (base::PathExists(filename)) { - base::PlatformFileInfo info; - if (file_util::GetFileInfo(filename, &info)) + base::File::Info info; + if (base::GetFileInfo(filename, &info)) return info.last_modified; } return base::Time(); @@ -83,8 +82,8 @@ base::Time GetFileLastModifiedTime(const base::FilePath& filename) { base::Time GetFileCreationTime(const base::FilePath& filename) { if (base::PathExists(filename)) { - base::PlatformFileInfo info; - if (file_util::GetFileInfo(filename, &info)) + base::File::Info info; + if (base::GetFileInfo(filename, &info)) return info.creation_time; } return base::Time(); diff --git a/src/net/shell_network_delegate.cc b/src/net/shell_network_delegate.cc index 3485e276c1..3142e12238 100644 --- a/src/net/shell_network_delegate.cc +++ b/src/net/shell_network_delegate.cc @@ -75,7 +75,7 @@ void ShellNetworkDelegate::OnURLRequestDestroyed(net::URLRequest* request) { } void ShellNetworkDelegate::OnPACScriptError(int line_number, - const string16& error) { + const base::string16& error) { } ShellNetworkDelegate::AuthRequiredResponse ShellNetworkDelegate::OnAuthRequired( @@ -113,9 +113,4 @@ int ShellNetworkDelegate::OnBeforeSocketStreamConnect( return net::OK; } -void ShellNetworkDelegate::OnRequestWaitStateChange( - const net::URLRequest& request, - RequestWaitState waiting) { -} - } // namespace content diff --git a/src/net/shell_network_delegate.h b/src/net/shell_network_delegate.h index 14c0bf08b7..11cc34f4cd 100644 --- a/src/net/shell_network_delegate.h +++ b/src/net/shell_network_delegate.h @@ -57,7 +57,7 @@ class ShellNetworkDelegate : public net::NetworkDelegate { virtual void OnCompleted(net::URLRequest* request, bool started) OVERRIDE; virtual void OnURLRequestDestroyed(net::URLRequest* request) OVERRIDE; virtual void OnPACScriptError(int line_number, - const string16& error) OVERRIDE; + const base::string16& error) OVERRIDE; virtual AuthRequiredResponse OnAuthRequired( net::URLRequest* request, const net::AuthChallengeInfo& auth_info, @@ -75,8 +75,6 @@ class ShellNetworkDelegate : public net::NetworkDelegate { virtual int OnBeforeSocketStreamConnect( net::SocketStream* stream, const net::CompletionCallback& callback) OVERRIDE; - virtual void OnRequestWaitStateChange(const net::URLRequest& request, - RequestWaitState state) OVERRIDE; DISALLOW_COPY_AND_ASSIGN(ShellNetworkDelegate); }; diff --git a/src/net/shell_url_request_context_getter.cc b/src/net/shell_url_request_context_getter.cc index 5020b71771..0595186d07 100644 --- a/src/net/shell_url_request_context_getter.cc +++ b/src/net/shell_url_request_context_getter.cc @@ -176,11 +176,11 @@ net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() { FilePath cookie_path = data_path_.Append(FILE_PATH_LITERAL("cookies")); scoped_refptr cookie_store = NULL; - cookie_store = content::CreatePersistentCookieStore( - cookie_path, - false, - NULL, - new NWCookieMonsterDelegate(browser_context_)); + + content::CookieStoreConfig cookie_config( + cookie_path, content::CookieStoreConfig::PERSISTANT_SESSION_COOKIES, + NULL, new NWCookieMonsterDelegate(browser_context_)); + cookie_store = content::CreateCookieStore(cookie_config); cookie_store->GetCookieMonster()->SetPersistSessionCookies(true); storage_->set_cookie_store(cookie_store); @@ -199,7 +199,7 @@ net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() { storage_->set_http_user_agent_settings( new net::StaticHttpUserAgentSettings( net::HttpUtil::GenerateAcceptLanguageHeader(accept_lang), - EmptyString())); + base::EmptyString())); scoped_ptr host_resolver( net::HostResolver::CreateDefaultResolver(NULL)); @@ -270,7 +270,7 @@ net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() { new net::URLRequestJobFactoryImpl()); InstallProtocolHandlers(job_factory.get(), &protocol_handlers_); job_factory->SetProtocolHandler( - chrome::kFileScheme, + content::kFileScheme, new net::FileProtocolHandler( content::BrowserThread::GetBlockingPool()-> GetTaskRunnerWithShutdownBehavior( diff --git a/src/nw_package.cc b/src/nw_package.cc index 6131cfca21..e78c6d0564 100644 --- a/src/nw_package.cc +++ b/src/nw_package.cc @@ -45,9 +45,11 @@ #include "ui/gfx/image/image_skia_rep.h" #include "ui/gfx/codec/png_codec.h" +namespace base { bool IsSwitch(const CommandLine::StringType& string, CommandLine::StringType* switch_string, CommandLine::StringType* switch_value); +} namespace nw { @@ -64,7 +66,7 @@ bool MakePathAbsolute(FilePath* file_path) { DCHECK(file_path); FilePath current_directory; - if (!file_util::GetCurrentDirectory(¤t_directory)) + if (!base::GetCurrentDirectory(¤t_directory)) return false; if (file_path->IsAbsolute()) @@ -266,7 +268,7 @@ bool Package::InitFromPath() { // Parse file. std::string error; JSONFileValueSerializer serializer(manifest_path); - scoped_ptr root(serializer.Deserialize(NULL, &error)); + scoped_ptr root(serializer.Deserialize(NULL, &error)); if (!root.get()) { ReportError("Unable to parse package.json", error.empty() ? @@ -274,14 +276,14 @@ bool Package::InitFromPath() { manifest_path.AsUTF8Unsafe() : error); return false; - } else if (!root->IsType(Value::TYPE_DICTIONARY)) { + } else if (!root->IsType(base::Value::TYPE_DICTIONARY)) { ReportError("Invalid package.json", "package.json's content should be a object type."); return false; } // Save result in global - root_.reset(static_cast(root.release())); + root_.reset(static_cast(root.release())); // Save origin package info // Since we will change some value in root_, @@ -355,7 +357,7 @@ bool Package::ExtractPath() { // Read symbolic link. #if defined(OS_POSIX) FilePath target; - if (file_util::ReadSymbolicLink(path_, &target)) + if (base::ReadSymbolicLink(path_, &target)) path_ = target; #endif @@ -378,9 +380,9 @@ bool Package::ExtractPackage(const FilePath& zip_file, FilePath* where) { if (!scoped_temp_dir_.IsValid()) { #if defined(OS_WIN) - if (!file_util::CreateNewTempDirectory(L"nw", where)) { + if (!base::CreateNewTempDirectory(L"nw", where)) { #else - if (!file_util::CreateNewTempDirectory("nw", where)) { + if (!base::CreateNewTempDirectory("nw", where)) { #endif ReportError("Cannot extract package", "Unable to create temporary directory."); @@ -411,7 +413,7 @@ void Package::ReadChromiumArgs() { tokenizer.set_quote_chars("\'"); while (tokenizer.GetNext()) { std::string token = tokenizer.token(); - RemoveChars(token, "\'", &token); + base::RemoveChars(token, "\'", &token); chromium_args.push_back(token); } @@ -423,12 +425,12 @@ void Package::ReadChromiumArgs() { // Note:: On Windows, the |CommandLine::StringType| will be |std::wstring|, // so the chromium_args[i] is not compatible. We convert the wstring to // string here is safe beacuse we use ASCII only. - if (!IsSwitch(ASCIIToWide(chromium_args[i]), &key, &value)) + if (!base::IsSwitch(ASCIIToWide(chromium_args[i]), &key, &value)) continue; command_line->AppendSwitchASCII(WideToASCII(key), WideToASCII(value)); #else - if (!IsSwitch(chromium_args[i], &key, &value)) + if (!base::IsSwitch(chromium_args[i], &key, &value)) continue; command_line->AppendSwitchASCII(key, value); #endif diff --git a/src/nw_shell.cc b/src/nw_shell.cc index ffb76671eb..dcde623269 100644 --- a/src/nw_shell.cc +++ b/src/nw_shell.cc @@ -154,7 +154,7 @@ Shell* Shell::FromRenderViewHost(RenderViewHost* rvh) { return windows_[i]; }else{ WebContentsImpl* impl = static_cast(web_contents); - RenderViewHostManager* rvhm = impl->GetRenderManagerForTesting(); + RenderFrameHostManager* rvhm = impl->GetRenderManagerForTesting(); if (rvhm && static_cast(rvhm->pending_render_view_host()) == rvh) return windows_[i]; } @@ -289,9 +289,9 @@ void Shell::PrintCriticalError(const std::string& title, error_page_url = "data:text/html;base64,VW5hYmxlIHRvIGZpbmQgbncucGFrLgo="; } else { std::string content_with_no_newline, content_with_no_space; - ReplaceChars(net::EscapeForHTML(content), + base::ReplaceChars(net::EscapeForHTML(content), "\n", "
", &content_with_no_newline); - ReplaceChars(content_with_no_newline, + base::ReplaceChars(content_with_no_newline, " ", " ", &content_with_no_space); std::vector subst; @@ -399,7 +399,7 @@ void Shell::ShowDevTools(const char* jail_id, bool headless) { if (nodejs()) { std::string jscript = std::string("require('nw.gui').Window.get().__setDevToolsJail('") + (jail_id ? jail_id : "(null)") + "');"; - inspected_rvh->ExecuteJavascriptInWebFrame(string16(), UTF8ToUTF16(jscript.c_str())); + inspected_rvh->ExecuteJavascriptInWebFrame(base::string16(), base::UTF8ToUTF16(jscript.c_str())); } scoped_refptr agent(DevToolsAgentHost::GetOrCreateFor(inspected_rvh)); @@ -448,7 +448,7 @@ void Shell::ShowDevTools(const char* jail_id, bool headless) { DevToolsAgentHost::GetOrCreateFor(inspected_rvh).get()); int rh_id = shell->web_contents_->GetRenderProcessHost()->GetID(); - ChildProcessSecurityPolicyImpl::GetInstance()->GrantScheme(rh_id, chrome::kFileScheme); + ChildProcessSecurityPolicyImpl::GetInstance()->GrantScheme(rh_id, content::kFileScheme); ChildProcessSecurityPolicyImpl::GetInstance()->GrantScheme(rh_id, "app"); shell->is_devtools_ = true; shell->devtools_owner_ = weak_ptr_factory_.GetWeakPtr(); @@ -539,7 +539,7 @@ bool Shell::IsPopupOrPanel(const WebContents* source) const { // Window opened by window.open void Shell::WebContentsCreated(WebContents* source_contents, int64 source_frame_id, - const string16& frame_name, + const base::string16& frame_name, const GURL& target_url, WebContents* new_contents) { // Create with package's manifest @@ -547,7 +547,7 @@ void Shell::WebContentsCreated(WebContents* source_contents, GetPackage()->window()->DeepCopy()); // Get window features - WebKit::WebWindowFeatures features = new_contents->GetWindowFeatures(); + blink::WebWindowFeatures features = new_contents->GetWindowFeatures(); manifest->SetBoolean(switches::kmResizable, features.resizable); manifest->SetBoolean(switches::kmFullscreen, features.fullscreen); if (features.widthSet) @@ -604,9 +604,9 @@ JavaScriptDialogManager* Shell::GetJavaScriptDialogManager() { bool Shell::AddMessageToConsole(WebContents* source, int32 level, - const string16& message, + const base::string16& message, int32 line_no, - const string16& source_id) { + const base::string16& source_id) { return false; } @@ -639,7 +639,7 @@ void Shell::Observe(int type, Details >(details).ptr(); if (title->first) { - string16 text = title->first->GetTitle(); + base::string16 text = title->first->GetTitle(); window()->SetTitle(UTF16ToUTF8(text)); } } else if (type == NOTIFICATION_RENDERER_PROCESS_CLOSED) { diff --git a/src/nw_shell.h b/src/nw_shell.h index 45b8636de7..c6781ded9e 100644 --- a/src/nw_shell.h +++ b/src/nw_shell.h @@ -150,7 +150,7 @@ class Shell : public WebContentsDelegate, virtual bool IsPopupOrPanel(const WebContents* source) const OVERRIDE; virtual void WebContentsCreated(WebContents* source_contents, int64 source_frame_id, - const string16& frame_name, + const base::string16& frame_name, const GURL& target_url, WebContents* new_contents) OVERRIDE; #if defined(OS_WIN) @@ -175,9 +175,9 @@ class Shell : public WebContentsDelegate, const NativeWebKeyboardEvent& event) OVERRIDE; virtual bool AddMessageToConsole(WebContents* source, int32 level, - const string16& message, + const base::string16& message, int32 line_no, - const string16& source_id) OVERRIDE; + const base::string16& source_id) OVERRIDE; virtual void RequestMediaAccessPermission( WebContents* web_contents, const MediaStreamRequest& request, diff --git a/src/renderer/nw_render_view_observer.cc b/src/renderer/nw_render_view_observer.cc index 68b438d079..6e6b2d059a 100644 --- a/src/renderer/nw_render_view_observer.cc +++ b/src/renderer/nw_render_view_observer.cc @@ -33,15 +33,14 @@ #include "third_party/WebKit/public/web/WebFrame.h" #include "third_party/WebKit/public/web/WebScriptSource.h" #include "third_party/WebKit/public/web/WebView.h" -#include "webkit/glue/webkit_glue.h" using content::RenderView; using content::RenderViewImpl; -using WebKit::WebFrame; -using WebKit::WebRect; -using WebKit::WebScriptSource; -using WebKit::WebSize; +using blink::WebFrame; +using blink::WebRect; +using blink::WebScriptSource; +using blink::WebSize; namespace nw { @@ -80,7 +79,7 @@ void NwRenderViewObserver::OnCaptureSnapshot() { Send(new NwViewHostMsg_Snapshot(routing_id(), snapshot)); } -void NwRenderViewObserver::DidFinishDocumentLoad(WebKit::WebFrame* frame) { +void NwRenderViewObserver::DidFinishDocumentLoad(blink::WebFrame* frame) { RenderViewImpl* rv = RenderViewImpl::FromWebView(frame->view()); if (!rv) return; @@ -88,7 +87,7 @@ void NwRenderViewObserver::DidFinishDocumentLoad(WebKit::WebFrame* frame) { OnDocumentCallback(rv, js_fn, frame); } -void NwRenderViewObserver::DidCreateDocumentElement(WebKit::WebFrame* frame) { +void NwRenderViewObserver::DidCreateDocumentElement(blink::WebFrame* frame) { RenderViewImpl* rv = RenderViewImpl::FromWebView(frame->view()); if (!rv) return; @@ -98,7 +97,7 @@ void NwRenderViewObserver::DidCreateDocumentElement(WebKit::WebFrame* frame) { void NwRenderViewObserver::OnDocumentCallback(RenderViewImpl* rv, const std::string& js_fn, - WebKit::WebFrame* frame) { + blink::WebFrame* frame) { if (js_fn.empty()) return; std::string content; @@ -113,7 +112,7 @@ void NwRenderViewObserver::OnDocumentCallback(RenderViewImpl* rv, frame->executeScriptAndReturnValue(WebScriptSource(jscript)); } -bool NwRenderViewObserver::CaptureSnapshot(WebKit::WebView* view, +bool NwRenderViewObserver::CaptureSnapshot(blink::WebView* view, SkBitmap* snapshot) { view->layout(); const WebSize& size = view->size(); @@ -132,7 +131,7 @@ bool NwRenderViewObserver::CaptureSnapshot(WebKit::WebView* view, SkBaseDevice* device = skia::GetTopDevice(*canvas); const SkBitmap& bitmap = device->accessBitmap(false); - if (!bitmap.copyTo(snapshot, SkBitmap::kARGB_8888_Config)) + if (!bitmap.copyTo(snapshot, SkBitmapConfigToColorType(SkBitmap::kARGB_8888_Config))) return false; return true; diff --git a/src/renderer/nw_render_view_observer.h b/src/renderer/nw_render_view_observer.h index d697ff9c4c..0449c1db08 100644 --- a/src/renderer/nw_render_view_observer.h +++ b/src/renderer/nw_render_view_observer.h @@ -29,7 +29,7 @@ namespace content { class RenderViewImpl; } -namespace WebKit { +namespace blink { class WebView; } @@ -42,8 +42,8 @@ class NwRenderViewObserver : public content::RenderViewObserver { // RenderViewObserver implementation. virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; - virtual void DidCreateDocumentElement(WebKit::WebFrame* frame) OVERRIDE; - virtual void DidFinishDocumentLoad(WebKit::WebFrame* frame) OVERRIDE; + virtual void DidCreateDocumentElement(blink::WebFrame* frame) OVERRIDE; + virtual void DidFinishDocumentLoad(blink::WebFrame* frame) OVERRIDE; private: @@ -51,11 +51,11 @@ class NwRenderViewObserver : public content::RenderViewObserver { // Capture a snapshot of a view. This is used to allow an extension // to get a snapshot of a tab using chrome.tabs.captureVisibleTab(). - bool CaptureSnapshot(WebKit::WebView* view, SkBitmap* snapshot); + bool CaptureSnapshot(blink::WebView* view, SkBitmap* snapshot); void OnDocumentCallback(content::RenderViewImpl* rv, const std::string& js_fn, - WebKit::WebFrame* frame); + blink::WebFrame* frame); DISALLOW_COPY_AND_ASSIGN(NwRenderViewObserver); }; diff --git a/src/renderer/prerenderer/prerenderer_client.cc b/src/renderer/prerenderer/prerenderer_client.cc index cbe5f08d47..22d4d1bd5b 100644 --- a/src/renderer/prerenderer/prerenderer_client.cc +++ b/src/renderer/prerenderer/prerenderer_client.cc @@ -37,7 +37,7 @@ PrerendererClient::~PrerendererClient() { } void PrerendererClient::willAddPrerender( - WebKit::WebPrerender* prerender) { + blink::WebPrerender* prerender) { } } // namespace prerender diff --git a/src/renderer/prerenderer/prerenderer_client.h b/src/renderer/prerenderer/prerenderer_client.h index 8bcea1422f..42ed0063b9 100644 --- a/src/renderer/prerenderer/prerenderer_client.h +++ b/src/renderer/prerenderer/prerenderer_client.h @@ -28,15 +28,15 @@ namespace prerender { class PrerendererClient : public content::RenderViewObserver, - public WebKit::WebPrerendererClient { + public blink::WebPrerendererClient { public: explicit PrerendererClient(content::RenderView* render_view); private: virtual ~PrerendererClient(); - // Implements WebKit::WebPrerendererClient - virtual void willAddPrerender(WebKit::WebPrerender* prerender) OVERRIDE; + // Implements blink::WebPrerendererClient + virtual void willAddPrerender(blink::WebPrerender* prerender) OVERRIDE; }; } // namespace prerender diff --git a/src/renderer/printing/print_web_view_helper.cc b/src/renderer/printing/print_web_view_helper.cc index 395f9969cf..8e5c18b3bc 100644 --- a/src/renderer/printing/print_web_view_helper.cc +++ b/src/renderer/printing/print_web_view_helper.cc @@ -24,6 +24,7 @@ #include "content/public/renderer/render_view.h" #include "grit/nw_resources.h" //#include "grit/generated_resources.h" +#include "net/base/escape.h" #include "printing/metafile.h" #include "printing/metafile_impl.h" #include "printing/units.h" @@ -60,13 +61,13 @@ const char kPageLoadScriptFormat[] = const char kPageSetupScriptFormat[] = "setup(%s);"; -void ExecuteScript(WebKit::WebFrame* frame, +void ExecuteScript(blink::WebFrame* frame, const char* script_format, const base::Value& parameters) { std::string json; base::JSONWriter::Write(¶meters, &json); std::string script = base::StringPrintf(script_format, json.c_str()); - frame->executeScript(WebKit::WebString(UTF8ToUTF16(script))); + frame->executeScript(blink::WebString(base::UTF8ToUTF16(script))); } int GetDPI(const PrintMsg_Print_Params* print_params) { @@ -88,13 +89,13 @@ bool PrintMsg_Print_Params_IsValid(const PrintMsg_Print_Params& params) { PrintMsg_Print_Params GetCssPrintParams( - WebKit::WebFrame* frame, + blink::WebFrame* frame, int page_index, const PrintMsg_Print_Params& page_params) { PrintMsg_Print_Params page_css_params = page_params; int dpi = GetDPI(&page_params); - WebKit::WebSize page_size_in_pixels( + blink::WebSize page_size_in_pixels( ConvertUnit(page_params.page_size.width(), dpi, kPixelsPerInch), ConvertUnit(page_params.page_size.height(), dpi, kPixelsPerInch)); int margin_top_in_pixels = @@ -111,7 +112,7 @@ PrintMsg_Print_Params GetCssPrintParams( page_params.margin_left, dpi, kPixelsPerInch); - WebKit::WebSize original_page_size_in_pixels = page_size_in_pixels; + blink::WebSize original_page_size_in_pixels = page_size_in_pixels; if (frame) { frame->pageSizeAndMarginsInPixels(page_index, @@ -238,7 +239,7 @@ void EnsureOrientationMatches(const PrintMsg_Print_Params& css_params, void ComputeWebKitPrintParamsInDesiredDpi( const PrintMsg_Print_Params& print_params, - WebKit::WebPrintParams* webkit_print_params) { + blink::WebPrintParams* webkit_print_params) { int dpi = GetDPI(&print_params); webkit_print_params->printerDPI = dpi; webkit_print_params->printScalingOption = print_params.print_scaling_option; @@ -271,18 +272,18 @@ void ComputeWebKitPrintParamsInDesiredDpi( print_params.desired_dpi); } -bool PrintingNodeOrPdfFrame(const WebKit::WebFrame* frame, - const WebKit::WebNode& node) { +bool PrintingNodeOrPdfFrame(const blink::WebFrame* frame, + const blink::WebNode& node) { if (!node.isNull()) return true; if (!frame->document().isPluginDocument()) return false; - WebKit::WebPlugin* plugin = - frame->document().to().plugin(); + blink::WebPlugin* plugin = + frame->document().to().plugin(); return plugin && plugin->supportsPaginatedPrint(); } -bool PrintingFrameHasPageSizeStyle(WebKit::WebFrame* frame, +bool PrintingFrameHasPageSizeStyle(blink::WebFrame* frame, int total_page_count) { if (!frame) return false; @@ -296,15 +297,15 @@ bool PrintingFrameHasPageSizeStyle(WebKit::WebFrame* frame, return frame_has_custom_page_size_style; } -MarginType GetMarginsForPdf(WebKit::WebFrame* frame, - const WebKit::WebNode& node) { +MarginType GetMarginsForPdf(blink::WebFrame* frame, + const blink::WebNode& node) { if (frame->isPrintScalingDisabledForPlugin(node)) return NO_MARGINS; else return PRINTABLE_AREA_MARGINS; } -bool FitToPageEnabled(const DictionaryValue& job_settings) { +bool FitToPageEnabled(const base::DictionaryValue& job_settings) { bool fit_to_paper_size = false; if (!job_settings.GetBoolean(kSettingFitToPageEnabled, &fit_to_paper_size)) { NOTREACHED(); @@ -313,7 +314,7 @@ bool FitToPageEnabled(const DictionaryValue& job_settings) { } PrintMsg_Print_Params CalculatePrintParamsForCss( - WebKit::WebFrame* frame, + blink::WebFrame* frame, int page_index, const PrintMsg_Print_Params& page_params, bool ignore_css_margins, @@ -369,12 +370,12 @@ bool IsPrintThrottlingDisabled() { // static - Not anonymous so that platform implementations can use it. void PrintWebViewHelper::PrintHeaderAndFooter( - WebKit::WebCanvas* canvas, + blink::WebCanvas* canvas, int page_number, int total_pages, float webkit_scale_factor, const PageSizeMargins& page_layout, - const DictionaryValue& header_footer_info, + const base::DictionaryValue& header_footer_info, const PrintMsg_Print_Params& params) { skia::VectorPlatformDeviceSkia* device = static_cast(canvas->getTopDevice()); @@ -383,16 +384,16 @@ void PrintWebViewHelper::PrintHeaderAndFooter( SkAutoCanvasRestore auto_restore(canvas, true); canvas->scale(1 / webkit_scale_factor, 1 / webkit_scale_factor); - WebKit::WebSize page_size(page_layout.margin_left + page_layout.margin_right + + blink::WebSize page_size(page_layout.margin_left + page_layout.margin_right + page_layout.content_width, page_layout.margin_top + page_layout.margin_bottom + page_layout.content_height); - WebKit::WebView* web_view = WebKit::WebView::create(NULL); + blink::WebView* web_view = blink::WebView::create(NULL); web_view->settings()->setJavaScriptEnabled(true); - web_view->initializeMainFrame(NULL); - WebKit::WebFrame* frame = web_view->mainFrame(); + blink::WebFrame* frame = blink::WebFrame::create(NULL); + web_view->setMainFrame(frame); base::StringValue html( ResourceBundle::GetSharedInstance().GetLocalizedString( @@ -410,7 +411,7 @@ void PrintWebViewHelper::PrintHeaderAndFooter( ExecuteScript(frame, kPageSetupScriptFormat, *options); - WebKit::WebPrintParams webkit_params(page_size); + blink::WebPrintParams webkit_params(page_size); webkit_params.printerDPI = GetDPI(¶ms); frame->printBegin(webkit_params); @@ -423,12 +424,12 @@ void PrintWebViewHelper::PrintHeaderAndFooter( } // static - Not anonymous so that platform implementations can use it. -float PrintWebViewHelper::RenderPageContent(WebKit::WebFrame* frame, +float PrintWebViewHelper::RenderPageContent(blink::WebFrame* frame, int page_number, const gfx::Rect& canvas_area, const gfx::Rect& content_area, double scale_factor, - WebKit::WebCanvas* canvas) { + blink::WebCanvas* canvas) { SkAutoCanvasRestore auto_restore(canvas, true); if (content_area != canvas_area) { canvas->translate((content_area.x() - canvas_area.x()) / scale_factor, @@ -448,12 +449,12 @@ float PrintWebViewHelper::RenderPageContent(WebKit::WebFrame* frame, // Class that calls the Begin and End print functions on the frame and changes // the size of the view temporarily to support full page printing.. -class PrepareFrameAndViewForPrint : public WebKit::WebViewClient, - public WebKit::WebFrameClient { +class PrepareFrameAndViewForPrint : public blink::WebViewClient, + public blink::WebFrameClient { public: PrepareFrameAndViewForPrint(const PrintMsg_Print_Params& params, - WebKit::WebFrame* frame, - const WebKit::WebNode& node, + blink::WebFrame* frame, + const blink::WebNode& node, bool ignore_css_margins); virtual ~PrepareFrameAndViewForPrint(); @@ -465,11 +466,11 @@ class PrepareFrameAndViewForPrint : public WebKit::WebViewClient, // Prepares frame for printing. void StartPrinting(); - WebKit::WebFrame* frame() const { + blink::WebFrame* frame() const { return frame_; } - const WebKit::WebNode& node() const { + const blink::WebNode& node() const { return node_to_print_; } @@ -487,7 +488,7 @@ class PrepareFrameAndViewForPrint : public WebKit::WebViewClient, } protected: - // WebKit::WebViewClient override: + // blink::WebViewClient override: virtual void didStopLoading(); virtual void CallOnReady(); @@ -499,10 +500,10 @@ class PrepareFrameAndViewForPrint : public WebKit::WebViewClient, base::WeakPtrFactory weak_ptr_factory_; - WebKit::WebFrame* frame_; - WebKit::WebNode node_to_print_; + blink::WebFrame* frame_; + blink::WebNode node_to_print_; bool owns_web_view_; - WebKit::WebPrintParams web_print_params_; + blink::WebPrintParams web_print_params_; gfx::Size prev_view_size_; gfx::Size prev_scroll_offset_; int expected_pages_count_; @@ -516,8 +517,8 @@ class PrepareFrameAndViewForPrint : public WebKit::WebViewClient, PrepareFrameAndViewForPrint::PrepareFrameAndViewForPrint( const PrintMsg_Print_Params& params, - WebKit::WebFrame* frame, - const WebKit::WebNode& node, + blink::WebFrame* frame, + const blink::WebNode& node, bool ignore_css_margins) : weak_ptr_factory_(this), frame_(frame), @@ -532,7 +533,7 @@ PrepareFrameAndViewForPrint::PrepareFrameAndViewForPrint( !PrintingNodeOrPdfFrame(frame_, node_to_print_)) { bool fit_to_page = ignore_css_margins && print_params.print_scaling_option == - WebKit::WebPrintScalingOptionFitToPrintableArea; + blink::WebPrintScalingOptionFitToPrintableArea; print_params = CalculatePrintParamsForCss(frame_, 0, print_params, ignore_css_margins, fit_to_page, NULL); @@ -559,10 +560,10 @@ void PrepareFrameAndViewForPrint::ResizeForPrinting() { if (!frame_) return; - WebKit::WebView* web_view = frame_->view(); + blink::WebView* web_view = frame_->view(); // Backup size and offset. - if (WebKit::WebFrame* web_frame = web_view->mainFrame()) + if (blink::WebFrame* web_frame = web_view->mainFrame()) prev_scroll_offset_ = web_frame->scrollOffset(); prev_view_size_ = web_view->size(); @@ -572,7 +573,7 @@ void PrepareFrameAndViewForPrint::ResizeForPrinting() { void PrepareFrameAndViewForPrint::StartPrinting() { ResizeForPrinting(); - WebKit::WebView* web_view = frame_->view(); + blink::WebView* web_view = frame_->view(); web_view->settings()->setShouldPrintBackgrounds(should_print_backgrounds_); // TODO(vitalybuka): Update call after // https://bugs.webkit.org/show_bug.cgi?id=107718 is fixed. @@ -594,7 +595,8 @@ void PrepareFrameAndViewForPrint::CopySelection( const WebPreferences& preferences) { ResizeForPrinting(); std::string url_str = "data:text/html;charset=utf-8,"; - url_str.append(frame_->selectionAsMarkup().utf8()); + url_str.append( + net::EscapeQueryParamValue(frame()->selectionAsMarkup().utf8(), false)); RestoreSize(); // Create a new WebView with the same settings as the current display one. // Except that we disable javascript (don't want any active content running @@ -603,16 +605,16 @@ void PrepareFrameAndViewForPrint::CopySelection( prefs.javascript_enabled = false; prefs.java_enabled = false; - WebKit::WebView* web_view = WebKit::WebView::create(this); + blink::WebView* web_view = blink::WebView::create(this); owns_web_view_ = true; content::ApplyWebPreferences(prefs, web_view); - web_view->initializeMainFrame(this); + web_view->setMainFrame(blink::WebFrame::create(this)); frame_ = web_view->mainFrame(); node_to_print_.reset(); // When loading is done this will call didStopLoading() and that will do the // actual printing. - frame_->loadRequest(WebKit::WebURLRequest(GURL(url_str))); + frame_->loadRequest(blink::WebURLRequest(GURL(url_str))); } void PrepareFrameAndViewForPrint::didStopLoading() { @@ -635,16 +637,16 @@ gfx::Size PrepareFrameAndViewForPrint::GetPrintCanvasSize() const { void PrepareFrameAndViewForPrint::RestoreSize() { if (frame_) { - WebKit::WebView* web_view = frame_->view(); + blink::WebView* web_view = frame_->view(); web_view->resize(prev_view_size_); - if (WebKit::WebFrame* web_frame = web_view->mainFrame()) + if (blink::WebFrame* web_frame = web_view->mainFrame()) web_frame->setScrollOffset(prev_scroll_offset_); } } void PrepareFrameAndViewForPrint::FinishPrinting() { if (frame_) { - WebKit::WebView* web_view = frame_->view(); + blink::WebView* web_view = frame_->view(); if (is_printing_started_) { is_printing_started_ = false; frame_->printEnd(); @@ -684,7 +686,7 @@ PrintWebViewHelper::PrintWebViewHelper(content::RenderView* render_view) PrintWebViewHelper::~PrintWebViewHelper() {} bool PrintWebViewHelper::IsScriptInitiatedPrintAllowed( - WebKit::WebFrame* frame, bool user_initiated) { + blink::WebFrame* frame, bool user_initiated) { if (is_scripted_printing_blocked_) return false; // If preview is enabled, then the print dialog is tab modal, and the user @@ -699,7 +701,7 @@ bool PrintWebViewHelper::IsScriptInitiatedPrintAllowed( } // Prints |frame| which called window.print(). -void PrintWebViewHelper::PrintPage(WebKit::WebFrame* frame, +void PrintWebViewHelper::PrintPage(blink::WebFrame* frame, bool user_initiated) { DCHECK(frame); @@ -711,7 +713,7 @@ void PrintWebViewHelper::PrintPage(WebKit::WebFrame* frame, print_preview_context_.InitWithFrame(frame); RequestPrintPreview(PRINT_PREVIEW_SCRIPTED); } else { - Print(frame, WebKit::WebNode()); + Print(frame, blink::WebNode()); } } @@ -721,8 +723,6 @@ bool PrintWebViewHelper::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(PrintMsg_PrintPages, OnPrintPages) IPC_MESSAGE_HANDLER(PrintMsg_PrintForSystemDialog, OnPrintForSystemDialog) IPC_MESSAGE_HANDLER(PrintMsg_InitiatePrintPreview, OnInitiatePrintPreview) - IPC_MESSAGE_HANDLER(PrintMsg_PrintNodeUnderContextMenu, - OnPrintNodeUnderContextMenu) IPC_MESSAGE_HANDLER(PrintMsg_PrintPreview, OnPrintPreview) IPC_MESSAGE_HANDLER(PrintMsg_PrintForPrintPreview, OnPrintForPrintPreview) IPC_MESSAGE_HANDLER(PrintMsg_PrintingDone, OnPrintingDone) @@ -736,7 +736,7 @@ bool PrintWebViewHelper::OnMessageReceived(const IPC::Message& message) { } void PrintWebViewHelper::OnPrintForPrintPreview( - const DictionaryValue& job_settings) { + const base::DictionaryValue& job_settings) { DCHECK(is_preview_enabled_); // If still not finished with earlier print request simply ignore. if (prep_frame_view_) @@ -744,14 +744,14 @@ void PrintWebViewHelper::OnPrintForPrintPreview( if (!render_view()->GetWebView()) return; - WebKit::WebFrame* main_frame = render_view()->GetWebView()->mainFrame(); + blink::WebFrame* main_frame = render_view()->GetWebView()->mainFrame(); if (!main_frame) return; - WebKit::WebDocument document = main_frame->document(); + blink::WebDocument document = main_frame->document(); // with id="pdf-viewer" is created in // chrome/browser/resources/print_preview/print_preview.js - WebKit::WebElement pdf_element = document.getElementById("pdf-viewer"); + blink::WebElement pdf_element = document.getElementById("pdf-viewer"); if (pdf_element.isNull()) { NOTREACHED(); return; @@ -761,7 +761,7 @@ void PrintWebViewHelper::OnPrintForPrintPreview( // on return. base::AutoReset set_printing_flag(&print_for_preview_, true); - WebKit::WebFrame* pdf_frame = pdf_element.document().frame(); + blink::WebFrame* pdf_frame = pdf_element.document().frame(); if (!UpdatePrintSettings(pdf_frame, pdf_element, job_settings)) { LOG(ERROR) << "UpdatePrintSettings failed"; DidFinishPrinting(FAIL_PRINT); @@ -787,7 +787,7 @@ void PrintWebViewHelper::OnPrintForPrintPreview( } } -bool PrintWebViewHelper::GetPrintFrame(WebKit::WebFrame** frame) { +bool PrintWebViewHelper::GetPrintFrame(blink::WebFrame** frame) { DCHECK(frame); DCHECK(render_view()->GetWebView()); if (!render_view()->GetWebView()) @@ -802,13 +802,13 @@ bool PrintWebViewHelper::GetPrintFrame(WebKit::WebFrame** frame) { } void PrintWebViewHelper::OnPrintPages() { - WebKit::WebFrame* frame; + blink::WebFrame* frame; if (GetPrintFrame(&frame)) - Print(frame, WebKit::WebNode()); + Print(frame, blink::WebNode()); } void PrintWebViewHelper::OnPrintForSystemDialog() { - WebKit::WebFrame* frame = print_preview_context_.source_frame(); + blink::WebFrame* frame = print_preview_context_.source_frame(); if (!frame) { NOTREACHED(); return; @@ -835,7 +835,7 @@ void PrintWebViewHelper::GetPageSizeAndContentAreaFromPageLayout( } void PrintWebViewHelper::UpdateFrameMarginsCssInfo( - const DictionaryValue& settings) { + const base::DictionaryValue& settings) { int margins_type = 0; if (!settings.GetInteger(kSettingMarginsType, &margins_type)) margins_type = DEFAULT_MARGINS; @@ -843,36 +843,36 @@ void PrintWebViewHelper::UpdateFrameMarginsCssInfo( } bool PrintWebViewHelper::IsPrintToPdfRequested( - const DictionaryValue& job_settings) { + const base::DictionaryValue& job_settings) { bool print_to_pdf = false; if (!job_settings.GetBoolean(kSettingPrintToPDF, &print_to_pdf)) NOTREACHED(); return print_to_pdf; } -WebKit::WebPrintScalingOption PrintWebViewHelper::GetPrintScalingOption( - bool source_is_html, const DictionaryValue& job_settings, +blink::WebPrintScalingOption PrintWebViewHelper::GetPrintScalingOption( + bool source_is_html, const base::DictionaryValue& job_settings, const PrintMsg_Print_Params& params) { DCHECK(!print_for_preview_); if (params.print_to_pdf) - return WebKit::WebPrintScalingOptionSourceSize; + return blink::WebPrintScalingOptionSourceSize; if (!source_is_html) { if (!FitToPageEnabled(job_settings)) - return WebKit::WebPrintScalingOptionNone; + return blink::WebPrintScalingOptionNone; bool no_plugin_scaling = print_preview_context_.source_frame()->isPrintScalingDisabledForPlugin( print_preview_context_.source_node()); if (params.is_first_request && no_plugin_scaling) - return WebKit::WebPrintScalingOptionNone; + return blink::WebPrintScalingOptionNone; } - return WebKit::WebPrintScalingOptionFitToPrintableArea; + return blink::WebPrintScalingOptionFitToPrintableArea; } -void PrintWebViewHelper::OnPrintPreview(const DictionaryValue& settings) { +void PrintWebViewHelper::OnPrintPreview(const base::DictionaryValue& settings) { DCHECK(is_preview_enabled_); print_preview_context_.OnPrintPreview(); @@ -1030,7 +1030,6 @@ bool PrintWebViewHelper::FinalizePrintReadyDocument() { DCHECK_GT(buf_size, 0u); PrintHostMsg_DidPreviewDocument_Params preview_params; - preview_params.reuse_existing_data = false; preview_params.data_size = buf_size; preview_params.document_cookie = print_pages_params_->params.document_cookie; preview_params.expected_pages_count = @@ -1063,13 +1062,9 @@ void PrintWebViewHelper::SetScriptedPrintBlocked(bool blocked) { is_scripted_printing_blocked_ = blocked; } -void PrintWebViewHelper::OnPrintNodeUnderContextMenu() { - PrintNode(render_view()->GetContextMenuNode()); -} - void PrintWebViewHelper::OnInitiatePrintPreview(bool selection_only) { DCHECK(is_preview_enabled_); - WebKit::WebFrame* frame; + blink::WebFrame* frame; if (GetPrintFrame(&frame)) { print_preview_context_.InitWithFrame(frame); RequestPrintPreview(selection_only ? @@ -1084,7 +1079,7 @@ void PrintWebViewHelper::OnInitiatePrintPreview(bool selection_only) { } } -void PrintWebViewHelper::PrintNode(const WebKit::WebNode& node) { +void PrintWebViewHelper::PrintNode(const blink::WebNode& node) { if (node.isNull() || !node.document().frame()) { // This can occur when the context menu refers to an invalid WebNode. // See http://crbug.com/100890#c17 for a repro case. @@ -1106,15 +1101,15 @@ void PrintWebViewHelper::PrintNode(const WebKit::WebNode& node) { print_preview_context_.InitWithNode(node); RequestPrintPreview(PRINT_PREVIEW_USER_INITIATED_CONTEXT_NODE); } else { - WebKit::WebNode duplicate_node(node); + blink::WebNode duplicate_node(node); Print(duplicate_node.document().frame(), duplicate_node); } print_node_in_progress_ = false; } -void PrintWebViewHelper::Print(WebKit::WebFrame* frame, - const WebKit::WebNode& node) { +void PrintWebViewHelper::Print(blink::WebFrame* frame, + const blink::WebNode& node) { // If still not finished with earlier print request simply ignore. if (prep_frame_view_) return; @@ -1223,8 +1218,8 @@ void PrintWebViewHelper::FinishFramePrinting() { } #if defined(OS_MACOSX) || defined(OS_WIN) -bool PrintWebViewHelper::PrintPagesNative(WebKit::WebFrame* frame, - const WebKit::WebNode& node, +bool PrintWebViewHelper::PrintPagesNative(blink::WebFrame* frame, + const blink::WebNode& node, int page_count, const gfx::Size& canvas_size) { const PrintMsg_PrintPages_Params& params = *print_pages_params_; @@ -1252,7 +1247,7 @@ bool PrintWebViewHelper::PrintPagesNative(WebKit::WebFrame* frame, // static - Not anonymous so that platform implementations can use it. void PrintWebViewHelper::ComputePageLayoutInPointsForCss( - WebKit::WebFrame* frame, + blink::WebFrame* frame, int page_index, const PrintMsg_Print_Params& page_params, bool ignore_css_margins, @@ -1261,7 +1256,7 @@ void PrintWebViewHelper::ComputePageLayoutInPointsForCss( PrintMsg_Print_Params params = CalculatePrintParamsForCss( frame, page_index, page_params, ignore_css_margins, page_params.print_scaling_option == - WebKit::WebPrintScalingOptionFitToPrintableArea, + blink::WebPrintScalingOptionFitToPrintableArea, scale_factor); CalculatePageLayoutFromPrintParams(params, page_layout_in_points); } @@ -1289,18 +1284,18 @@ bool PrintWebViewHelper::InitPrintSettings(bool fit_to_paper_size) { settings.pages.clear(); settings.params.print_scaling_option = - WebKit::WebPrintScalingOptionSourceSize; + blink::WebPrintScalingOptionSourceSize; if (fit_to_paper_size) { settings.params.print_scaling_option = - WebKit::WebPrintScalingOptionFitToPrintableArea; + blink::WebPrintScalingOptionFitToPrintableArea; } print_pages_params_.reset(new PrintMsg_PrintPages_Params(settings)); return result; } -bool PrintWebViewHelper::CalculateNumberOfPages(WebKit::WebFrame* frame, - const WebKit::WebNode& node, +bool PrintWebViewHelper::CalculateNumberOfPages(blink::WebFrame* frame, + const blink::WebNode& node, int* number_of_pages) { DCHECK(frame); bool fit_to_paper_size = !(PrintingNodeOrPdfFrame(frame, node)); @@ -1323,12 +1318,12 @@ bool PrintWebViewHelper::CalculateNumberOfPages(WebKit::WebFrame* frame, } bool PrintWebViewHelper::UpdatePrintSettings( - WebKit::WebFrame* frame, - const WebKit::WebNode& node, - const DictionaryValue& passed_job_settings) { + blink::WebFrame* frame, + const blink::WebNode& node, + const base::DictionaryValue& passed_job_settings) { DCHECK(is_preview_enabled_); - const DictionaryValue* job_settings = &passed_job_settings; - DictionaryValue modified_job_settings; + const base::DictionaryValue* job_settings = &passed_job_settings; + base::DictionaryValue modified_job_settings; if (job_settings->empty()) { if (!print_for_preview_) print_preview_context_.set_error(PREVIEW_ERROR_BAD_SETTING); @@ -1365,7 +1360,7 @@ bool PrintWebViewHelper::UpdatePrintSettings( print_preview_context_.set_error(PREVIEW_ERROR_INVALID_PRINTER_SETTINGS); } else { // PrintForPrintPreview - WebKit::WebFrame* print_frame = NULL; + blink::WebFrame* print_frame = NULL; // This may not be the right frame, but the alert will be modal, // therefore it works well enough. GetPrintFrame(&print_frame); @@ -1408,7 +1403,7 @@ bool PrintWebViewHelper::UpdatePrintSettings( // Header/Footer: Set |header_footer_info_|. if (settings.params.display_header_footer) { - header_footer_info_.reset(new DictionaryValue()); + header_footer_info_.reset(new base::DictionaryValue()); header_footer_info_->SetDouble(kSettingHeaderFooterDate, base::Time::Now().ToJsTime()); header_footer_info_->SetString(kSettingHeaderFooterURL, @@ -1425,8 +1420,8 @@ bool PrintWebViewHelper::UpdatePrintSettings( return true; } -bool PrintWebViewHelper::GetPrintSettingsFromUser(WebKit::WebFrame* frame, - const WebKit::WebNode& node, +bool PrintWebViewHelper::GetPrintSettingsFromUser(blink::WebFrame* frame, + const blink::WebNode& node, int expected_pages_count) { PrintHostMsg_ScriptedPrint_Params params; PrintMsg_PrintPages_Params print_settings; @@ -1443,7 +1438,7 @@ bool PrintWebViewHelper::GetPrintSettingsFromUser(WebKit::WebFrame* frame, // PrintHostMsg_ScriptedPrint will reset print_scaling_option, so we save the // value before and restore it afterwards. - WebKit::WebPrintScalingOption scaling_option = + blink::WebPrintScalingOption scaling_option = print_pages_params_->params.print_scaling_option; print_pages_params_.reset(); @@ -1457,8 +1452,8 @@ bool PrintWebViewHelper::GetPrintSettingsFromUser(WebKit::WebFrame* frame, return (print_settings.params.dpi && print_settings.params.document_cookie); } -bool PrintWebViewHelper::RenderPagesForPrint(WebKit::WebFrame* frame, - const WebKit::WebNode& node) { +bool PrintWebViewHelper::RenderPagesForPrint(blink::WebFrame* frame, + const blink::WebNode& node) { if (prep_frame_view_) return false; const PrintMsg_PrintPages_Params& params = *print_pages_params_; @@ -1498,7 +1493,7 @@ bool PrintWebViewHelper::CopyMetafileDataToSharedMem( #endif // defined(OS_POSIX) bool PrintWebViewHelper::IsScriptInitiatedPrintTooFrequent( - WebKit::WebFrame* frame) { + blink::WebFrame* frame) { const int kMinSecondsToIgnoreJavascriptInitiatedPrint = 2; const int kMaxSecondsToIgnoreJavascriptInitiatedPrint = 32; bool too_frequent = false; @@ -1526,11 +1521,11 @@ bool PrintWebViewHelper::IsScriptInitiatedPrintTooFrequent( if (!too_frequent) return false; - WebKit::WebString message( - WebKit::WebString::fromUTF8("Ignoring too frequent calls to print().")); + blink::WebString message( + blink::WebString::fromUTF8("Ignoring too frequent calls to print().")); frame->addMessageToConsole( - WebKit::WebConsoleMessage( - WebKit::WebConsoleMessage::LevelWarning, message)); + blink::WebConsoleMessage( + blink::WebConsoleMessage::LevelWarning, message)); return true; } @@ -1639,7 +1634,7 @@ PrintWebViewHelper::PrintPreviewContext::~PrintPreviewContext() { } void PrintWebViewHelper::PrintPreviewContext::InitWithFrame( - WebKit::WebFrame* web_frame) { + blink::WebFrame* web_frame) { DCHECK(web_frame); DCHECK(!IsRendering()); state_ = INITIALIZED; @@ -1648,7 +1643,7 @@ void PrintWebViewHelper::PrintPreviewContext::InitWithFrame( } void PrintWebViewHelper::PrintPreviewContext::InitWithNode( - const WebKit::WebNode& web_node) { + const blink::WebNode& web_node) { DCHECK(!web_node.isNull()); DCHECK(web_node.document().frame()); DCHECK(!IsRendering()); @@ -1815,27 +1810,27 @@ void PrintWebViewHelper::PrintPreviewContext::set_error( error_ = error; } -WebKit::WebFrame* PrintWebViewHelper::PrintPreviewContext::source_frame() { +blink::WebFrame* PrintWebViewHelper::PrintPreviewContext::source_frame() { // TODO(thestig) turn this back into a DCHECK when http://crbug.com/118303 is // resolved. CHECK(state_ != UNINITIALIZED); return source_frame_; } -const WebKit::WebNode& +const blink::WebNode& PrintWebViewHelper::PrintPreviewContext::source_node() const { DCHECK(state_ != UNINITIALIZED); return source_node_; } -WebKit::WebFrame* PrintWebViewHelper::PrintPreviewContext::prepared_frame() { +blink::WebFrame* PrintWebViewHelper::PrintPreviewContext::prepared_frame() { // TODO(thestig) turn this back into a DCHECK when http://crbug.com/118303 is // resolved. CHECK(state_ != UNINITIALIZED); return prep_frame_view_->frame(); } -const WebKit::WebNode& +const blink::WebNode& PrintWebViewHelper::PrintPreviewContext::prepared_node() const { DCHECK(state_ != UNINITIALIZED); return prep_frame_view_->node(); diff --git a/src/renderer/printing/print_web_view_helper.h b/src/renderer/printing/print_web_view_helper.h index 1bcd47dc8a..5298812be6 100644 --- a/src/renderer/printing/print_web_view_helper.h +++ b/src/renderer/printing/print_web_view_helper.h @@ -28,7 +28,7 @@ namespace base { class DictionaryValue; } -namespace WebKit { +namespace blink { class WebFrame; class WebView; } @@ -48,7 +48,7 @@ class PrintWebViewHelper explicit PrintWebViewHelper(content::RenderView* render_view); virtual ~PrintWebViewHelper(); - void PrintNode(const WebKit::WebNode& node); + void PrintNode(const blink::WebNode& node); private: friend class PrintWebViewHelperTestBase; @@ -92,7 +92,7 @@ class PrintWebViewHelper // RenderViewObserver implementation. virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; - virtual void PrintPage(WebKit::WebFrame* frame, bool user_initiated) OVERRIDE; + virtual void PrintPage(blink::WebFrame* frame, bool user_initiated) OVERRIDE; // Message handlers --------------------------------------------------------- @@ -129,7 +129,7 @@ class PrintWebViewHelper // option is disabled for initiator renderer plugin. // // In all other cases, we scale the source page to fit the printable area. - WebKit::WebPrintScalingOption GetPrintScalingOption( + blink::WebPrintScalingOption GetPrintScalingOption( bool source_is_html, const base::DictionaryValue& job_settings, const PrintMsg_Print_Params& params); @@ -157,9 +157,6 @@ class PrintWebViewHelper // Finalize the print ready preview document. bool FinalizePrintReadyDocument(); - // Print / preview the node under the context menu. - void OnPrintNodeUnderContextMenu(); - // Print the pages for print preview. Do not display the native print dialog // for user settings. |job_settings| has new print job settings values. void OnPrintForPrintPreview(const base::DictionaryValue& job_settings); @@ -172,7 +169,7 @@ class PrintWebViewHelper // Main printing code ------------------------------------------------------- - void Print(WebKit::WebFrame* frame, const WebKit::WebNode& node); + void Print(blink::WebFrame* frame, const blink::WebNode& node); // Notification when printing is done - signal tear-down/free resources. void DidFinishPrinting(PrintingResult result); @@ -184,29 +181,29 @@ class PrintWebViewHelper bool InitPrintSettings(bool fit_to_paper_size); // Calculate number of pages in source document. - bool CalculateNumberOfPages(WebKit::WebFrame* frame, - const WebKit::WebNode& node, + bool CalculateNumberOfPages(blink::WebFrame* frame, + const blink::WebNode& node, int* number_of_pages); // Update the current print settings with new |passed_job_settings|. // |passed_job_settings| dictionary contains print job details such as printer // name, number of copies, page range, etc. - bool UpdatePrintSettings(WebKit::WebFrame* frame, - const WebKit::WebNode& node, + bool UpdatePrintSettings(blink::WebFrame* frame, + const blink::WebNode& node, const base::DictionaryValue& passed_job_settings); // Get final print settings from the user. // Return false if the user cancels or on error. - bool GetPrintSettingsFromUser(WebKit::WebFrame* frame, - const WebKit::WebNode& node, + bool GetPrintSettingsFromUser(blink::WebFrame* frame, + const blink::WebNode& node, int expected_pages_count); // Page Printing / Rendering ------------------------------------------------ void OnFramePreparedForPrintPages(); void PrintPages(); - bool PrintPagesNative(WebKit::WebFrame* frame, - const WebKit::WebNode& node, + bool PrintPagesNative(blink::WebFrame* frame, + const blink::WebNode& node, int page_count, const gfx::Size& canvas_size); void FinishFramePrinting(); @@ -215,23 +212,23 @@ class PrintWebViewHelper #if defined(USE_X11) void PrintPageInternal(const PrintMsg_PrintPage_Params& params, const gfx::Size& canvas_size, - WebKit::WebFrame* frame, + blink::WebFrame* frame, Metafile* metafile); #else void PrintPageInternal(const PrintMsg_PrintPage_Params& params, const gfx::Size& canvas_size, - WebKit::WebFrame* frame); + blink::WebFrame* frame); #endif // Render the frame for printing. - bool RenderPagesForPrint(WebKit::WebFrame* frame, - const WebKit::WebNode& node); + bool RenderPagesForPrint(blink::WebFrame* frame, + const blink::WebNode& node); // Platform specific helper function for rendering page(s) to |metafile|. #if defined(OS_WIN) void RenderPage(const PrintMsg_Print_Params& params, int page_number, - WebKit::WebFrame* frame, + blink::WebFrame* frame, bool is_preview, Metafile* metafile, double* scale_factor, @@ -240,7 +237,7 @@ class PrintWebViewHelper #elif defined(OS_MACOSX) void RenderPage(const PrintMsg_Print_Params& params, int page_number, - WebKit::WebFrame* frame, + blink::WebFrame* frame, bool is_preview, Metafile* metafile, gfx::Size* page_size, @@ -251,12 +248,12 @@ class PrintWebViewHelper // |page_number| is zero-based. // When method is called, canvas should be setup to draw to |canvas_area| // with |scale_factor|. - static float RenderPageContent(WebKit::WebFrame* frame, + static float RenderPageContent(blink::WebFrame* frame, int page_number, const gfx::Rect& canvas_area, const gfx::Rect& content_area, double scale_factor, - WebKit::WebCanvas* canvas); + blink::WebCanvas* canvas); // Helper methods ----------------------------------------------------------- @@ -265,7 +262,7 @@ class PrintWebViewHelper // Helper method to get page layout in points and fit to page if needed. static void ComputePageLayoutInPointsForCss( - WebKit::WebFrame* frame, + blink::WebFrame* frame, int page_index, const PrintMsg_Print_Params& default_params, bool ignore_css_margins, @@ -275,7 +272,7 @@ class PrintWebViewHelper // Given the |device| and |canvas| to draw on, prints the appropriate headers // and footers using strings from |header_footer_info| on to the canvas. static void PrintHeaderAndFooter( - WebKit::WebCanvas* canvas, + blink::WebCanvas* canvas, int page_number, int total_pages, float webkit_scale_factor, @@ -283,7 +280,7 @@ class PrintWebViewHelper const base::DictionaryValue& header_footer_info, const PrintMsg_Print_Params& params); - bool GetPrintFrame(WebKit::WebFrame** frame); + bool GetPrintFrame(blink::WebFrame** frame); // This reports the current time - |start_time| as the time to render a page. void ReportPreviewPageRenderTime(base::TimeTicks start_time); @@ -293,11 +290,11 @@ class PrintWebViewHelper // Return true if script initiated printing is currently // allowed. |user_initiated| should be true when a user event triggered the // script, most likely by pressing a print button on the page. - bool IsScriptInitiatedPrintAllowed(WebKit::WebFrame* frame, + bool IsScriptInitiatedPrintAllowed(blink::WebFrame* frame, bool user_initiated); // Returns true if script initiated printing occurs too often. - bool IsScriptInitiatedPrintTooFrequent(WebKit::WebFrame* frame); + bool IsScriptInitiatedPrintTooFrequent(blink::WebFrame* frame); // Reset the counter for script initiated printing. // Scripted printing will be allowed to continue. @@ -356,8 +353,8 @@ class PrintWebViewHelper // Initializes the print preview context. Need to be called to set // the |web_frame| / |web_node| to generate the print preview for. - void InitWithFrame(WebKit::WebFrame* web_frame); - void InitWithNode(const WebKit::WebNode& web_node); + void InitWithFrame(blink::WebFrame* web_frame); + void InitWithNode(const blink::WebNode& web_node); // Does bookkeeping at the beginning of print preview. void OnPrintPreview(); @@ -397,16 +394,16 @@ class PrintWebViewHelper // Getters // Original frame for which preview was requested. - WebKit::WebFrame* source_frame(); + blink::WebFrame* source_frame(); // Original node for which preview was requested. - const WebKit::WebNode& source_node() const; + const blink::WebNode& source_node() const; // Frame to be use to render preview. May be the same as source_frame(), or // generated from it, e.g. copy of selected block. - WebKit::WebFrame* prepared_frame(); + blink::WebFrame* prepared_frame(); // Node to be use to render preview. May be the same as source_node(), or // generated from it, e.g. copy of selected block. - const WebKit::WebNode& prepared_node() const; + const blink::WebNode& prepared_node() const; int total_page_count() const; bool generate_draft_pages() const; @@ -426,8 +423,8 @@ class PrintWebViewHelper void ClearContext(); // Specifies what to render for print preview. - WebKit::WebFrame* source_frame_; - WebKit::WebNode source_node_; + blink::WebFrame* source_frame_; + blink::WebNode source_node_; scoped_ptr prep_frame_view_; scoped_ptr metafile_; diff --git a/src/renderer/printing/print_web_view_helper_linux.cc b/src/renderer/printing/print_web_view_helper_linux.cc index 0039d99522..a55fd9d3d6 100644 --- a/src/renderer/printing/print_web_view_helper_linux.cc +++ b/src/renderer/printing/print_web_view_helper_linux.cc @@ -20,8 +20,8 @@ namespace printing { -using WebKit::WebFrame; -using WebKit::WebNode; +using blink::WebFrame; +using blink::WebNode; bool PrintWebViewHelper::RenderPreviewPage( int page_number, @@ -54,8 +54,8 @@ bool PrintWebViewHelper::RenderPreviewPage( return PreviewPageRendered(page_number, draft_metafile.get()); } -bool PrintWebViewHelper::PrintPagesNative(WebKit::WebFrame* frame, - const WebKit::WebNode& node, +bool PrintWebViewHelper::PrintPagesNative(blink::WebFrame* frame, + const blink::WebNode& node, int page_count, const gfx::Size& canvas_size) { NativeMetafile metafile; @@ -88,7 +88,7 @@ bool PrintWebViewHelper::PrintPagesNative(WebKit::WebFrame* frame, PrintPageInternal(page_params, canvas_size, frame, &metafile); } - // WebKit::printEnd() for PDF should be called before metafile is closed. + // blink::printEnd() for PDF should be called before metafile is closed. FinishFramePrinting(); metafile.FinishDocument(); diff --git a/src/renderer/shell_content_renderer_client.cc b/src/renderer/shell_content_renderer_client.cc index 77a181b566..075c2e7e1d 100644 --- a/src/renderer/shell_content_renderer_client.cc +++ b/src/renderer/shell_content_renderer_client.cc @@ -41,7 +41,6 @@ #include "content/nw/src/nw_version.h" #include "components/autofill/content/renderer/autofill_agent.h" #include "components/autofill/content/renderer/password_autofill_agent.h" -#include "content/nw/src/renderer/autofill_agent.h" #include "content/nw/src/renderer/nw_render_view_observer.h" #include "content/nw/src/renderer/prerenderer/prerenderer_client.h" #include "content/nw/src/renderer/printing/print_web_view_helper.h" @@ -68,10 +67,10 @@ using content::RenderViewImpl; using autofill::AutofillAgent; using autofill::PasswordAutofillAgent; using net::ProxyBypassRules; -using WebKit::WebFrame; -using WebKit::WebView; -using WebKit::WebString; -using WebKit::WebSecurityPolicy; +using blink::WebFrame; +using blink::WebView; +using blink::WebString; +using blink::WebSecurityPolicy; namespace content { @@ -106,10 +105,10 @@ void ShellContentRendererClient::RenderThreadStarted() { // Change working directory. CommandLine* command_line = CommandLine::ForCurrentProcess(); if (command_line->HasSwitch(switches::kWorkingDirectory)) { - file_util::SetCurrentDirectory( + base::SetCurrentDirectory( command_line->GetSwitchValuePath(switches::kWorkingDirectory)); } - +#if 0 int argc = 1; char* argv[] = { const_cast("node"), NULL, NULL }; std::string node_main; @@ -138,10 +137,11 @@ void ShellContentRendererClient::RenderThreadStarted() { } // Initialize node after render thread is started. if (!snapshot_path.empty()) { - v8::V8::Initialize(snapshot_path.c_str()); + v8::V8::Initialize(); //FIXME }else v8::V8::Initialize(); - v8::HandleScope scope; + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + v8::HandleScope scope(isolate); // Install window bindings into node. The Window API is implemented in node's // context, so when a Shell changes to a new location and destroy previous @@ -154,19 +154,18 @@ void ShellContentRendererClient::RenderThreadStarted() { node::g_context.Reset(v8::Isolate::GetCurrent(), v8::Context::New(v8::Isolate::GetCurrent(), &extension_configuration)); - node::g_context->SetSecurityToken(v8::String::NewSymbol("nw-token", 8)); - node::g_context->Enter(); + v8::Local context = + v8::Local::New(isolate, node::g_context); + context->SetSecurityToken(v8::String::NewFromUtf8(isolate, "nw-token", v8::String::kInternalizedString)); + context->Enter(); - node::g_context->SetEmbedderData(0, v8::String::NewSymbol("node")); + context->SetEmbedderData(0, v8::String::NewFromUtf8(isolate, "node", v8::String::kInternalizedString)); // Setup node.js. - v8::Local context = - v8::Local::New(node::g_context->GetIsolate(), node::g_context); - node::SetupContext(argc, argv, context); #if !defined(OS_WIN) - v8::Local script = v8::Script::New(v8::String::New(( + v8::Local script = v8::Script::Compile(v8::String::NewFromUtf8(isolate, ( "process.__nwfds_to_close = [" + base::StringPrintf("%d", base::GlobalDescriptors::GetInstance()->Get(kPrimaryIPCChannel)) + "];" @@ -174,11 +173,14 @@ void ShellContentRendererClient::RenderThreadStarted() { CHECK(*script); script->Run(); #endif + +#endif //0 + // Start observers. shell_observer_.reset(new ShellRenderProcessObserver()); - WebString file_scheme(ASCIIToUTF16("file")); - WebString app_scheme(ASCIIToUTF16("app")); + WebString file_scheme(base::ASCIIToUTF16("file")); + WebString app_scheme(base::ASCIIToUTF16("app")); // file: resources should be allowed to receive CORS requests. WebSecurityPolicy::registerURLSchemeAsCORSEnabled(file_scheme); WebSecurityPolicy::registerURLSchemeAsCORSEnabled(app_scheme); @@ -193,11 +195,11 @@ void ShellContentRendererClient::RenderViewCreated(RenderView* render_view) { new printing::PrintWebViewHelper(render_view); #endif - nw::AutofillAgent* autofill_agent = new nw::AutofillAgent(render_view); + // FIXME: nw::AutofillAgent* autofill_agent = new nw::AutofillAgent(render_view); // The PageClickTracker is a RenderViewObserver, and hence will be freed when // the RenderView is destroyed. - new autofill::PageClickTracker(render_view, autofill_agent); + // FIXME: new autofill::PageClickTracker(render_view, autofill_agent); // PasswordAutofillAgent* password_autofill_agent = // new PasswordAutofillAgent(render_view); @@ -205,7 +207,7 @@ void ShellContentRendererClient::RenderViewCreated(RenderView* render_view) { } void ShellContentRendererClient::DidCreateScriptContext( - WebKit::WebFrame* frame, + blink::WebFrame* frame, v8::Handle context, int extension_group, int world_id) { @@ -215,7 +217,7 @@ void ShellContentRendererClient::DidCreateScriptContext( creating_first_context_ = false; } -bool ShellContentRendererClient::goodForNode(WebKit::WebFrame* frame) +bool ShellContentRendererClient::goodForNode(blink::WebFrame* frame) { RenderViewImpl* rv = RenderViewImpl::FromWebView(frame->view()); GURL url(frame->document().url()); @@ -231,13 +233,17 @@ bool ShellContentRendererClient::goodForNode(WebKit::WebFrame* frame) } bool ShellContentRendererClient::WillSetSecurityToken( - WebKit::WebFrame* frame, + blink::WebFrame* frame, v8::Handle context) { GURL url(frame->document().url()); VLOG(1) << "WillSetSecurityToken: " << url; if (goodForNode(frame)) { // Override context's security token - context->SetSecurityToken(node::g_context->GetSecurityToken()); + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + v8::HandleScope scope(isolate); + v8::Local g_context = + v8::Local::New(isolate, node::g_context); + context->SetSecurityToken(g_context->GetSecurityToken()); frame->document().securityOrigin().grantUniversalAccess(); int ret = 0; @@ -256,19 +262,22 @@ bool ShellContentRendererClient::WillSetSecurityToken( } void ShellContentRendererClient::InstallNodeSymbols( - WebKit::WebFrame* frame, + blink::WebFrame* frame, v8::Handle context, const GURL& url) { - v8::HandleScope handle_scope; + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + v8::HandleScope scope(isolate); + v8::Local g_context = + v8::Local::New(isolate, node::g_context); static bool installed_once = false; - v8::Local nodeGlobal = node::g_context->Global(); + v8::Local nodeGlobal = g_context->Global(); v8::Local v8Global = context->Global(); // Use WebKit's console globally - nodeGlobal->Set(v8::String::New("console"), - v8Global->Get(v8::String::New("console"))); + nodeGlobal->Set(v8::String::NewFromUtf8(isolate, "console"), + v8Global->Get(v8::String::NewFromUtf8(isolate, "console"))); // Do we integrate node? bool use_node = goodForNode(frame); @@ -281,11 +290,11 @@ void ShellContentRendererClient::InstallNodeSymbols( if (use_node || is_nw_protocol) { frame->setNodeJS(true); - v8::Local symbols = v8::Array::New(4); - symbols->Set(0, v8::String::New("global")); - symbols->Set(1, v8::String::New("process")); - symbols->Set(2, v8::String::New("Buffer")); - symbols->Set(3, v8::String::New("root")); + v8::Local symbols = v8::Array::New(isolate, 4); + symbols->Set(0, v8::String::NewFromUtf8(isolate, "global")); + symbols->Set(1, v8::String::NewFromUtf8(isolate, "process")); + symbols->Set(2, v8::String::NewFromUtf8(isolate, "Buffer")); + symbols->Set(3, v8::String::NewFromUtf8(isolate, "root")); for (unsigned i = 0; i < symbols->Length(); ++i) { v8::Local key = symbols->Get(i); @@ -300,13 +309,13 @@ void ShellContentRendererClient::InstallNodeSymbols( // reference to the closure created by the call back and leak // memory (see #203) - nodeGlobal->Set(v8::String::New("window"), v8Global); + nodeGlobal->Set(v8::String::NewFromUtf8(isolate, "window"), v8Global); // Listen uncaughtException with ReportException. - v8::Local cb = v8::FunctionTemplate::New(ReportException)-> + v8::Local cb = v8::FunctionTemplate::New(isolate, ReportException)-> GetFunction(); - v8::Local argv[] = { v8::String::New("uncaughtException"), cb }; - node::MakeCallback(node::g_env->process_object(), "on", 2, argv); + v8::Local argv[] = { v8::String::NewFromUtf8(isolate, "uncaughtException"), cb }; + node::MakeCallback(isolate, node::g_env->process_object(), "on", 2, argv); } } @@ -314,10 +323,10 @@ void ShellContentRendererClient::InstallNodeSymbols( RenderViewImpl* rv = RenderViewImpl::FromWebView(frame->view()); std::string root_path = rv->renderer_preferences_.nw_app_root_path.AsUTF8Unsafe(); #if defined(OS_WIN) - ReplaceChars(root_path, "\\", "\\\\", &root_path); + base::ReplaceChars(root_path, "\\", "\\\\", &root_path); #endif - ReplaceChars(root_path, "'", "\\'", &root_path); - v8::Local script = v8::Script::New(v8::String::New(( + base::ReplaceChars(root_path, "'", "\\'", &root_path); + v8::Local script = v8::Script::Compile(v8::String::NewFromUtf8(isolate, ( // Make node's relative modules work "if (!process.mainModule.filename) {" " var root = '" + root_path + "';" @@ -330,13 +339,13 @@ void ShellContentRendererClient::InstallNodeSymbols( "process.mainModule.paths = global.require('module')._nodeModulePaths(process.cwd());" "process.mainModule.loaded = true;" "}").c_str() - )); + )); CHECK(*script); script->Run(); } if (use_node || is_nw_protocol) { - v8::Local script = v8::Script::New(v8::String::New( + v8::Local script = v8::Script::Compile(v8::String::NewFromUtf8(isolate, // Overload require "window.require = function(name) {" " if (name == 'nw.gui')" @@ -349,7 +358,7 @@ void ShellContentRendererClient::InstallNodeSymbols( "process.versions['chromium'] = '" CHROME_VERSION "';" )); script->Run(); - v8::Local script2 = v8::Script::New(v8::String::New( + v8::Local script2 = v8::Script::Compile(v8::String::NewFromUtf8(isolate, " nwDispatcher.requireNwGui().Window.get();" )); script2->Run(); @@ -362,32 +371,34 @@ void ShellContentRendererClient::InstallNodeSymbols( // could override parent settings here render_view->Send(new ShellViewHostMsg_SetForceClose( render_view->GetRoutingID(), true, &ret)); + } } } // static void ShellContentRendererClient::ReportException( const v8::FunctionCallbackInfo& args) { - v8::HandleScope handle_scope; + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + v8::HandleScope scope(isolate); // Do nothing if user is listening to uncaughtException. v8::Local listeners_v = - node::g_env->process_object()->Get(v8::String::New("listeners")); + node::g_env->process_object()->Get(v8::String::NewFromUtf8(isolate, "listeners")); v8::Local listeners = v8::Local::Cast(listeners_v); - v8::Local argv[1] = { v8::String::New("uncaughtException") }; + v8::Local argv[1] = { v8::String::NewFromUtf8(isolate, "uncaughtException") }; v8::Local ret = listeners->Call(node::g_env->process_object(), 1, argv); v8::Local listener_array = v8::Local::Cast(ret); uint32_t length = listener_array->Length(); if (length > 1) { - args.GetReturnValue().Set(v8::Undefined()); + args.GetReturnValue().Set(v8::Undefined(isolate)); return; } // Print stacktrace. - v8::Local stack_symbol = v8::String::New("stack"); + v8::Local stack_symbol = v8::String::NewFromUtf8(isolate, "stack"); std::string error; v8::Local exception = args[0]->ToObject(); @@ -398,7 +409,7 @@ void ShellContentRendererClient::ReportException( RenderView* render_view = GetCurrentRenderView(); if (!render_view) { - args.GetReturnValue().Set(v8::Undefined()); + args.GetReturnValue().Set(v8::Undefined(isolate)); return; } @@ -406,21 +417,22 @@ void ShellContentRendererClient::ReportException( render_view->GetRoutingID(), error)); - args.GetReturnValue().Set(v8::Undefined()); + args.GetReturnValue().Set(v8::Undefined(isolate)); } void ShellContentRendererClient::UninstallNodeSymbols( - WebKit::WebFrame* frame, + blink::WebFrame* frame, v8::Handle context) { - v8::HandleScope handle_scope; + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + v8::HandleScope scope(isolate); v8::Local v8Global = context->Global(); - v8::Local symbols = v8::Array::New(5); - symbols->Set(0, v8::String::New("global")); - symbols->Set(1, v8::String::New("process")); - symbols->Set(2, v8::String::New("Buffer")); - symbols->Set(3, v8::String::New("root")); - symbols->Set(4, v8::String::New("require")); + v8::Local symbols = v8::Array::New(isolate, 5); + symbols->Set(0, v8::String::NewFromUtf8(isolate, "global")); + symbols->Set(1, v8::String::NewFromUtf8(isolate, "process")); + symbols->Set(2, v8::String::NewFromUtf8(isolate, "Buffer")); + symbols->Set(3, v8::String::NewFromUtf8(isolate, "root")); + symbols->Set(4, v8::String::NewFromUtf8(isolate, "require")); for (unsigned i = 0; i < symbols->Length(); ++i) { v8::Local key = symbols->Get(i)->ToString(); @@ -431,9 +443,9 @@ void ShellContentRendererClient::UninstallNodeSymbols( void ShellContentRendererClient::willHandleNavigationPolicy( RenderView* rv, - WebKit::WebFrame* frame, - const WebKit::WebURLRequest& request, - WebKit::WebNavigationPolicy* policy) { + blink::WebFrame* frame, + const blink::WebURLRequest& request, + blink::WebNavigationPolicy* policy) { nwapi::Dispatcher::willHandleNavigationPolicy(rv, frame, request, policy); } diff --git a/src/renderer/shell_content_renderer_client.h b/src/renderer/shell_content_renderer_client.h index 3a6aecbcd6..2e73788093 100644 --- a/src/renderer/shell_content_renderer_client.h +++ b/src/renderer/shell_content_renderer_client.h @@ -44,17 +44,17 @@ class ShellContentRendererClient : public ContentRendererClient { virtual void RenderThreadStarted() OVERRIDE; virtual void RenderViewCreated(RenderView* render_view) OVERRIDE; - virtual void DidCreateScriptContext(WebKit::WebFrame* frame, + virtual void DidCreateScriptContext(blink::WebFrame* frame, v8::Handle context, int extension_group, int world_id) OVERRIDE; - virtual bool WillSetSecurityToken(WebKit::WebFrame* frame, + virtual bool WillSetSecurityToken(blink::WebFrame* frame, v8::Handle) OVERRIDE; virtual void willHandleNavigationPolicy(RenderView* rv, - WebKit::WebFrame* frame, - const WebKit::WebURLRequest& request, - WebKit::WebNavigationPolicy* policy) OVERRIDE; + blink::WebFrame* frame, + const blink::WebURLRequest& request, + blink::WebNavigationPolicy* policy) OVERRIDE; private: scoped_ptr shell_observer_; @@ -62,11 +62,11 @@ class ShellContentRendererClient : public ContentRendererClient { bool creating_first_context_; - void InstallNodeSymbols(WebKit::WebFrame* frame, + void InstallNodeSymbols(blink::WebFrame* frame, v8::Handle context, const GURL& url); - void UninstallNodeSymbols(WebKit::WebFrame* frame, + void UninstallNodeSymbols(blink::WebFrame* frame, v8::Handle context); - bool goodForNode(WebKit::WebFrame* frame); + bool goodForNode(blink::WebFrame* frame); // Catch node uncaughtException. static void ReportException(const v8::FunctionCallbackInfo& args); diff --git a/src/renderer/shell_render_process_observer.cc b/src/renderer/shell_render_process_observer.cc index 5441b59fcf..325290f47f 100644 --- a/src/renderer/shell_render_process_observer.cc +++ b/src/renderer/shell_render_process_observer.cc @@ -25,8 +25,7 @@ #include "content/public/renderer/render_thread.h" #include "content/nw/src/api/api_messages.h" #include "content/nw/src/api/dispatcher_bindings.h" -#include "content/shell/renderer/gc_extension.h" -#include "webkit/glue/webkit_glue.h" +//#include "content/shell/renderer/gc_extension.h" #include "third_party/node/src/node.h" #undef CHECK #include "third_party/node/src/node_internals.h" @@ -35,7 +34,7 @@ #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" #include "v8/include/v8.h" -using WebKit::WebRuntimeFeatures; +using blink::WebRuntimeFeatures; namespace content { @@ -72,36 +71,38 @@ void ShellRenderProcessObserver::WebKitInitialized() { } void ShellRenderProcessObserver::OnOpen(const std::string& path) { - v8::HandleScope handle_scope; + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + v8::HandleScope scope(isolate); // the App object is stored in process["_nw_app"]. v8::Local process = node::g_env->process_object(); - v8::Local app_symbol = v8::String::NewSymbol("_nw_app"); + v8::Local app_symbol = v8::String::NewFromUtf8(isolate, "_nw_app", v8::String::kInternalizedString); if (process->Has(app_symbol)) { // process["_nw_app"].emit(path). v8::Local app = process->Get(app_symbol)->ToObject(); v8::Local emit = v8::Local::Cast( - app->Get(v8::String::New("emit"))); + app->Get(v8::String::NewFromUtf8(isolate, "emit"))); v8::Local argv[] = { - v8::String::New("open"), v8::String::New(path.c_str()) + v8::String::NewFromUtf8(isolate, "open"), v8::String::NewFromUtf8(isolate, path.c_str()) }; emit->Call(app, 2, argv); } } void ShellRenderProcessObserver::OnReopen() { - v8::HandleScope handle_scope; + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + v8::HandleScope scope(isolate); // the App object is stored in process["_nw_app"]. v8::Local process = node::g_env->process_object(); - v8::Local app_symbol = v8::String::NewSymbol("_nw_app"); + v8::Local app_symbol = v8::String::NewFromUtf8(isolate, "_nw_app", v8::String::kInternalizedString); if (process->Has(app_symbol)) { // process["_nw_app"].emit(path). v8::Local app = process->Get(app_symbol)->ToObject(); v8::Local emit = v8::Local::Cast( - app->Get(v8::String::New("emit"))); + app->Get(v8::String::NewFromUtf8(isolate, "emit"))); v8::Local argv[] = { - v8::String::New("reopen") + v8::String::NewFromUtf8(isolate, "reopen") }; emit->Call(app, 1, argv); } @@ -109,7 +110,7 @@ void ShellRenderProcessObserver::OnReopen() { void ShellRenderProcessObserver::OnClearCache() { if (webkit_initialized_) - WebKit::WebCache::clear(); + blink::WebCache::clear(); } } // namespace content diff --git a/src/shell_browser_context.cc b/src/shell_browser_context.cc index e7edd8176e..48a56e4c67 100644 --- a/src/shell_browser_context.cc +++ b/src/shell_browser_context.cc @@ -127,7 +127,7 @@ void ShellBrowserContext::InitWhileIOAllowed() { #endif if (!base::PathExists(path_)) - file_util::CreateDirectory(path_); + base::CreateDirectory(path_); } FilePath ShellBrowserContext::GetPath() const { @@ -154,7 +154,9 @@ net::URLRequestContextGetter* ShellBrowserContext::GetRequestContext() { } net::URLRequestContextGetter* ShellBrowserContext::CreateRequestContext( - ProtocolHandlerMap* protocol_handlers) { + ProtocolHandlerMap* protocol_handlers, + ProtocolHandlerScopedVector protocol_interceptors) { + DCHECK(!url_request_getter_); CommandLine* cmd_line = CommandLine::ForCurrentProcess(); std::string auth_server_whitelist = @@ -228,20 +230,36 @@ quota::SpecialStoragePolicy* ShellBrowserContext::GetSpecialStoragePolicy() { return NULL; } -void ShellBrowserContext::RequestMIDISysExPermission( +void ShellBrowserContext::RequestMidiSysExPermission( int render_process_id, int render_view_id, int bridge_id, const GURL& requesting_frame, - const MIDISysExPermissionCallback& callback) { + bool user_gesture, + const MidiSysExPermissionCallback& callback) { callback.Run(true); } -void ShellBrowserContext::CancelMIDISysExPermissionRequest( +void ShellBrowserContext::CancelMidiSysExPermissionRequest( int render_process_id, int render_view_id, int bridge_id, const GURL& requesting_frame) { } +void ShellBrowserContext::RequestProtectedMediaIdentifierPermission( + int render_process_id, + int render_view_id, + int bridge_id, + int group_id, + const GURL& requesting_frame, + const ProtectedMediaIdentifierPermissionCallback& callback) { + callback.Run(true); +} + +void ShellBrowserContext::CancelProtectedMediaIdentifierPermissionRequests( + int group_id) { +} + + } // namespace content diff --git a/src/shell_browser_context.h b/src/shell_browser_context.h index 372c243b7c..ff42d55f74 100644 --- a/src/shell_browser_context.h +++ b/src/shell_browser_context.h @@ -51,25 +51,36 @@ class ShellBrowserContext : public BrowserContext { virtual GeolocationPermissionContext* GetGeolocationPermissionContext() OVERRIDE; virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE; - virtual void RequestMIDISysExPermission( + + virtual void RequestMidiSysExPermission( int render_process_id, int render_view_id, int bridge_id, const GURL& requesting_frame, - const MIDISysExPermissionCallback& callback) OVERRIDE; - virtual void CancelMIDISysExPermissionRequest( - int render_process_id, - int render_view_id, - int bridge_id, - const GURL& requesting_frame) OVERRIDE; - - - net::URLRequestContextGetter* CreateRequestContext( - ProtocolHandlerMap* protocol_handlers); - net::URLRequestContextGetter* CreateRequestContextForStoragePartition( + bool user_gesture, + const MidiSysExPermissionCallback& callback) OVERRIDE; + virtual void CancelMidiSysExPermissionRequest( + int render_process_id, + int render_view_id, + int bridge_id, + const GURL& requesting_frame) OVERRIDE; + virtual void RequestProtectedMediaIdentifierPermission( + int render_process_id, + int render_view_id, + int bridge_id, + int group_id, + const GURL& requesting_frame, + const ProtectedMediaIdentifierPermissionCallback& callback) OVERRIDE; + virtual void CancelProtectedMediaIdentifierPermissionRequests( + int group_id) OVERRIDE; + + virtual net::URLRequestContextGetter* CreateRequestContext( + ProtocolHandlerMap* protocol_handlers, + ProtocolHandlerScopedVector protocol_interceptors) OVERRIDE; + virtual net::URLRequestContextGetter* CreateRequestContextForStoragePartition( const base::FilePath& partition_path, bool in_memory, - ProtocolHandlerMap* protocol_handlers); + ProtocolHandlerMap* protocol_handlers) OVERRIDE; bool pinning_renderer() { return !disable_pinning_renderer_; } void set_pinning_renderer(bool val) { disable_pinning_renderer_ = !val; } diff --git a/src/shell_browser_main_parts.cc b/src/shell_browser_main_parts.cc index f12b8aa500..a64c5ce1fb 100644 --- a/src/shell_browser_main_parts.cc +++ b/src/shell_browser_main_parts.cc @@ -141,7 +141,7 @@ void ShellBrowserMainParts::PostMainMessageLoopRun() { void ShellBrowserMainParts::PostMainMessageLoopStart() { #if defined(TOOLKIT_GTK) - printing::PrintingContextGtk::SetCreatePrintDialogFunction( + printing::PrintingContextLinux::SetCreatePrintDialogFunction( &PrintDialogGtk::CreatePrintDialog); #endif } diff --git a/src/shell_content_browser_client.cc b/src/shell_content_browser_client.cc index 3b5b63cc8e..6965b595e2 100644 --- a/src/shell_content_browser_client.cc +++ b/src/shell_content_browser_client.cc @@ -66,10 +66,10 @@ #include "ui/base/ui_base_switches.h" #include "content/common/dom_storage/dom_storage_map.h" #include "webkit/common/webpreferences.h" -#include "webkit/common/user_agent/user_agent_util.h" +#include "content/public/common/user_agent.h" #include "content/common/plugin_list.h" #include "content/public/browser/plugin_service.h" - +#include "chrome/common/chrome_switches.h" #if defined(OS_LINUX) #include "base/linux_util.h" #include "content/nw/src/crash_handler_host_linux.h" @@ -128,8 +128,8 @@ bool ShellContentBrowserClient::GetUserAgentManifest(std::string* agent) { ReplaceSubstringsAfterOffset(&user_agent, 0, "%name", name); ReplaceSubstringsAfterOffset(&user_agent, 0, "%ver", version); ReplaceSubstringsAfterOffset(&user_agent, 0, "%nwver", NW_VERSION_STRING); - ReplaceSubstringsAfterOffset(&user_agent, 0, "%webkit_ver", webkit_glue::GetWebKitVersion()); - ReplaceSubstringsAfterOffset(&user_agent, 0, "%osinfo", webkit_glue::BuildOSInfo()); + ReplaceSubstringsAfterOffset(&user_agent, 0, "%webkit_ver", content::GetWebKitVersion()); + ReplaceSubstringsAfterOffset(&user_agent, 0, "%osinfo", content::BuildOSInfo()); *agent = user_agent; return true; } @@ -157,6 +157,8 @@ WebContentsViewPort* ShellContentBrowserClient::OverrideCreateWebContentsView( } std::string ShellContentBrowserClient::GetApplicationLocale() { + base::ThreadRestrictions::ScopedAllowIO allow_io; + CommandLine* cmd_line = CommandLine::ForCurrentProcess(); std::string pref_locale; if (cmd_line->HasSwitch(switches::kLang)) { @@ -331,10 +333,11 @@ bool ShellContentBrowserClient::IsSuitableHost(RenderProcessHost* process_host, net::URLRequestContextGetter* ShellContentBrowserClient::CreateRequestContext( BrowserContext* content_browser_context, - ProtocolHandlerMap* protocol_handlers) { + ProtocolHandlerMap* protocol_handlers, + ProtocolHandlerScopedVector protocol_interceptors) { ShellBrowserContext* shell_browser_context = ShellBrowserContextForBrowserContext(content_browser_context); - return shell_browser_context->CreateRequestContext(protocol_handlers); + return shell_browser_context->CreateRequestContext(protocol_handlers, protocol_interceptors.Pass()); } net::URLRequestContextGetter* @@ -371,7 +374,7 @@ void ShellContentBrowserClient::RenderProcessHostCreated( // Grant file: scheme to the whole process, since we impose // per-view access checks. content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme( - host->GetID(), chrome::kFileScheme); + host->GetID(), content::kFileScheme); content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme( host->GetID(), "app"); @@ -387,8 +390,8 @@ bool ShellContentBrowserClient::IsHandledURL(const GURL& url) { // Keep in sync with ProtocolHandlers added by // ShellURLRequestContextGetter::GetURLRequestContext(). static const char* const kProtocolList[] = { - chrome::kFileSystemScheme, - chrome::kFileScheme, + content::kFileSystemScheme, + content::kFileScheme, "app", }; for (size_t i = 0; i < arraysize(kProtocolList); ++i) { diff --git a/src/shell_content_browser_client.h b/src/shell_content_browser_client.h index a6d54eebc8..ceda35317b 100644 --- a/src/shell_content_browser_client.h +++ b/src/shell_content_browser_client.h @@ -37,7 +37,7 @@ class ShellContentBrowserClient : public ContentBrowserClient { RenderViewHostDelegateView** render_view_host_delegate_view, const WebContents::CreateParams& params) OVERRIDE; virtual std::string GetApplicationLocale() OVERRIDE; - virtual void AppendExtraCommandLineSwitches(CommandLine* command_line, + virtual void AppendExtraCommandLineSwitches(base::CommandLine* command_line, int child_process_id) OVERRIDE; virtual void ResourceDispatcherHostCreated() OVERRIDE; virtual AccessTokenStore* CreateAccessTokenStore() OVERRIDE; @@ -65,7 +65,7 @@ class ShellContentBrowserClient : public ContentBrowserClient { virtual void RenderProcessHostCreated(RenderProcessHost* host) OVERRIDE; virtual net::URLRequestContextGetter* CreateRequestContext( BrowserContext* browser_context, - ProtocolHandlerMap* protocol_handlers) OVERRIDE; + ProtocolHandlerMap* protocol_handlers, ProtocolHandlerScopedVector protocol_interceptors) OVERRIDE; virtual net::URLRequestContextGetter* CreateRequestContextForStoragePartition( BrowserContext* browser_context, const base::FilePath& partition_path, @@ -86,7 +86,7 @@ class ShellContentBrowserClient : public ContentBrowserClient { std::vector* additional_schemes) OVERRIDE; #if defined(OS_POSIX) && !defined(OS_MACOSX) virtual void GetAdditionalMappedFilesForChildProcess( - const CommandLine& command_line, + const base::CommandLine& command_line, int child_process_id, std::vector* mappings) OVERRIDE; #endif diff --git a/src/shell_content_client.cc b/src/shell_content_client.cc index 4b42ed7e77..581940d71c 100644 --- a/src/shell_content_client.cc +++ b/src/shell_content_client.cc @@ -24,9 +24,9 @@ #include "content/nw/src/api/api_messages.h" #include "content/nw/src/nw_version.h" #include "content/nw/src/renderer/common/render_messages.h" +#include "content/public/common/user_agent.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" -#include "webkit/common/user_agent/user_agent_util.h" namespace content { @@ -34,10 +34,10 @@ ShellContentClient::~ShellContentClient() { } std::string ShellContentClient::GetUserAgent() const { - return webkit_glue::BuildUserAgentFromProduct("Chrome/" CHROME_VERSION); + return content::BuildUserAgentFromProduct("Chrome/" CHROME_VERSION); } -string16 ShellContentClient::GetLocalizedString(int message_id) const { +base::string16 ShellContentClient::GetLocalizedString(int message_id) const { return l10n_util::GetStringUTF16(message_id); } diff --git a/src/shell_content_client.h b/src/shell_content_client.h index 09f4701611..1284655387 100644 --- a/src/shell_content_client.h +++ b/src/shell_content_client.h @@ -18,7 +18,7 @@ class ShellContentClient : public ContentClient { virtual ~ShellContentClient(); virtual std::string GetUserAgent() const OVERRIDE; - virtual string16 GetLocalizedString(int message_id) const OVERRIDE; + virtual base::string16 GetLocalizedString(int message_id) const OVERRIDE; virtual base::StringPiece GetDataResource( int resource_id, ui::ScaleFactor scale_factor) const OVERRIDE; diff --git a/src/shell_main.cc b/src/shell_main.cc index 2148f4f3be..02b706163b 100644 --- a/src/shell_main.cc +++ b/src/shell_main.cc @@ -49,7 +49,10 @@ int main(int argc, const char** argv) { return ::ContentMain(argc, argv); #else content::ShellMainDelegate delegate; - return content::ContentMain(argc, argv, &delegate); + content::ContentMainParams params(&delegate); + params.argc = argc; + params.argv = argv; + return content::ContentMain(params); #endif // OS_MACOSX } diff --git a/src/shell_main_delegate.cc b/src/shell_main_delegate.cc index 0d9b2bfafe..c132a66a6b 100644 --- a/src/shell_main_delegate.cc +++ b/src/shell_main_delegate.cc @@ -70,7 +70,7 @@ using base::FilePath; #define IPC_LOG_TABLE_ADD_ENTRY(msg_id, logger) \ content::RegisterIPCLogger(msg_id, logger) #include "content/nw/src/common/common_message_generator.h" -#include "components/autofill/core/common/autofill_messages.h" +//#include "components/autofill/core/common/autofill_messages.h" #endif namespace { @@ -130,7 +130,7 @@ bool ShellMainDelegate::BasicStartupComplete(int* exit_code) { #endif InitLogging(); - net::CookieMonster::EnableFileScheme(); + // FIXME: net::CookieMonster::EnableFileScheme(); SetContentClient(&content_client_); return false;