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

Side by Side Diff: webkit/glue/webframe_impl.cc

Issue 203034: Theme support for the extension shelf (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
3 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. 3 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 // Returns the V8 context for this frame, or an empty handle if there is 694 // Returns the V8 context for this frame, or an empty handle if there is
695 // none. 695 // none.
696 v8::Local<v8::Context> WebFrameImpl::mainWorldScriptContext() const { 696 v8::Local<v8::Context> WebFrameImpl::mainWorldScriptContext() const {
697 if (!frame_) 697 if (!frame_)
698 return v8::Local<v8::Context>(); 698 return v8::Local<v8::Context>();
699 699
700 return WebCore::V8Proxy::mainWorldContext(frame_); 700 return WebCore::V8Proxy::mainWorldContext(frame_);
701 } 701 }
702 #endif 702 #endif
703 703
704 bool WebFrameImpl::insertStyleText(const WebString& css) { 704 bool WebFrameImpl::insertStyleText(
705 const WebString& css, const WebString& id) {
705 Document* document = frame()->document(); 706 Document* document = frame()->document();
706 if (!document) 707 if (!document)
707 return false; 708 return false;
708 WebCore::Element* document_element = document->documentElement(); 709 WebCore::Element* document_element = document->documentElement();
709 if (!document_element) 710 if (!document_element)
710 return false; 711 return false;
711 712
713 ExceptionCode err = 0;
714
715 if (!id.isEmpty()) {
716 WebCore::Element* old_element =
717 document->getElementById(webkit_glue::WebStringToString(id));
718 if (old_element) {
719 Node* parent = old_element->parent();
720 if (!parent)
721 return false;
722 parent->removeChild(old_element, err);
723 }
724 }
725
712 RefPtr<WebCore::Element> stylesheet = document->createElement( 726 RefPtr<WebCore::Element> stylesheet = document->createElement(
713 WebCore::HTMLNames::styleTag, false); 727 WebCore::HTMLNames::styleTag, false);
714 ExceptionCode err = 0; 728 if (!id.isEmpty())
729 stylesheet->setAttribute(WebCore::HTMLNames::idAttr,
730 webkit_glue::WebStringToString(id));
715 stylesheet->setTextContent(webkit_glue::WebStringToString(css), err); 731 stylesheet->setTextContent(webkit_glue::WebStringToString(css), err);
716 DCHECK(!err) << "Failed to set style element content"; 732 DCHECK(!err) << "Failed to set style element content";
717 WebCore::Node* first = document_element->firstChild(); 733 WebCore::Node* first = document_element->firstChild();
718 bool success = document_element->insertBefore(stylesheet, first, err); 734 bool success = document_element->insertBefore(stylesheet, first, err);
719 DCHECK(success) << "Failed to insert stylesheet"; 735 DCHECK(success) << "Failed to insert stylesheet";
720 return success; 736 return success;
721 } 737 }
722 738
723 void WebFrameImpl::reload() { 739 void WebFrameImpl::reload() {
724 frame_->loader()->saveDocumentAndScrollState(); 740 frame_->loader()->saveDocumentAndScrollState();
(...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1887 1903
1888 SecurityOrigin* security_origin = frame_->document()->securityOrigin(); 1904 SecurityOrigin* security_origin = frame_->document()->securityOrigin();
1889 1905
1890 if (!frame_->loader()->isScheduledLocationChangePending()) { 1906 if (!frame_->loader()->isScheduledLocationChangePending()) {
1891 frame_->loader()->stopAllLoaders(); 1907 frame_->loader()->stopAllLoaders();
1892 frame_->loader()->begin(frame_->loader()->url(), true, security_origin); 1908 frame_->loader()->begin(frame_->loader()->url(), true, security_origin);
1893 frame_->loader()->write(script_result); 1909 frame_->loader()->write(script_result);
1894 frame_->loader()->end(); 1910 frame_->loader()->end();
1895 } 1911 }
1896 } 1912 }
OLDNEW
« chrome/browser/views/extensions/extension_shelf.cc ('K') | « webkit/glue/webframe_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698