diff options
author | brg@chromium.com <brg@chromium.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-07 23:18:04 +0000 |
---|---|---|
committer | brg@chromium.com <brg@chromium.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-07 23:18:04 +0000 |
commit | 4f8b87a4c6d06ebad053160a61fc90492afc8439 (patch) | |
tree | 7e5aa7e40c9462cf1dea2a7f91994913b748faa0 | |
parent | cd79040ec825dbb60f89a7607da6099a74cbfc3a (diff) | |
download | chromium_src-4f8b87a4c6d06ebad053160a61fc90492afc8439.zip chromium_src-4f8b87a4c6d06ebad053160a61fc90492afc8439.tar.gz chromium_src-4f8b87a4c6d06ebad053160a61fc90492afc8439.tar.bz2 |
Removed lint problems. NO funcationality changes.
Review URL: http://codereview.chromium.org/10219
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5031 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/importer/toolbar_importer.cc | 52 | ||||
-rw-r--r-- | chrome/browser/importer/toolbar_importer.h | 22 | ||||
-rw-r--r-- | chrome/browser/importer/toolbar_importer_unittest.cc | 70 |
3 files changed, 71 insertions, 73 deletions
diff --git a/chrome/browser/importer/toolbar_importer.cc b/chrome/browser/importer/toolbar_importer.cc index e96435f..54f75d6 100644 --- a/chrome/browser/importer/toolbar_importer.cc +++ b/chrome/browser/importer/toolbar_importer.cc @@ -107,13 +107,13 @@ void Toolbar5Importer::Cancel() { // In the case when the thread is not importing messages we are to // cancel as soon as possible. Importer::Cancel(); - - // If we are conducting network operations, post a message to the importer + + // If we are conducting network operations, post a message to the importer // thread for synchronization. if (NULL != delagate_loop_) { if (delagate_loop_ != MessageLoop::current()) { delagate_loop_->PostTask( - FROM_HERE, + FROM_HERE, NewRunnableMethod(this, &Toolbar5Importer::Cancel)); } else { EndImport(); @@ -132,7 +132,7 @@ void Toolbar5Importer::OnURLFetchComplete( EndImport(); return; } - + if (200 != response_code) { // HTTP/Ok // Display to the user an error dialog and cancel the import EndImportBookmarks(false); @@ -207,7 +207,7 @@ void Toolbar5Importer::GetAuthenticationFromServer() { EndImport(); return; } - + // Authentication is a token string retreived from the authentication server // To access it we call the url below with a random number replacing the // value in the string. @@ -234,7 +234,7 @@ void Toolbar5Importer::GetBookmarkDataFromServer(const std::string& response) { EndImport(); return; } - + state_ = GET_BOOKMARKS; // Parse and verify the authorization token from the response. @@ -268,9 +268,9 @@ void Toolbar5Importer::GetBookmarsFromServerDataResponse( EndImport(); return; } - + state_ = PARSE_BOOKMARKS; - + bool retval = false; XmlReader reader; if (reader.Load(response) && !cancelled()) { @@ -285,7 +285,7 @@ void Toolbar5Importer::GetBookmarsFromServerDataResponse( bool Toolbar5Importer::ParseAuthenticationTokenResponse( const std::string& response, std::string* token) { - DCHECK(token); + DCHECK(token); *token = response; size_t position = token->find(kAuthorizationTokenPrefix); @@ -322,14 +322,14 @@ bool Toolbar5Importer::ParseBookmarksFromReader( return false; // Parse each |bookmark| blob - while (LocateNextTagWithStopByName(reader, kBookmarkXmlTag, + while (LocateNextTagWithStopByName(reader, kBookmarkXmlTag, kBookmarksXmlTag)) { ProfileWriter::BookmarkEntry bookmark_entry; std::vector<BOOKMARK_FOLDER> folders; if (ExtractBookmarkInformation(reader, &bookmark_entry, &folders)) { // For each folder we create a new bookmark entry. Duplicates will // be detected whence we attempt to creaete the bookmark in the profile. - for(std::vector<BOOKMARK_FOLDER>::iterator folder = folders.begin(); + for (std::vector<BOOKMARK_FOLDER>::iterator folder = folders.begin(); folder != folders.end(); ++folder) { bookmark_entry.path = *folder; @@ -347,7 +347,7 @@ bool Toolbar5Importer::ParseBookmarksFromReader( bool Toolbar5Importer::LocateNextOpenTag(XmlReader* reader) { DCHECK(reader); - while(!reader->SkipToElement()) { + while (!reader->SkipToElement()) { if (!reader->Read()) return false; } @@ -374,12 +374,12 @@ bool Toolbar5Importer::LocateNextTagWithStopByName(XmlReader* reader, DCHECK_NE(tag, stop); // Locate the |tag| blob. while (tag != reader->NodeName()) { - // move to the next open tag - if (!reader->Read() || !LocateNextOpenTag(reader)) - return false; - // if we encounter the stop word return false - if (stop == reader->NodeName()) - return false; + // Move to the next open tag. + if (!reader->Read() || !LocateNextOpenTag(reader)) + return false; + // If we encounter the stop word return false. + if (stop == reader->NodeName()) + return false; } return true; } @@ -516,12 +516,12 @@ bool Toolbar5Importer::ExtractFoldersFromXmlReader( // labels for any one bookmark. if (!LocateNextTagWithStopByName(reader, kLabelsXmlTag, kAttributesXmlTag)) return false; - + // It is within scope to have an empty labels section, so we do not // return false if the labels are empty. if (!reader->Read() || !LocateNextOpenTag(reader)) return false; - + std::vector<std::wstring> label_vector; while (kLabelXmlTag == reader->NodeName()) { std::string label_buffer; @@ -537,7 +537,7 @@ bool Toolbar5Importer::ExtractFoldersFromXmlReader( bookmark_folders->resize(1); (*bookmark_folders)[0].push_back( l10n_util::GetString(IDS_BOOKMARK_GROUP_FROM_GOOGLE_TOOLBAR)); - } + } return true; } @@ -546,15 +546,15 @@ bool Toolbar5Importer::ExtractFoldersFromXmlReader( for (size_t index = 0; index < label_vector.size(); ++index) { // If this is the first run then we place favorites with no labels - // in the title bar. Else they are placed in the "Google Toolbar" folder. + // in the title bar. Else they are placed in the "Google Toolbar" folder. if (!FirstRun::IsChromeFirstRun() || !label_vector[index].empty()) { (*bookmark_folders)[index].push_back( l10n_util::GetString(IDS_BOOKMARK_GROUP_FROM_GOOGLE_TOOLBAR)); } - - // If the label and is in the form "xxx:yyy:zzz" this was created from an - // IE or Firefox folder. We undo the label creation and recreate the correct - // folder. + + // If the label and is in the form "xxx:yyy:zzz" this was created from an + // IE or Firefox folder. We undo the label creation and recreate the + // correct folder. std::vector<std::wstring> folder_names; SplitString(label_vector[index], L':', &folder_names); (*bookmark_folders)[index].insert((*bookmark_folders)[index].end(), diff --git a/chrome/browser/importer/toolbar_importer.h b/chrome/browser/importer/toolbar_importer.h index 1b82655..eb2e5f8 100644 --- a/chrome/browser/importer/toolbar_importer.h +++ b/chrome/browser/importer/toolbar_importer.h @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// The functionality provided here allows the user to import their bookmarks -// (favorites) from Google Toolbar. +// The functionality provided here allows the user to import their bookmarks +// (favorites) from Google Toolbar. // -// Currently the only configuration information we need is to check whether or +// Currently the only configuration information we need is to check whether or // not the user currently has their GAIA cookie. This is done by the functions // exposed through the ToolbarImportUtils namespace. // @@ -13,8 +13,8 @@ // communicate with the Google Toolbar v5 front-end, negotiate the download of // Toolbar bookmarks, parse them, and install them on the client. -#ifndef CHROME_BROWSER_IMPORTER_TOOLBAR_IMPROTER_H__ -#define CHROME_BROWSER_IMPORTER_TOOLBAR_IMPROTER_H__ +#ifndef CHROME_BROWSER_IMPORTER_TOOLBAR_IMPORTER_H__ +#define CHROME_BROWSER_IMPORTER_TOOLBAR_IMPORTER_H__ #include <string> #include <vector> @@ -25,10 +25,8 @@ class XmlReader; namespace ToolbarImporterUtils { - bool IsGoogleGAIACookieInstalled(); - -}; +} // namespace ToolbarImporterUtils class Toolbar5Importer : public URLFetcher::Delegate, public Importer { @@ -58,7 +56,7 @@ class Toolbar5Importer : public URLFetcher::Delegate, private: FRIEND_TEST(Toolbar5ImporterTest, BookmarkParse); - + // Internal state enum INTERNAL_STATE { NOT_USED = -1, @@ -117,8 +115,8 @@ class Toolbar5Importer : public URLFetcher::Delegate, static bool LocateNextOpenTag(XmlReader* reader); static bool LocateNextTagByName(XmlReader* reader, const std::string& tag); static bool LocateNextTagWithStopByName( - XmlReader* reader, - const std::string& tag, + XmlReader* reader, + const std::string& tag, const std::string& stop); static bool ExtractBookmarkInformation( @@ -158,4 +156,4 @@ class Toolbar5Importer : public URLFetcher::Delegate, DISALLOW_COPY_AND_ASSIGN(Toolbar5Importer); }; -#endif // CHROME_BROWSER_IMPORTER_TOOLBAR_IMPROTER_H__ +#endif // CHROME_BROWSER_IMPORTER_TOOLBAR_IMPORTER_H__ diff --git a/chrome/browser/importer/toolbar_importer_unittest.cc b/chrome/browser/importer/toolbar_importer_unittest.cc index b2b2e3b..8c291d0 100644 --- a/chrome/browser/importer/toolbar_importer_unittest.cc +++ b/chrome/browser/importer/toolbar_importer_unittest.cc @@ -289,7 +289,7 @@ static const std::string kBadBookMarkNoLabels = "<attribute> <name>section_name</name> <value>My section 0 " "</value> </attribute> </attributes> " "</bookmark> </bookmarks>"; -} +} // namespace toolbar_importer_unittest // Since the above is very dense to read I enumerate the test cases here. // 1. Correct bookmark structure with one label @@ -326,12 +326,12 @@ TEST(Toolbar5ImporterTest, BookmarkParse) { &bookmarks)); // verificaiton - EXPECT_TRUE(bookmarks.size() == 1); + EXPECT_EQ(bookmarks.size(), 1); EXPECT_FALSE(bookmarks[0].in_toolbar); - EXPECT_TRUE(toolbar_importer_unittest::kTitle == bookmarks[0].title); - EXPECT_TRUE(url == bookmarks[0].url); - EXPECT_TRUE(2 == bookmarks[0].path.size()); - EXPECT_TRUE(toolbar_importer_unittest::kFolder == bookmarks[0].path[1]); + EXPECT_EQ(toolbar_importer_unittest::kTitle, bookmarks[0].title); + EXPECT_EQ(url, bookmarks[0].url); + EXPECT_EQ(2, bookmarks[0].path.size()); + EXPECT_EQ(toolbar_importer_unittest::kFolder, bookmarks[0].path[1]); // Test case 2 - No labels bookmarks.clear(); @@ -341,11 +341,11 @@ TEST(Toolbar5ImporterTest, BookmarkParse) { &bookmarks)); // verificaiton - EXPECT_TRUE(bookmarks.size() == 1); + EXPECT_EQ(bookmarks.size(), 1); EXPECT_FALSE(bookmarks[0].in_toolbar); - EXPECT_TRUE(toolbar_importer_unittest::kTitle == bookmarks[0].title); - EXPECT_TRUE(bookmarks[0].url == url); - EXPECT_TRUE(1 == bookmarks[0].path.size()); + EXPECT_EQ(toolbar_importer_unittest::kTitle, bookmarks[0].title); + EXPECT_EQ(bookmarks[0].url, url); + EXPECT_EQ(1, bookmarks[0].path.size()); // Test case 3 - Two labels bookmarks.clear(); @@ -355,15 +355,15 @@ TEST(Toolbar5ImporterTest, BookmarkParse) { &bookmarks)); // verificaiton - EXPECT_TRUE(2 == bookmarks.size()); + EXPECT_EQ(2, bookmarks.size()); EXPECT_FALSE(bookmarks[0].in_toolbar); EXPECT_FALSE(bookmarks[1].in_toolbar); - EXPECT_TRUE(toolbar_importer_unittest::kTitle == bookmarks[0].title); - EXPECT_TRUE(toolbar_importer_unittest::kTitle == bookmarks[1].title); - EXPECT_TRUE(bookmarks[0].url == url); - EXPECT_TRUE(bookmarks[1].url == url); - EXPECT_TRUE(toolbar_importer_unittest::kFolder == bookmarks[0].path[1]); - EXPECT_TRUE(toolbar_importer_unittest::kFolder2 == bookmarks[1].path[1]); + EXPECT_EQ(toolbar_importer_unittest::kTitle, bookmarks[0].title); + EXPECT_EQ(toolbar_importer_unittest::kTitle, bookmarks[1].title); + EXPECT_EQ(bookmarks[0].url, url); + EXPECT_EQ(bookmarks[1].url, url); + EXPECT_EQ(toolbar_importer_unittest::kFolder, bookmarks[0].path[1]); + EXPECT_EQ(toolbar_importer_unittest::kFolder2, bookmarks[1].path[1]); // Test case 4 - Label with a colon (file name translation). bookmarks.clear(); @@ -373,11 +373,11 @@ TEST(Toolbar5ImporterTest, BookmarkParse) { &bookmarks)); // verificaiton - EXPECT_TRUE(bookmarks.size() == 1); + EXPECT_EQ(bookmarks.size(), 1); EXPECT_FALSE(bookmarks[0].in_toolbar); - EXPECT_TRUE(toolbar_importer_unittest::kTitle == bookmarks[0].title); - EXPECT_TRUE(bookmarks[0].url == url); - EXPECT_TRUE(4 == bookmarks[0].path.size()); + EXPECT_EQ(toolbar_importer_unittest::kTitle, bookmarks[0].title); + EXPECT_EQ(bookmarks[0].url, url); + EXPECT_EQ(4, bookmarks[0].path.size()); EXPECT_TRUE(toolbar_importer_unittest::kFolderArray[0] == bookmarks[0].path[1]); EXPECT_TRUE(toolbar_importer_unittest::kFolderArray[1] == @@ -393,12 +393,12 @@ TEST(Toolbar5ImporterTest, BookmarkParse) { &bookmarks)); // verificaiton - EXPECT_TRUE(1 == bookmarks.size()); + EXPECT_EQ(1, bookmarks.size()); EXPECT_FALSE(bookmarks[0].in_toolbar); - EXPECT_TRUE(toolbar_importer_unittest::kTitle == bookmarks[0].title); - EXPECT_TRUE(bookmarks[0].url == url); - EXPECT_TRUE(2 == bookmarks[0].path.size()); - EXPECT_TRUE(toolbar_importer_unittest::kFolder == bookmarks[0].path[1]); + EXPECT_EQ(toolbar_importer_unittest::kTitle, bookmarks[0].title); + EXPECT_EQ(bookmarks[0].url, url); + EXPECT_EQ(2, bookmarks[0].path.size()); + EXPECT_EQ(toolbar_importer_unittest::kFolder, bookmarks[0].path[1]); // Test case 6 - Two bookmarks bookmarks.clear(); @@ -408,17 +408,17 @@ TEST(Toolbar5ImporterTest, BookmarkParse) { &bookmarks)); // verificaiton - EXPECT_TRUE(2 == bookmarks.size()); + EXPECT_EQ(2, bookmarks.size()); EXPECT_FALSE(bookmarks[0].in_toolbar); EXPECT_FALSE(bookmarks[1].in_toolbar); - EXPECT_TRUE(toolbar_importer_unittest::kTitle == bookmarks[0].title); - EXPECT_TRUE(toolbar_importer_unittest::kOtherTitle == bookmarks[1].title); - EXPECT_TRUE(bookmarks[0].url == url); - EXPECT_TRUE(bookmarks[1].url == other_url); - EXPECT_TRUE(2 == bookmarks[0].path.size()); - EXPECT_TRUE(toolbar_importer_unittest::kFolder == bookmarks[0].path[1]); - EXPECT_TRUE(2 == bookmarks[0].path.size()); - EXPECT_TRUE(toolbar_importer_unittest::kOtherFolder == bookmarks[1].path[1]); + EXPECT_EQ(toolbar_importer_unittest::kTitle, bookmarks[0].title); + EXPECT_EQ(toolbar_importer_unittest::kOtherTitle, bookmarks[1].title); + EXPECT_EQ(bookmarks[0].url, url); + EXPECT_EQ(bookmarks[1].url, other_url); + EXPECT_EQ(2, bookmarks[0].path.size()); + EXPECT_EQ(toolbar_importer_unittest::kFolder, bookmarks[0].path[1]); + EXPECT_EQ(2, bookmarks[0].path.size()); + EXPECT_EQ(toolbar_importer_unittest::kOtherFolder, bookmarks[1].path[1]); // Test case 7 - Empty string bookmarks.clear(); |