From 513209b27ff55e2841eac0e4120199c23acce758 Mon Sep 17 00:00:00 2001 From: Ben Murdoch Date: Thu, 18 Nov 2010 18:32:45 +0000 Subject: Merge Chromium at r65505: Initial merge by git. Change-Id: I31d8f1d8cd33caaf7f47ffa7350aef42d5fbdb45 --- webkit/glue/dom_operations.cc | 165 +--------- webkit/glue/dom_operations.h | 7 - webkit/glue/media/buffered_data_source.cc | 62 ++-- webkit/glue/media/buffered_data_source.h | 44 ++- webkit/glue/media/buffered_data_source_unittest.cc | 80 +++-- webkit/glue/media/simple_data_source.cc | 42 ++- webkit/glue/media/simple_data_source.h | 36 +-- webkit/glue/media/simple_data_source_unittest.cc | 27 +- webkit/glue/media/video_renderer_impl.cc | 29 +- webkit/glue/media/video_renderer_impl.h | 38 +-- webkit/glue/media/web_data_source.cc | 17 + webkit/glue/media/web_data_source.h | 36 +++ webkit/glue/media/web_video_renderer.h | 4 + webkit/glue/multipart_response_delegate.cc | 24 +- webkit/glue/plugins/DEPS | 2 +- .../plugins/carbon_plugin_window_tracker_mac.cc | 8 +- .../plugins/carbon_plugin_window_tracker_mac.h | 16 +- webkit/glue/plugins/npapi_extension_thunk.cc | 70 ++-- webkit/glue/plugins/pepper_audio.cc | 21 +- webkit/glue/plugins/pepper_audio.h | 12 +- webkit/glue/plugins/pepper_buffer.cc | 19 +- webkit/glue/plugins/pepper_char_set.cc | 2 +- webkit/glue/plugins/pepper_class.h | 66 ++++ webkit/glue/plugins/pepper_common.h | 24 ++ webkit/glue/plugins/pepper_cursor_control.cc | 41 +-- webkit/glue/plugins/pepper_directory_reader.cc | 103 +++++- webkit/glue/plugins/pepper_directory_reader.h | 11 + webkit/glue/plugins/pepper_error_util.cc | 2 +- webkit/glue/plugins/pepper_event_conversion.cc | 6 +- webkit/glue/plugins/pepper_file_callbacks.cc | 25 +- webkit/glue/plugins/pepper_file_callbacks.h | 12 +- webkit/glue/plugins/pepper_file_chooser.cc | 15 +- webkit/glue/plugins/pepper_file_chooser.h | 4 +- webkit/glue/plugins/pepper_file_io.cc | 13 +- webkit/glue/plugins/pepper_file_io.h | 6 +- webkit/glue/plugins/pepper_file_ref.cc | 37 ++- webkit/glue/plugins/pepper_file_ref.h | 2 +- webkit/glue/plugins/pepper_file_system.cc | 7 +- webkit/glue/plugins/pepper_file_system.h | 2 +- webkit/glue/plugins/pepper_font.cc | 36 ++- webkit/glue/plugins/pepper_font.h | 2 +- webkit/glue/plugins/pepper_fullscreen_container.h | 3 + webkit/glue/plugins/pepper_graphics_2d.cc | 67 ++-- webkit/glue/plugins/pepper_graphics_2d.h | 6 +- webkit/glue/plugins/pepper_graphics_3d.cc | 180 +++++------ webkit/glue/plugins/pepper_graphics_3d.h | 49 +-- webkit/glue/plugins/pepper_graphics_3d_gl.cc | 2 +- webkit/glue/plugins/pepper_image_data.cc | 41 +-- webkit/glue/plugins/pepper_image_data.h | 4 +- webkit/glue/plugins/pepper_plugin_delegate.h | 49 ++- webkit/glue/plugins/pepper_plugin_instance.cc | 267 ++++++++++----- webkit/glue/plugins/pepper_plugin_instance.h | 62 +++- webkit/glue/plugins/pepper_plugin_module.cc | 86 ++--- webkit/glue/plugins/pepper_plugin_module.h | 4 +- webkit/glue/plugins/pepper_plugin_object.cc | 360 ++++++++++++++++++--- webkit/glue/plugins/pepper_private.cc | 14 +- webkit/glue/plugins/pepper_private2.cc | 14 +- webkit/glue/plugins/pepper_private2.h | 4 +- webkit/glue/plugins/pepper_private2_linux.cc | 6 +- webkit/glue/plugins/pepper_resource.cc | 4 + webkit/glue/plugins/pepper_resource.h | 16 +- webkit/glue/plugins/pepper_resource_tracker.cc | 12 +- webkit/glue/plugins/pepper_resource_tracker.h | 18 +- webkit/glue/plugins/pepper_scrollbar.cc | 12 +- webkit/glue/plugins/pepper_scrollbar.h | 2 +- webkit/glue/plugins/pepper_transport.cc | 11 +- webkit/glue/plugins/pepper_transport.h | 2 +- webkit/glue/plugins/pepper_url_loader.cc | 219 +++++++++++-- webkit/glue/plugins/pepper_url_loader.h | 54 +++- webkit/glue/plugins/pepper_url_request_info.cc | 74 +++-- webkit/glue/plugins/pepper_url_request_info.h | 11 +- webkit/glue/plugins/pepper_url_response_info.cc | 31 +- webkit/glue/plugins/pepper_url_response_info.h | 6 +- webkit/glue/plugins/pepper_url_util.cc | 29 +- webkit/glue/plugins/pepper_var.cc | 270 +++++++++++++++- webkit/glue/plugins/pepper_var.h | 4 + webkit/glue/plugins/pepper_video_decoder.cc | 27 +- webkit/glue/plugins/pepper_webplugin_impl.cc | 6 +- webkit/glue/plugins/pepper_webplugin_impl.h | 1 + webkit/glue/plugins/pepper_widget.cc | 29 +- webkit/glue/plugins/pepper_widget.h | 2 +- webkit/glue/plugins/plugin_group.cc | 4 +- webkit/glue/plugins/plugin_host.cc | 61 ++-- webkit/glue/plugins/plugin_instance.cc | 7 +- webkit/glue/plugins/plugin_instance.h | 4 + webkit/glue/plugins/plugin_lib.cc | 2 +- webkit/glue/plugins/plugin_lib_unittest.cc | 4 +- webkit/glue/plugins/plugin_list_posix.cc | 3 +- .../glue/plugins/plugin_web_event_converter_mac.mm | 23 +- webkit/glue/plugins/ppb_private.h | 13 +- webkit/glue/plugins/ppb_private2.h | 23 +- webkit/glue/plugins/ppp_private.h | 6 +- .../test/plugin_create_instance_in_paint.cc | 1 + .../plugins/test/plugin_get_javascript_url_test.cc | 1 + .../plugins/test/plugin_npobject_lifetime_test.cc | 1 + webkit/glue/plugins/test/plugin_setup_test.cc | 22 ++ webkit/glue/plugins/test/plugin_setup_test.h | 24 ++ webkit/glue/plugins/test/plugin_test_factory.cc | 4 + webkit/glue/plugins/test/plugin_windowed_test.cc | 1 + webkit/glue/plugins/webplugin_delegate_impl.cc | 8 +- webkit/glue/plugins/webplugin_impl.cc | 14 + webkit/glue/plugins/webplugin_impl.h | 1 + webkit/glue/resource_loader_bridge.h | 4 - webkit/glue/site_isolation_metrics.cc | 2 +- webkit/glue/webaccessibility.cc | 37 ++- webkit/glue/webaccessibility.h | 10 +- webkit/glue/webfileutilities_impl.cc | 4 + webkit/glue/webfileutilities_impl.h | 1 + webkit/glue/webkit_glue.cc | 10 - webkit/glue/webkit_glue.gypi | 5 +- webkit/glue/webkit_glue.h | 10 +- webkit/glue/webkitclient_impl.cc | 6 +- webkit/glue/webmediaplayer_impl.cc | 87 +++-- webkit/glue/webmediaplayer_impl.h | 66 ++-- webkit/glue/weburlloader_impl.cc | 10 +- 115 files changed, 2465 insertions(+), 1247 deletions(-) create mode 100644 webkit/glue/media/web_data_source.cc create mode 100644 webkit/glue/media/web_data_source.h create mode 100644 webkit/glue/plugins/pepper_class.h create mode 100644 webkit/glue/plugins/pepper_common.h create mode 100644 webkit/glue/plugins/test/plugin_setup_test.cc create mode 100644 webkit/glue/plugins/test/plugin_setup_test.h (limited to 'webkit') diff --git a/webkit/glue/dom_operations.cc b/webkit/glue/dom_operations.cc index aab6f36..2d0fb68 100644 --- a/webkit/glue/dom_operations.cc +++ b/webkit/glue/dom_operations.cc @@ -9,30 +9,28 @@ #include "base/compiler_specific.h" #include "base/string_number_conversions.h" #include "base/string_split.h" +#include "base/string_util.h" #include "third_party/WebKit/WebKit/chromium/public/WebAnimationController.h" #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" #include "third_party/WebKit/WebKit/chromium/public/WebElement.h" -#include "third_party/WebKit/WebKit/chromium/public/WebFormElement.h" #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" #include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h" #include "third_party/WebKit/WebKit/chromium/public/WebNode.h" #include "third_party/WebKit/WebKit/chromium/public/WebNodeCollection.h" #include "third_party/WebKit/WebKit/chromium/public/WebNodeList.h" +#include "third_party/WebKit/WebKit/chromium/public/WebString.h" #include "third_party/WebKit/WebKit/chromium/public/WebVector.h" #include "third_party/WebKit/WebKit/chromium/public/WebView.h" -#include "webkit/glue/form_data.h" -#include "webkit/glue/password_form_dom_manager.h" -#include "webkit/glue/webpasswordautocompletelistener_impl.h" using WebKit::WebAnimationController; using WebKit::WebDocument; using WebKit::WebElement; -using WebKit::WebFormElement; using WebKit::WebFrame; using WebKit::WebInputElement; using WebKit::WebNode; using WebKit::WebNodeCollection; using WebKit::WebNodeList; +using WebKit::WebString; using WebKit::WebVector; using WebKit::WebView; @@ -153,163 +151,6 @@ void GetAllSavableResourceLinksForFrame(WebFrame* current_frame, namespace webkit_glue { -// Map element name to a list of pointers to corresponding elements to simplify -// form filling. -typedef std::map - FormInputElementMap; - -// Utility struct for form lookup and autofill. When we parse the DOM to lookup -// a form, in addition to action and origin URL's we have to compare all -// necessary form elements. To avoid having to look these up again when we want -// to fill the form, the FindFormElements function stores the pointers -// in a FormElements* result, referenced to ensure they are safe to use. -struct FormElements { - WebFormElement form_element; - FormInputElementMap input_elements; - FormElements() { - } -}; - -typedef std::vector FormElementsList; - -// Internal implementation of FillForm API. -static bool FillFormImpl(FormElements* fe, const FormData& data) { - if (!fe->form_element.autoComplete()) - return false; - - std::map data_map; - for (size_t i = 0; i < data.fields.size(); i++) - data_map[data.fields[i].name()] = data.fields[i].value(); - - for (FormInputElementMap::iterator it = fe->input_elements.begin(); - it != fe->input_elements.end(); ++it) { - WebKit::WebInputElement& element = it->second; - if (!element.value().isEmpty()) // Don't overwrite pre-filled values. - continue; - if (element.isPasswordField() && - (!element.isEnabledFormControl() || element.hasAttribute("readonly"))) { - continue; // Don't fill uneditable password fields. - } - if (!element.isValidValue(data_map[it->first])) - continue; - - element.setValue(data_map[it->first]); - element.setAutofilled(true); - element.dispatchFormControlChangeEvent(); - } - - return false; -} - -// Helper to search the given form element for the specified input elements -// in |data|, and add results to |result|. -static bool FindFormInputElements(WebFormElement* fe, - const FormData& data, - FormElements* result) { - // Loop through the list of elements we need to find on the form in - // order to autofill it. If we don't find any one of them, abort - // processing this form; it can't be the right one. - for (size_t j = 0; j < data.fields.size(); j++) { - WebVector temp_elements; - fe->getNamedElements(data.fields[j].name(), temp_elements); - if (temp_elements.isEmpty()) { - // We didn't find a required element. This is not the right form. - // Make sure no input elements from a partially matched form - // in this iteration remain in the result set. - // Note: clear will remove a reference from each InputElement. - result->input_elements.clear(); - return false; - } - // This element matched, add it to our temporary result. It's possible - // there are multiple matches, but for purposes of identifying the form - // one suffices and if some function needs to deal with multiple - // matching elements it can get at them through the FormElement*. - // Note: This assignment adds a reference to the InputElement. - result->input_elements[data.fields[j].name()] = - temp_elements[0].to(); - } - return true; -} - -// Helper to locate form elements identified by |data|. -static void FindFormElements(WebView* view, - const FormData& data, - FormElementsList* results) { - DCHECK(view); - DCHECK(results); - WebFrame* main_frame = view->mainFrame(); - if (!main_frame) - return; - - GURL::Replacements rep; - rep.ClearQuery(); - rep.ClearRef(); - - // Loop through each frame. - for (WebFrame* f = main_frame; f; f = f->traverseNext(false)) { - WebDocument doc = f->document(); - if (!doc.isHTMLDocument()) - continue; - - GURL full_origin(f->url()); - if (data.origin != full_origin.ReplaceComponents(rep)) - continue; - - WebVector forms; - f->forms(forms); - - for (size_t i = 0; i < forms.size(); ++i) { - WebFormElement fe = forms[i]; - // Action URL must match. - GURL full_action(f->document().completeURL(fe.action())); - if (data.action != full_action.ReplaceComponents(rep)) - continue; - - scoped_ptr curr_elements(new FormElements); - if (!FindFormInputElements(&fe, data, curr_elements.get())) - continue; - - // We found the right element. - // Note: this assignment adds a reference to |fe|. - curr_elements->form_element = fe; - results->push_back(curr_elements.release()); - } - } -} - -void FillPasswordForm(WebView* view, - const PasswordFormFillData& data) { - FormElementsList forms; - // We own the FormElements* in forms. - FindFormElements(view, data.basic_data, &forms); - FormElementsList::iterator iter; - for (iter = forms.begin(); iter != forms.end(); ++iter) { - scoped_ptr form_elements(*iter); - - // If wait_for_username is true, we don't want to initially fill the form - // until the user types in a valid username. - if (!data.wait_for_username) - FillFormImpl(form_elements.get(), data.basic_data); - - // Attach autocomplete listener to enable selecting alternate logins. - // First, get pointers to username element. - WebInputElement username_element = - form_elements->input_elements[data.basic_data.fields[0].name()]; - - // Get pointer to password element. (We currently only support single - // password forms). - WebInputElement password_element = - form_elements->input_elements[data.basic_data.fields[1].name()]; - - username_element.document().frame()->registerPasswordListener( - username_element, - new WebPasswordAutocompleteListenerImpl( - new WebInputElementDelegate(username_element), - new WebInputElementDelegate(password_element), - data)); - } -} - WebString GetSubResourceLinkFromElement(const WebElement& element) { const char* attribute_name = NULL; if (element.hasTagName("img") || diff --git a/webkit/glue/dom_operations.h b/webkit/glue/dom_operations.h index 1b6151b..951eb0f 100644 --- a/webkit/glue/dom_operations.h +++ b/webkit/glue/dom_operations.h @@ -21,13 +21,6 @@ class WebView; // A collection of operations that access the underlying WebKit DOM directly. namespace webkit_glue { -struct PasswordFormFillData; - -// Fill matching password forms and trigger autocomplete in the case of multiple -// matching logins. -void FillPasswordForm(WebKit::WebView* view, - const PasswordFormFillData& data); - // Structure for storage the result of getting all savable resource links // for current page. The consumer of the SavableResourcesResult is responsible // for keeping these pointers valid for the lifetime of the diff --git a/webkit/glue/media/buffered_data_source.cc b/webkit/glue/media/buffered_data_source.cc index 3456e3a..29c86ac 100644 --- a/webkit/glue/media/buffered_data_source.cc +++ b/webkit/glue/media/buffered_data_source.cc @@ -15,6 +15,7 @@ #include "net/http/http_response_headers.h" #include "webkit/glue/media/buffered_data_source.h" #include "webkit/glue/webkit_glue.h" +#include "webkit/glue/webmediaplayer_impl.h" namespace { @@ -126,7 +127,7 @@ void BufferedResourceLoader::Start(net::CompletionCallback* start_callback, bridge_.reset( bridge_factory_->CreateBridge( url_, - IsMediaCacheEnabled() ? net::LOAD_NORMAL : net::LOAD_BYPASS_CACHE, + net::LOAD_NORMAL, first_byte_position_, last_byte_position_)); @@ -521,31 +522,14 @@ void BufferedResourceLoader::NotifyNetworkEvent() { } ///////////////////////////////////////////////////////////////////////////// -// BufferedDataSource, static methods -bool BufferedDataSource::IsMediaFormatSupported( - const media::MediaFormat& media_format) { - std::string mime_type; - std::string url; - if (media_format.GetAsString(media::MediaFormat::kMimeType, &mime_type) && - media_format.GetAsString(media::MediaFormat::kURL, &url)) { - GURL gurl(url); - - // This data source doesn't support data:// protocol, so reject it - // explicitly. - if (IsProtocolSupportedForMedia(gurl) && !IsDataProtocol(gurl)) - return true; - } - return false; -} - -///////////////////////////////////////////////////////////////////////////// -// BufferedDataSource, protected +// BufferedDataSource BufferedDataSource::BufferedDataSource( MessageLoop* render_loop, webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory) : total_bytes_(kPositionNotSpecified), loaded_(false), streaming_(false), + single_origin_(true), bridge_factory_(bridge_factory), loader_(NULL), network_activity_(false), @@ -614,6 +598,13 @@ void BufferedDataSource::Initialize(const std::string& url, NewRunnableMethod(this, &BufferedDataSource::InitializeTask)); } +bool BufferedDataSource::IsUrlSupported(const std::string& url) { + GURL gurl(url); + + // This data source doesn't support data:// protocol so reject it. + return IsProtocolSupportedForMedia(gurl) && !IsDataProtocol(gurl); +} + void BufferedDataSource::Stop(media::FilterCallback* callback) { { AutoLock auto_lock(lock_); @@ -623,6 +614,7 @@ void BufferedDataSource::Stop(media::FilterCallback* callback) { callback->Run(); delete callback; } + render_loop_->PostTask(FROM_HERE, NewRunnableMethod(this, &BufferedDataSource::CleanupTask)); } @@ -655,6 +647,25 @@ bool BufferedDataSource::IsStreaming() { return streaming_; } +bool BufferedDataSource::HasSingleOrigin() { + DCHECK(MessageLoop::current() == render_loop_); + return single_origin_; +} + +void BufferedDataSource::Abort() { + DCHECK(MessageLoop::current() == render_loop_); + + // If we are told to abort, immediately return from any pending read + // with an error. + if (read_callback_.get()) { + { + AutoLock auto_lock(lock_); + DoneRead_Locked(net::ERR_FAILED); + } + CleanupTask(); + } +} + ///////////////////////////////////////////////////////////////////////////// // BufferedDataSource, render thread tasks void BufferedDataSource::InitializeTask() { @@ -720,7 +731,10 @@ void BufferedDataSource::ReadTask( void BufferedDataSource::CleanupTask() { DCHECK(MessageLoop::current() == render_loop_); - DCHECK(!stopped_on_render_loop_); + + // If we have already stopped, do nothing. + if (stopped_on_render_loop_) + return; // Stop the watch dog. watch_dog_timer_.Stop(); @@ -865,6 +879,9 @@ void BufferedDataSource::HttpInitialStartCallback(int error) { DCHECK(MessageLoop::current() == render_loop_); DCHECK(loader_.get()); + // Check if the request ended up at a different origin via redirect. + single_origin_ = url_.GetOrigin() == loader_->url().GetOrigin(); + int64 instance_size = loader_->instance_size(); bool partial_response = loader_->partial_response(); bool success = error == net::OK; @@ -929,6 +946,9 @@ void BufferedDataSource::NonHttpInitialStartCallback(int error) { DCHECK(MessageLoop::current() == render_loop_); DCHECK(loader_.get()); + // Check if the request ended up at a different origin via redirect. + single_origin_ = url_.GetOrigin() == loader_->url().GetOrigin(); + int64 instance_size = loader_->instance_size(); bool success = error == net::OK && instance_size != kPositionNotSpecified; diff --git a/webkit/glue/media/buffered_data_source.h b/webkit/glue/media/buffered_data_source.h index e7b2e47..2af9e84 100644 --- a/webkit/glue/media/buffered_data_source.h +++ b/webkit/glue/media/buffered_data_source.h @@ -13,7 +13,6 @@ #include "base/timer.h" #include "base/condition_variable.h" #include "googleurl/src/gurl.h" -#include "media/base/factory.h" #include "media/base/filters.h" #include "media/base/media_format.h" #include "media/base/pipeline.h" @@ -21,6 +20,8 @@ #include "net/base/completion_callback.h" #include "net/base/file_stream.h" #include "webkit/glue/media/media_resource_loader_bridge_factory.h" +#include "webkit/glue/media/web_data_source.h" +#include "webkit/glue/webmediaplayer_impl.h" namespace webkit_glue { ///////////////////////////////////////////////////////////////////////////// @@ -105,6 +106,9 @@ class BufferedResourceLoader : // Returns true if network is currently active. virtual bool network_activity() { return !completed_ && !deferred_; } + // Returns resulting URL. + virtual const GURL& url() { return url_; } + ///////////////////////////////////////////////////////////////////////////// // webkit_glue::ResourceLoaderBridge::Peer implementations. virtual void OnUploadProgress(uint64 position, uint64 size) {} @@ -122,7 +126,6 @@ class BufferedResourceLoader : const URLRequestStatus& status, const std::string& security_info, const base::Time& completion_time); - GURL GetURLForDebugging() const { return url_; } protected: friend class base::RefCountedThreadSafe; @@ -212,27 +215,18 @@ class BufferedResourceLoader : DISALLOW_COPY_AND_ASSIGN(BufferedResourceLoader); }; -class BufferedDataSource : public media::DataSource { +class BufferedDataSource : public WebDataSource { public: - // Methods called from pipeline thread - // Static methods for creating this class. - static media::FilterFactory* CreateFactory( - MessageLoop* message_loop, - webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory) { - return new media::FilterFactoryImpl2< - BufferedDataSource, - MessageLoop*, - webkit_glue::MediaResourceLoaderBridgeFactory*>( - message_loop, bridge_factory); - } + BufferedDataSource( + MessageLoop* render_loop, + webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory); - // media::FilterFactoryImpl2 implementation. - static bool IsMediaFormatSupported( - const media::MediaFormat& media_format); + virtual ~BufferedDataSource(); // media::MediaFilter implementation. virtual void Initialize(const std::string& url, media::FilterCallback* callback); + virtual bool IsUrlSupported(const std::string& url); virtual void Stop(media::FilterCallback* callback); virtual void SetPlaybackRate(float playback_rate); @@ -248,11 +242,11 @@ class BufferedDataSource : public media::DataSource { return media_format_; } + // webkit_glue::WebDataSource implementation. + virtual bool HasSingleOrigin(); + virtual void Abort(); + protected: - BufferedDataSource( - MessageLoop* render_loop, - webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory); - virtual ~BufferedDataSource(); // A factory method to create a BufferedResourceLoader based on the read // parameters. We can override this file to object a mock @@ -266,11 +260,6 @@ class BufferedDataSource : public media::DataSource { virtual base::TimeDelta GetTimeoutMilliseconds(); private: - friend class media::FilterFactoryImpl2< - BufferedDataSource, - MessageLoop*, - webkit_glue::MediaResourceLoaderBridgeFactory*>; - // Posted to perform initialization on render thread and start resource // loading. void InitializeTask(); @@ -349,6 +338,9 @@ class BufferedDataSource : public media::DataSource { // i.e. range request is not supported. bool streaming_; + // True if the media resource has a single origin. + bool single_origin_; + // A factory object to produce ResourceLoaderBridge. scoped_ptr bridge_factory_; diff --git a/webkit/glue/media/buffered_data_source_unittest.cc b/webkit/glue/media/buffered_data_source_unittest.cc index f032595..81103b2 100644 --- a/webkit/glue/media/buffered_data_source_unittest.cc +++ b/webkit/glue/media/buffered_data_source_unittest.cc @@ -27,6 +27,7 @@ using ::testing::Invoke; using ::testing::InvokeWithoutArgs; using ::testing::NotNull; using ::testing::Return; +using ::testing::ReturnRef; using ::testing::SetArgumentPointee; using ::testing::StrictMock; using ::testing::NiceMock; @@ -79,7 +80,6 @@ class BufferedResourceLoaderTest : public testing::Test { loader_ = new BufferedResourceLoader(&bridge_factory_, gurl_, first_position_, last_position_); - EXPECT_EQ(gurl_.spec(), loader_->GetURLForDebugging().spec()); } void SetLoaderBuffer(size_t forward_capacity, size_t backward_capacity) { @@ -526,6 +526,7 @@ class MockBufferedResourceLoader : public BufferedResourceLoader { MOCK_METHOD0(instance_size, int64()); MOCK_METHOD0(partial_response, bool()); MOCK_METHOD0(network_activity, bool()); + MOCK_METHOD0(url, const GURL&()); MOCK_METHOD0(GetBufferedFirstBytePosition, int64()); MOCK_METHOD0(GetBufferedLastBytePosition, int64()); @@ -539,15 +540,9 @@ class MockBufferedResourceLoader : public BufferedResourceLoader { // CreateResourceLoader() method. class MockBufferedDataSource : public BufferedDataSource { public: - // Static methods for creating this class. - static media::FilterFactory* CreateFactory( - MessageLoop* message_loop, - MediaResourceLoaderBridgeFactory* bridge_factory) { - return new media::FilterFactoryImpl2< - MockBufferedDataSource, - MessageLoop*, - MediaResourceLoaderBridgeFactory*>(message_loop, - bridge_factory); + MockBufferedDataSource( + MessageLoop* message_loop, MediaResourceLoaderBridgeFactory* factory) + : BufferedDataSource(message_loop, factory) { } virtual base::TimeDelta GetTimeoutMilliseconds() { @@ -558,18 +553,7 @@ class MockBufferedDataSource : public BufferedDataSource { MOCK_METHOD2(CreateResourceLoader, BufferedResourceLoader*( int64 first_position, int64 last_position)); - protected: - MockBufferedDataSource( - MessageLoop* message_loop, MediaResourceLoaderBridgeFactory* factory) - : BufferedDataSource(message_loop, factory) { - } - private: - friend class media::FilterFactoryImpl2< - MockBufferedDataSource, - MessageLoop*, - MediaResourceLoaderBridgeFactory*>; - DISALLOW_COPY_AND_ASSIGN(MockBufferedDataSource); }; @@ -579,8 +563,6 @@ class BufferedDataSourceTest : public testing::Test { message_loop_ = MessageLoop::current(); bridge_factory_.reset( new StrictMock()); - factory_ = MockBufferedDataSource::CreateFactory(message_loop_, - bridge_factory_.get()); // Prepare test data. for (size_t i = 0; i < sizeof(data_); ++i) { @@ -619,14 +601,15 @@ class BufferedDataSourceTest : public testing::Test { url_format.SetAsString(media::MediaFormat::kMimeType, media::mime_type::kURL); url_format.SetAsString(media::MediaFormat::kURL, url); - data_source_ = factory_->Create(url_format); + data_source_ = new MockBufferedDataSource(MessageLoop::current(), + bridge_factory_.get()); CHECK(data_source_); // There is no need to provide a message loop to data source. data_source_->set_host(&host_); - scoped_refptr > first_loader = - new NiceMock(); + scoped_refptr > first_loader( + new NiceMock()); // Creates the mock loader to be injected. loader_ = first_loader; @@ -641,6 +624,8 @@ class BufferedDataSourceTest : public testing::Test { // to be created. if (partial_response && (error == net::ERR_INVALID_RESPONSE)) { // Verify that the initial loader is stopped. + EXPECT_CALL(*loader_, url()) + .WillRepeatedly(ReturnRef(gurl_)); EXPECT_CALL(*loader_, Stop()); // Replace loader_ with a new instance. @@ -655,11 +640,18 @@ class BufferedDataSourceTest : public testing::Test { } } + // Attach a static function that deletes the memory referred by the + // "callback" parameter. + ON_CALL(*loader_, Read(_, _, _ , _)) + .WillByDefault(DeleteArg<3>()); + StrictMock callback; - EXPECT_CALL(*loader_, instance_size()) - .WillRepeatedly(Return(instance_size)); - EXPECT_CALL(*loader_, partial_response()) - .WillRepeatedly(Return(partial_response)); + ON_CALL(*loader_, instance_size()) + .WillByDefault(Return(instance_size)); + ON_CALL(*loader_, partial_response()) + .WillByDefault(Return(partial_response)); + ON_CALL(*loader_, url()) + .WillByDefault(ReturnRef(gurl_)); if (initialized_ok) { // Expected loaded or not. EXPECT_CALL(host_, SetLoaded(loaded)); @@ -757,6 +749,27 @@ class BufferedDataSourceTest : public testing::Test { memcmp(buffer_, data_ + static_cast(position), read_size)); } + void ReadDataSourceHang(int64 position, int size) { + EXPECT_TRUE(loader_); + + // Expect a call to read, but the call never returns. + EXPECT_CALL(*loader_, Read(position, size, NotNull(), NotNull())); + data_source_->Read( + position, size, buffer_, + NewCallback(this, &BufferedDataSourceTest::ReadCallback)); + message_loop_->RunAllPending(); + + // Now expect the read to return after aborting the data source. + EXPECT_CALL(*this, ReadCallback(_)); + EXPECT_CALL(*loader_, Stop()); + data_source_->Abort(); + message_loop_->RunAllPending(); + + // The loader has now been stopped. Set this to null so that when the + // DataSource is stopped, it does not expect a call to stop the loader. + loader_ = NULL; + } + void ReadDataSourceMiss(int64 position, int size) { EXPECT_TRUE(loader_); @@ -880,7 +893,6 @@ class BufferedDataSourceTest : public testing::Test { bridge_factory_; scoped_refptr > loader_; scoped_refptr data_source_; - scoped_refptr factory_; StrictMock host_; GURL gurl_; @@ -946,6 +958,12 @@ TEST_F(BufferedDataSourceTest, ReadCacheMiss) { StopDataSource(); } +TEST_F(BufferedDataSourceTest, ReadHang) { + InitializeDataSource(kHttpUrl, net::OK, true, 25, LOADING); + ReadDataSourceHang(10, 10); + StopDataSource(); +} + TEST_F(BufferedDataSourceTest, ReadFailed) { InitializeDataSource(kHttpUrl, net::OK, true, 1024, LOADING); ReadDataSourceHit(10, 10, 10); diff --git a/webkit/glue/media/simple_data_source.cc b/webkit/glue/media/simple_data_source.cc index 0b09edf..291928e 100644 --- a/webkit/glue/media/simple_data_source.cc +++ b/webkit/glue/media/simple_data_source.cc @@ -28,25 +28,13 @@ bool IsDataProtocol(const GURL& url) { namespace webkit_glue { -bool SimpleDataSource::IsMediaFormatSupported( - const media::MediaFormat& media_format) { - std::string mime_type; - std::string url; - if (media_format.GetAsString(media::MediaFormat::kMimeType, &mime_type) && - media_format.GetAsString(media::MediaFormat::kURL, &url)) { - GURL gurl(url); - if (IsProtocolSupportedForMedia(gurl)) - return true; - } - return false; -} - SimpleDataSource::SimpleDataSource( MessageLoop* render_loop, webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory) : render_loop_(render_loop), bridge_factory_(bridge_factory), size_(-1), + single_origin_(true), state_(UNINITIALIZED) { DCHECK(render_loop); } @@ -125,7 +113,9 @@ bool SimpleDataSource::OnReceivedRedirect( const webkit_glue::ResourceResponseInfo& info, bool* has_new_first_party_for_cookies, GURL* new_first_party_for_cookies) { - SetURL(new_url); + DCHECK(MessageLoop::current() == render_loop_); + single_origin_ = url_.GetOrigin() == new_url.GetOrigin(); + // TODO(wtc): should we return a new first party for cookies URL? *has_new_first_party_for_cookies = false; return true; @@ -134,22 +124,24 @@ bool SimpleDataSource::OnReceivedRedirect( void SimpleDataSource::OnReceivedResponse( const webkit_glue::ResourceResponseInfo& info, bool content_filtered) { + DCHECK(MessageLoop::current() == render_loop_); size_ = info.content_length; } void SimpleDataSource::OnReceivedData(const char* data, int len) { + DCHECK(MessageLoop::current() == render_loop_); data_.append(data, len); } void SimpleDataSource::OnCompletedRequest(const URLRequestStatus& status, const std::string& security_info, const base::Time& completion_time) { + DCHECK(MessageLoop::current() == render_loop_); AutoLock auto_lock(lock_); // It's possible this gets called after Stop(), in which case |host_| is no // longer valid. - if (state_ == STOPPED) { + if (state_ == STOPPED) return; - } // Otherwise we should be initializing and have created a bridge. DCHECK_EQ(state_, INITIALIZING); @@ -158,16 +150,21 @@ void SimpleDataSource::OnCompletedRequest(const URLRequestStatus& status, // If we don't get a content length or the request has failed, report it // as a network error. - DCHECK(size_ == -1 || static_cast(size_) == data_.length()); - if (size_ == -1) { + if (size_ == -1) size_ = data_.length(); - } + DCHECK(static_cast(size_) == data_.length()); DoneInitialization_Locked(status.is_success()); } -GURL SimpleDataSource::GetURLForDebugging() const { - return url_; +bool SimpleDataSource::HasSingleOrigin() { + DCHECK(MessageLoop::current() == render_loop_); + return single_origin_; +} + +void SimpleDataSource::Abort() { + DCHECK(MessageLoop::current() == render_loop_); + NOTIMPLEMENTED(); } void SimpleDataSource::SetURL(const GURL& url) { @@ -179,8 +176,8 @@ void SimpleDataSource::SetURL(const GURL& url) { } void SimpleDataSource::StartTask() { - AutoLock auto_lock(lock_); DCHECK(MessageLoop::current() == render_loop_); + AutoLock auto_lock(lock_); // We may have stopped. if (state_ == STOPPED) @@ -205,6 +202,7 @@ void SimpleDataSource::StartTask() { } void SimpleDataSource::CancelTask() { + DCHECK(MessageLoop::current() == render_loop_); AutoLock auto_lock(lock_); DCHECK_EQ(state_, STOPPED); diff --git a/webkit/glue/media/simple_data_source.h b/webkit/glue/media/simple_data_source.h index d649c0d..ff1e247 100644 --- a/webkit/glue/media/simple_data_source.h +++ b/webkit/glue/media/simple_data_source.h @@ -12,31 +12,22 @@ #include "base/message_loop.h" #include "base/scoped_ptr.h" -#include "media/base/factory.h" #include "media/base/filters.h" #include "webkit/glue/media/media_resource_loader_bridge_factory.h" +#include "webkit/glue/media/web_data_source.h" class MessageLoop; class WebMediaPlayerDelegateImpl; namespace webkit_glue { -class SimpleDataSource : public media::DataSource, +class SimpleDataSource : public WebDataSource, public webkit_glue::ResourceLoaderBridge::Peer { public: - static media::FilterFactory* CreateFactory( - MessageLoop* message_loop, - webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory) { - return new media::FilterFactoryImpl2< - SimpleDataSource, - MessageLoop*, - webkit_glue::MediaResourceLoaderBridgeFactory*>(message_loop, - bridge_factory); - } - - // media::FilterFactoryImpl2 implementation. - static bool IsMediaFormatSupported( - const media::MediaFormat& media_format); + SimpleDataSource( + MessageLoop* render_loop, + webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory); + virtual ~SimpleDataSource(); // MediaFilter implementation. virtual void Stop(media::FilterCallback* callback); @@ -65,18 +56,12 @@ class SimpleDataSource : public media::DataSource, virtual void OnCompletedRequest(const URLRequestStatus& status, const std::string& security_info, const base::Time& completion_time); - virtual GURL GetURLForDebugging() const; - private: - friend class media::FilterFactoryImpl2< - SimpleDataSource, - MessageLoop*, - webkit_glue::MediaResourceLoaderBridgeFactory*>; - SimpleDataSource( - MessageLoop* render_loop, - webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory); - virtual ~SimpleDataSource(); + // webkit_glue::WebDataSource implementation. + virtual bool HasSingleOrigin(); + virtual void Abort(); + private: // Updates |url_| and |media_format_| with the given URL. void SetURL(const GURL& url); @@ -102,6 +87,7 @@ class SimpleDataSource : public media::DataSource, GURL url_; std::string data_; int64 size_; + bool single_origin_; // Simple state tracking variable. enum State { diff --git a/webkit/glue/media/simple_data_source_unittest.cc b/webkit/glue/media/simple_data_source_unittest.cc index 50c8910..537798f 100644 --- a/webkit/glue/media/simple_data_source_unittest.cc +++ b/webkit/glue/media/simple_data_source_unittest.cc @@ -42,8 +42,6 @@ class SimpleDataSourceTest : public testing::Test { bridge_factory_.reset( new NiceMock()); bridge_.reset(new NiceMock()); - factory_ = SimpleDataSource::CreateFactory(MessageLoop::current(), - bridge_factory_.get()); for (int i = 0; i < kDataSize; ++i) { data_[i] = i; @@ -58,11 +56,8 @@ class SimpleDataSourceTest : public testing::Test { } void InitializeDataSource(const char* url) { - media::MediaFormat url_format; - url_format.SetAsString(media::MediaFormat::kMimeType, - media::mime_type::kURL); - url_format.SetAsString(media::MediaFormat::kURL, url); - data_source_ = factory_->Create(url_format); + data_source_ = new SimpleDataSource(MessageLoop::current(), + bridge_factory_.get()); CHECK(data_source_); // There is no need to provide a message loop to data source. @@ -167,7 +162,6 @@ class SimpleDataSourceTest : public testing::Test { scoped_ptr message_loop_; scoped_ptr > bridge_factory_; scoped_ptr > bridge_; - scoped_refptr factory_; scoped_refptr data_source_; StrictMock host_; StrictMock callback_; @@ -195,11 +189,9 @@ TEST_F(SimpleDataSourceTest, InitializeFile) { } TEST_F(SimpleDataSourceTest, InitializeData) { - media::MediaFormat url_format; - url_format.SetAsString(media::MediaFormat::kMimeType, - media::mime_type::kURL); - url_format.SetAsString(media::MediaFormat::kURL, kDataUrl); - data_source_ = factory_->Create(url_format); + data_source_ = new SimpleDataSource(MessageLoop::current(), + bridge_factory_.get()); + EXPECT_TRUE(data_source_->IsUrlSupported(kDataUrl)); CHECK(data_source_); // There is no need to provide a message loop to data source. @@ -217,15 +209,6 @@ TEST_F(SimpleDataSourceTest, InitializeData) { DestroyDataSource(); } -TEST_F(SimpleDataSourceTest, InitializeInvalid) { - media::MediaFormat url_format; - url_format.SetAsString(media::MediaFormat::kMimeType, - media::mime_type::kURL); - url_format.SetAsString(media::MediaFormat::kURL, kInvalidUrl); - data_source_ = factory_->Create(url_format); - EXPECT_FALSE(data_source_); -} - TEST_F(SimpleDataSourceTest, RequestFailed) { InitializeDataSource(kHttpUrl); RequestFailed(); diff --git a/webkit/glue/media/video_renderer_impl.cc b/webkit/glue/media/video_renderer_impl.cc index 16c9ef6..3bbd626 100644 --- a/webkit/glue/media/video_renderer_impl.cc +++ b/webkit/glue/media/video_renderer_impl.cc @@ -10,33 +10,13 @@ namespace webkit_glue { -VideoRendererImpl::VideoRendererImpl(WebMediaPlayerImpl::Proxy* proxy, - bool pts_logging) - : proxy_(proxy), - last_converted_frame_(NULL), +VideoRendererImpl::VideoRendererImpl(bool pts_logging) + : last_converted_frame_(NULL), pts_logging_(pts_logging) { - // TODO(hclam): decide whether to do the following line in this thread or - // in the render thread. - proxy_->SetVideoRenderer(this); } VideoRendererImpl::~VideoRendererImpl() {} -// static -media::FilterFactory* VideoRendererImpl::CreateFactory( - WebMediaPlayerImpl::Proxy* proxy, - bool pts_logging) { - return new media::FilterFactoryImpl2(proxy, pts_logging); -} - -// static -bool VideoRendererImpl::IsMediaFormatSupported( - const media::MediaFormat& media_format) { - return ParseMediaFormat(media_format, NULL, NULL, NULL, NULL); -} - bool VideoRendererImpl::OnInitialize(media::VideoDecoder* decoder) { video_size_.SetSize(width(), height()); bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width(), height()); @@ -60,6 +40,11 @@ void VideoRendererImpl::OnFrameAvailable() { proxy_->Repaint(); } +void VideoRendererImpl::SetWebMediaPlayerImplProxy( + WebMediaPlayerImpl::Proxy* proxy) { + proxy_ = proxy; +} + void VideoRendererImpl::SetRect(const gfx::Rect& rect) { } diff --git a/webkit/glue/media/video_renderer_impl.h b/webkit/glue/media/video_renderer_impl.h index 38e8851..34c67d3 100644 --- a/webkit/glue/media/video_renderer_impl.h +++ b/webkit/glue/media/video_renderer_impl.h @@ -24,39 +24,16 @@ namespace webkit_glue { class VideoRendererImpl : public WebVideoRenderer { public: + explicit VideoRendererImpl(bool pts_logging); + virtual ~VideoRendererImpl(); + // WebVideoRenderer implementation. + virtual void SetWebMediaPlayerImplProxy(WebMediaPlayerImpl::Proxy* proxy); virtual void SetRect(const gfx::Rect& rect); virtual void Paint(skia::PlatformCanvas* canvas, const gfx::Rect& dest_rect); virtual void GetCurrentFrame(scoped_refptr* frame_out); virtual void PutCurrentFrame(scoped_refptr frame); - // Static method for creating factory for this object. - static media::FilterFactory* CreateFactory(WebMediaPlayerImpl::Proxy* proxy, - bool pts_logging); - - // FilterFactoryImpl2 implementation. - static bool IsMediaFormatSupported(const media::MediaFormat& media_format); - - // TODO(scherkus): remove this mega-hack, see http://crbug.com/28207 - class FactoryFactory : public webkit_glue::WebVideoRendererFactoryFactory { - public: - FactoryFactory(bool pts_logging) - : webkit_glue::WebVideoRendererFactoryFactory(), - pts_logging_(pts_logging) { - } - - virtual media::FilterFactory* CreateFactory( - webkit_glue::WebMediaPlayerImpl::Proxy* proxy) { - return VideoRendererImpl::CreateFactory(proxy, pts_logging_); - } - - private: - // Whether we're logging video presentation timestamps (PTS). - bool pts_logging_; - - DISALLOW_COPY_AND_ASSIGN(FactoryFactory); - }; - protected: // Method called by VideoRendererBase during initialization. virtual bool OnInitialize(media::VideoDecoder* decoder); @@ -68,13 +45,6 @@ class VideoRendererImpl : public WebVideoRenderer { virtual void OnFrameAvailable(); private: - // Only the filter factories can create instances. - friend class media::FilterFactoryImpl2; - VideoRendererImpl(WebMediaPlayerImpl::Proxy* proxy, bool pts_logging); - virtual ~VideoRendererImpl(); - // Determine the conditions to perform fast paint. Returns true if we can do // fast paint otherwise false. bool CanFastPaint(skia::PlatformCanvas* canvas, const gfx::Rect& dest_rect); diff --git a/webkit/glue/media/web_data_source.cc b/webkit/glue/media/web_data_source.cc new file mode 100644 index 0000000..a46d594 --- /dev/null +++ b/webkit/glue/media/web_data_source.cc @@ -0,0 +1,17 @@ +// Copyright (c) 2010 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 "media/base/filters.h" +#include "webkit/glue/media/web_data_source.h" + +namespace webkit_glue { + +WebDataSource::WebDataSource() + : media::DataSource() { +} + +WebDataSource::~WebDataSource() { +} + +} // namespace webkit_glue diff --git a/webkit/glue/media/web_data_source.h b/webkit/glue/media/web_data_source.h new file mode 100644 index 0000000..956ac9e --- /dev/null +++ b/webkit/glue/media/web_data_source.h @@ -0,0 +1,36 @@ +// Copyright (c) 2010 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 WEBKIT_GLUE_MEDIA_WEB_DATA_SOURCE_H_ +#define WEBKIT_GLUE_MEDIA_WEB_DATA_SOURCE_H_ + +#include "media/base/filters.h" + +namespace webkit_glue { + +// An interface that allows WebMediaPlayerImpl::Proxy to communicate with the +// DataSource in the pipeline. +class WebDataSource : public media::DataSource { + public: + WebDataSource(); + virtual ~WebDataSource(); + + // Returns true if the media resource has a single origin, false otherwise. + // + // Method called on the render thread. + virtual bool HasSingleOrigin() = 0; + + // This method is used to unblock any read calls that would cause the + // media pipeline to stall. + // + // Method called on the render thread. + virtual void Abort() = 0; + + private: + DISALLOW_COPY_AND_ASSIGN(WebDataSource); +}; + +} // namespace webkit_glue + +#endif // WEBKIT_GLUE_MEDIA_WEB_DATA_SOURCE_H_ diff --git a/webkit/glue/media/web_video_renderer.h b/webkit/glue/media/web_video_renderer.h index d8b47ad..efd3109 100644 --- a/webkit/glue/media/web_video_renderer.h +++ b/webkit/glue/media/web_video_renderer.h @@ -7,6 +7,7 @@ #include "media/base/video_frame.h" #include "media/filters/video_renderer_base.h" +#include "webkit/glue/webmediaplayer_impl.h" namespace webkit_glue { @@ -16,6 +17,9 @@ class WebVideoRenderer : public media::VideoRendererBase { WebVideoRenderer() : media::VideoRendererBase() {} virtual ~WebVideoRenderer() {} + // Saves the reference to WebMediaPlayerImpl::Proxy. + virtual void SetWebMediaPlayerImplProxy(WebMediaPlayerImpl::Proxy* proxy) = 0; + // This method is called with the same rect as the Paint() method and could // be used by future implementations to implement an improved color space + // scale code on a separate thread. Since we always do the stretch on the diff --git a/webkit/glue/multipart_response_delegate.cc b/webkit/glue/multipart_response_delegate.cc index 4839a91..99a9e4c 100644 --- a/webkit/glue/multipart_response_delegate.cc +++ b/webkit/glue/multipart_response_delegate.cc @@ -342,12 +342,6 @@ bool MultipartResponseDelegate::ReadContentRanges( return false; } - size_t byte_range_lower_bound_characters = - byte_range_lower_bound_end_offset - byte_range_lower_bound_start_offset; - std::string byte_range_lower_bound = - content_range.substr(byte_range_lower_bound_start_offset, - byte_range_lower_bound_characters); - size_t byte_range_upper_bound_start_offset = byte_range_lower_bound_end_offset + 1; @@ -357,16 +351,16 @@ bool MultipartResponseDelegate::ReadContentRanges( return false; } - size_t byte_range_upper_bound_characters = - byte_range_upper_bound_end_offset - byte_range_upper_bound_start_offset; - - std::string byte_range_upper_bound = - content_range.substr(byte_range_upper_bound_start_offset, - byte_range_upper_bound_characters); - - if (!base::StringToInt(byte_range_lower_bound, content_range_lower_bound)) + if (!base::StringToInt( + content_range.begin() + byte_range_lower_bound_start_offset, + content_range.begin() + byte_range_lower_bound_end_offset, + content_range_lower_bound)) return false; - if (!base::StringToInt(byte_range_upper_bound, content_range_upper_bound)) + + if (!base::StringToInt( + content_range.begin() + byte_range_upper_bound_start_offset, + content_range.begin() + byte_range_upper_bound_end_offset, + content_range_upper_bound)) return false; return true; } diff --git a/webkit/glue/plugins/DEPS b/webkit/glue/plugins/DEPS index 4ac8845..cfee702 100644 --- a/webkit/glue/plugins/DEPS +++ b/webkit/glue/plugins/DEPS @@ -1,4 +1,4 @@ include_rules = [ + "+ppapi", "+printing", - "+third_party/ppapi/c", ] diff --git a/webkit/glue/plugins/carbon_plugin_window_tracker_mac.cc b/webkit/glue/plugins/carbon_plugin_window_tracker_mac.cc index 6131b45..c4ae72d 100644 --- a/webkit/glue/plugins/carbon_plugin_window_tracker_mac.cc +++ b/webkit/glue/plugins/carbon_plugin_window_tracker_mac.cc @@ -14,7 +14,7 @@ CarbonPluginWindowTracker* CarbonPluginWindowTracker::SharedInstance() { } WindowRef CarbonPluginWindowTracker::CreateDummyWindowForDelegate( - WebPluginDelegateImpl* delegate) { + OpaquePluginRef delegate) { // The real size will be set by the plugin instance, once that size is known. Rect window_bounds = { 0, 0, 100, 100 }; WindowRef new_ref = NULL; @@ -28,7 +28,7 @@ WindowRef CarbonPluginWindowTracker::CreateDummyWindowForDelegate( return new_ref; } -WebPluginDelegateImpl* CarbonPluginWindowTracker::GetDelegateForDummyWindow( +OpaquePluginRef CarbonPluginWindowTracker::GetDelegateForDummyWindow( WindowRef window) const { WindowToDelegateMap::const_iterator i = window_to_delegate_map_.find(window); if (i != window_to_delegate_map_.end()) @@ -37,7 +37,7 @@ WebPluginDelegateImpl* CarbonPluginWindowTracker::GetDelegateForDummyWindow( } WindowRef CarbonPluginWindowTracker::GetDummyWindowForDelegate( - WebPluginDelegateImpl* delegate) const { + OpaquePluginRef delegate) const { DelegateToWindowMap::const_iterator i = delegate_to_window_map_.find(delegate); if (i != delegate_to_window_map_.end()) @@ -46,7 +46,7 @@ WindowRef CarbonPluginWindowTracker::GetDummyWindowForDelegate( } void CarbonPluginWindowTracker::DestroyDummyWindowForDelegate( - WebPluginDelegateImpl* delegate, WindowRef window) { + OpaquePluginRef delegate, WindowRef window) { DCHECK(GetDelegateForDummyWindow(window) == delegate); window_to_delegate_map_.erase(window); delegate_to_window_map_.erase(delegate); diff --git a/webkit/glue/plugins/carbon_plugin_window_tracker_mac.h b/webkit/glue/plugins/carbon_plugin_window_tracker_mac.h index 3e6ef2d..90fc318 100644 --- a/webkit/glue/plugins/carbon_plugin_window_tracker_mac.h +++ b/webkit/glue/plugins/carbon_plugin_window_tracker_mac.h @@ -10,7 +10,9 @@ #include "base/basictypes.h" -class WebPluginDelegateImpl; +// This is really a WebPluginDelegateImpl, but that class is private to the +// framework, and these functions are called from a dylib. +typedef void* OpaquePluginRef; // Creates and tracks the invisible windows that are necessary for // Carbon-event-model plugins. @@ -27,21 +29,21 @@ class __attribute__((visibility("default"))) CarbonPluginWindowTracker { static CarbonPluginWindowTracker* SharedInstance(); // Creates a new carbon window associated with |delegate|. - WindowRef CreateDummyWindowForDelegate(WebPluginDelegateImpl* delegate); + WindowRef CreateDummyWindowForDelegate(OpaquePluginRef delegate); // Returns the WebPluginDelegate associated with the given dummy window. - WebPluginDelegateImpl* GetDelegateForDummyWindow(WindowRef window) const; + OpaquePluginRef GetDelegateForDummyWindow(WindowRef window) const; // Returns the dummy window associated with |delegate|. - WindowRef GetDummyWindowForDelegate(WebPluginDelegateImpl* delegate) const; + WindowRef GetDummyWindowForDelegate(OpaquePluginRef delegate) const; // Destroys the dummy window for |delegate|. - void DestroyDummyWindowForDelegate(WebPluginDelegateImpl* delegate, + void DestroyDummyWindowForDelegate(OpaquePluginRef delegate, WindowRef window); private: - typedef std::map WindowToDelegateMap; - typedef std::map DelegateToWindowMap; + typedef std::map WindowToDelegateMap; + typedef std::map DelegateToWindowMap; WindowToDelegateMap window_to_delegate_map_; DelegateToWindowMap delegate_to_window_map_; diff --git a/webkit/glue/plugins/npapi_extension_thunk.cc b/webkit/glue/plugins/npapi_extension_thunk.cc index 4779535..05a9c5d 100644 --- a/webkit/glue/plugins/npapi_extension_thunk.cc +++ b/webkit/glue/plugins/npapi_extension_thunk.cc @@ -28,7 +28,7 @@ static NPAPI::PluginInstance* FindInstance(NPP id) { static NPError Device2DQueryCapability(NPP id, int32_t capability, int32_t* value) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); if (plugin) { plugin->webplugin()->delegate()->Device2DQueryCapability(capability, value); return NPERR_NO_ERROR; @@ -40,7 +40,7 @@ static NPError Device2DQueryCapability(NPP id, int32_t capability, static NPError Device2DQueryConfig(NPP id, const NPDeviceConfig* request, NPDeviceConfig* obtain) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); if (plugin) { return plugin->webplugin()->delegate()->Device2DQueryConfig( static_cast(request), @@ -52,7 +52,7 @@ static NPError Device2DQueryConfig(NPP id, static NPError Device2DInitializeContext(NPP id, const NPDeviceConfig* config, NPDeviceContext* context) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); if (plugin) { return plugin->webplugin()->delegate()->Device2DInitializeContext( static_cast(config), @@ -65,7 +65,7 @@ static NPError Device2DSetStateContext(NPP id, NPDeviceContext* context, int32_t state, intptr_t value) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); if (plugin) { return plugin->webplugin()->delegate()->Device2DSetStateContext( static_cast(context), state, value); @@ -77,7 +77,7 @@ static NPError Device2DGetStateContext(NPP id, NPDeviceContext* context, int32_t state, intptr_t* value) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); if (plugin) { return plugin->webplugin()->delegate()->Device2DGetStateContext( static_cast(context), state, value); @@ -89,7 +89,7 @@ static NPError Device2DFlushContext(NPP id, NPDeviceContext* context, NPDeviceFlushContextCallbackPtr callback, void* user_data) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); if (plugin) { NPError err = plugin->webplugin()->delegate()->Device2DFlushContext( id, static_cast(context), callback, user_data); @@ -109,7 +109,7 @@ static NPError Device2DFlushContext(NPP id, static NPError Device2DDestroyContext(NPP id, NPDeviceContext* context) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); if (plugin) { return plugin->webplugin()->delegate()->Device2DDestroyContext( static_cast(context)); @@ -141,7 +141,7 @@ static NPError Device2DMapBuffer(NPP id, static NPError Device3DQueryCapability(NPP id, int32_t capability, int32_t* value) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); if (plugin) { plugin->webplugin()->delegate()->Device3DQueryCapability(capability, value); return NPERR_NO_ERROR; @@ -153,7 +153,7 @@ static NPError Device3DQueryCapability(NPP id, int32_t capability, static NPError Device3DQueryConfig(NPP id, const NPDeviceConfig* request, NPDeviceConfig* obtain) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); if (plugin) { return plugin->webplugin()->delegate()->Device3DQueryConfig( static_cast(request), @@ -165,7 +165,7 @@ static NPError Device3DQueryConfig(NPP id, static NPError Device3DInitializeContext(NPP id, const NPDeviceConfig* config, NPDeviceContext* context) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); if (plugin) { return plugin->webplugin()->delegate()->Device3DInitializeContext( static_cast(config), @@ -178,7 +178,7 @@ static NPError Device3DSetStateContext(NPP id, NPDeviceContext* context, int32_t state, intptr_t value) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); if (plugin) { return plugin->webplugin()->delegate()->Device3DSetStateContext( static_cast(context), state, value); @@ -190,7 +190,7 @@ static NPError Device3DGetStateContext(NPP id, NPDeviceContext* context, int32_t state, intptr_t* value) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); if (plugin) { return plugin->webplugin()->delegate()->Device3DGetStateContext( static_cast(context), state, value); @@ -202,7 +202,7 @@ static NPError Device3DFlushContext(NPP id, NPDeviceContext* context, NPDeviceFlushContextCallbackPtr callback, void* user_data) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); if (plugin) { return plugin->webplugin()->delegate()->Device3DFlushContext( id, static_cast(context), callback, user_data); @@ -212,7 +212,7 @@ static NPError Device3DFlushContext(NPP id, static NPError Device3DDestroyContext(NPP id, NPDeviceContext* context) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); if (plugin) { return plugin->webplugin()->delegate()->Device3DDestroyContext( static_cast(context)); @@ -224,7 +224,7 @@ static NPError Device3DCreateBuffer(NPP id, NPDeviceContext* context, size_t size, int32_t* buffer_id) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); if (plugin) { return plugin->webplugin()->delegate()->Device3DCreateBuffer( static_cast(context), size, buffer_id); @@ -235,7 +235,7 @@ static NPError Device3DCreateBuffer(NPP id, static NPError Device3DDestroyBuffer(NPP id, NPDeviceContext* context, int32_t buffer_id) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); if (plugin) { return plugin->webplugin()->delegate()->Device3DDestroyBuffer( static_cast(context), buffer_id); @@ -247,7 +247,7 @@ static NPError Device3DMapBuffer(NPP id, NPDeviceContext* context, int32_t buffer_id, NPDeviceBuffer* buffer) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); if (plugin) { return plugin->webplugin()->delegate()->Device3DMapBuffer( static_cast(context), buffer_id, buffer); @@ -258,7 +258,7 @@ static NPError Device3DMapBuffer(NPP id, // Experimental 3D device API -------------------------------------------------- static NPError Device3DGetNumConfigs(NPP id, int32_t* num_configs) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); if (plugin) { return plugin->webplugin()->delegate()->Device3DGetNumConfigs(num_configs); } @@ -268,7 +268,7 @@ static NPError Device3DGetNumConfigs(NPP id, int32_t* num_configs) { static NPError Device3DGetConfigAttribs(NPP id, int32_t config, int32_t* attrib_list) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); if (plugin) { return plugin->webplugin()->delegate()->Device3DGetConfigAttribs( config, @@ -281,7 +281,7 @@ static NPError Device3DCreateContext(NPP id, int32_t config, const int32_t* attrib_list, NPDeviceContext** context) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); if (plugin) { return plugin->webplugin()->delegate()->Device3DCreateContext( config, @@ -299,7 +299,7 @@ static NPError Device3DSynchronizeContext( int32_t* output_attrib_list, NPDeviceSynchronizeContextCallbackPtr callback, void* callback_data) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); if (plugin) { return plugin->webplugin()->delegate()->Device3DSynchronizeContext( id, @@ -319,7 +319,7 @@ static NPError Device3DRegisterCallback( int32_t callback_type, NPDeviceGenericCallbackPtr callback, void* callback_data) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); if (plugin) { return plugin->webplugin()->delegate()->Device3DRegisterCallback( id, @@ -335,7 +335,7 @@ static NPError Device3DRegisterCallback( static NPError DeviceAudioQueryCapability(NPP id, int32_t capability, int32_t* value) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); if (plugin) { plugin->webplugin()->delegate()->DeviceAudioQueryCapability(capability, value); @@ -348,7 +348,7 @@ static NPError DeviceAudioQueryCapability(NPP id, int32_t capability, static NPError DeviceAudioQueryConfig(NPP id, const NPDeviceConfig* request, NPDeviceConfig* obtain) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); if (plugin) { return plugin->webplugin()->delegate()->DeviceAudioQueryConfig( static_cast(request), @@ -360,7 +360,7 @@ static NPError DeviceAudioQueryConfig(NPP id, static NPError DeviceAudioInitializeContext(NPP id, const NPDeviceConfig* config, NPDeviceContext* context) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); if (plugin) { return plugin->webplugin()->delegate()->DeviceAudioInitializeContext( static_cast(config), @@ -373,7 +373,7 @@ static NPError DeviceAudioSetStateContext(NPP id, NPDeviceContext* context, int32_t state, intptr_t value) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); if (plugin) { return plugin->webplugin()->delegate()->DeviceAudioSetStateContext( static_cast(context), state, value); @@ -385,7 +385,7 @@ static NPError DeviceAudioGetStateContext(NPP id, NPDeviceContext* context, int32_t state, intptr_t* value) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); return plugin->webplugin()->delegate()->DeviceAudioGetStateContext( static_cast(context), state, value); } @@ -394,14 +394,14 @@ static NPError DeviceAudioFlushContext(NPP id, NPDeviceContext* context, NPDeviceFlushContextCallbackPtr callback, void* user_data) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); return plugin->webplugin()->delegate()->DeviceAudioFlushContext( id, static_cast(context), callback, user_data); } static NPError DeviceAudioDestroyContext(NPP id, NPDeviceContext* context) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); return plugin->webplugin()->delegate()->DeviceAudioDestroyContext( static_cast(context)); } @@ -477,7 +477,7 @@ static NPError ChooseFile(NPP id, NPChooseFileMode mode, NPChooseFileCallback callback, void* user_data) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); if (!plugin) return NPERR_GENERIC_ERROR; @@ -490,7 +490,7 @@ static NPError ChooseFile(NPP id, } static void NumberOfFindResultsChanged(NPP id, int total, bool final_result) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); if (plugin) { plugin->webplugin()->delegate()->NumberOfFindResultsChanged( total, final_result); @@ -498,13 +498,13 @@ static void NumberOfFindResultsChanged(NPP id, int total, bool final_result) { } static void SelectedFindResultChanged(NPP id, int index) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); if (plugin) plugin->webplugin()->delegate()->SelectedFindResultChanged(index); } static NPWidgetExtensions* GetWidgetExtensions(NPP id) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); if (!plugin) return NULL; @@ -512,7 +512,7 @@ static NPWidgetExtensions* GetWidgetExtensions(NPP id) { } static NPError NPSetCursor(NPP id, NPCursorType type) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); if (!plugin) return NPERR_GENERIC_ERROR; @@ -521,7 +521,7 @@ static NPError NPSetCursor(NPP id, NPCursorType type) { } static NPFontExtensions* GetFontExtensions(NPP id) { - scoped_refptr plugin = FindInstance(id); + scoped_refptr plugin(FindInstance(id)); if (!plugin) return NULL; diff --git a/webkit/glue/plugins/pepper_audio.cc b/webkit/glue/plugins/pepper_audio.cc index 5a76670..d98ef1b 100644 --- a/webkit/glue/plugins/pepper_audio.cc +++ b/webkit/glue/plugins/pepper_audio.cc @@ -5,8 +5,9 @@ #include "webkit/glue/plugins/pepper_audio.h" #include "base/logging.h" -#include "third_party/ppapi/c/dev/ppb_audio_dev.h" -#include "third_party/ppapi/c/dev/ppb_audio_trusted_dev.h" +#include "ppapi/c/dev/ppb_audio_dev.h" +#include "ppapi/c/dev/ppb_audio_trusted_dev.h" +#include "webkit/glue/plugins/pepper_common.h" namespace pepper { @@ -50,9 +51,9 @@ uint32_t RecommendSampleFrameCount(uint32_t requested_sample_frame_count) { return requested_sample_frame_count; } -bool IsAudioConfig(PP_Resource resource) { +PP_Bool IsAudioConfig(PP_Resource resource) { scoped_refptr config = Resource::GetAs(resource); - return !!config; + return BoolToPPBool(!!config); } PP_AudioSampleRate_Dev GetSampleRate(PP_Resource config_id) { @@ -87,9 +88,9 @@ PP_Resource Create(PP_Instance instance_id, PP_Resource config_id, return audio->GetReference(); } -bool IsAudio(PP_Resource resource) { +PP_Bool IsAudio(PP_Resource resource) { scoped_refptr