diff options
author | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-14 17:48:40 +0000 |
---|---|---|
committer | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-14 17:48:40 +0000 |
commit | 405ed122f92ca9248de2a65103edba9b02471a9f (patch) | |
tree | 9d8cb957ff47ba6790107feec65acdfa592d9747 /chrome/browser | |
parent | 296d61e24b5a5311f120a767a59ac006176f6f9a (diff) | |
download | chromium_src-405ed122f92ca9248de2a65103edba9b02471a9f.zip chromium_src-405ed122f92ca9248de2a65103edba9b02471a9f.tar.gz chromium_src-405ed122f92ca9248de2a65103edba9b02471a9f.tar.bz2 |
Port some files in chrome/browser/
#ifdef out windows-specific portion of chrome/common/l10n_util.h,
which allows me to port some other files.
I also extracted parts of chrome/views/tree_view.h to tree_model.h,
so that ATL/WTL-specific parts stay in tree_view.h, but tree_model.h
is platform-independent and can be included in files using it as base class.
Review URL: http://codereview.chromium.org/8618
Patch from Paweł Hajdan jr.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5483 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/autocomplete/autocomplete.h | 6 | ||||
-rw-r--r-- | chrome/browser/autocomplete/history_url_provider.h | 3 | ||||
-rw-r--r-- | chrome/browser/browser.scons | 10 | ||||
-rw-r--r-- | chrome/browser/history/expire_history_backend.cc | 19 | ||||
-rw-r--r-- | chrome/browser/history/expire_history_backend.h | 2 | ||||
-rw-r--r-- | chrome/browser/history/history_backend.cc | 33 | ||||
-rw-r--r-- | chrome/browser/history/history_backend.h | 3 | ||||
-rw-r--r-- | chrome/browser/template_url_parser.cc | 28 | ||||
-rw-r--r-- | chrome/browser/views/bookmark_editor_view.h | 1 |
9 files changed, 41 insertions, 64 deletions
diff --git a/chrome/browser/autocomplete/autocomplete.h b/chrome/browser/autocomplete/autocomplete.h index 71da6ef..d60167a 100644 --- a/chrome/browser/autocomplete/autocomplete.h +++ b/chrome/browser/autocomplete/autocomplete.h @@ -439,9 +439,9 @@ class AutocompleteProvider AutocompleteProvider(ACProviderListener* listener, Profile* profile, - char* name) - : listener_(listener), - profile_(profile), + const char* name) + : profile_(profile), + listener_(listener), done_(true), name_(name) { } diff --git a/chrome/browser/autocomplete/history_url_provider.h b/chrome/browser/autocomplete/history_url_provider.h index 6261a47..e8d1838 100644 --- a/chrome/browser/autocomplete/history_url_provider.h +++ b/chrome/browser/autocomplete/history_url_provider.h @@ -39,7 +39,8 @@ class HistoryBackend; // -> DoAutocomplete (for inline autocomplete) // -> URLDatabase::AutocompleteForPrefix (on in-memory DB) // -> HistoryService::ScheduleAutocomplete -// (return to controller) \ +// (return to controller) ---- +// / // HistoryBackend::ScheduleAutocomplete // -> HistoryURLProvider::ExecuteWithDB // -> DoAutocomplete diff --git a/chrome/browser/browser.scons b/chrome/browser/browser.scons index 8336af8..60f19ae 100644 --- a/chrome/browser/browser.scons +++ b/chrome/browser/browser.scons @@ -64,6 +64,9 @@ if env['PLATFORM'] in ('posix', 'win32'): 'google_url_tracker.cc', 'google_util.cc', 'history/archived_database.cc', + 'history/expire_history_backend.cc', + 'history/history_backend.cc', + 'history/history_database.cc', 'history/history_types.cc', 'history/in_memory_database.cc', 'history/in_memory_history_backend.cc', @@ -72,6 +75,7 @@ if env['PLATFORM'] in ('posix', 'win32'): 'history/text_database.cc', 'history/text_database_manager.cc', 'history/thumbnail_database.cc', + 'history/query_parser.cc', 'history/visit_database.cc', 'history/visit_tracker.cc', 'history/visitsegment_database.cc', @@ -93,6 +97,7 @@ if env['PLATFORM'] in ('posix', 'win32'): 'safe_browsing/safe_browsing_service.cc', 'safe_browsing/safe_browsing_util.cc', 'session_startup_pref.cc', + 'template_url_parser.cc', 'url_fetcher_protect.cc', 'user_metrics.cc', ]) @@ -175,12 +180,8 @@ if env['PLATFORM'] == 'win32': 'hang_monitor/hung_plugin_action.cc', 'hang_monitor/hung_window_detector.cc', 'history/download_database.cc', - 'history/expire_history_backend.cc', 'history/history.cc', - 'history/history_backend.cc', - 'history/history_database.cc', 'history/history_publisher.cc', - 'history/query_parser.cc', 'history/starred_url_database.cc', 'history/url_database.cc', 'history_model.cc', @@ -275,7 +276,6 @@ if env['PLATFORM'] == 'win32': 'template_url.cc', 'template_url_fetcher.cc', 'template_url_model.cc', - 'template_url_parser.cc', 'template_url_prepopulate_data.cc', 'toolbar_model.cc', 'url_fetcher.cc', diff --git a/chrome/browser/history/expire_history_backend.cc b/chrome/browser/history/expire_history_backend.cc index 0944b87..955b837 100644 --- a/chrome/browser/history/expire_history_backend.cc +++ b/chrome/browser/history/expire_history_backend.cc @@ -7,6 +7,7 @@ #include <algorithm> #include <limits> +#include "base/compiler_specific.h" #include "base/file_util.h" #include "chrome/browser/bookmarks/bookmark_service.h" #include "chrome/browser/history/archived_database.h" @@ -74,8 +75,7 @@ ExpireHistoryBackend::ExpireHistoryBackend( archived_db_(NULL), thumb_db_(NULL), text_db_(NULL), -#pragma warning(suppress: 4355) // Okay to pass "this" here. - factory_(this), + ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)), bookmark_service_(bookmark_service) { } @@ -297,16 +297,21 @@ URLID ExpireHistoryBackend::ArchiveOneURL(const URLRow& url_row) { return archived_db_->AddURL(url_row); } +namespace { + +struct ChangedURL { + ChangedURL() : visit_count(0), typed_count(0) {} + int visit_count; + int typed_count; +}; + +} // namespace + void ExpireHistoryBackend::ExpireURLsForVisits( const VisitVector& visits, DeleteDependencies* dependencies) { // First find all unique URLs and the number of visits we're deleting for // each one. - struct ChangedURL { - ChangedURL() : visit_count(0), typed_count(0) {} - int visit_count; - int typed_count; - }; std::map<URLID, ChangedURL> changed_urls; for (size_t i = 0; i < visits.size(); i++) { ChangedURL& cur = changed_urls[visits[i].url_id]; diff --git a/chrome/browser/history/expire_history_backend.h b/chrome/browser/history/expire_history_backend.h index 55c72c3..5d26ddc 100644 --- a/chrome/browser/history/expire_history_backend.h +++ b/chrome/browser/history/expire_history_backend.h @@ -13,11 +13,11 @@ #include "base/time.h" #include "chrome/browser/history/history_types.h" #include "chrome/browser/history/text_database_manager.h" +#include "chrome/common/notification_types.h" #include "testing/gtest/include/gtest/gtest_prod.h" class BookmarkService; class GURL; -enum NotificationType; namespace history { diff --git a/chrome/browser/history/history_backend.cc b/chrome/browser/history/history_backend.cc index d904148..fd7d465 100644 --- a/chrome/browser/history/history_backend.cc +++ b/chrome/browser/history/history_backend.cc @@ -6,6 +6,7 @@ #include <set> +#include "base/compiler_specific.h" #include "base/file_util.h" #include "base/histogram.h" #include "base/message_loop.h" @@ -78,32 +79,6 @@ static const int kMaxRedirectCount = 32; // and is archived. static const int kArchiveDaysThreshold = 90; -// Comparison used when inserting entries into visits vector. -static bool VisitOccursAfter(const PageVisit& elem1, - const PageVisit& elem2) { - return elem1.visit_time > elem2.visit_time; -} - -static bool IsMatchingHost(const URLRow& row, - const std::string& host_name) { - const GURL& url = row.url(); - if (!url.is_valid() || !url.IsStandard()) - return false; - - const std::string& spec = url.spec(); - url_parse::Parsed parsed = url.parsed_for_possibly_invalid_spec(); - if (!parsed.host.is_nonempty()) - return false; // Empty host. - - if (parsed.host.len != host_name.size()) - return false; // Hosts are different lengths, can not match. - - // TODO(brettw) we may want to also match hosts ending with a period, since - // these will typically be the same. - return strncmp(&spec[parsed.host.begin], host_name.c_str(), - host_name.size()) == 0; -} - // This task is run on a timer so that commits happen at regular intervals // so they are batched together. The important thing about this class is that // it supports canceling of the task so the reference to the backend will be @@ -195,10 +170,9 @@ HistoryBackend::HistoryBackend(const std::wstring& history_dir, BookmarkService* bookmark_service) : delegate_(delegate), history_dir_(history_dir), -#pragma warning(suppress: 4355) // OK to pass "this" here. - expirer_(this, bookmark_service), - backend_destroy_message_loop_(NULL), + ALLOW_THIS_IN_INITIALIZER_LIST(expirer_(this, bookmark_service)), recent_redirects_(kMaxRedirectCount), + backend_destroy_message_loop_(NULL), backend_destroy_task_(NULL), segment_queried_(false), bookmark_service_(bookmark_service) { @@ -620,7 +594,6 @@ std::pair<URLID, VisitID> HistoryBackend::AddPageVisit( // Update of an existing row. if (PageTransition::StripQualifier(transition) != PageTransition::RELOAD) url_info.set_visit_count(url_info.visit_count() + 1); - int old_typed_count = url_info.typed_count(); if (typed_increment) url_info.set_typed_count(url_info.typed_count() + typed_increment); url_info.set_last_visit(time); diff --git a/chrome/browser/history/history_backend.h b/chrome/browser/history/history_backend.h index a7c9310..8918742 100644 --- a/chrome/browser/history/history_backend.h +++ b/chrome/browser/history/history_backend.h @@ -262,9 +262,6 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, FRIEND_TEST(HistoryBackendTest, URLsNoLongerBookmarked); friend class TestingProfile; - // For invoking methods that circumvent requests. - friend class HistoryTest; - // Computes the name of the specified database on disk. std::wstring GetThumbnailFileName() const; std::wstring GetArchivedFileName() const; diff --git a/chrome/browser/template_url_parser.cc b/chrome/browser/template_url_parser.cc index 8c4f8be..93f9f79 100644 --- a/chrome/browser/template_url_parser.cc +++ b/chrome/browser/template_url_parser.cc @@ -93,12 +93,12 @@ class ParsingContext { ParsingContext(TemplateURLParser::ParameterFilter* parameter_filter, TemplateURL* url) - : parameter_filter_(parameter_filter), - url_(url), - is_suggest_url_(false), - derive_image_from_url_(false), + : url_(url), + parameter_filter_(parameter_filter), method_(GET), - suggestion_method_(GET) { + suggestion_method_(GET), + is_suggest_url_(false), + derive_image_from_url_(false) { if (kElementNameToElementTypeMap == NULL) InitMapping(); } @@ -145,7 +145,7 @@ class ParsingContext { void SetImageURL(const std::wstring& url) { if (current_image_.get()) { - current_image_->url = GURL(url); + current_image_->url = GURL(WideToUTF8(url)); url_->add_image_ref(*current_image_); current_image_.reset(); } @@ -197,7 +197,7 @@ class ParsingContext { void DeriveImageFromURL() { if (derive_image_from_url_ && url_->GetFavIconURL().is_empty() && url_->url()) { - GURL url(url_->url()->url()); // More url's please... + GURL url(WideToUTF8(url_->url()->url())); // More url's please... url_->SetFavIconURL(TemplateURL::GenerateFaviconURL(url)); } } @@ -310,9 +310,9 @@ void ParseURL(const xmlChar** atts, ParsingContext* context) { } else if (name == kURLTemplateAttribute) { template_url = XMLCharToWide(value); } else if (name == kURLIndexOffsetAttribute) { - index_offset = std::max(1, _wtoi(XMLCharToWide(value).c_str())); + index_offset = std::max(1, StringToInt(XMLCharToWide(value))); } else if (name == kURLPageOffsetAttribute) { - page_offset = std::max(1, _wtoi(XMLCharToWide(value).c_str())); + page_offset = std::max(1, StringToInt(XMLCharToWide(value))); } else if (name == kParamMethodAttribute) { is_post = LowerCaseEqualsASCII(XMLCharToString(value), "post"); } @@ -345,9 +345,9 @@ void ParseImage(const xmlChar** atts, ParsingContext* context) { if (name == kImageTypeAttribute) { type = XMLCharToWide(value); } else if (name == kImageWidthAttribute) { - width = _wtoi(XMLCharToWide(value).c_str()); + width = StringToInt(XMLCharToWide(value)); } else if (name == kImageHeightAttribute) { - height = _wtoi(XMLCharToWide(value).c_str()); + height = StringToInt(XMLCharToWide(value)); } attributes += 2; } @@ -401,7 +401,7 @@ void ProcessURLParams(ParsingContext* context) { if (!context->parameter_filter() && context->extra_params().empty()) return; - GURL url(t_url_ref->url()); + GURL url(WideToUTF8(t_url_ref->url())); // If there is a parameter filter, parse the existing URL and remove any // unwanted parameter. TemplateURLParser::ParameterFilter* filter = context->parameter_filter(); @@ -481,7 +481,7 @@ void EndElementImpl(void *ctx, const xmlChar *name) { context->template_url()->set_description(context->GetString()); break; case ParsingContext::IMAGE: { - GURL image_url(context->GetString()); + GURL image_url(WideToUTF8(context->GetString())); if (image_url.SchemeIs("data")) { // TODO (jcampan): bug 1169256: when dealing with data URL, we need to // decode the data URL in the renderer. For now, we'll just point to the @@ -522,7 +522,7 @@ void CharactersImpl(void *ctx, const xmlChar *ch, int len) { bool IsHTTPRef(const TemplateURLRef* ref) { if (ref == NULL) return true; - GURL url(ref->url()); + GURL url(WideToUTF8(ref->url())); return (url.is_valid() && (url.SchemeIs("http") || url.SchemeIs("https"))); } diff --git a/chrome/browser/views/bookmark_editor_view.h b/chrome/browser/views/bookmark_editor_view.h index 2cd4b01..629e6ab 100644 --- a/chrome/browser/views/bookmark_editor_view.h +++ b/chrome/browser/views/bookmark_editor_view.h @@ -14,6 +14,7 @@ #include "chrome/views/native_button.h" #include "chrome/views/text_field.h" #include "chrome/views/tree_node_model.h" +#include "chrome/views/tree_view.h" namespace views { class Window; |