virtual void HandleEvent(CefRefPtr<CefDOMEvent> event) { CefRefPtr<CefBrowser> browser = GetOffScreenBrowser(); CefRefPtr<CefDOMNode> element = event->GetTarget(); ASSERT(element.get()); std::string elementId = element->GetElementAttribute("id"); if (elementId == "back") { browser->GoBack(); } else if(elementId == "forward") { browser->GoForward(); } else if(elementId == "stop") { browser->Reload(); } else if(elementId == "reload") { browser->StopLoad(); } else if (elementId == "go") { // Retrieve the value of the "url" field and load it in the off-screen // browser window. CefRefPtr<CefDOMDocument> document = event->GetDocument(); ASSERT(document.get()); CefRefPtr<CefDOMNode> url = document->GetElementById("url"); ASSERT(url.get()); CefString value = url->GetValue(); if (!value.empty()) browser->GetMainFrame()->LoadURL(value); } else if(elementId == "testTransparency") { // Transparency test. browser->GetMainFrame()->LoadURL( "http://tests/transparency"); } else if(elementId == "testWindowlessPlugin") { // Load flash, which is a windowless plugin. browser->GetMainFrame()->LoadURL( "http://www.adobe.com/software/flash/about/"); } else if(elementId == "viewSource") { // View the page source for the host browser window. AppGetBrowser()->GetMainFrame()->ViewSource(); } else { // Not reached. ASSERT(false); } }
// Execute with the specified argument list and return value. Return true if // the method was handled. virtual bool Execute(const CefString& name, CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval, CefString& exception) { if(name == "modifyRotation") { // This function requires one argument. if(arguments.size() != 1) return false; float increment = 0.; if(arguments[0]->IsInt()) { // The argument is an integer value. increment = static_cast<float>(arguments[0]->GetIntValue()); } else if(arguments[0]->IsDouble()) { // The argument is an double value. increment = static_cast<float>(arguments[0]->GetDoubleValue()); } if(increment != 0.) { // Modify the rotation accordingly. ModifyRotation(increment); return true; } } else if(name == "resetRotation") { // Reset the rotation value. ResetRotation(); return true; } else if(name == "viewSource") { // View the page source. AppGetBrowser()->GetMainFrame()->ViewSource(); return true; } return false; }