Skip to content

Instantly share code, notes, and snippets.

@hbt
Last active December 26, 2016 11:29
Show Gist options
  • Save hbt/94e527e6aba99baffba27259a98198b1 to your computer and use it in GitHub Desktop.
Save hbt/94e527e6aba99baffba27259a98198b1 to your computer and use it in GitHub Desktop.
chromium improvement notes
sample code to write file using chromium api
read/write file example that works in renderer but not in webkit
'content/browser/renderer_host/render_widget_host_view_base.cc:34'
//#include <iostream>
//#include <fstream>
//#include <cstdlib>
//#include <fstream>
//#include <iostream>
//#include "chrome/browser/chrome_content_browser_client.h"
//#include "chrome/browser/profiles/profile.h"
//#include "chrome/browser/profiles/profile_io_data.h"
//std::ifstream file("/tmp/r");
//std::string str;
//std::string file_contents;
//while (std::getline(file, str))
//{
// file_contents += str;
// file_contents.push_back('\n');
//}
//
// std::cout << file_contents;
// ChromeContentBrowserClient::test();
// ChromeContentBrowserClient::test();
// ProfileIOData::SetCertVerifierForTesting(NULL);
// std::string css;
// base::ReadFileToString(base::FilePath("/tmp/r"), &css);
// std::cout << css;
base::WriteFile(base::FilePath("/tmp/r3"), "ggas", strlen("ggas"));
"
============================
'fixing background color in frameview' => [
'third_party/WebKit/Source/core/frame/FrameView.cpp:2204',
'FrameView::setBaseBackgroundColor',
],
===================================
css injection example in document
third_party/WebKit/Source/core/dom/Document.cpp:569
// #include "base/bind.h"
//#include "base/files/file_util.h"
//#include "base/guid.h"
//#include "base/i18n/rtl.h"
//#include "content/public/browser/browser_thread.h"
//
//
//#include <iostream>
//#include <fstream>
//#include <cstdlib>
//#include <fstream>
//#include <iostream>
//
//#include "base/bind.h"
//#include "base/command_line.h"
//#include "base/files/file_enumerator.h"
//#include "base/files/file_path.h"
//#include "base/files/file_util.h"
//#include "base/path_service.h"
// // Since CSSFontSelector requires Document::m_fetcher and StyleEngine owns
// // CSSFontSelector, need to initialize m_styleEngine after initializing
// // m_fetcher.
// m_styleEngine = StyleEngine::create(*this);
//
//
//// ifstream inFile;
//// inFile.open(inFileName);//open the input file
//// stringstream strStream;
//// strStream << inFile.rdbuf();//read the file
//// string str = strStream.str();//str holds the content of the file
//////
////// cout << str << endl;//you can do anything with the string!!!
//
//// std::ifstream t("/tmp/f.css");
//// std::stringstream buffer;
//// buffer << t.rdbuf();
//// const std::string tmp = buffer.str();
//// const char* cstr = tmp.c_str();
//// String str = cstr;
//
// std::ifstream file("/tmp/r");
//std::string str;
//std::string file_contents;
//while (std::getline(file, str))
//{
// file_contents += str;
// file_contents.push_back('\n');
//}
//
//// std::system("echo \"" + file_contents + "\"") ;
// std::cout << file_contents;
//
//
//
// std::ofstream myfile;
// myfile.open ("/tmp/example2.txt");
// myfile << "Writing this to a file.\n";
// myfile.close();
//
// //Document* document = this;
// StyleSheetContents* parsedSheet = StyleSheetContents::create(CSSParserContext(*this, 0));
//// StyleSheetContents* parsedSheet = StyleSheetContents::create("file::///tmp/f.css", CSSParserContext(*this, 0));
//
//
//// String sourceCode = "* {"
//// "color: rgb(237, 237, 237);"
////" font-size: 14px;"
////" background-image: initial !important;"
////" background-attachment: initial;"
////" background-origin: initial;"
////" background-clip: initial;"
////" background-color: rgb(15, 15, 15) !important;"
////" background-position: initial initial;"
////" background-repeat: initial initial;"
////" text-shadow: 0 !important;"
////"}"
////"html > body,"
////"html > body * {"
////" background-color: rgb(15, 15, 15) !important;"
////" color: #EDEDED !important;"
////" text-shadow: 0 !important;"
////" webkit-text-fill-color: none !important;"
////" webkit-text-stroke: 0 !important;"
////"}";
//
// String src = ""
//" /** dark_colors */"
//""
//" /** handle checkvist */"
//" .currentTask, .selectedTask "
//" {"
//" border-color: red !important;"
//" }"
//""
//" * {"
//" color: rgb(237, 237, 237);"
//" font-size: 14px;"
//" background-image: initial !important;"
//" background-attachment: initial;"
//" background-origin: initial;"
//" background-clip: initial;"
//" background-color: rgb(15, 15, 15) !important;"
//" background-position: initial initial;"
//" background-repeat: initial initial;"
//" text-shadow: 0 !important;"
//" }"
//" html > body,"
//" html > body * {"
//" background-color: rgb(15, 15, 15) !important;"
//" color: #EDEDED !important;"
//" text-shadow: 0 !important;"
//" webkit-text-fill-color: none !important;"
//" webkit-text-stroke: 0 !important;"
//" }"
//" html > body,"
//" html > body *:not([onclick]):not(:link):not(:visited) { background-image: none !important }"
//" /** beginning fix */"
//" html {"
//" background-color: #222 !important;"
//" */"
//" }"
//" body,"
//" div,"
//" h1,"
//" h2,"
//" h3,"
//" h4,"
//" h5,"
//" h6,"
//" table,"
//" tbody,"
//" thead,"
//" tr,"
//" td,"
//" th,"
//" ul,"
//" li,"
//" p,"
//" i,"
//" dd,"
//" dt,"
//" strong,"
//" code,"
//" iframe,"
//" embed,"
//" section,"
//" blockquote,"
//" legend,"
//" label,"
//" form,"
//" pre,"
//" dl,"
//" img {"
//" color: rgb(237, 237, 237);"
//" text-shadow: 0px 0px 1px #000 !important;"
//" background-color: transparent !important;"
//" border-color: #444 !important;"
//" -moz-border-top-colors: #444 !important;"
//" -moz-border-bottom-colors: #444 !important;"
//" -moz-border-left-colors: #444 !important;"
//" -moz-border-right-colors: #444 !important;"
//" }"
//" a:not([style*=\"color\"]),"
//" span:not([style*=\"color\"]) {"
//" color: rgb(237, 237, 237);"
//" text-shadow: 0px 0px 1px #000 !important;"
//" background-color: transparent !important;"
//" border-color: #444 !important;"
//" -moz-border-top-colors: #444 !important;"
//" -moz-border-bottom-colors: #444 !important;"
//" -moz-border-left-colors: #444 !important;"
//" -moz-border-right-colors: #444 !important;"
//" }"
//" *[style*=\"color\"]:not([style=\"abcxyz\"]),"
//" *[style*=\"color\"]:not([style=\"abcxyz\"]) * { text-shadow: 0 0 3px #000 !important }"
//" table {"
//" /* background-color: rgba(40,30,30,.6) !important; */"
//" border-radius: 6px !important;"
//" }"
//" div[style] > form {"
//" /* background-color: rgba(10,20,20,.8) !important; */"
//" border-radius: 6px !important;"
//" }"
//" /** end fix */"
//" html > body a:link,"
//" html > body a:visited,"
//" html > body a:hover,"
//" html > body a:active,"
//" html > body a:link *,"
//" html > body a:visited *,"
//" html > body a:hover *,"
//" html > body a:active * {"
//" border-bottom: 0 !important;"
//" text-decoration: underline !important;"
//" }"
//" html > body a:link,"
//" html > body a:link *,"
//" html > body a:link:hover,"
//" html > body a:link:hover *,"
//" html > body a:link:active,"
//" html > body a:link:active * { color: #42ADDB !important }"
//" html > body a:visited,"
//" html > body a:visited *,"
//" html > body a:visited:hover,"
//" html > body a:visited:hover *,"
//" html > body a:visited:active,"
//" html > body"
//" a:visited:active * { color: #0FF000 !important }"
//" html > body,"
//" html > body * { font-family: sans-serif !important }"
//" html > body code,"
//" html > body kbd,"
//" html > body listing,"
//" html > body plaintext,"
//" html > body pre,"
//" html > body samp,"
//" html > body tt,"
//" html > body xmp,"
//" html > body"
//" code *,"
//" html > body kbd *,"
//" html > body listing *,"
//" html > body plaintext *,"
//" html > body pre *,"
//" html > body samp *,"
//" html > body tt *,"
//" hTml > body xmp * { font-family: monospace !important }"
//" html > body h1,"
//" html > body h2,"
//" html > body h3,"
//" html > body h4,"
//" html > body h5,"
//" html > body h6,"
//" html > body h1 *,"
//" html > body h2 *,"
//" html > body h3 *,"
//" html >"
//" body h4 *,"
//" html > body h5 *,"
//" html > body h6 * { font-family: serif !important }"
//" html,"
//" body { background-color: rgb(15, 15, 15) !important }"
//" Works in Safari"
//" ::selection {"
//" color: orange;"
//" background-color: grey;"
//" }"
// ;
//
//
// parsedSheet->parseString(src);
// styleEngine().injectAuthorSheet(parsedSheet);
//
// std::string css;
// base::ReadFileToString(base::FilePath("/tmp/r"), &css);
// std::cout << css;
// base::WriteFile(base::FilePath("/home/hassen/.config/chromium/Default/Local Storage/asd"), "ggas", strlen("ggas"));
//
// addConsoleMessage(
// ConsoleMessage::create(JSMessageSource, WarningMessageLevel,
// ExceptionMessages::failedToExecute(
// "write", "Document",
// "It isnasdasd asda't possible to write into a document "
// "from an asynchronously-loaded external "
// "script unless it is explicitly opened.")));
// working version with --no-sandbox
#include "base/bind.h"
#include "base/files/file_util.h"
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <fstream>
#include <iostream>
std::string css;
base::ReadFileToString(base::FilePath("/tmp/r"), &css);
std::cout << css;
base::WriteFile(base::FilePath("/tmp/r3"), "ggas", strlen("ggas"));
StyleSheetContents *parsedSheet = StyleSheetContents::create(CSSParserContext(*this, 0));
String css2 = String::String(css.c_str());
parsedSheet->parseString(css2);
styleEngine().injectAuthorSheet(parsedSheet);
<?php
$todos = [
'add option to specify different colors',
'add gdoc to collect emails for other platforms',
'look into fixing the embedded flash -- currently using nohup /opt/chromium.org/chromium-beta/chrome --ppapi-flash-path=/home/hassen/Downloads/flash_player_ppapi_linux.x86_64/libpepflashplayer.so --allow-file-access %U --disk-cache-dir="/tmp/ram" &> /dev/null',
'fix google keys issue http://www.chromium.org/developers/how-tos/api-keys or at least hide message',
'deb files' => [
'inv why library version missing when producing deb -- currently using EXPORT ignore deps + copying libs manually',
],
'css inject' => [
'fix document.cpp injection css -- ideally should be read by file but already have code sample to inject it anywhere and could be controlled by option -- view document.cpp snippet and uses --no-sandbox flag and works but creates security issues',
' look into old code for user stylesheet that was removed https://codereview.chromium.org/64843004' => [
'potential fix with browserthread::postTask -- using callbacks ',
],
],
];
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment