Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
Meego:Netbook
chromium
chromium-20100506-expose-chromium-browser-api.p...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File chromium-20100506-expose-chromium-browser-api.patch of Package chromium
--- chromium/src/app/l10n_util.cc +++ chromium/src/app/l10n_util.cc @@ -384,9 +384,14 @@ namespace l10n_util { std::string GetApplicationLocale(const std::string& pref_locale) { -#if !defined(OS_MACOSX) FilePath locale_path; PathService::Get(app::DIR_LOCALES, &locale_path); + return GetApplicationLocale(pref_locale, locale_path); +} + +std::string GetApplicationLocale(const std::string& pref_locale, + FilePath& locale_path) { +#if !defined(OS_MACOSX) std::string resolved_locale; std::vector<std::string> candidates; const std::string system_locale = GetSystemLocale(); --- chromium/src/app/l10n_util.h +++ chromium/src/app/l10n_util.h @@ -20,6 +20,7 @@ #include "base/scoped_ptr.h" #include "base/string16.h" #include "base/string_util.h" +#include "base/file_path.h" #if defined(OS_MACOSX) #include "app/l10n_util_mac.h" @@ -38,6 +39,10 @@ // we fall back to en-us. std::string GetApplicationLocale(const std::string& pref_locale); +std::string GetApplicationLocale(const std::string& pref_locale, + FilePath& locale_path); + + // Given a locale code, return true if the OS is capable of supporting it. // For instance, Oriya is not well supported on Windows XP and we return // false for "or". --- chromium/src/app/resource_bundle.cc +++ chromium/src/app/resource_bundle.cc @@ -54,6 +54,17 @@ return g_shared_instance_->LoadLocaleResources(pref_locale); } +std::string ResourceBundle::InitSharedInstance( + const std::string& pref_locale, + FilePath& bundle_path, + FilePath& locale_path) { + DCHECK(g_shared_instance_ == NULL) << "ResourceBundle initialized twice"; + g_shared_instance_ = new ResourceBundle(); + + g_shared_instance_->LoadCommonResources(bundle_path); + return g_shared_instance_->LoadLocaleResources(pref_locale, locale_path); +} + /* static */ void ResourceBundle::AddDataPackToSharedInstance(const FilePath& path) { DCHECK(g_shared_instance_ != NULL) << "ResourceBundle not initialized"; --- chromium/src/app/resource_bundle.h +++ chromium/src/app/resource_bundle.h @@ -78,6 +78,10 @@ // the UI thread. static std::string ReloadSharedInstance(const std::string& pref_locale); + static std::string InitSharedInstance(const std::string& pref_locale, + FilePath& bundle_path, + FilePath& locale_path); + // Registers additional data pack files with the global ResourceBundle. When // looking for a DataResource, we will search these files after searching the // main module. This method is not thread safe! You should call it @@ -198,10 +202,14 @@ // Load the main resources. void LoadCommonResources(); + void LoadCommonResources(FilePath& resources_file_path); + // Try to load the locale specific strings from an external data module. // Returns the locale that is loaded. std::string LoadLocaleResources(const std::string& pref_locale); + std::string LoadLocaleResources(const std::string& pref_locale, FilePath& locale_dir_path); + // Unload the locale specific strings and prepares to load new ones. See // comments for ReloadSharedInstance(). void UnloadLocaleResources(); @@ -219,6 +227,9 @@ // string if no locale data files are found. static FilePath GetLocaleFilePath(const std::string& app_locale); + static FilePath GetLocaleFilePath(const std::string& app_locale, + FilePath& locale_path); + // Returns a handle to bytes from the resource |module|, without doing any // processing or interpretation of the resource. Returns whether we // successfully read the resource. Caller does not own the data returned --- chromium/src/app/resource_bundle_linux.cc +++ chromium/src/app/resource_bundle_linux.cc @@ -84,6 +84,19 @@ return locale_file_path; } +// static +FilePath ResourceBundle::GetLocaleFilePath(const std::string& app_locale, + FilePath& locale_path) { + if (locale_path.empty()) + return locale_path; + if (app_locale.empty()) + return FilePath(); + locale_path = locale_path.AppendASCII(app_locale + ".pak"); + if (!file_util::PathExists(locale_path)) + return FilePath(); + return locale_path; +} + GdkPixbuf* ResourceBundle::GetPixbufImpl(int resource_id, bool rtl_enabled) { // Use the negative |resource_id| for the key for BIDI-aware images. int key = rtl_enabled ? -resource_id : resource_id; --- chromium/src/app/resource_bundle_posix.cc +++ chromium/src/app/resource_bundle_posix.cc @@ -101,6 +101,12 @@ CHECK(resources_data_) << "failed to load chrome.pak"; } +void ResourceBundle::LoadCommonResources(FilePath& resources_file_path) { + CHECK(!resources_file_path.empty()) << "chrome.pak not found"; + resources_data_ = LoadResourcesDataPak(resources_file_path); + CHECK(resources_data_) << "failed to load chrome.pak"; +} + std::string ResourceBundle::LoadLocaleResources( const std::string& pref_locale) { DCHECK(!locale_resources_data_) << "locale.pak already loaded"; @@ -115,3 +121,20 @@ CHECK(locale_resources_data_) << "failed to load locale.pak"; return app_locale; } + +std::string ResourceBundle::LoadLocaleResources( + const std::string& pref_locale, + FilePath& locale_dir_path) { + DCHECK(!locale_resources_data_) << "locale.pak already loaded"; + std::string app_locale = l10n_util::GetApplicationLocale(pref_locale, locale_dir_path); + FilePath locale_file_path = GetLocaleFilePath(app_locale, locale_dir_path); + if (locale_file_path.empty()) { + // It's possible that there is no locale.pak. + NOTREACHED(); + return std::string(); + } + locale_resources_data_ = LoadResourcesDataPak(locale_file_path); + CHECK(locale_resources_data_) << "failed to load locale.pak"; + return app_locale; +} + --- chromium/src/build/common.gypi +++ chromium/src/build/common.gypi @@ -70,7 +70,7 @@ # or you can add the following line (without the #) to # ~/.gyp/include.gypi {'variables': {'library': 'shared_library'}} # to compile as shared by default - 'library%': 'static_library', + 'library%': 'shared_library', }, # We set those at this level of nesting so the values are available for --- chromium/src/chrome/browser/browser_process.h +++ chromium/src/chrome/browser/browser_process.h @@ -92,6 +92,8 @@ // Returns the thread that is used for background cache operations. virtual base::Thread* cache_thread() = 0; + virtual base::Thread* process_launcher_thread() = 0; + #if defined(USE_X11) // Returns the thread that is used to process UI requests in cases where // we can't route the request to the UI thread. Note that this thread --- chromium/src/chrome/browser/sessions/session_backend.cc +++ chromium/src/chrome/browser/sessions/session_backend.cc @@ -19,7 +19,7 @@ // The signature at the beginning of the file = SSNS (Sessions). static const int32 kFileSignature = 0x53534E53; -namespace { +//namespace { // SessionFileReader ---------------------------------------------------------- @@ -27,56 +27,6 @@ // describe a Session back from a file. SessionFileRead does minimal error // checking on the file (pretty much only that the header is valid). -class SessionFileReader { - public: - typedef SessionCommand::id_type id_type; - typedef SessionCommand::size_type size_type; - - explicit SessionFileReader(const FilePath& path) - : errored_(false), - buffer_(SessionBackend::kFileReadBufferSize, 0), - buffer_position_(0), - available_count_(0) { - file_.reset(new net::FileStream()); - file_->Open(path, base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ); - } - // Reads the contents of the file specified in the constructor, returning - // true on success. It is up to the caller to free all SessionCommands - // added to commands. - bool Read(BaseSessionService::SessionType type, - std::vector<SessionCommand*>* commands); - - private: - // Reads a single command, returning it. A return value of NULL indicates - // either there are no commands, or there was an error. Use errored_ to - // distinguish the two. If NULL is returned, and there is no error, it means - // the end of file was successfully reached. - SessionCommand* ReadCommand(); - - // Shifts the unused portion of buffer_ to the beginning and fills the - // remaining portion with data from the file. Returns false if the buffer - // couldn't be filled. A return value of false only signals an error if - // errored_ is set to true. - bool FillBuffer(); - - // Whether an error condition has been detected ( - bool errored_; - - // As we read from the file, data goes here. - std::string buffer_; - - // The file. - scoped_ptr<net::FileStream> file_; - - // Position in buffer_ of the data. - size_t buffer_position_; - - // Number of available bytes; relative to buffer_position_. - size_t available_count_; - - DISALLOW_COPY_AND_ASSIGN(SessionFileReader); -}; - bool SessionFileReader::Read(BaseSessionService::SessionType type, std::vector<SessionCommand*>* commands) { if (!file_->IsOpen()) @@ -172,7 +122,7 @@ return true; } -} // namespace +//} // namespace // SessionBackend ------------------------------------------------------------- --- chromium/src/chrome/browser/sessions/session_backend.h +++ chromium/src/chrome/browser/sessions/session_backend.h @@ -10,6 +10,7 @@ #include "base/ref_counted.h" #include "base/scoped_ptr.h" +#include "net/base/file_stream.h" #include "chrome/browser/sessions/base_session_service.h" #include "chrome/browser/sessions/session_command.h" @@ -148,4 +149,58 @@ DISALLOW_COPY_AND_ASSIGN(SessionBackend); }; +// SessionFileReader is responsible for reading the set of SessionCommands that +// describe a Session back from a file. SessionFileRead does minimal error +// checking on the file (pretty much only that the header is valid). + +class SessionFileReader { + public: + typedef SessionCommand::id_type id_type; + typedef SessionCommand::size_type size_type; + + explicit SessionFileReader(const FilePath& path) + : errored_(false), + buffer_(SessionBackend::kFileReadBufferSize, 0), + buffer_position_(0), + available_count_(0) { + file_.reset(new net::FileStream()); + file_->Open(path, base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ); + } + // Reads the contents of the file specified in the constructor, returning + // true on success. It is up to the caller to free all SessionCommands + // added to commands. + bool Read(BaseSessionService::SessionType type, + std::vector<SessionCommand*>* commands); + + private: + // Reads a single command, returning it. A return value of NULL indicates + // either there are no commands, or there was an error. Use errored_ to + // distinguish the two. If NULL is returned, and there is no error, it means + // the end of file was successfully reached. + SessionCommand* ReadCommand(); + + // Shifts the unused portion of buffer_ to the beginning and fills the + // remaining portion with data from the file. Returns false if the buffer + // couldn't be filled. A return value of false only signals an error if + // errored_ is set to true. + bool FillBuffer(); + + // Whether an error condition has been detected ( + bool errored_; + + // As we read from the file, data goes here. + std::string buffer_; + + // The file. + scoped_ptr<net::FileStream> file_; + + // Position in buffer_ of the data. + size_t buffer_position_; + + // Number of available bytes; relative to buffer_position_. + size_t available_count_; + + DISALLOW_COPY_AND_ASSIGN(SessionFileReader); +}; + #endif // CHROME_BROWSER_SESSIONS_SESSION_BACKEND_H_
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor