A method for migrating browser history

By porting the history function code in the chromium project, the problem of missing history function in the content_shell project is solved, and the complete history function of the custom browser is realized, improving the user experience.

CN114036441BActive Publication Date: 2025-07-08SICHUAN CHANGHONG ELECTRIC CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111371364.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-18
Publication Date
2025-07-08
Estimated Expiration
2041-11-18

AI Technical Summary

Technical Problem

The content_shell project does not implement the history function and cannot provide the complete browser history function in a custom browser.

Method used

By porting the history function code in the chromium project, including modifying compiled files, porting related files, realizing history initialization, writing, querying and deleting functions, building the history function of a custom browser.

Benefits of technology

It realizes the history function of a custom browser, has the ability to write, query and delete, and improves the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114036441B_ABST
    Figure CN114036441B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for transplanting browser history records. By transplanting the code related to the history record function in the chromium project, the history record function can be implemented at the application layer, with functions of writing, querying, and deleting history records, achieving the effect of expanding the history record function of browser applications and improving the user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of browsers, and in particular, to a method for transplanting browser history records. Background Art

[0002] With the popularization of web technology, the use and dependence on browsers are also increasing. The traditional method is to perform secondary development based on the chromium browser. However, the chromium project is extremely large and it is impossible to extract a single jar package to provide to partners. In contrast, the official content_shell project is much simpler.

[0003] Therefore, it is decided to build a custom browser project based on the official content_shell project (version 78), and finally implement a single jar package for use by other projects. However, since content_shell only implements the basic functions of the browser and does not have other functions such as history records, cache, bookmarks, etc., it needs to be developed separately. Since the chromium project implements the history record function, it only needs to be transplanted to the content_shell project. Therefore, a method for transplanting the history record function needs to be constructed. Summary of the Invention

[0004] The purpose of the present invention is to provide a method for transplanting browser history records to solve the problem that the content shell project does not support the history record function. The present invention solves this problem by transplanting the code related to the history record function in the chromium project.

[0005] Glossary of Terms:

[0006] Chromium: Chromium is a web browser mainly developed by Google. It is distributed under multiple free licenses such as the BSD license and is open source. The development of Chromium may have started as early as 2006. Its design concept is based on ideas such as simplicity, high speed, stability, and security. It uses the V8 engine exclusively developed by Google to improve the efficiency of interpreting JavaScript, and has designed functions such as "sandbox", "blacklist", and "incognito browsing" to achieve a stable and secure web browsing environment.

[0007] Content_shell: Content_shell is a simple test program based on the content api. It is just a shell that calls the content API and implements some necessary callback interfaces, realizing the most basic functions of the browser.

[0008] The Content shell project does not implement the history function, but the chromium project does implement the history function.

[0009] The present invention achieves the above object through the following technical solutions:

[0010] A method for transplanting browser history records includes the following steps:

[0011] Step s1, modify the project compilation file and add files on which the history function depends;

[0012] Step s2, modify the relevant files under the chrome directory and remove redundant code irrelevant to the history function;

[0013] Step s3, transplant the modified code files in s2 to the content_shell project;

[0014] Step s4, modify the compilation file and add the modified files in s3 to the dependencies;

[0015] Step s5, call the history initialization function during the shell initialization process;

[0016] Step s6, remove redundant code and implement the history writing process;

[0017] Step s7, imitate the file browsing_history_bridge.cc to implement the class BrowsingHistoryBridge and implement the history query process;

[0018] Step s8, imitate the files browsing_data_bridge.cc and, implement the class BrowsingDataBridge and remove redundant code;

[0019] Step s9, imitate the file chrome_browsing_data_remover_delegate.cc to implement the class ChromeBrowsingDataRemoverDelegate and implement the history deletion process.

[0020] A further solution is that in step s1, some files related to history in the native chromium project are implemented under the chrome directory. After modifying them, transplant them to the content / shell / chrome directory and add the dependencies of these files to the compilation configuration file Build.gn.

[0021] A further solution is that in step s5, starting from the function HistoryService::Init() and ending at HistoryDatabase::Init() is the creation process related to the history record function. A database file named History is created in the system, and the access records of users are saved in the table urls in the database content.

[0022] A further solution is that in step s6, a database for historical records is created during initialization and will be automatically written when accessing websites.

[0023] A further solution is that in step s9, the application layer deletes historical records by calling the Jni function JNI_BrowsingDataBrigde_ClearBrowsingData to the underlying layer.

[0024] The beneficial effects of the present invention are as follows:

[0025] A method for transplanting browser historical records of the present invention can implement the historical record function at the application layer by transplanting the code related to the historical record function in the chromium project, and has the functions of writing, querying, and deleting historical records, achieving the effect of expanding the historical record function of the browser application and improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0027] Figure 1 It is a flow chart of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0028] To make the objectives, technical solutions, and advantages of the present invention clearer, the technical solutions of the present invention will be described in detail below. Obviously, the described embodiments are only some embodiments of the present invention, rather than all embodiments. Based on the embodiments of the present invention, all other implementation manners obtained by those of ordinary skill in the art without creative efforts fall within the scope protected by the present invention.

[0029] In any embodiment, as Figure 1 shown, a method for transplanting browser historical records of the present invention includes:

[0030] Step s1, modify the project compilation file and add the files on which the historical record function depends;

[0031] Step s2, modify the relevant files under the chrome directory and remove the redundant code unrelated to the history function;

[0032] Step s3, transplant the modified code files in s2 to the content_shell project;

[0033] Step s4, modify the compilation file and add the modified files in s3 to the dependencies;

[0034] Step s5, call the history initialization function during the shell initialization process;

[0035] Step s6, remove the redundant code and implement the history writing process;

[0036] Step s7, imitate the file browsing_history_bridge.cc to implement the class BrowsingHistoryBridge and implement the history query process;

[0037] Step s8, imitate the files browsing_data_bridge.cc and, implement the class BrowsingDataBridge and remove the redundant code;

[0038] Step s9, imitate the file chrome_browsing_data_remover_delegate.cc to implement the class ChromeBrowsingDataRemoverDelegate and implement the history deletion process.

[0039] In a specific embodiment, as Figure 1 shown, a method for transplanting browser history of the present invention includes the following steps:

[0040] Modify the project compilation file.

[0041] In the content shell project, the core history function is not compiled. Therefore, the following content needs to be added to the deps option in the file / content / shell / BUILD.gn:

[0042] " / / components / history / content / browser",

[0043] " / / components / history / core / browser",

[0044] " / / components / history / core / common",

[0045] " / / components / ntp_snippets",

[0046] " / / components / previews / core",

[0047] " / / components / browsing_data / core",

[0048] Porting code files.

[0049] In the native chromium project, some files related to history are implemented in the chrome directory. These files need to be modified and ported to the content / shell / chrome directory. And add the dependencies of these files to the compilation configuration file Build.gn.

[0050] Specifically as follows:

[0051] "chrome / browser / history / history_tab_helper.cc",

[0052] "chrome / browser / history / history_tab_helper.h",

[0053] "chrome / browser / history / history_service_factory.cc",

[0054] "chrome / browser / history / history_service_factory.h",

[0055] "chrome / browser / history / profile_based_browsing_history_driver.cc",

[0056] "chrome / browser / history / profile_based_browsing_history_driver.h",

[0057] "chrome / browser / android / history / browsing_history_bridge.cc",

[0058] "chrome / browser / android / history / browsing_history_bridge.h",

[0059] "chrome / browser / browsing_data / browsing_data_important_sites_util.cc",

[0060] "chrome / browser / browsing_data / browsing_data_important_sites_util.h",

[0061] "chrome / browser / browsing_data / chrome_browsing_data_remover_delegate_factory.cc",

[0062] "chrome / browser / browsing_data / chrome_browsing_data_remover_delegate_factory.h",

[0063] "chrome / browser / browsing_data / chrome_browsing_data_remover_delegate.cc",

[0064] "chrome / browser / browsing_data / chrome_browsing_data_remover_delegate.h",

[0065] "chrome / browser / android / browsing_data / browsing_data_bridge.cc",

[0066] "chrome / browser / android / browsing_data / browsing_data_bridge.h",

[0067] "android / ch_pango_view.cc",

[0068] Among them, the browsing_data_bridge.cc file implements the relevant Jni functions for deleting records, and the browsing_history_bridge.cc file implements the relevant Jni functions for querying records. The chrome_browsing_data_remover_delegate.cc file deletes various types of data, including cache, password, etc., and is the place where the underlying deletion interface is actually called. In addition, the rest are all utility class files.

[0069] Implementation of the historical record initialization function.

[0070] The actual creation process related to the historical record function starts from the function HistoryService::Init() and ends at HistoryDatabase::Init(). Finally, a database file named History will be created in the system. The access records of the user are saved in the table urls in the database content.

[0071] In order not to add redundant code, the original initialization process was not used during modification, and only the creation process related to the historical record function was retained. Adding the code HistoryTabHelper::CreateForWebContents(web_contents.get()) will create the database of the historical record. It is now added in Shell::CreateNewWindow(). At this time, a HistoryTabHelper object will be created, and then when obtaining the HistoryService, the function HistoryTabHelper::GetHistoryService() will be called. At this time, the HistoryService will be created through the factory HistoryServiceFactory, and then HistoryService::Init() will be called. The subsequent process will be the same as the original process. Here, the task HistoryBackend::Init will be sent to another thread, and finally HistoryDatabase::Init() will be called to create the database file of the historical record, where the parameter history_name represents the file path to be created. Thus, the entire initialization process ends.

[0072] Implementation of the historical record writing function.

[0073] Writing does not require manual function calls. As long as the database for historical records is created during initialization, it will be automatically written when accessing the website. Since it has little association with Chromium, the original process is retained, and only the HistoryTabHelper class is slightly modified to remove redundant code.

[0074] The historical record query function is implemented.

[0075] The function QueryHistory() of the class BrowsingHistoryBridge is a Jni function. After comparison, it is found that only this function is related to the files in the chrome directory during the entire query process. Therefore, only the file of this class needs to be slightly modified, and the Jni interface is rewritten elsewhere to add the entire process (since the content shell project does not have a historical record function, there is no corresponding Java file for this class in the application layer).

[0076] When using it, the application layer can directly call BrowsingHistoryBridge::QueryHistory(). Among them, the parameter j_result_obj saves the query result, and the parameter j_query is the query keyword.

[0077] The historical record deletion function is implemented.

[0078] The application layer deletes historical records at the bottom layer by calling the Jni function JNI_BrowsingDataBridge_ClearBrowsingData. Only the namespace browsing_data_important_sites_util and the class ChromeBrowsingDataRemoverDelegate are in the chrome directory during the entire process. Therefore, only these two files need to be modified to remove redundant code related to the chrome directory to add the entire process.

[0079] The function ChromeBrowsingDataRemoverDelegate::RemoveEmbedderData() not only handles the deletion of historical records but also the deletion of cache, cookies, etc. The relevant code is temporarily blocked here. If relevant functions need to be added later, it can be modified here.

[0080] Finally, in URLDatabase::DeleteURLRow(), the corresponding row is deleted from the database table.

[0081] As described above, it is only the specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present invention can easily think of changes or substitutions, which should all be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims. Additionally, it should be noted that in the various specific technical features described in the above specific implementation manner, they can be combined in any appropriate manner without contradiction. To avoid unnecessary repetition, the present invention will not separately describe various possible combination methods. Furthermore, any arbitrary combination can be made between different implementation manners of the present invention, as long as it does not violate the idea of the present invention, it should equally be regarded as the content disclosed by the present invention.

Claims

1. A method for transplanting browser history records, characterized in that, It includes the following steps: Step s1, modify the content shell project compilation file and add the files required for the history function dependency; Step s2, modify the files related to the history function under the chrome / browser / history directory and remove the redundant code unrelated to the history function; Step s3, transplant the modified code files in s2 to the content_shell project; Step s4, continue to add the modified files in s3 to the dependencies in the compilation file in s1; Step s5, call the history initialization function during the shell initialization process; Step s6, remove the redundant code and implement the history writing process; Step s7, imitate the file browsing_history_bridge.cc to implement the class BrowsingHistoryBridge and implement the history query process; Step s8, imitate the files browsing_data_bridge.cc and, implement the class BrowsingDataBridge and remove the redundant code; Step s9, imitate the file chrome_browsing_data_remover_delegate.cc to implement the class ChromeBrowsingDataRemoverDelegate and implement the history deletion process.

2. The browser history record transplantation method according to claim 1, wherein In step s1, some files related to history in the native chromium project are implemented in the chrome directory. After modification, they are transplanted to the content / shell / chrome directory, and the dependencies of these files are added to the compilation configuration file Build.gn.

3. The method for transplanting browser history records according to claim 1, wherein In step s5, starting from the function HistoryService::Init() and ending at HistoryDatabase::Init() is the creation process related to the history function. A database file named History is created in the system, and the access records of users are saved in the table urls in the database content.

4. The browser history record transplantation method according to claim 1, wherein In step s6, a history database is created during initialization, and it will be automatically written when accessing a website.

5. The method for transplanting browser history records according to claim 1, characterized in that In step s9, the application layer deletes the history at the bottom layer by calling the Jni function JNI_BrowsingDataBridge_ClearBrowsingData.

Citation Information

Patent Citations

  • Method for increasing running speed of embedded browser

    CN107491330A

  • Browser that supports addition and deletion of history

    KR1020010008189A