Merge from Chromium at DEPS revision r213605
This commit was generated by merge_to_master.py.
Change-Id: I5ef9e03bf077dac295a7904f06b3cb6dec9fe213
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index ca66678..9879d13 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -715,7 +715,8 @@
IDS_FLAGS_ENABLE_QUIC_HTTPS_NAME,
IDS_FLAGS_ENABLE_QUIC_HTTPS_DESCRIPTION,
kOsAll,
- SINGLE_VALUE_TYPE(switches::kEnableQuicHttps)
+ ENABLE_DISABLE_VALUE_TYPE(switches::kEnableQuicHttps,
+ switches::kDisableQuicHttps)
},
{
"enable-spdy4a2",
@@ -1323,6 +1324,15 @@
},
#endif
{
+ "scroll-end-effect",
+ IDS_FLAGS_SCROLL_END_EFFECT_NAME,
+ IDS_FLAGS_SCROLL_END_EFFECT_DESCRIPTION,
+ kOsCrOS,
+ ENABLE_DISABLE_VALUE_TYPE_AND_VALUE(
+ switches::kScrollEndEffect, "1",
+ switches::kScrollEndEffect, "0")
+ },
+ {
"enable-touch-drag-drop",
IDS_FLAGS_ENABLE_TOUCH_DRAG_DROP_NAME,
IDS_FLAGS_ENABLE_TOUCH_DRAG_DROP_DESCRIPTION,
diff --git a/chrome/browser/android/crash_dump_manager.cc b/chrome/browser/android/crash_dump_manager.cc
index de2923e..5604f68 100644
--- a/chrome/browser/android/crash_dump_manager.cc
+++ b/chrome/browser/android/crash_dump_manager.cc
@@ -10,7 +10,7 @@
#include "base/logging.h"
#include "base/path_service.h"
#include "base/posix/global_descriptors.h"
-#include "base/process.h"
+#include "base/process/process.h"
#include "base/rand_util.h"
#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
diff --git a/chrome/browser/android/crash_dump_manager.h b/chrome/browser/android/crash_dump_manager.h
index 0c25a89..16c24a0 100644
--- a/chrome/browser/android/crash_dump_manager.h
+++ b/chrome/browser/android/crash_dump_manager.h
@@ -9,7 +9,7 @@
#include "base/files/file_path.h"
#include "base/platform_file.h"
-#include "base/process.h"
+#include "base/process/process.h"
#include "base/synchronization/lock.h"
#include "content/public/browser/browser_child_process_observer.h"
#include "content/public/browser/notification_observer.h"
diff --git a/chrome/browser/autocomplete/extension_app_provider_unittest.cc b/chrome/browser/autocomplete/extension_app_provider_unittest.cc
index f9eec44..7ccafc2 100644
--- a/chrome/browser/autocomplete/extension_app_provider_unittest.cc
+++ b/chrome/browser/autocomplete/extension_app_provider_unittest.cc
@@ -42,7 +42,7 @@
void ExtensionAppProviderTest::SetUp() {
profile_.reset(new TestingProfile());
- profile_->CreateHistoryService(true, false);
+ ASSERT_TRUE(profile_->CreateHistoryService(true, false));
profile_->BlockUntilHistoryProcessesPendingRequests();
history_service_ =
HistoryServiceFactory::GetForProfile(profile_.get(),
diff --git a/chrome/browser/autocomplete/history_quick_provider_unittest.cc b/chrome/browser/autocomplete/history_quick_provider_unittest.cc
index fe50366..3b203cc 100644
--- a/chrome/browser/autocomplete/history_quick_provider_unittest.cc
+++ b/chrome/browser/autocomplete/history_quick_provider_unittest.cc
@@ -151,7 +151,7 @@
void HistoryQuickProviderTest::SetUp() {
profile_.reset(new TestingProfile());
- profile_->CreateHistoryService(true, false);
+ ASSERT_TRUE(profile_->CreateHistoryService(true, false));
profile_->CreateBookmarkModel(true);
ui_test_utils::WaitForBookmarkModelToLoad(profile_.get());
profile_->BlockUntilHistoryIndexIsRefreshed();
@@ -212,7 +212,7 @@
// Mark the most recent |cur.typed_count| visits as typed.
std::string sql_cmd_line = base::StringPrintf(
"INSERT INTO \"visits\" VALUES(%" PRIuS ", %" PRIuS ", %" PRId64
- ", 0, %d, 0, 0, 1)",
+ ", 0, %d, 0, 1)",
visit_id++, i + 1, visit_time.ToInternalValue(),
(j < cur.typed_count) ? content::PAGE_TRANSITION_TYPED :
content::PAGE_TRANSITION_LINK);
diff --git a/chrome/browser/autocomplete/history_url_provider_unittest.cc b/chrome/browser/autocomplete/history_url_provider_unittest.cc
index b26c9a0..0138751 100644
--- a/chrome/browser/autocomplete/history_url_provider_unittest.cc
+++ b/chrome/browser/autocomplete/history_url_provider_unittest.cc
@@ -152,12 +152,12 @@
// testing::Test
virtual void SetUp() {
- SetUpImpl(false);
+ ASSERT_TRUE(SetUpImpl(false));
}
virtual void TearDown();
// Does the real setup.
- void SetUpImpl(bool no_db);
+ bool SetUpImpl(bool no_db) WARN_UNUSED_RESULT;
// Fills test data into the history system.
void FillData();
@@ -195,7 +195,7 @@
class HistoryURLProviderTestNoDB : public HistoryURLProviderTest {
protected:
virtual void SetUp() {
- SetUpImpl(true);
+ ASSERT_TRUE(SetUpImpl(true));
}
};
@@ -204,9 +204,10 @@
base::MessageLoop::current()->Quit();
}
-void HistoryURLProviderTest::SetUpImpl(bool no_db) {
+bool HistoryURLProviderTest::SetUpImpl(bool no_db) {
profile_.reset(new TestingProfile());
- profile_->CreateHistoryService(true, no_db);
+ if (!(profile_->CreateHistoryService(true, no_db)))
+ return false;
if (!no_db) {
profile_->BlockUntilHistoryProcessesPendingRequests();
profile_->BlockUntilHistoryIndexIsRefreshed();
@@ -219,6 +220,7 @@
TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
profile_.get(), &HistoryURLProviderTest::CreateTemplateURLService);
FillData();
+ return true;
}
void HistoryURLProviderTest::TearDown() {
diff --git a/chrome/browser/autocomplete/search_provider_unittest.cc b/chrome/browser/autocomplete/search_provider_unittest.cc
index 4aeb1c1..ef4bfa4 100644
--- a/chrome/browser/autocomplete/search_provider_unittest.cc
+++ b/chrome/browser/autocomplete/search_provider_unittest.cc
@@ -183,7 +183,7 @@
test_factory_.set_remove_fetcher_on_delete(true);
// We need both the history service and template url model loaded.
- profile_.CreateHistoryService(true, false);
+ ASSERT_TRUE(profile_.CreateHistoryService(true, false));
TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
&profile_, &TemplateURLServiceFactory::BuildInstanceFor);
diff --git a/chrome/browser/autocomplete/shortcuts_provider_unittest.cc b/chrome/browser/autocomplete/shortcuts_provider_unittest.cc
index 735313b..bd700aa 100644
--- a/chrome/browser/autocomplete/shortcuts_provider_unittest.cc
+++ b/chrome/browser/autocomplete/shortcuts_provider_unittest.cc
@@ -179,7 +179,7 @@
&profile_, &ShortcutsBackendFactory::BuildProfileNoDatabaseForTesting);
backend_ = ShortcutsBackendFactory::GetForProfile(&profile_);
ASSERT_TRUE(backend_.get());
- profile_.CreateHistoryService(true, false);
+ ASSERT_TRUE(profile_.CreateHistoryService(true, false));
provider_ = new ShortcutsProvider(this, &profile_);
FillData(shortcut_test_db, arraysize(shortcut_test_db));
}
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index 316ccc0..0793da1 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -18,7 +18,6 @@
#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
#include "base/prefs/pref_service.h"
-#include "base/process_util.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index ea10c51..55b25f9 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -18,8 +18,8 @@
#include "base/json/string_escape.h"
#include "base/path_service.h"
#include "base/prefs/pref_service.h"
-#include "base/process.h"
-#include "base/process_util.h"
+#include "base/process/process.h"
+#include "base/process/process_iterator.h"
#include "base/sequenced_task_runner.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
diff --git a/chrome/browser/bookmarks/bookmark_html_writer_unittest.cc b/chrome/browser/bookmarks/bookmark_html_writer_unittest.cc
index b9c7bed..8f532bc 100644
--- a/chrome/browser/bookmarks/bookmark_html_writer_unittest.cc
+++ b/chrome/browser/bookmarks/bookmark_html_writer_unittest.cc
@@ -148,7 +148,7 @@
content::TestBrowserThreadBundle thread_bundle;
TestingProfile profile;
- profile.CreateHistoryService(true, false);
+ ASSERT_TRUE(profile.CreateHistoryService(true, false));
profile.BlockUntilHistoryProcessesPendingRequests();
profile.CreateFaviconService();
profile.CreateBookmarkModel(true);
diff --git a/chrome/browser/bookmarks/bookmark_index_unittest.cc b/chrome/browser/bookmarks/bookmark_index_unittest.cc
index 724b6c8..caef831 100644
--- a/chrome/browser/bookmarks/bookmark_index_unittest.cc
+++ b/chrome/browser/bookmarks/bookmark_index_unittest.cc
@@ -236,7 +236,7 @@
content::TestBrowserThreadBundle thread_bundle;
TestingProfile profile;
- profile.CreateHistoryService(true, false);
+ ASSERT_TRUE(profile.CreateHistoryService(true, false));
profile.BlockUntilHistoryProcessesPendingRequests();
profile.CreateBookmarkModel(true);
diff --git a/chrome/browser/bookmarks/bookmark_model_unittest.cc b/chrome/browser/bookmarks/bookmark_model_unittest.cc
index 06610d7..65f5c65 100644
--- a/chrome/browser/bookmarks/bookmark_model_unittest.cc
+++ b/chrome/browser/bookmarks/bookmark_model_unittest.cc
@@ -910,15 +910,6 @@
ui_test_utils::WaitForBookmarkModelToLoad(bb_model_);
}
- // Destroys the current profile, creates a new one and creates the history
- // service.
- void RecreateProfile() {
- // Need to shutdown the old one before creating a new one.
- profile_.reset(NULL);
- profile_.reset(new TestingProfile());
- profile_->CreateHistoryService(true, false);
- }
-
// The profile.
scoped_ptr<TestingProfile> profile_;
BookmarkModel* bb_model_;
@@ -954,7 +945,7 @@
profile_.reset(NULL);
profile_.reset(new TestingProfile());
profile_->CreateBookmarkModel(true);
- profile_->CreateHistoryService(true, false);
+ ASSERT_TRUE(profile_->CreateHistoryService(true, false));
BlockTillBookmarkModelLoaded();
TestNode bbn;
diff --git a/chrome/browser/browser_about_handler.h b/chrome/browser/browser_about_handler.h
index efc2c70..640101d 100644
--- a/chrome/browser/browser_about_handler.h
+++ b/chrome/browser/browser_about_handler.h
@@ -9,7 +9,7 @@
#include <string>
#include <vector>
-#include "base/process.h"
+#include "base/process/process.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h" // USE_TCMALLOC
diff --git a/chrome/browser/browser_process_platform_part_aurawin.cc b/chrome/browser/browser_process_platform_part_aurawin.cc
index 34813a6..068a3ee 100644
--- a/chrome/browser/browser_process_platform_part_aurawin.cc
+++ b/chrome/browser/browser_process_platform_part_aurawin.cc
@@ -6,7 +6,7 @@
#include "base/command_line.h"
#include "base/logging.h"
-#include "base/process_util.h"
+#include "base/process/kill.h"
#include "base/win/windows_version.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/metro_viewer/chrome_metro_viewer_process_host_aurawin.h"
diff --git a/chrome/browser/browser_shutdown.cc b/chrome/browser/browser_shutdown.cc
index 5dc8651..bfbe171 100644
--- a/chrome/browser/browser_shutdown.cc
+++ b/chrome/browser/browser_shutdown.cc
@@ -15,7 +15,6 @@
#include "base/path_service.h"
#include "base/prefs/pref_registry_simple.h"
#include "base/prefs/pref_service.h"
-#include "base/process_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/threading/thread.h"
diff --git a/chrome/browser/browsing_data/browsing_data_remover.cc b/chrome/browser/browsing_data/browsing_data_remover.cc
index 15b8959..1eb406a 100644
--- a/chrome/browser/browsing_data/browsing_data_remover.cc
+++ b/chrome/browser/browsing_data/browsing_data_remover.cc
@@ -849,8 +849,10 @@
void BrowsingDataRemover::ClearShaderCacheOnUIThread() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- BrowserContext::GetDefaultStoragePartition(profile_)->AsyncClearDataBetween(
- content::StoragePartition::kShaderStorage, delete_begin_, delete_end_,
+ BrowserContext::GetDefaultStoragePartition(profile_)->ClearDataForRange(
+ content::StoragePartition::REMOVE_DATA_MASK_SHADER_CACHE,
+ content::StoragePartition::kAllStorage,
+ delete_begin_, delete_end_,
base::Bind(&BrowsingDataRemover::ClearedShaderCache,
base::Unretained(this)));
}
diff --git a/chrome/browser/browsing_data/browsing_data_remover_unittest.cc b/chrome/browser/browsing_data/browsing_data_remover_unittest.cc
index fc758e4..b0746c2 100644
--- a/chrome/browser/browsing_data/browsing_data_remover_unittest.cc
+++ b/chrome/browser/browsing_data/browsing_data_remover_unittest.cc
@@ -331,11 +331,14 @@
class RemoveHistoryTester {
public:
- explicit RemoveHistoryTester(TestingProfile* profile)
- : query_url_success_(false) {
- profile->CreateHistoryService(true, false);
+ RemoveHistoryTester() : query_url_success_(false), history_service_(NULL) {}
+
+ bool Init(TestingProfile* profile) WARN_UNUSED_RESULT {
+ if (!profile->CreateHistoryService(true, false))
+ return false;
history_service_ = HistoryServiceFactory::GetForProfile(
profile, Profile::EXPLICIT_ACCESS);
+ return true;
}
// Returns true, if the given URL exists in the history service.
@@ -824,7 +827,8 @@
}
TEST_F(BrowsingDataRemoverTest, RemoveHistoryForever) {
- RemoveHistoryTester tester(GetProfile());
+ RemoveHistoryTester tester;
+ ASSERT_TRUE(tester.Init(GetProfile()));
tester.AddHistory(kOrigin1, base::Time::Now());
ASSERT_TRUE(tester.HistoryContainsURL(kOrigin1));
@@ -838,7 +842,8 @@
}
TEST_F(BrowsingDataRemoverTest, RemoveHistoryForLastHour) {
- RemoveHistoryTester tester(GetProfile());
+ RemoveHistoryTester tester;
+ ASSERT_TRUE(tester.Init(GetProfile()));
base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2);
@@ -860,7 +865,8 @@
// here.
#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
TEST_F(BrowsingDataRemoverTest, RemoveHistoryProhibited) {
- RemoveHistoryTester tester(GetProfile());
+ RemoveHistoryTester tester;
+ ASSERT_TRUE(tester.Init(GetProfile()));
PrefService* prefs = GetProfile()->GetPrefs();
prefs->SetBoolean(prefs::kAllowDeletingBrowserHistory, false);
@@ -884,7 +890,8 @@
TEST_F(BrowsingDataRemoverTest, RemoveMultipleTypes) {
// Add some history.
- RemoveHistoryTester history_tester(GetProfile());
+ RemoveHistoryTester history_tester;
+ ASSERT_TRUE(history_tester.Init(GetProfile()));
history_tester.AddHistory(kOrigin1, base::Time::Now());
ASSERT_TRUE(history_tester.HistoryContainsURL(kOrigin1));
@@ -913,7 +920,8 @@
prefs->SetBoolean(prefs::kAllowDeletingBrowserHistory, false);
// Add some history.
- RemoveHistoryTester history_tester(GetProfile());
+ RemoveHistoryTester history_tester;
+ ASSERT_TRUE(history_tester.Init(GetProfile()));
history_tester.AddHistory(kOrigin1, base::Time::Now());
ASSERT_TRUE(history_tester.HistoryContainsURL(kOrigin1));
@@ -1286,7 +1294,8 @@
}
TEST_F(BrowsingDataRemoverTest, OriginBasedHistoryRemoval) {
- RemoveHistoryTester tester(GetProfile());
+ RemoveHistoryTester tester;
+ ASSERT_TRUE(tester.Init(GetProfile()));
base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2);
@@ -1307,7 +1316,8 @@
}
TEST_F(BrowsingDataRemoverTest, OriginAndTimeBasedHistoryRemoval) {
- RemoveHistoryTester tester(GetProfile());
+ RemoveHistoryTester tester;
+ ASSERT_TRUE(tester.Init(GetProfile()));
base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2);
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc
index 5d316ee..19c1690 100644
--- a/chrome/browser/chrome_browser_main.cc
+++ b/chrome/browser/chrome_browser_main.cc
@@ -25,8 +25,7 @@
#include "base/prefs/pref_registry_simple.h"
#include "base/prefs/pref_service.h"
#include "base/prefs/pref_value_store.h"
-#include "base/process_info.h"
-#include "base/process_util.h"
+#include "base/process/process_info.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h"
@@ -82,6 +81,7 @@
#include "chrome/browser/pref_service_flags_storage.h"
#include "chrome/browser/prefs/chrome_pref_service_factory.h"
#include "chrome/browser/prefs/command_line_pref_store.h"
+#include "chrome/browser/prefs/pref_metrics_service.h"
#include "chrome/browser/prefs/scoped_user_pref_update.h"
#include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h"
#include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.h"
@@ -1522,6 +1522,9 @@
NaClProcessHost::EarlyStartup(new NaClBrowserDelegateImpl);
#endif
+ // Make sure initial prefs are recorded
+ PrefMetricsService::Factory::GetForProfile(profile_);
+
PreBrowserStart();
// Instantiate the notification UI manager, as this triggers a perf timer
@@ -1687,10 +1690,11 @@
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
chrome_extra_parts_[i]->PostMainMessageLoopRun();
- // TranslateManager's URL fetchers should be destructed in the main thread
+ // Some tests don't set parameters.ui_task, so they started translate
+ // language fetch that was never completed so we need to cleanup here
// otherwise it will be done by the destructor in a wrong thread.
- if (translate_manager_ != NULL)
- translate_manager_->CleanupPendingUrlFetcher();
+ if (parameters().ui_task == NULL && translate_manager_ != NULL)
+ translate_manager_->CleanupPendingUlrFetcher();
if (notify_result_ == ProcessSingleton::PROCESS_NONE)
process_singleton_->Cleanup();
diff --git a/chrome/browser/chrome_main_browsertest.cc b/chrome/browser/chrome_main_browsertest.cc
index d1fc436..d8cbfd6 100644
--- a/chrome/browser/chrome_main_browsertest.cc
+++ b/chrome/browser/chrome_main_browsertest.cc
@@ -6,7 +6,7 @@
#include "base/command_line.h"
#include "base/path_service.h"
-#include "base/process_util.h"
+#include "base/process/launch.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
diff --git a/chrome/browser/chrome_plugin_browsertest.cc b/chrome/browser/chrome_plugin_browsertest.cc
index 6b2bcba..5386e42 100644
--- a/chrome/browser/chrome_plugin_browsertest.cc
+++ b/chrome/browser/chrome_plugin_browsertest.cc
@@ -10,7 +10,7 @@
#include "base/file_util.h"
#include "base/memory/ref_counted.h"
#include "base/path_service.h"
-#include "base/process_util.h"
+#include "base/process/kill.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/plugins/plugin_prefs.h"
#include "chrome/browser/ui/browser.h"
diff --git a/chrome/browser/chrome_process_finder_win.cc b/chrome/browser/chrome_process_finder_win.cc
index abd6c2b..e1d66ee 100644
--- a/chrome/browser/chrome_process_finder_win.cc
+++ b/chrome/browser/chrome_process_finder_win.cc
@@ -11,8 +11,8 @@
#include "base/file_util.h"
#include "base/files/file_path.h"
#include "base/logging.h"
-#include "base/process_info.h"
-#include "base/process_util.h"
+#include "base/process/process_handle.h"
+#include "base/process/process_info.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
diff --git a/chrome/browser/chromeos/boot_times_loader.cc b/chrome/browser/chromeos/boot_times_loader.cc
index bd94c2d..2fd1b0a 100644
--- a/chrome/browser/chromeos/boot_times_loader.cc
+++ b/chrome/browser/chromeos/boot_times_loader.cc
@@ -15,7 +15,6 @@
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/metrics/histogram.h"
-#include "base/process_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
diff --git a/chrome/browser/chromeos/drive/dummy_file_system.h b/chrome/browser/chromeos/drive/dummy_file_system.h
index 92e546f..f614ce0 100644
--- a/chrome/browser/chromeos/drive/dummy_file_system.h
+++ b/chrome/browser/chromeos/drive/dummy_file_system.h
@@ -79,6 +79,10 @@
const SearchMetadataCallback& callback) OVERRIDE {}
virtual void GetAvailableSpace(
const GetAvailableSpaceCallback& callback) OVERRIDE {}
+ virtual void GetShareUrl(
+ const base::FilePath& file_path,
+ const GURL& embed_origin,
+ const GetShareUrlCallback& callback) OVERRIDE {}
virtual void GetMetadata(
const GetFilesystemMetadataCallback& callback) OVERRIDE {}
virtual void MarkCacheFileAsMounted(
diff --git a/chrome/browser/chromeos/drive/fake_file_system.cc b/chrome/browser/chromeos/drive/fake_file_system.cc
index 234aadb..1bb1ca3 100644
--- a/chrome/browser/chromeos/drive/fake_file_system.cc
+++ b/chrome/browser/chromeos/drive/fake_file_system.cc
@@ -198,6 +198,13 @@
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
}
+void FakeFileSystem::GetShareUrl(
+ const base::FilePath& file_path,
+ const GURL& embed_origin,
+ const GetShareUrlCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+}
+
void FakeFileSystem::GetMetadata(
const GetFilesystemMetadataCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
diff --git a/chrome/browser/chromeos/drive/fake_file_system.h b/chrome/browser/chromeos/drive/fake_file_system.h
index c1320ad..c59975a 100644
--- a/chrome/browser/chromeos/drive/fake_file_system.h
+++ b/chrome/browser/chromeos/drive/fake_file_system.h
@@ -111,6 +111,10 @@
const SearchMetadataCallback& callback) OVERRIDE;
virtual void GetAvailableSpace(
const GetAvailableSpaceCallback& callback) OVERRIDE;
+ virtual void GetShareUrl(
+ const base::FilePath& file_path,
+ const GURL& embed_origin,
+ const GetShareUrlCallback& callback) OVERRIDE;
virtual void GetMetadata(
const GetFilesystemMetadataCallback& callback) OVERRIDE;
virtual void MarkCacheFileAsMounted(
diff --git a/chrome/browser/chromeos/drive/file_cache.cc b/chrome/browser/chromeos/drive/file_cache.cc
index 32455e9..1b1ef5e 100644
--- a/chrome/browser/chromeos/drive/file_cache.cc
+++ b/chrome/browser/chromeos/drive/file_cache.cc
@@ -390,7 +390,6 @@
}
void FileCache::MarkDirtyOnUIThread(const std::string& resource_id,
- const std::string& md5,
const FileOperationCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
@@ -398,28 +397,20 @@
base::PostTaskAndReplyWithResult(
blocking_task_runner_.get(),
FROM_HERE,
- base::Bind(
- &FileCache::MarkDirty, base::Unretained(this), resource_id, md5),
+ base::Bind(&FileCache::MarkDirty, base::Unretained(this), resource_id),
callback);
}
-FileError FileCache::MarkDirty(const std::string& resource_id,
- const std::string& md5) {
+FileError FileCache::MarkDirty(const std::string& resource_id) {
AssertOnSequencedWorkerPool();
- // If file has already been marked dirty in previous instance of chrome, we
- // would have lost the md5 info during cache initialization, because the file
- // would have been renamed to .local extension.
- // So, search for entry in cache without comparing md5.
-
// Marking a file dirty means its entry and actual file blob must exist in
// cache.
FileCacheEntry cache_entry;
- if (!GetCacheEntry(resource_id, md5, &cache_entry) ||
+ if (!storage_->GetCacheEntry(resource_id, &cache_entry) ||
!cache_entry.is_present()) {
- LOG(WARNING) << "Can't mark dirty a file that wasn't cached: res_id="
- << resource_id
- << ", md5=" << md5;
+ LOG(WARNING) << "Can't mark dirty a file that wasn't cached: "
+ << resource_id;
return FILE_ERROR_NOT_FOUND;
}
diff --git a/chrome/browser/chromeos/drive/file_cache.h b/chrome/browser/chromeos/drive/file_cache.h
index 7777077..c576b7b 100644
--- a/chrome/browser/chromeos/drive/file_cache.h
+++ b/chrome/browser/chromeos/drive/file_cache.h
@@ -200,12 +200,10 @@
// |callback| must not be null.
// Must be called on the UI thread.
void MarkDirtyOnUIThread(const std::string& resource_id,
- const std::string& md5,
const FileOperationCallback& callback);
// Marks the specified entry dirty.
- FileError MarkDirty(const std::string& resource_id,
- const std::string& md5);
+ FileError MarkDirty(const std::string& resource_id);
// Clears dirty state of the specified entry.
FileError ClearDirty(const std::string& resource_id,
diff --git a/chrome/browser/chromeos/drive/file_cache_unittest.cc b/chrome/browser/chromeos/drive/file_cache_unittest.cc
index 6f70aca..f18830a 100644
--- a/chrome/browser/chromeos/drive/file_cache_unittest.cc
+++ b/chrome/browser/chromeos/drive/file_cache_unittest.cc
@@ -200,7 +200,6 @@
}
void TestMarkDirty(const std::string& resource_id,
- const std::string& md5,
FileError expected_error,
int expected_cache_state) {
expected_error_ = expected_error;
@@ -208,17 +207,17 @@
FileError error = FILE_ERROR_OK;
cache_->MarkDirtyOnUIThread(
- resource_id, md5,
+ resource_id,
google_apis::test_util::CreateCopyResultCallback(&error));
test_util::RunBlockingPoolTask();
- VerifyCacheFileState(error, resource_id, md5);
+ VerifyCacheFileState(error, resource_id, std::string());
// Verify filename.
if (error == FILE_ERROR_OK) {
base::FilePath cache_file_path;
cache_->GetFileOnUIThread(
- resource_id, md5,
+ resource_id, std::string(),
google_apis::test_util::CreateCopyResultCallback(
&error, &cache_file_path));
test_util::RunBlockingPoolTask();
@@ -554,7 +553,7 @@
FILE_ERROR_OK, TEST_CACHE_STATE_PRESENT);
// Mark the file dirty.
- TestMarkDirty(resource_id, md5, FILE_ERROR_OK,
+ TestMarkDirty(resource_id, FILE_ERROR_OK,
TEST_CACHE_STATE_PRESENT | TEST_CACHE_STATE_DIRTY);
// Clear dirty state of the file.
@@ -572,7 +571,7 @@
TEST_CACHE_STATE_PRESENT | TEST_CACHE_STATE_PINNED);
// Mark the file dirty.
- TestMarkDirty(resource_id, md5, FILE_ERROR_OK,
+ TestMarkDirty(resource_id, FILE_ERROR_OK,
TEST_CACHE_STATE_PRESENT |
TEST_CACHE_STATE_DIRTY |
TEST_CACHE_STATE_PINNED);
@@ -589,7 +588,7 @@
// First store a file to cache and mark it as dirty.
TestStoreToCache(resource_id, md5, dummy_file_path_,
FILE_ERROR_OK, TEST_CACHE_STATE_PRESENT);
- TestMarkDirty(resource_id, md5, FILE_ERROR_OK,
+ TestMarkDirty(resource_id, FILE_ERROR_OK,
TEST_CACHE_STATE_PRESENT | TEST_CACHE_STATE_DIRTY);
// Verifies dirty file exists.
@@ -628,11 +627,11 @@
FILE_ERROR_OK, TEST_CACHE_STATE_PRESENT);
// Mark the file dirty.
- TestMarkDirty(resource_id, md5, FILE_ERROR_OK,
+ TestMarkDirty(resource_id, FILE_ERROR_OK,
TEST_CACHE_STATE_PRESENT | TEST_CACHE_STATE_DIRTY);
// Again, mark the file dirty. Nothing should change.
- TestMarkDirty(resource_id, md5, FILE_ERROR_OK,
+ TestMarkDirty(resource_id, FILE_ERROR_OK,
TEST_CACHE_STATE_PRESENT | TEST_CACHE_STATE_DIRTY);
// Clear dirty state of the file.
@@ -648,7 +647,7 @@
std::string md5("abcdef0123456789");
// Mark a non-existent file dirty.
- TestMarkDirty(resource_id, md5, FILE_ERROR_NOT_FOUND, TEST_CACHE_STATE_NONE);
+ TestMarkDirty(resource_id, FILE_ERROR_NOT_FOUND, TEST_CACHE_STATE_NONE);
// Clear dirty state of a non-existent file.
TestClearDirty(resource_id, md5, FILE_ERROR_NOT_FOUND, TEST_CACHE_STATE_NONE);
@@ -663,7 +662,7 @@
// Mark an existing file dirty, then store a new file to the same resource id
// but different md5, which should fail.
- TestMarkDirty(resource_id, md5, FILE_ERROR_OK,
+ TestMarkDirty(resource_id, FILE_ERROR_OK,
TEST_CACHE_STATE_PRESENT | TEST_CACHE_STATE_DIRTY);
md5 = "new_md5";
TestStoreToCache(resource_id, md5, dummy_file_path_,
@@ -680,7 +679,7 @@
FILE_ERROR_OK, TEST_CACHE_STATE_PRESENT);
TestPin(resource_id, FILE_ERROR_OK,
TEST_CACHE_STATE_PRESENT | TEST_CACHE_STATE_PINNED);
- TestMarkDirty(resource_id, md5, FILE_ERROR_OK,
+ TestMarkDirty(resource_id, FILE_ERROR_OK,
TEST_CACHE_STATE_PRESENT |
TEST_CACHE_STATE_PINNED |
TEST_CACHE_STATE_DIRTY);
diff --git a/chrome/browser/chromeos/drive/file_system.cc b/chrome/browser/chromeos/drive/file_system.cc
index b3b22b5..674dbc4 100644
--- a/chrome/browser/chromeos/drive/file_system.cc
+++ b/chrome/browser/chromeos/drive/file_system.cc
@@ -671,6 +671,72 @@
about_resource->quota_bytes_used());
}
+void FileSystem::GetShareUrl(
+ const base::FilePath& file_path,
+ const GURL& embed_origin,
+ const GetShareUrlCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
+
+ // Resolve the resource id.
+ resource_metadata_->GetResourceEntryByPathOnUIThread(
+ file_path,
+ base::Bind(&FileSystem::GetShareUrlAfterGetResourceEntry,
+ weak_ptr_factory_.GetWeakPtr(),
+ file_path,
+ embed_origin,
+ callback));
+}
+
+void FileSystem::GetShareUrlAfterGetResourceEntry(
+ const base::FilePath& file_path,
+ const GURL& embed_origin,
+ const GetShareUrlCallback& callback,
+ FileError error,
+ scoped_ptr<ResourceEntry> entry) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
+
+ if (error != FILE_ERROR_OK) {
+ callback.Run(error, GURL());
+ return;
+ }
+ if (util::IsSpecialResourceId(entry->resource_id())) {
+ // Do not load special directories. Just return.
+ callback.Run(FILE_ERROR_FAILED, GURL());
+ return;
+ }
+
+ scheduler_->GetShareUrl(
+ entry->resource_id(),
+ embed_origin,
+ ClientContext(USER_INITIATED),
+ base::Bind(&FileSystem::OnGetResourceEntryForGetShareUrl,
+ weak_ptr_factory_.GetWeakPtr(),
+ callback));
+}
+
+void FileSystem::OnGetResourceEntryForGetShareUrl(
+ const GetShareUrlCallback& callback,
+ google_apis::GDataErrorCode status,
+ const GURL& share_url) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
+
+ FileError error = util::GDataToFileError(status);
+ if (error != FILE_ERROR_OK) {
+ callback.Run(error, GURL());
+ return;
+ }
+
+ if (share_url.is_empty()) {
+ callback.Run(FILE_ERROR_FAILED, GURL());
+ return;
+ }
+
+ callback.Run(FILE_ERROR_OK, share_url);
+}
+
void FileSystem::Search(const std::string& search_query,
const GURL& next_url,
const SearchCallback& callback) {
diff --git a/chrome/browser/chromeos/drive/file_system.h b/chrome/browser/chromeos/drive/file_system.h
index 351f637..2d471e3 100644
--- a/chrome/browser/chromeos/drive/file_system.h
+++ b/chrome/browser/chromeos/drive/file_system.h
@@ -136,6 +136,10 @@
const ReadDirectoryCallback& callback) OVERRIDE;
virtual void GetAvailableSpace(
const GetAvailableSpaceCallback& callback) OVERRIDE;
+ virtual void GetShareUrl(
+ const base::FilePath& file_path,
+ const GURL& embed_origin,
+ const GetShareUrlCallback& callback) OVERRIDE;
virtual void GetMetadata(
const GetFilesystemMetadataCallback& callback) OVERRIDE;
virtual void MarkCacheFileAsMounted(
@@ -292,6 +296,19 @@
FileError error,
scoped_ptr<ResourceEntry> entry);
+ // Part of GetShareUrl. Resolves the resource entry to get the resource it,
+ // and then uses it to ask for the share url. |callback| must not be null.
+ void GetShareUrlAfterGetResourceEntry(
+ const base::FilePath& file_path,
+ const GURL& embed_origin,
+ const GetShareUrlCallback& callback,
+ FileError error,
+ scoped_ptr<ResourceEntry> entry);
+ void OnGetResourceEntryForGetShareUrl(
+ const GetShareUrlCallback& callback,
+ google_apis::GDataErrorCode status,
+ const GURL& share_url);
+
// Used to get Drive related preferences.
PrefService* pref_service_;
diff --git a/chrome/browser/chromeos/drive/file_system/copy_operation.cc b/chrome/browser/chromeos/drive/file_system/copy_operation.cc
index 3b10008..f83b918 100644
--- a/chrome/browser/chromeos/drive/file_system/copy_operation.cc
+++ b/chrome/browser/chromeos/drive/file_system/copy_operation.cc
@@ -46,7 +46,7 @@
internal::FileCache::FILE_OPERATION_COPY);
if (error != FILE_ERROR_OK)
return error;
- return cache->MarkDirty(resource_id, md5);
+ return cache->MarkDirty(resource_id);
}
} // namespace
diff --git a/chrome/browser/chromeos/drive/file_system/download_operation_unittest.cc b/chrome/browser/chromeos/drive/file_system/download_operation_unittest.cc
index 5d0f298..3bf85c2 100644
--- a/chrome/browser/chromeos/drive/file_system/download_operation_unittest.cc
+++ b/chrome/browser/chromeos/drive/file_system/download_operation_unittest.cc
@@ -414,7 +414,6 @@
EXPECT_EQ(FILE_ERROR_OK, error);
cache()->MarkDirtyOnUIThread(
src_entry.resource_id(),
- src_entry.file_specific_info().md5(),
google_apis::test_util::CreateCopyResultCallback(&error));
test_util::RunBlockingPoolTask();
EXPECT_EQ(FILE_ERROR_OK, error);
diff --git a/chrome/browser/chromeos/drive/file_system/open_file_operation.cc b/chrome/browser/chromeos/drive/file_system/open_file_operation.cc
index 4a49830..d23c488 100644
--- a/chrome/browser/chromeos/drive/file_system/open_file_operation.cc
+++ b/chrome/browser/chromeos/drive/file_system/open_file_operation.cc
@@ -28,7 +28,7 @@
const std::string& resource_id,
const std::string& md5,
base::FilePath* local_file_path) {
- FileError error = cache->MarkDirty(resource_id, md5);
+ FileError error = cache->MarkDirty(resource_id);
if (error != FILE_ERROR_OK)
return error;
diff --git a/chrome/browser/chromeos/drive/file_system/truncate_operation.cc b/chrome/browser/chromeos/drive/file_system/truncate_operation.cc
index df3918c..3711aaa 100644
--- a/chrome/browser/chromeos/drive/file_system/truncate_operation.cc
+++ b/chrome/browser/chromeos/drive/file_system/truncate_operation.cc
@@ -48,12 +48,11 @@
// then marks the resource is dirty on |cache|.
FileError TruncateOnBlockingPool(internal::FileCache* cache,
const std::string& resource_id,
- const std::string& md5,
const base::FilePath& local_cache_path,
int64 length) {
DCHECK(cache);
- FileError error = cache->MarkDirty(resource_id, md5);
+ FileError error = cache->MarkDirty(resource_id);
if (error != FILE_ERROR_OK)
return error;
@@ -149,7 +148,7 @@
FROM_HERE,
base::Bind(&TruncateOnBlockingPool,
base::Unretained(cache_),
- entry->resource_id(), entry->file_specific_info().md5(),
+ entry->resource_id(),
local_file_path, length),
base::Bind(
&TruncateOperation::TruncateAfterTruncateOnBlockingPool,
diff --git a/chrome/browser/chromeos/drive/file_system/update_operation_unittest.cc b/chrome/browser/chromeos/drive/file_system/update_operation_unittest.cc
index b9aa729..7ce3ebc 100644
--- a/chrome/browser/chromeos/drive/file_system/update_operation_unittest.cc
+++ b/chrome/browser/chromeos/drive/file_system/update_operation_unittest.cc
@@ -57,7 +57,7 @@
// Add the dirty bit.
error = FILE_ERROR_FAILED;
cache()->MarkDirtyOnUIThread(
- kResourceId, kMd5,
+ kResourceId,
google_apis::test_util::CreateCopyResultCallback(&error));
test_util::RunBlockingPoolTask();
EXPECT_EQ(FILE_ERROR_OK, error);
@@ -132,7 +132,7 @@
// Add the dirty bit.
error = FILE_ERROR_FAILED;
cache()->MarkDirtyOnUIThread(
- kResourceId, kMd5,
+ kResourceId,
google_apis::test_util::CreateCopyResultCallback(&error));
test_util::RunBlockingPoolTask();
EXPECT_EQ(FILE_ERROR_OK, error);
@@ -178,7 +178,7 @@
// Again mark the cache file dirty.
error = FILE_ERROR_FAILED;
cache()->MarkDirtyOnUIThread(
- kResourceId, server_entry->file_md5(),
+ kResourceId,
google_apis::test_util::CreateCopyResultCallback(&error));
test_util::RunBlockingPoolTask();
EXPECT_EQ(FILE_ERROR_OK, error);
diff --git a/chrome/browser/chromeos/drive/file_system_interface.h b/chrome/browser/chromeos/drive/file_system_interface.h
index 98ccf11..93b5324 100644
--- a/chrome/browser/chromeos/drive/file_system_interface.h
+++ b/chrome/browser/chromeos/drive/file_system_interface.h
@@ -112,6 +112,10 @@
int64 bytes_total,
int64 bytes_used)> GetAvailableSpaceCallback;
+// Used to get the url to the sharing dialog.
+typedef base::Callback<void(FileError error,
+ const GURL& share_url)> GetShareUrlCallback;
+
// Used to get filesystem metadata.
typedef base::Callback<void(const FileSystemMetadata&)>
GetFilesystemMetadataCallback;
@@ -382,6 +386,13 @@
// and returns it to the callback.
virtual void GetAvailableSpace(const GetAvailableSpaceCallback& callback) = 0;
+ // Fetches the url to the sharing dialog to be embedded in |embed_origin|,
+ // for the specified file or directory. |callback| must not be null.
+ virtual void GetShareUrl(
+ const base::FilePath& file_path,
+ const GURL& embed_origin,
+ const GetShareUrlCallback& callback) = 0;
+
// Returns miscellaneous metadata of the file system like the largest
// timestamp. Used in chrome:drive-internals. |callback| must not be null.
virtual void GetMetadata(
diff --git a/chrome/browser/chromeos/drive/file_system_unittest.cc b/chrome/browser/chromeos/drive/file_system_unittest.cc
index a5a7922..95bfd1b 100644
--- a/chrome/browser/chromeos/drive/file_system_unittest.cc
+++ b/chrome/browser/chromeos/drive/file_system_unittest.cc
@@ -846,4 +846,46 @@
EXPECT_EQ(FILE_ERROR_OK, cache_->Remove(entry->resource_id()));
}
+TEST_F(FileSystemTest, GetShareUrl) {
+ ASSERT_TRUE(LoadFullResourceList());
+
+ const base::FilePath kFileInRoot(FILE_PATH_LITERAL("drive/root/File 1.txt"));
+ const GURL kEmbedOrigin("chrome-extension://test-id");
+
+ // Try to fetch the URL for the sharing dialog.
+ FileError error = FILE_ERROR_FAILED;
+ GURL share_url;
+ file_system_->GetShareUrl(
+ kFileInRoot,
+ kEmbedOrigin,
+ google_apis::test_util::CreateCopyResultCallback(&error, &share_url));
+ test_util::RunBlockingPoolTask();
+
+ // Verify the share url to the sharing dialog.
+ EXPECT_EQ(FILE_ERROR_OK, error);
+ EXPECT_EQ(GURL("https://file_link_share/"), share_url);
+}
+
+TEST_F(FileSystemTest, GetShareUrlNotAvailable) {
+ ASSERT_TRUE(LoadFullResourceList());
+
+ const base::FilePath kFileInRoot(
+ FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt"));
+ const GURL kEmbedOrigin("chrome-extension://test-id");
+
+ // Try to fetch the URL for the sharing dialog.
+ FileError error = FILE_ERROR_FAILED;
+ GURL share_url;
+
+ file_system_->GetShareUrl(
+ kFileInRoot,
+ kEmbedOrigin,
+ google_apis::test_util::CreateCopyResultCallback(&error, &share_url));
+ test_util::RunBlockingPoolTask();
+
+ // Verify the error and the share url, which should be empty.
+ EXPECT_EQ(FILE_ERROR_FAILED, error);
+ EXPECT_TRUE(share_url.is_empty());
+}
+
} // namespace drive
diff --git a/chrome/browser/chromeos/drive/job_list.cc b/chrome/browser/chromeos/drive/job_list.cc
index ae87b46..accb090 100644
--- a/chrome/browser/chromeos/drive/job_list.cc
+++ b/chrome/browser/chromeos/drive/job_list.cc
@@ -28,6 +28,8 @@
return "TYPE_CONTINUE_GET_RESOURCE_LIST";
case TYPE_GET_RESOURCE_ENTRY:
return "TYPE_GET_RESOURCE_ENTRY";
+ case TYPE_GET_SHARE_URL:
+ return "TYPE_GET_SHARE_URL";
case TYPE_DELETE_RESOURCE:
return "TYPE_DELETE_RESOURCE";
case TYPE_COPY_RESOURCE:
@@ -115,6 +117,7 @@
case TYPE_GET_CHANGE_LIST:
case TYPE_CONTINUE_GET_RESOURCE_LIST:
case TYPE_GET_RESOURCE_ENTRY:
+ case TYPE_GET_SHARE_URL:
case TYPE_DELETE_RESOURCE:
case TYPE_COPY_RESOURCE:
case TYPE_COPY_HOSTED_DOCUMENT:
diff --git a/chrome/browser/chromeos/drive/job_list.h b/chrome/browser/chromeos/drive/job_list.h
index 8859b03..dbd74b9 100644
--- a/chrome/browser/chromeos/drive/job_list.h
+++ b/chrome/browser/chromeos/drive/job_list.h
@@ -23,6 +23,7 @@
TYPE_GET_CHANGE_LIST,
TYPE_CONTINUE_GET_RESOURCE_LIST,
TYPE_GET_RESOURCE_ENTRY,
+ TYPE_GET_SHARE_URL,
TYPE_DELETE_RESOURCE,
TYPE_COPY_RESOURCE,
TYPE_COPY_HOSTED_DOCUMENT,
diff --git a/chrome/browser/chromeos/drive/job_scheduler.cc b/chrome/browser/chromeos/drive/job_scheduler.cc
index 83a3d00..c8e48af 100644
--- a/chrome/browser/chromeos/drive/job_scheduler.cc
+++ b/chrome/browser/chromeos/drive/job_scheduler.cc
@@ -334,6 +334,29 @@
StartJob(new_job);
}
+void JobScheduler::GetShareUrl(
+ const std::string& resource_id,
+ const GURL& embed_origin,
+ const ClientContext& context,
+ const google_apis::GetShareUrlCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
+
+ JobEntry* new_job = CreateNewJob(TYPE_GET_SHARE_URL);
+ new_job->context = context;
+ new_job->task = base::Bind(
+ &DriveServiceInterface::GetShareUrl,
+ base::Unretained(drive_service_),
+ resource_id,
+ embed_origin,
+ base::Bind(&JobScheduler::OnGetShareUrlJobDone,
+ weak_ptr_factory_.GetWeakPtr(),
+ new_job->job_info.job_id,
+ callback));
+ new_job->abort_callback = google_apis::CreateErrorRunCallback(callback);
+ StartJob(new_job);
+}
+
void JobScheduler::DeleteResource(
const std::string& resource_id,
const google_apis::EntryActionCallback& callback) {
@@ -850,6 +873,18 @@
callback.Run(error, about_resource.Pass());
}
+void JobScheduler::OnGetShareUrlJobDone(
+ JobID job_id,
+ const google_apis::GetShareUrlCallback& callback,
+ google_apis::GDataErrorCode error,
+ const GURL& share_url) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
+
+ if (OnJobDone(job_id, error))
+ callback.Run(error, share_url);
+}
+
void JobScheduler::OnGetAppListJobDone(
JobID job_id,
const google_apis::GetAppListCallback& callback,
@@ -952,6 +987,7 @@
case TYPE_GET_CHANGE_LIST:
case TYPE_CONTINUE_GET_RESOURCE_LIST:
case TYPE_GET_RESOURCE_ENTRY:
+ case TYPE_GET_SHARE_URL:
case TYPE_DELETE_RESOURCE:
case TYPE_COPY_RESOURCE:
case TYPE_COPY_HOSTED_DOCUMENT:
diff --git a/chrome/browser/chromeos/drive/job_scheduler.h b/chrome/browser/chromeos/drive/job_scheduler.h
index 404ce7f..d10f8c9 100644
--- a/chrome/browser/chromeos/drive/job_scheduler.h
+++ b/chrome/browser/chromeos/drive/job_scheduler.h
@@ -102,6 +102,11 @@
const ClientContext& context,
const google_apis::GetResourceEntryCallback& callback);
+ // Adds a GetShareUrl operation to the queue.
+ void GetShareUrl(const std::string& resource_id,
+ const GURL& embed_origin,
+ const ClientContext& context,
+ const google_apis::GetShareUrlCallback& callback);
// Adds a DeleteResource operation to the queue.
void DeleteResource(const std::string& resource_id,
@@ -270,6 +275,13 @@
google_apis::GDataErrorCode error,
scoped_ptr<google_apis::AboutResource> about_resource);
+ // Callback for job finishing with a GetShareUrlCallback.
+ void OnGetShareUrlJobDone(
+ JobID job_id,
+ const google_apis::GetShareUrlCallback& callback,
+ google_apis::GDataErrorCode error,
+ const GURL& share_url);
+
// Callback for job finishing with a GetAppListCallback.
void OnGetAppListJobDone(
JobID job_id,
diff --git a/chrome/browser/chromeos/drive/job_scheduler_unittest.cc b/chrome/browser/chromeos/drive/job_scheduler_unittest.cc
index f734529..40050a3 100644
--- a/chrome/browser/chromeos/drive/job_scheduler_unittest.cc
+++ b/chrome/browser/chromeos/drive/job_scheduler_unittest.cc
@@ -304,6 +304,23 @@
ASSERT_TRUE(entry);
}
+TEST_F(JobSchedulerTest, GetShareUrl) {
+ ConnectToWifi();
+
+ google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
+ GURL share_url;
+
+ scheduler_->GetShareUrl(
+ "file:2_file_resource_id", // resource ID
+ GURL("chrome-extension://test-id/"), // embed origin
+ ClientContext(USER_INITIATED),
+ google_apis::test_util::CreateCopyResultCallback(&error, &share_url));
+ base::RunLoop().RunUntilIdle();
+
+ ASSERT_EQ(google_apis::HTTP_SUCCESS, error);
+ ASSERT_FALSE(share_url.is_empty());
+}
+
TEST_F(JobSchedulerTest, DeleteResource) {
ConnectToWifi();
diff --git a/chrome/browser/chromeos/drive/remove_stale_cache_files_unittest.cc b/chrome/browser/chromeos/drive/remove_stale_cache_files_unittest.cc
index 751b6a8..41e647b 100644
--- a/chrome/browser/chromeos/drive/remove_stale_cache_files_unittest.cc
+++ b/chrome/browser/chromeos/drive/remove_stale_cache_files_unittest.cc
@@ -94,7 +94,7 @@
EXPECT_EQ(FILE_ERROR_OK,
cache_->Store(resource_id_1, md5_1, dummy_file,
FileCache::FILE_OPERATION_COPY));
- EXPECT_EQ(FILE_ERROR_OK, cache_->MarkDirty(resource_id_1, md5_1));
+ EXPECT_EQ(FILE_ERROR_OK, cache_->MarkDirty(resource_id_1));
// Dirty and mismatching-MD5 entry.
std::string resource_id_2("file:2");
@@ -103,7 +103,7 @@
EXPECT_EQ(FILE_ERROR_OK,
cache_->Store(resource_id_2, md5_2_cache, dummy_file,
FileCache::FILE_OPERATION_COPY));
- EXPECT_EQ(FILE_ERROR_OK, cache_->MarkDirty(resource_id_2, md5_2_cache));
+ EXPECT_EQ(FILE_ERROR_OK, cache_->MarkDirty(resource_id_2));
ResourceEntry entry;
entry.set_resource_id(resource_id_2);
diff --git a/chrome/browser/chromeos/drive/sync_client_unittest.cc b/chrome/browser/chromeos/drive/sync_client_unittest.cc
index de42956..c209643 100644
--- a/chrome/browser/chromeos/drive/sync_client_unittest.cc
+++ b/chrome/browser/chromeos/drive/sync_client_unittest.cc
@@ -178,8 +178,7 @@
cache_->Store(resource_ids_["dirty"], md5_dirty,
temp_file, FileCache::FILE_OPERATION_COPY));
EXPECT_EQ(FILE_ERROR_OK, cache_->Pin(resource_ids_["dirty"]));
- EXPECT_EQ(FILE_ERROR_OK,
- cache_->MarkDirty(resource_ids_["dirty"], md5_dirty));
+ EXPECT_EQ(FILE_ERROR_OK, cache_->MarkDirty(resource_ids_["dirty"]));
// Load data from the service to the metadata.
FileError error = FILE_ERROR_FAILED;
diff --git a/chrome/browser/chromeos/drive/test_util.cc b/chrome/browser/chromeos/drive/test_util.cc
index 1a70d69..c2cd679 100644
--- a/chrome/browser/chromeos/drive/test_util.cc
+++ b/chrome/browser/chromeos/drive/test_util.cc
@@ -158,7 +158,6 @@
FileError error = FILE_ERROR_OK;
cache->MarkDirtyOnUIThread(
resources[i].resource_id,
- resources[i].md5,
google_apis::test_util::CreateCopyResultCallback(&error));
test_util::RunBlockingPoolTask();
if (error != FILE_ERROR_OK)
diff --git a/chrome/browser/chromeos/extensions/file_manager/file_browser_private_api.cc b/chrome/browser/chromeos/extensions/file_manager/file_browser_private_api.cc
index 35f3f6a..5f9e4ca 100644
--- a/chrome/browser/chromeos/extensions/file_manager/file_browser_private_api.cc
+++ b/chrome/browser/chromeos/extensions/file_manager/file_browser_private_api.cc
@@ -441,6 +441,7 @@
registry->RegisterFunction<ValidatePathNameLengthFunction>();
registry->RegisterFunction<ZoomFunction>();
registry->RegisterFunction<RequestAccessTokenFunction>();
+ registry->RegisterFunction<GetShareUrlFunction>();
event_router_->ObserveFileSystemEvents();
}
@@ -1985,10 +1986,10 @@
SET_STRING("CUT_BUTTON_LABEL", IDS_FILE_BROWSER_CUT_BUTTON_LABEL);
SET_STRING("ZIP_SELECTION_BUTTON_LABEL",
IDS_FILE_BROWSER_ZIP_SELECTION_BUTTON_LABEL);
- SET_STRING("PIN_FOLDER_BUTTON_LABEL",
- IDS_FILE_BROWSER_PIN_FOLDER_BUTTON_LABEL);
- SET_STRING("UNPIN_FOLDER_BUTTON_LABEL",
- IDS_FILE_BROWSER_UNPIN_FOLDER_BUTTON_LABEL);
+ SET_STRING("CREATE_FOLDER_SHORTCUT_BUTTON_LABEL",
+ IDS_FILE_BROWSER_CREATE_FOLDER_SHORTCUT_BUTTON_LABEL);
+ SET_STRING("REMOVE_FOLDER_SHORTCUT_BUTTON_LABEL",
+ IDS_FILE_BROWSER_REMOVE_FOLDER_SHORTCUT_BUTTON_LABEL);
SET_STRING("SHARE_BUTTON_LABEL",
IDS_FILE_BROWSER_SHARE_BUTTON_LABEL);
@@ -3077,3 +3078,45 @@
SetResult(new base::StringValue(access_token));
SendResponse(true);
}
+
+GetShareUrlFunction::GetShareUrlFunction() {
+}
+
+GetShareUrlFunction::~GetShareUrlFunction() {
+}
+
+bool GetShareUrlFunction::RunImpl() {
+ std::string file_url;
+ if (!args_->GetString(0, &file_url))
+ return false;
+
+ const base::FilePath path = GetLocalPathFromURL(GURL(file_url));
+ DCHECK(drive::util::IsUnderDriveMountPoint(path));
+
+ base::FilePath drive_path = drive::util::ExtractDrivePath(path);
+
+ drive::DriveIntegrationService* integration_service =
+ drive::DriveIntegrationServiceFactory::GetForProfile(profile_);
+ // |integration_service| is NULL if Drive is disabled.
+ if (!integration_service)
+ return false;
+
+ integration_service->file_system()->GetShareUrl(
+ drive_path,
+ file_manager_util::GetFileBrowserExtensionUrl(), // embed origin
+ base::Bind(&GetShareUrlFunction::OnGetShareUrl, this));
+ return true;
+}
+
+
+void GetShareUrlFunction::OnGetShareUrl(drive::FileError error,
+ const GURL& share_url) {
+ if (error != drive::FILE_ERROR_OK) {
+ error_ = "Share Url for this item is not available.";
+ SendResponse(false);
+ return;
+ }
+
+ SetResult(new base::StringValue(share_url.spec()));
+ SendResponse(true);
+}
diff --git a/chrome/browser/chromeos/extensions/file_manager/file_browser_private_api.h b/chrome/browser/chromeos/extensions/file_manager/file_browser_private_api.h
index bf5ff1e..e29b7bf 100644
--- a/chrome/browser/chromeos/extensions/file_manager/file_browser_private_api.h
+++ b/chrome/browser/chromeos/extensions/file_manager/file_browser_private_api.h
@@ -780,9 +780,28 @@
// AsyncExtensionFunction overrides.
virtual bool RunImpl() OVERRIDE;
- // Received the cached auth token (if available) or the fetched one.
+ // Callback with a cached auth token (if available) or a fetched one.
void OnAccessTokenFetched(google_apis::GDataErrorCode code,
const std::string& access_token);
};
+// Implements the chrome.fileBrowserPrivate.getShareUrl method.
+class GetShareUrlFunction : public FileBrowserFunction {
+ public:
+ DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getShareUrl",
+ FILEBROWSERPRIVATE_GETSHAREURL)
+
+ GetShareUrlFunction();
+
+ protected:
+ virtual ~GetShareUrlFunction();
+
+ // AsyncExtensionFunction overrides.
+ virtual bool RunImpl() OVERRIDE;
+
+ // Callback with an url to the sharing dialog as |share_url|, called by
+ // FileSystem::GetShareUrl.
+ void OnGetShareUrl(drive::FileError error, const GURL& share_url);
+};
+
#endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_FILE_BROWSER_PRIVATE_API_H_
diff --git a/chrome/browser/chromeos/fileapi/file_system_backend.cc b/chrome/browser/chromeos/fileapi/file_system_backend.cc
index fce5776..a259b1a 100644
--- a/chrome/browser/chromeos/fileapi/file_system_backend.cc
+++ b/chrome/browser/chromeos/fileapi/file_system_backend.cc
@@ -106,12 +106,14 @@
}
}
-void FileSystemBackend::InitializeFileSystem(
+void FileSystemBackend::Initialize(fileapi::FileSystemContext* context) {
+}
+
+void FileSystemBackend::OpenFileSystem(
const GURL& origin_url,
fileapi::FileSystemType type,
fileapi::OpenFileSystemMode mode,
- fileapi::FileSystemContext* context,
- const InitializeFileSystemCallback& callback) {
+ const OpenFileSystemCallback& callback) {
DCHECK(fileapi::IsolatedContext::IsIsolatedType(type));
// Nothing to validate for external filesystem.
callback.Run(GetFileSystemRootURI(origin_url, type),
diff --git a/chrome/browser/chromeos/fileapi/file_system_backend.h b/chrome/browser/chromeos/fileapi/file_system_backend.h
index d08c34a..1ca1050 100644
--- a/chrome/browser/chromeos/fileapi/file_system_backend.h
+++ b/chrome/browser/chromeos/fileapi/file_system_backend.h
@@ -66,7 +66,7 @@
//
class FileSystemBackend : public fileapi::ExternalFileSystemBackend {
public:
- using fileapi::FileSystemBackend::InitializeFileSystemCallback;
+ using fileapi::FileSystemBackend::OpenFileSystemCallback;
// FileSystemBackend will take an ownership of a |mount_points|
// reference. On the other hand, |system_mount_points| will be kept as a raw
@@ -90,12 +90,12 @@
// fileapi::FileSystemBackend overrides.
virtual bool CanHandleType(fileapi::FileSystemType type) const OVERRIDE;
- virtual void InitializeFileSystem(
+ virtual void Initialize(fileapi::FileSystemContext* context) OVERRIDE;
+ virtual void OpenFileSystem(
const GURL& origin_url,
fileapi::FileSystemType type,
fileapi::OpenFileSystemMode mode,
- fileapi::FileSystemContext* context,
- const InitializeFileSystemCallback& callback) OVERRIDE;
+ const OpenFileSystemCallback& callback) OVERRIDE;
virtual fileapi::FileSystemFileUtil* GetFileUtil(
fileapi::FileSystemType type) OVERRIDE;
virtual fileapi::AsyncFileUtil* GetAsyncFileUtil(
diff --git a/chrome/browser/chromeos/input_method/ibus_controller_impl.h b/chrome/browser/chromeos/input_method/ibus_controller_impl.h
index 0852d87..af0892a 100644
--- a/chrome/browser/chromeos/input_method/ibus_controller_impl.h
+++ b/chrome/browser/chromeos/input_method/ibus_controller_impl.h
@@ -8,7 +8,6 @@
#include <string>
#include <vector>
-#include "base/process_util.h"
#include "base/threading/thread_checker.h"
#include "chrome/browser/chromeos/input_method/ibus_controller_base.h"
#include "chromeos/dbus/ibus/ibus_panel_service.h"
diff --git a/chrome/browser/chromeos/input_method/input_method_manager_impl.cc b/chrome/browser/chromeos/input_method/input_method_manager_impl.cc
index 7f2fa95..56ade22 100644
--- a/chrome/browser/chromeos/input_method/input_method_manager_impl.cc
+++ b/chrome/browser/chromeos/input_method/input_method_manager_impl.cc
@@ -75,6 +75,8 @@
{ "m17n:vi:viqr", "_comp_ime_jhffeifommiaekmbkkjlpmilogcfdohpvkd_vi_viqr" },
{ "m17n:vi:telex",
"_comp_ime_jhffeifommiaekmbkkjlpmilogcfdohpvkd_vi_telex" },
+ { "m17n:vi:vni",
+ "_comp_ime_jhffeifommiaekmbkkjlpmilogcfdohpvkd_vi_vni" },
{ "m17n:am:sera",
"_comp_ime_jhffeifommiaekmbkkjlpmilogcfdohpvkd_ethi" },
{ "m17n:bn:itrans",
@@ -88,7 +90,7 @@
{ "m17n:ml:itrans",
"_comp_ime_jhffeifommiaekmbkkjlpmilogcfdohpvkd_ml_phone" },
{ "m17n:mr:itrans",
- "_comp_ime_jhffeifommiaekmbkkjlpmilogcfdohpvkd_deva_phone-" },
+ "_comp_ime_jhffeifommiaekmbkkjlpmilogcfdohpvkd_deva_phone" },
{ "m17n:te:itrans",
"_comp_ime_jhffeifommiaekmbkkjlpmilogcfdohpvkd_te_phone" },
{ "m17n:fa:isiri", "_comp_ime_jhffeifommiaekmbkkjlpmilogcfdohpvkd_fa" },
diff --git a/chrome/browser/chromeos/login/chrome_restart_request.cc b/chrome/browser/chromeos/login/chrome_restart_request.cc
index d8f2671..aa317f3 100644
--- a/chrome/browser/chromeos/login/chrome_restart_request.cc
+++ b/chrome/browser/chromeos/login/chrome_restart_request.cc
@@ -14,7 +14,7 @@
#include "base/path_service.h"
#include "base/prefs/json_pref_store.h"
#include "base/prefs/pref_service.h"
-#include "base/process_util.h"
+#include "base/process/launch.h"
#include "base/strings/string_split.h"
#include "base/strings/stringprintf.h"
#include "base/timer/timer.h"
diff --git a/chrome/browser/chromeos/memory/oom_priority_manager.cc b/chrome/browser/chromeos/memory/oom_priority_manager.cc
index 85b6217..69477ae 100644
--- a/chrome/browser/chromeos/memory/oom_priority_manager.cc
+++ b/chrome/browser/chromeos/memory/oom_priority_manager.cc
@@ -13,8 +13,7 @@
#include "base/command_line.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/histogram.h"
-#include "base/process.h"
-#include "base/process_util.h"
+#include "base/process/process.h"
#include "base/strings/string16.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
diff --git a/chrome/browser/chromeos/memory/oom_priority_manager.h b/chrome/browser/chromeos/memory/oom_priority_manager.h
index f666db7..2834291 100644
--- a/chrome/browser/chromeos/memory/oom_priority_manager.h
+++ b/chrome/browser/chromeos/memory/oom_priority_manager.h
@@ -11,7 +11,7 @@
#include "base/containers/hash_tables.h"
#include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h"
-#include "base/process.h"
+#include "base/process/process.h"
#include "base/strings/string16.h"
#include "base/synchronization/lock.h"
#include "base/time/time.h"
diff --git a/chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.cc b/chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.cc
index 0cb76cc..d013d5e 100644
--- a/chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.cc
+++ b/chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.cc
@@ -134,16 +134,20 @@
base::FilePath policy_key_dir;
CHECK(PathService::Get(chromeos::DIR_USER_POLICY_KEYS, &policy_key_dir));
- scoped_ptr<CloudPolicyStore> store(
+ scoped_ptr<UserCloudPolicyStoreChromeOS> store(
new UserCloudPolicyStoreChromeOS(
chromeos::DBusThreadManager::Get()->GetCryptohomeClient(),
chromeos::DBusThreadManager::Get()->GetSessionManagerClient(),
username, policy_key_dir, token_cache_file, policy_cache_file));
+ if (force_immediate_load)
+ store->LoadImmediately();
+
scoped_ptr<ResourceCache> resource_cache;
if (command_line->HasSwitch(switches::kEnableComponentCloudPolicy))
resource_cache.reset(new ResourceCache(resource_cache_dir));
+
scoped_ptr<UserCloudPolicyManagerChromeOS> manager(
- new UserCloudPolicyManagerChromeOS(store.Pass(),
+ new UserCloudPolicyManagerChromeOS(store.PassAs<CloudPolicyStore>(),
resource_cache.Pass(),
wait_for_initial_policy));
manager->Init();
diff --git a/chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.cc b/chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.cc
index c6cb989..2d6232d 100644
--- a/chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.cc
+++ b/chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.cc
@@ -203,6 +203,54 @@
weak_factory_.GetWeakPtr()));
}
+void UserCloudPolicyStoreChromeOS::LoadImmediately() {
+ // This blocking DBus call is in the startup path and will block the UI
+ // thread. This only happens when the Profile is created synchronously, which
+ // on ChromeOS happens whenever the browser is restarted into the same
+ // session. That happens when the browser crashes, or right after signin if
+ // the user has flags configured in about:flags.
+ // However, on those paths we must load policy synchronously so that the
+ // Profile initialization never sees unmanaged prefs, which would lead to
+ // data loss. http://crbug.com/263061
+ std::string policy_blob =
+ session_manager_client_->BlockingRetrievePolicyForUser(username_);
+ if (policy_blob.empty()) {
+ // The session manager doesn't have policy, or the call failed.
+ // Just notify that the load is done, and don't bother with the legacy
+ // caches in this case.
+ NotifyStoreLoaded();
+ return;
+ }
+
+ scoped_ptr<em::PolicyFetchResponse> policy(new em::PolicyFetchResponse());
+ if (!policy->ParseFromString(policy_blob)) {
+ status_ = STATUS_PARSE_ERROR;
+ NotifyStoreError();
+ return;
+ }
+
+ std::string sanitized_username =
+ cryptohome_client_->BlockingGetSanitizedUsername(username_);
+ if (sanitized_username.empty()) {
+ status_ = STATUS_LOAD_ERROR;
+ NotifyStoreError();
+ return;
+ }
+
+ policy_key_path_ = user_policy_key_dir_.Append(
+ base::StringPrintf(kPolicyKeyFile, sanitized_username.c_str()));
+ LoadPolicyKey(policy_key_path_, &policy_key_);
+ policy_key_loaded_ = true;
+
+ scoped_ptr<UserCloudPolicyValidator> validator =
+ CreateValidator(policy.Pass());
+ validator->ValidateUsername(username_);
+ const bool allow_rotation = false;
+ validator->ValidateSignature(policy_key_, allow_rotation);
+ validator->RunValidation();
+ OnRetrievedPolicyValidated(validator.get());
+}
+
void UserCloudPolicyStoreChromeOS::ValidatePolicyForStore(
scoped_ptr<em::PolicyFetchResponse> policy) {
// Create and configure a validator.
diff --git a/chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.h b/chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.h
index 4f1ff6d..913235d 100644
--- a/chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.h
+++ b/chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.h
@@ -49,6 +49,9 @@
const enterprise_management::PolicyFetchResponse& policy) OVERRIDE;
virtual void Load() OVERRIDE;
+ // Loads the policy synchronously on the current thread.
+ void LoadImmediately();
+
private:
// Starts validation of |policy| before storing it.
void ValidatePolicyForStore(
diff --git a/chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos_unittest.cc b/chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos_unittest.cc
index a05504e..993f789 100644
--- a/chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos_unittest.cc
+++ b/chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos_unittest.cc
@@ -32,6 +32,7 @@
using testing::Eq;
using testing::Mock;
using testing::Property;
+using testing::Return;
using testing::SaveArg;
using testing::_;
@@ -519,6 +520,104 @@
EXPECT_FALSE(base::PathExists(policy_file()));
}
+TEST_F(UserCloudPolicyStoreChromeOSTest, LoadImmediately) {
+ EXPECT_CALL(observer_, OnStoreLoaded(store_.get()));
+ EXPECT_CALL(session_manager_client_,
+ BlockingRetrievePolicyForUser(PolicyBuilder::kFakeUsername))
+ .WillOnce(Return(policy_.GetBlob()));
+ EXPECT_CALL(cryptohome_client_,
+ BlockingGetSanitizedUsername(PolicyBuilder::kFakeUsername))
+ .WillOnce(Return(kSanitizedUsername));
+
+ EXPECT_FALSE(store_->policy());
+ store_->LoadImmediately();
+ // Note: verify that the |observer_| got notified synchronously, without
+ // having to spin the current loop. TearDown() will flush the loop so this
+ // must be done within the test.
+ Mock::VerifyAndClearExpectations(&observer_);
+ Mock::VerifyAndClearExpectations(&session_manager_client_);
+ Mock::VerifyAndClearExpectations(&cryptohome_client_);
+
+ // The policy should become available without having to spin any loops.
+ ASSERT_TRUE(store_->policy());
+ EXPECT_EQ(policy_.policy_data().SerializeAsString(),
+ store_->policy()->SerializeAsString());
+ VerifyPolicyMap(kDefaultHomepage);
+ EXPECT_EQ(CloudPolicyStore::STATUS_OK, store_->status());
+}
+
+TEST_F(UserCloudPolicyStoreChromeOSTest, LoadImmediatelyNoPolicy) {
+ EXPECT_CALL(observer_, OnStoreLoaded(store_.get()));
+ EXPECT_CALL(session_manager_client_,
+ BlockingRetrievePolicyForUser(PolicyBuilder::kFakeUsername))
+ .WillOnce(Return(""));
+
+ EXPECT_FALSE(store_->policy());
+ store_->LoadImmediately();
+ Mock::VerifyAndClearExpectations(&observer_);
+ Mock::VerifyAndClearExpectations(&session_manager_client_);
+
+ EXPECT_FALSE(store_->policy());
+ EXPECT_TRUE(store_->policy_map().empty());
+ EXPECT_EQ(CloudPolicyStore::STATUS_OK, store_->status());
+}
+
+TEST_F(UserCloudPolicyStoreChromeOSTest, LoadImmediatelyInvalidBlob) {
+ EXPECT_CALL(observer_, OnStoreError(store_.get()));
+ EXPECT_CALL(session_manager_client_,
+ BlockingRetrievePolicyForUser(PolicyBuilder::kFakeUsername))
+ .WillOnce(Return("le blob"));
+
+ EXPECT_FALSE(store_->policy());
+ store_->LoadImmediately();
+ Mock::VerifyAndClearExpectations(&observer_);
+ Mock::VerifyAndClearExpectations(&session_manager_client_);
+
+ EXPECT_FALSE(store_->policy());
+ EXPECT_TRUE(store_->policy_map().empty());
+ EXPECT_EQ(CloudPolicyStore::STATUS_PARSE_ERROR, store_->status());
+}
+
+TEST_F(UserCloudPolicyStoreChromeOSTest, LoadImmediatelyDBusFailure) {
+ EXPECT_CALL(observer_, OnStoreError(store_.get()));
+ EXPECT_CALL(session_manager_client_,
+ BlockingRetrievePolicyForUser(PolicyBuilder::kFakeUsername))
+ .WillOnce(Return(policy_.GetBlob()));
+ EXPECT_CALL(cryptohome_client_,
+ BlockingGetSanitizedUsername(PolicyBuilder::kFakeUsername))
+ .WillOnce(Return(""));
+
+ EXPECT_FALSE(store_->policy());
+ store_->LoadImmediately();
+ Mock::VerifyAndClearExpectations(&observer_);
+ Mock::VerifyAndClearExpectations(&session_manager_client_);
+ Mock::VerifyAndClearExpectations(&cryptohome_client_);
+
+ EXPECT_FALSE(store_->policy());
+ EXPECT_TRUE(store_->policy_map().empty());
+ EXPECT_EQ(CloudPolicyStore::STATUS_LOAD_ERROR, store_->status());
+}
+
+TEST_F(UserCloudPolicyStoreChromeOSTest, LoadImmediatelyNoUserPolicyKey) {
+ EXPECT_CALL(observer_, OnStoreError(store_.get()));
+ EXPECT_CALL(session_manager_client_,
+ BlockingRetrievePolicyForUser(PolicyBuilder::kFakeUsername))
+ .WillOnce(Return(policy_.GetBlob()));
+ EXPECT_CALL(cryptohome_client_,
+ BlockingGetSanitizedUsername(PolicyBuilder::kFakeUsername))
+ .WillOnce(Return("wrong"));
+
+ EXPECT_FALSE(store_->policy());
+ store_->LoadImmediately();
+ Mock::VerifyAndClearExpectations(&observer_);
+ Mock::VerifyAndClearExpectations(&session_manager_client_);
+ Mock::VerifyAndClearExpectations(&cryptohome_client_);
+
+ EXPECT_FALSE(store_->policy());
+ EXPECT_TRUE(store_->policy_map().empty());
+ EXPECT_EQ(CloudPolicyStore::STATUS_VALIDATION_ERROR, store_->status());
+}
+
} // namespace
} // namespace policy
diff --git a/chrome/browser/chromeos/settings/device_settings_test_helper.cc b/chrome/browser/chromeos/settings/device_settings_test_helper.cc
index 6545edb..d99553a 100644
--- a/chrome/browser/chromeos/settings/device_settings_test_helper.cc
+++ b/chrome/browser/chromeos/settings/device_settings_test_helper.cc
@@ -138,6 +138,11 @@
const RetrievePolicyCallback& callback) {
}
+std::string DeviceSettingsTestHelper::BlockingRetrievePolicyForUser(
+ const std::string& username) {
+ return "";
+}
+
void DeviceSettingsTestHelper::RetrieveDeviceLocalAccountPolicy(
const std::string& account_id,
const RetrievePolicyCallback& callback) {
diff --git a/chrome/browser/chromeos/settings/device_settings_test_helper.h b/chrome/browser/chromeos/settings/device_settings_test_helper.h
index ae7d52e..8e38806 100644
--- a/chrome/browser/chromeos/settings/device_settings_test_helper.h
+++ b/chrome/browser/chromeos/settings/device_settings_test_helper.h
@@ -99,6 +99,8 @@
virtual void RetrievePolicyForUser(
const std::string& username,
const RetrievePolicyCallback& callback) OVERRIDE;
+ virtual std::string BlockingRetrievePolicyForUser(
+ const std::string& username) OVERRIDE;
virtual void RetrieveDeviceLocalAccountPolicy(
const std::string& account_id,
const RetrievePolicyCallback& callback) OVERRIDE;
diff --git a/chrome/browser/chromeos/system/input_device_settings.cc b/chrome/browser/chromeos/system/input_device_settings.cc
index 09c17ae..48d3629 100644
--- a/chrome/browser/chromeos/system/input_device_settings.cc
+++ b/chrome/browser/chromeos/system/input_device_settings.cc
@@ -15,8 +15,9 @@
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
#include "base/message_loop/message_loop.h"
-#include "base/process.h"
-#include "base/process_util.h"
+#include "base/process/kill.h"
+#include "base/process/launch.h"
+#include "base/process/process_handle.h"
#include "base/strings/stringprintf.h"
#include "base/task_runner.h"
#include "base/threading/sequenced_worker_pool.h"
diff --git a/chrome/browser/chromeos/system_logs/command_line_log_source.cc b/chrome/browser/chromeos/system_logs/command_line_log_source.cc
index 5781876..43b7651 100644
--- a/chrome/browser/chromeos/system_logs/command_line_log_source.cc
+++ b/chrome/browser/chromeos/system_logs/command_line_log_source.cc
@@ -11,7 +11,7 @@
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/logging.h"
-#include "base/process_util.h"
+#include "base/process/launch.h"
#include "content/public/browser/browser_thread.h"
using content::BrowserThread;
diff --git a/chrome/browser/component_updater/DEPS b/chrome/browser/component_updater/DEPS
index 37c1ed1..2c90430 100644
--- a/chrome/browser/component_updater/DEPS
+++ b/chrome/browser/component_updater/DEPS
@@ -1,3 +1,4 @@
include_rules = [
+ "+ppapi/shared_impl/ppapi_permissions.h",
"+third_party/widevine"
]
diff --git a/chrome/browser/component_updater/component_patcher_win.cc b/chrome/browser/component_updater/component_patcher_win.cc
index 76a72c5..d583819 100644
--- a/chrome/browser/component_updater/component_patcher_win.cc
+++ b/chrome/browser/component_updater/component_patcher_win.cc
@@ -10,7 +10,8 @@
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/path_service.h"
-#include "base/process_util.h"
+#include "base/process/kill.h"
+#include "base/process/launch.h"
#include "base/strings/string_util.h"
#include "base/win/scoped_handle.h"
#include "chrome/installer/util/util_constants.h"
diff --git a/chrome/browser/component_updater/component_updater_service.cc b/chrome/browser/component_updater/component_updater_service.cc
index cd1ee8ef4..1a5bc76 100644
--- a/chrome/browser/component_updater/component_updater_service.cc
+++ b/chrome/browser/component_updater/component_updater_service.cc
@@ -30,7 +30,6 @@
#include "chrome/common/chrome_utility_messages.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/extensions/extension.h"
-#include "chrome/common/omaha_query_params/omaha_query_params.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/utility_process_host.h"
@@ -359,7 +358,6 @@
base::OneShotTimer<CrxUpdateService> timer_;
const Version chrome_version_;
- const std::string prod_id_;
bool running_;
@@ -375,8 +373,6 @@
config->PingUrl(),
config->RequestContext())),
chrome_version_(chrome::VersionInfo().Version()),
- prod_id_(chrome::OmahaQueryParams::GetProdIdString(
- chrome::OmahaQueryParams::CHROME)),
running_(false) {
}
diff --git a/chrome/browser/component_updater/pepper_flash_component_installer.cc b/chrome/browser/component_updater/pepper_flash_component_installer.cc
index 0897fe6..d9ac58c 100644
--- a/chrome/browser/component_updater/pepper_flash_component_installer.cc
+++ b/chrome/browser/component_updater/pepper_flash_component_installer.cc
@@ -34,6 +34,7 @@
#include "content/public/browser/plugin_service.h"
#include "content/public/common/pepper_plugin_info.h"
#include "ppapi/c/private/ppb_pdf.h"
+#include "ppapi/shared_impl/ppapi_permissions.h"
#include "webkit/common/plugins/ppapi/ppapi_utils.h"
#include "webkit/plugins/plugin_constants.h"
diff --git a/chrome/browser/component_updater/recovery_component_installer.cc b/chrome/browser/component_updater/recovery_component_installer.cc
index 625afd6..db620fe 100644
--- a/chrome/browser/component_updater/recovery_component_installer.cc
+++ b/chrome/browser/component_updater/recovery_component_installer.cc
@@ -14,7 +14,7 @@
#include "base/path_service.h"
#include "base/prefs/pref_registry_simple.h"
#include "base/prefs/pref_service.h"
-#include "base/process_util.h"
+#include "base/process/launch.h"
#include "base/strings/string_util.h"
#include "base/values.h"
#include "chrome/browser/component_updater/component_updater_service.h"
diff --git a/chrome/browser/devtools/adb/android_usb_device.cc b/chrome/browser/devtools/adb/android_usb_device.cc
index 9408328..a30b9e1 100644
--- a/chrome/browser/devtools/adb/android_usb_device.cc
+++ b/chrome/browser/devtools/adb/android_usb_device.cc
@@ -9,6 +9,7 @@
#include "base/base64.h"
#include "base/lazy_instance.h"
#include "base/message_loop/message_loop.h"
+#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "chrome/browser/devtools/adb/android_rsa.h"
#include "chrome/browser/devtools/adb/android_usb_socket.h"
@@ -40,54 +41,12 @@
base::LazyInstance<AndroidUsbDevices>::Leaky g_devices =
LAZY_INSTANCE_INITIALIZER;
-static std::string ReadSerialNumSync(libusb_device_handle* handle) {
- libusb_device* device = libusb_get_device(handle);
- libusb_device_descriptor descriptor;
- if (libusb_get_device_descriptor(device, &descriptor) != LIBUSB_SUCCESS)
- return std::string();
-
- if (!descriptor.iSerialNumber)
- return std::string();
-
- uint16 languages[128] = {0};
- memset(languages, 0, sizeof(languages));
-
- int res = libusb_control_transfer(
- handle,
- LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_STANDARD |
- LIBUSB_RECIPIENT_DEVICE,
- LIBUSB_REQUEST_GET_DESCRIPTOR, LIBUSB_DT_STRING << 8, 0,
- reinterpret_cast<uint8*>(languages), sizeof(languages), 0);
-
- if (res <= 0) {
- LOG(ERROR) << "Failed to get languages count";
- return std::string();
- }
-
- int language_count = (res - 2) / 2;
- uint16 buffer[128] = {0};
- for (int i = 1; i <= language_count; ++i) {
- memset(buffer, 0, sizeof(buffer));
-
- res = libusb_control_transfer(
- handle,
- LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_STANDARD |
- LIBUSB_RECIPIENT_DEVICE,
- LIBUSB_REQUEST_GET_DESCRIPTOR,
- (LIBUSB_DT_STRING << 8) | descriptor.iSerialNumber,
- languages[i], reinterpret_cast<uint8*>(buffer), sizeof(buffer), 0);
-
- if (res > 0) {
- res /= 2;
- char serial[256] = {0};
- int j;
- for (j = 1; j < res; ++j)
- serial[j - 1] = buffer[j];
- serial[j - 1] = '\0';
- return std::string(serial, j);
- }
- }
- return std::string();
+static std::string ReadSerialNumSync(scoped_refptr<UsbDeviceHandle> handle) {
+ base::string16 serial;
+ if (!handle->GetSerial(&serial))
+ return "";
+ else
+ return UTF16ToASCII(serial);
}
static void ClaimInterface(
@@ -130,7 +89,7 @@
if (!usb_device->ClaimInterface(1))
return;
- std::string serial = ReadSerialNumSync(usb_device->handle());
+ std::string serial = ReadSerialNumSync(usb_device);
scoped_refptr<AndroidUsbDevice> device =
new AndroidUsbDevice(rsa_key, usb_device, serial, inbound_address,
outbound_address, zero_mask);
diff --git a/chrome/browser/download/download_browsertest.cc b/chrome/browser/download/download_browsertest.cc
index b07cba9..37445e1 100644
--- a/chrome/browser/download/download_browsertest.cc
+++ b/chrome/browser/download/download_browsertest.cc
@@ -2804,8 +2804,6 @@
// Get the infobar at index 0.
InfoBarDelegate* infobar = infobar_service->infobar_at(0);
- ASSERT_TRUE(infobar != NULL);
-
ConfirmInfoBarDelegate* confirm_infobar = infobar->AsConfirmInfoBarDelegate();
ASSERT_TRUE(confirm_infobar != NULL);
diff --git a/chrome/browser/download/download_target_determiner_unittest.cc b/chrome/browser/download/download_target_determiner_unittest.cc
index ed943f7..46a1803 100644
--- a/chrome/browser/download/download_target_determiner_unittest.cc
+++ b/chrome/browser/download/download_target_determiner_unittest.cc
@@ -1087,7 +1087,7 @@
base::FilePath(FILE_PATH_LITERAL("foo.html"))));
// First the history service must exist.
- profile()->CreateHistoryService(false, false);
+ ASSERT_TRUE(profile()->CreateHistoryService(false, false));
GURL url("http://visited.example.com/visited-link.html");
// The time of visit is picked to be several seconds prior to the most recent
diff --git a/chrome/browser/drive/drive_api_service.cc b/chrome/browser/drive/drive_api_service.cc
index 5526fbb..9c963bd 100644
--- a/chrome/browser/drive/drive_api_service.cc
+++ b/chrome/browser/drive/drive_api_service.cc
@@ -43,6 +43,8 @@
using google_apis::GetFilelistRequest;
using google_apis::GetResourceEntryCallback;
using google_apis::GetResourceListCallback;
+using google_apis::GetShareUrlCallback;
+using google_apis::HTTP_NOT_IMPLEMENTED;
using google_apis::HTTP_SUCCESS;
using google_apis::InitiateUploadCallback;
using google_apis::ProgressCallback;
@@ -461,6 +463,20 @@
base::Bind(&ParseResourceEntryAndRun, callback)));
}
+CancelCallback DriveAPIService::GetShareUrl(
+ const std::string& resource_id,
+ const GURL& embed_origin,
+ const GetShareUrlCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
+
+ // TODO(mtomasz): Implement this, once it is supported by the Drive API.
+ NOTIMPLEMENTED();
+ callback.Run(HTTP_NOT_IMPLEMENTED, GURL());
+
+ return CancelCallback();
+}
+
CancelCallback DriveAPIService::GetAboutResource(
const GetAboutResourceCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
diff --git a/chrome/browser/drive/drive_api_service.h b/chrome/browser/drive/drive_api_service.h
index f2b2957..5c68586 100644
--- a/chrome/browser/drive/drive_api_service.h
+++ b/chrome/browser/drive/drive_api_service.h
@@ -89,6 +89,10 @@
virtual google_apis::CancelCallback GetResourceEntry(
const std::string& resource_id,
const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
+ virtual google_apis::CancelCallback GetShareUrl(
+ const std::string& resource_id,
+ const GURL& embed_origin,
+ const google_apis::GetShareUrlCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback GetAboutResource(
const google_apis::GetAboutResourceCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback GetAppList(
diff --git a/chrome/browser/drive/drive_service_interface.h b/chrome/browser/drive/drive_service_interface.h
index 7774727..a0149f5 100644
--- a/chrome/browser/drive/drive_service_interface.h
+++ b/chrome/browser/drive/drive_service_interface.h
@@ -155,6 +155,15 @@
const std::string& resource_id,
const google_apis::GetResourceEntryCallback& callback) = 0;
+ // Fetches an url for the sharing dialog for a single entry with id
+ // |resource_id|, to be embedded in a webview or an iframe with origin
+ // |embed_origin|. The url is returned via |callback| with results on the
+ // calling thread. |callback| must not be null.
+ virtual google_apis::CancelCallback GetShareUrl(
+ const std::string& resource_id,
+ const GURL& embed_origin,
+ const google_apis::GetShareUrlCallback& callback) = 0;
+
// Gets the about resource information from the server.
// Upon completion, invokes |callback| with results on the calling thread.
// |callback| must not be null.
diff --git a/chrome/browser/drive/dummy_drive_service.cc b/chrome/browser/drive/dummy_drive_service.cc
index 6d3d241..caf2d76 100644
--- a/chrome/browser/drive/dummy_drive_service.cc
+++ b/chrome/browser/drive/dummy_drive_service.cc
@@ -14,6 +14,7 @@
using google_apis::GetContentCallback;
using google_apis::GetResourceEntryCallback;
using google_apis::GetResourceListCallback;
+using google_apis::GetShareUrlCallback;
using google_apis::InitiateUploadCallback;
using google_apis::ProgressCallback;
using google_apis::UploadRangeCallback;
@@ -81,6 +82,11 @@
const std::string& resource_id,
const GetResourceEntryCallback& callback) { return CancelCallback(); }
+CancelCallback DummyDriveService::GetShareUrl(
+ const std::string& resource_id,
+ const GURL& embed_origin,
+ const GetShareUrlCallback& callback) { return CancelCallback(); }
+
CancelCallback DummyDriveService::GetAboutResource(
const GetAboutResourceCallback& callback) { return CancelCallback(); }
diff --git a/chrome/browser/drive/dummy_drive_service.h b/chrome/browser/drive/dummy_drive_service.h
index 8ebc922..315ad25 100644
--- a/chrome/browser/drive/dummy_drive_service.h
+++ b/chrome/browser/drive/dummy_drive_service.h
@@ -52,6 +52,10 @@
virtual google_apis::CancelCallback GetResourceEntry(
const std::string& resource_id,
const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
+ virtual google_apis::CancelCallback GetShareUrl(
+ const std::string& resource_id,
+ const GURL& embed_origin,
+ const google_apis::GetShareUrlCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback GetAboutResource(
const google_apis::GetAboutResourceCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback GetAppList(
diff --git a/chrome/browser/drive/event_logger.cc b/chrome/browser/drive/event_logger.cc
index 630a6be..0ba4034 100644
--- a/chrome/browser/drive/event_logger.cc
+++ b/chrome/browser/drive/event_logger.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/drive/event_logger.h"
+#include "base/logging.h"
#include "base/strings/stringprintf.h"
namespace drive {
@@ -30,6 +31,8 @@
base::StringAppendV(&what, format, args);
va_end(args);
+ DVLOG(1) << what;
+
base::AutoLock auto_lock(lock_);
history_.push_back(Event(next_event_id_, what));
++next_event_id_;
diff --git a/chrome/browser/drive/fake_drive_service.cc b/chrome/browser/drive/fake_drive_service.cc
index 36808b3..6c92c98 100644
--- a/chrome/browser/drive/fake_drive_service.cc
+++ b/chrome/browser/drive/fake_drive_service.cc
@@ -42,6 +42,7 @@
using google_apis::GetContentCallback;
using google_apis::GetResourceEntryCallback;
using google_apis::GetResourceListCallback;
+using google_apis::GetShareUrlCallback;
using google_apis::HTTP_BAD_REQUEST;
using google_apis::HTTP_CREATED;
using google_apis::HTTP_NOT_FOUND;
@@ -460,6 +461,49 @@
return CancelCallback();
}
+CancelCallback FakeDriveService::GetShareUrl(
+ const std::string& resource_id,
+ const GURL& /* embed_origin */,
+ const GetShareUrlCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
+
+ if (offline_) {
+ scoped_ptr<ResourceEntry> null;
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(callback,
+ GDATA_NO_CONNECTION,
+ GURL()));
+ return CancelCallback();
+ }
+
+ base::DictionaryValue* entry = FindEntryByResourceId(resource_id);
+ if (entry) {
+ // Share urls are stored in the resource entry, and they do not rely on the
+ // embedding origin.
+ scoped_ptr<ResourceEntry> resource_entry =
+ ResourceEntry::CreateFrom(*entry);
+ const Link* share_url = resource_entry->GetLinkByType(Link::LINK_SHARE);
+ if (share_url) {
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(callback, HTTP_SUCCESS, share_url->href()));
+ } else {
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(callback, HTTP_SUCCESS, GURL()));
+ }
+ return CancelCallback();
+ }
+
+ scoped_ptr<ResourceEntry> null;
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(callback, HTTP_NOT_FOUND, GURL()));
+ return CancelCallback();
+}
+
CancelCallback FakeDriveService::GetAboutResource(
const GetAboutResourceCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
diff --git a/chrome/browser/drive/fake_drive_service.h b/chrome/browser/drive/fake_drive_service.h
index 369eaa0..52fdfc6 100644
--- a/chrome/browser/drive/fake_drive_service.h
+++ b/chrome/browser/drive/fake_drive_service.h
@@ -114,6 +114,10 @@
virtual google_apis::CancelCallback GetResourceEntry(
const std::string& resource_id,
const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
+ virtual google_apis::CancelCallback GetShareUrl(
+ const std::string& resource_id,
+ const GURL& embed_origin,
+ const google_apis::GetShareUrlCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback GetAboutResource(
const google_apis::GetAboutResourceCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback GetAppList(
diff --git a/chrome/browser/drive/fake_drive_service_unittest.cc b/chrome/browser/drive/fake_drive_service_unittest.cc
index 7104094..ea988fe 100644
--- a/chrome/browser/drive/fake_drive_service_unittest.cc
+++ b/chrome/browser/drive/fake_drive_service_unittest.cc
@@ -806,6 +806,23 @@
EXPECT_FALSE(resource_entry);
}
+TEST_F(FakeDriveServiceTest, GetShareUrl) {
+ ASSERT_TRUE(fake_service_.LoadResourceListForWapi(
+ "gdata/root_feed.json"));
+
+ const std::string kResourceId = "file:2_file_resource_id";
+ GDataErrorCode error = GDATA_OTHER_ERROR;
+ GURL share_url;
+ fake_service_.GetShareUrl(
+ kResourceId,
+ GURL(), // embed origin
+ test_util::CreateCopyResultCallback(&error, &share_url));
+ base::RunLoop().RunUntilIdle();
+
+ EXPECT_EQ(HTTP_SUCCESS, error);
+ EXPECT_FALSE(share_url.is_empty());
+}
+
TEST_F(FakeDriveServiceTest, DeleteResource_ExistingFile) {
ASSERT_TRUE(fake_service_.LoadResourceListForWapi(
"gdata/root_feed.json"));
diff --git a/chrome/browser/drive/gdata_wapi_service.cc b/chrome/browser/drive/gdata_wapi_service.cc
index 239e888..d4e0b90 100644
--- a/chrome/browser/drive/gdata_wapi_service.cc
+++ b/chrome/browser/drive/gdata_wapi_service.cc
@@ -46,11 +46,13 @@
using google_apis::GetResourceEntryRequest;
using google_apis::GetResourceListCallback;
using google_apis::GetResourceListRequest;
+using google_apis::GetShareUrlCallback;
using google_apis::GetUploadStatusRequest;
using google_apis::HTTP_NOT_IMPLEMENTED;
using google_apis::InitiateUploadCallback;
using google_apis::InitiateUploadExistingFileRequest;
using google_apis::InitiateUploadNewFileRequest;
+using google_apis::Link;
using google_apis::ProgressCallback;
using google_apis::RemoveResourceFromDirectoryRequest;
using google_apis::RenameResourceRequest;
@@ -96,6 +98,30 @@
callback.Run(error, entry.Pass());
}
+// Extracts an url to the sharing dialog and returns it via |callback|. If
+// the share url doesn't exist, then an empty url is returned.
+void ParseShareUrlAndRun(const GetShareUrlCallback& callback,
+ GDataErrorCode error,
+ scoped_ptr<base::Value> value) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ if (!value) {
+ callback.Run(error, GURL());
+ return;
+ }
+
+ // Parsing ResourceEntry is cheap enough to do on UI thread.
+ scoped_ptr<ResourceEntry> entry =
+ google_apis::ResourceEntry::ExtractAndParse(*value);
+ if (!entry) {
+ callback.Run(GDATA_PARSE_ERROR, GURL());
+ return;
+ }
+
+ const Link* share_link = entry->GetLinkByType(Link::LINK_SHARE);
+ callback.Run(error, share_link ? share_link->href() : GURL());
+}
+
void ParseAboutResourceAndRun(
const GetAboutResourceCallback& callback,
GDataErrorCode error,
@@ -301,10 +327,27 @@
new GetResourceEntryRequest(sender_.get(),
url_generator_,
resource_id,
+ GURL(),
base::Bind(&ParseResourceEntryAndRun,
callback)));
}
+CancelCallback GDataWapiService::GetShareUrl(
+ const std::string& resource_id,
+ const GURL& embed_origin,
+ const GetShareUrlCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
+
+ return sender_->StartRequestWithRetry(
+ new GetResourceEntryRequest(sender_.get(),
+ url_generator_,
+ resource_id,
+ embed_origin,
+ base::Bind(&ParseShareUrlAndRun,
+ callback)));
+}
+
CancelCallback GDataWapiService::GetAboutResource(
const GetAboutResourceCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
diff --git a/chrome/browser/drive/gdata_wapi_service.h b/chrome/browser/drive/gdata_wapi_service.h
index 297c154..11294e9 100644
--- a/chrome/browser/drive/gdata_wapi_service.h
+++ b/chrome/browser/drive/gdata_wapi_service.h
@@ -90,6 +90,10 @@
virtual google_apis::CancelCallback GetResourceEntry(
const std::string& resource_id,
const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
+ virtual google_apis::CancelCallback GetShareUrl(
+ const std::string& resource_id,
+ const GURL& embed_origin,
+ const google_apis::GetShareUrlCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback GetAboutResource(
const google_apis::GetAboutResourceCallback& callback) OVERRIDE;
virtual google_apis::CancelCallback GetAppList(
diff --git a/chrome/browser/extensions/api/debugger/debugger_api.cc b/chrome/browser/extensions/api/debugger/debugger_api.cc
index b1d8962..f29ea9a 100644
--- a/chrome/browser/extensions/api/debugger/debugger_api.cc
+++ b/chrome/browser/extensions/api/debugger/debugger_api.cc
@@ -566,15 +566,14 @@
return false;
}
- ExtensionDevToolsInfoBarDelegate* infobar_delegate = NULL;
-
+ ExtensionDevToolsInfoBarDelegate* infobar = NULL;
if (!CommandLine::ForCurrentProcess()->
HasSwitch(switches::kSilentDebuggerExtensionAPI)) {
// Do not attach to the target if for any reason the infobar cannot be shown
// for this WebContents instance.
- infobar_delegate = ExtensionDevToolsInfoBarDelegate::Create(
+ infobar = ExtensionDevToolsInfoBarDelegate::Create(
agent_host_->GetRenderViewHost(), GetExtension()->name());
- if (!infobar_delegate) {
+ if (!infobar) {
error_ = ErrorUtils::FormatErrorMessage(
keys::kSilentDebuggingRequired,
switches::kSilentDebuggerExtensionAPI);
@@ -582,12 +581,9 @@
}
}
- new ExtensionDevToolsClientHost(profile(),
- agent_host_.get(),
- GetExtension()->id(),
- GetExtension()->name(),
- debuggee_,
- infobar_delegate);
+ new ExtensionDevToolsClientHost(profile(), agent_host_.get(),
+ GetExtension()->id(), GetExtension()->name(),
+ debuggee_, infobar);
SendResponse(true);
return true;
}
diff --git a/chrome/browser/extensions/api/messaging/native_message_process_host.cc b/chrome/browser/extensions/api/messaging/native_message_process_host.cc
index b39ea79..749cb43 100644
--- a/chrome/browser/extensions/api/messaging/native_message_process_host.cc
+++ b/chrome/browser/extensions/api/messaging/native_message_process_host.cc
@@ -8,7 +8,6 @@
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/platform_file.h"
-#include "base/process_util.h"
#include "base/values.h"
#include "chrome/browser/extensions/api/messaging/native_messaging_host_manifest.h"
#include "chrome/browser/extensions/api/messaging/native_process_launcher.h"
diff --git a/chrome/browser/extensions/api/messaging/native_message_process_host.h b/chrome/browser/extensions/api/messaging/native_message_process_host.h
index c4692f1..8458b28 100644
--- a/chrome/browser/extensions/api/messaging/native_message_process_host.h
+++ b/chrome/browser/extensions/api/messaging/native_message_process_host.h
@@ -11,7 +11,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop.h"
-#include "base/process.h"
+#include "base/process/process.h"
#include "chrome/browser/extensions/api/messaging/native_process_launcher.h"
#include "content/public/browser/browser_thread.h"
diff --git a/chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc b/chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc
index 5fd9338..8653d10 100644
--- a/chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc
+++ b/chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc
@@ -13,7 +13,6 @@
#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
#include "base/platform_file.h"
-#include "base/process_util.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/test/test_timeouts.h"
diff --git a/chrome/browser/extensions/api/messaging/native_process_launcher.cc b/chrome/browser/extensions/api/messaging/native_process_launcher.cc
index a10801e..654158a 100644
--- a/chrome/browser/extensions/api/messaging/native_process_launcher.cc
+++ b/chrome/browser/extensions/api/messaging/native_process_launcher.cc
@@ -11,7 +11,6 @@
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/path_service.h"
-#include "base/process_util.h"
#include "base/strings/string_split.h"
#include "base/threading/sequenced_worker_pool.h"
#include "chrome/browser/extensions/api/messaging/native_messaging_host_manifest.h"
diff --git a/chrome/browser/extensions/api/messaging/native_process_launcher.h b/chrome/browser/extensions/api/messaging/native_process_launcher.h
index aff6c87..0f5122bd 100644
--- a/chrome/browser/extensions/api/messaging/native_process_launcher.h
+++ b/chrome/browser/extensions/api/messaging/native_process_launcher.h
@@ -8,7 +8,7 @@
#include "base/callback_forward.h"
#include "base/memory/scoped_ptr.h"
#include "base/platform_file.h"
-#include "base/process.h"
+#include "base/process/process.h"
class CommandLine;
class GURL;
diff --git a/chrome/browser/extensions/api/messaging/native_process_launcher_posix.cc b/chrome/browser/extensions/api/messaging/native_process_launcher_posix.cc
index 411fb02..3cc4bc6 100644
--- a/chrome/browser/extensions/api/messaging/native_process_launcher_posix.cc
+++ b/chrome/browser/extensions/api/messaging/native_process_launcher_posix.cc
@@ -8,7 +8,7 @@
#include "base/file_util.h"
#include "base/logging.h"
#include "base/posix/eintr_wrapper.h"
-#include "base/process_util.h"
+#include "base/process/launch.h"
#include "chrome/browser/extensions/api/messaging/native_messaging_host_manifest.h"
namespace extensions {
diff --git a/chrome/browser/extensions/api/messaging/native_process_launcher_win.cc b/chrome/browser/extensions/api/messaging/native_process_launcher_win.cc
index 70d0fd6..0eed352 100644
--- a/chrome/browser/extensions/api/messaging/native_process_launcher_win.cc
+++ b/chrome/browser/extensions/api/messaging/native_process_launcher_win.cc
@@ -8,7 +8,8 @@
#include "base/command_line.h"
#include "base/logging.h"
-#include "base/process_util.h"
+#include "base/process/kill.h"
+#include "base/process/launch.h"
#include "base/strings/string16.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
diff --git a/chrome/browser/extensions/api/omnibox/omnibox_api.cc b/chrome/browser/extensions/api/omnibox/omnibox_api.cc
index 64066db..9a07ee9 100644
--- a/chrome/browser/extensions/api/omnibox/omnibox_api.cc
+++ b/chrome/browser/extensions/api/omnibox/omnibox_api.cc
@@ -242,8 +242,10 @@
}
}
} else if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) {
+ if (content::Details<UnloadedExtensionInfo>(details)->already_disabled)
+ return;
const Extension* extension =
- content::Details<const UnloadedExtensionInfo>(details)->extension;
+ content::Details<UnloadedExtensionInfo>(details)->extension;
if (!OmniboxInfo::GetKeyword(extension).empty()) {
if (url_service_) {
if (url_service_->loaded())
diff --git a/chrome/browser/extensions/api/record/record_api.cc b/chrome/browser/extensions/api/record/record_api.cc
index 820c346..b381316 100644
--- a/chrome/browser/extensions/api/record/record_api.cc
+++ b/chrome/browser/extensions/api/record/record_api.cc
@@ -9,7 +9,8 @@
#include "base/file_util.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
-#include "base/process_util.h"
+#include "base/process/kill.h"
+#include "base/process/launch.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
diff --git a/chrome/browser/extensions/api/system_info_storage/system_info_storage_apitest.cc b/chrome/browser/extensions/api/system_info_storage/system_info_storage_apitest.cc
index 671f628..cd8207d 100644
--- a/chrome/browser/extensions/api/system_info_storage/system_info_storage_apitest.cc
+++ b/chrome/browser/extensions/api/system_info_storage/system_info_storage_apitest.cc
@@ -1,10 +1,10 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+
#include "base/command_line.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/utf_string_conversions.h"
-#include "base/timer/timer.h"
#include "chrome/browser/extensions/api/system_info_storage/storage_info_provider.h"
#include "chrome/browser/extensions/api/system_info_storage/test_storage_info_provider.h"
#include "chrome/browser/extensions/extension_apitest.h"
@@ -27,7 +27,7 @@
using extensions::TestStorageUnitInfo;
using extensions::TestStorageInfoProvider;
-struct TestStorageUnitInfo kTestingData[] = {
+const struct TestStorageUnitInfo kTestingData[] = {
{"dcim:device:0004", "transient:0004", "0xbeaf", kStorageTypeUnknown,
4098, 1000, 0},
{"path:device:002", "transient:002", "/home", kStorageTypeFixed,
@@ -36,14 +36,14 @@
10000, 1000, 4097}
};
-struct TestStorageUnitInfo kRemovableStorageData[] = {
+const struct TestStorageUnitInfo kRemovableStorageData[] = {
{"dcim:device:0004", "transient:0004", "/media/usb1",
kStorageTypeRemovable, 4098, 1000, 1}
};
} // namespace
-class SystemInfoStorageApiTest: public ExtensionApiTest {
+class SystemInfoStorageApiTest : public ExtensionApiTest {
public:
SystemInfoStorageApiTest() {}
virtual ~SystemInfoStorageApiTest() {}
@@ -59,8 +59,7 @@
}
void AttachRemovableStorage(const std::string& device_id) {
- size_t len = arraysize(kRemovableStorageData);
- for (size_t i = 0; i < len; ++i) {
+ for (size_t i = 0; i < arraysize(kRemovableStorageData); ++i) {
if (kRemovableStorageData[i].device_id != device_id)
continue;
diff --git a/chrome/browser/extensions/data_deleter.cc b/chrome/browser/extensions/data_deleter.cc
index 46518b0..8c8fe4f 100644
--- a/chrome/browser/extensions/data_deleter.cc
+++ b/chrome/browser/extensions/data_deleter.cc
@@ -41,16 +41,19 @@
// preserve this code path without checking for isolation because it's
// simpler than special casing. This code should go away once we merge
// the various URLRequestContexts (http://crbug.com/159193).
- partition->AsyncClearDataForOrigin(
+ partition->ClearDataForOrigin(
+ content::StoragePartition::REMOVE_DATA_MASK_ALL,
content::StoragePartition::kAllStorage,
storage_origin,
profile->GetRequestContextForExtensions());
} else {
// We don't need to worry about the media request context because that
// shares the same cookie store as the main request context.
- partition->AsyncClearDataForOrigin(content::StoragePartition::kAllStorage,
- storage_origin,
- partition->GetURLRequestContext());
+ partition->ClearDataForOrigin(
+ content::StoragePartition::REMOVE_DATA_MASK_ALL,
+ content::StoragePartition::kAllStorage,
+ storage_origin,
+ partition->GetURLRequestContext());
}
// Begin removal of the settings for the current extension.
diff --git a/chrome/browser/extensions/extension_crash_recovery_browsertest.cc b/chrome/browser/extensions/extension_crash_recovery_browsertest.cc
index 5ca5607..42956ca 100644
--- a/chrome/browser/extensions/extension_crash_recovery_browsertest.cc
+++ b/chrome/browser/extensions/extension_crash_recovery_browsertest.cc
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/process_util.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/extension_browsertest.h"
#include "chrome/browser/extensions/extension_host.h"
diff --git a/chrome/browser/extensions/extension_function.h b/chrome/browser/extensions/extension_function.h
index 4afc40d..8ffee2e 100644
--- a/chrome/browser/extensions/extension_function.h
+++ b/chrome/browser/extensions/extension_function.h
@@ -13,7 +13,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
-#include "base/process.h"
+#include "base/process/process.h"
#include "base/sequenced_task_runner_helpers.h"
#include "chrome/browser/extensions/extension_function_histogram_value.h"
#include "chrome/browser/extensions/extension_info_map.h"
diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc
index 47241e9..1109652 100644
--- a/chrome/browser/extensions/extension_function_dispatcher.cc
+++ b/chrome/browser/extensions/extension_function_dispatcher.cc
@@ -9,8 +9,7 @@
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
-#include "base/process.h"
-#include "base/process_util.h"
+#include "base/process/process.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/browser/extensions/activity_log/activity_log.h"
diff --git a/chrome/browser/extensions/extension_function_histogram_value.h b/chrome/browser/extensions/extension_function_histogram_value.h
index f9123fd..77da406 100644
--- a/chrome/browser/extensions/extension_function_histogram_value.h
+++ b/chrome/browser/extensions/extension_function_histogram_value.h
@@ -571,6 +571,7 @@
SYSTEM_DISPLAY_GETINFO,
SYSTEM_DISPLAY_SETDISPLAYPROPERTIES,
SYSTEM_MEMORY_GETINFO,
+ FILEBROWSERPRIVATE_GETSHAREURL,
ENUM_BOUNDARY // Last entry: Add new entries above.
};
diff --git a/chrome/browser/extensions/extension_protocols.cc b/chrome/browser/extensions/extension_protocols.cc
index 2385d0e..fdafe9f 100644
--- a/chrome/browser/extensions/extension_protocols.cc
+++ b/chrome/browser/extensions/extension_protocols.cc
@@ -74,7 +74,7 @@
if (!last_modified_time.is_null()) {
// Hash the time and make an etag to avoid exposing the exact
// user installation time of the extension.
- std::string hash = base::StringPrintf("%"PRId64"",
+ std::string hash = base::StringPrintf("%" PRId64,
last_modified_time.ToInternalValue());
hash = base::SHA1HashString(hash);
std::string etag;
diff --git a/chrome/browser/extensions/extension_url_rewrite_browsertest.cc b/chrome/browser/extensions/extension_url_rewrite_browsertest.cc
index 0764187..0eb343f 100644
--- a/chrome/browser/extensions/extension_url_rewrite_browsertest.cc
+++ b/chrome/browser/extensions/extension_url_rewrite_browsertest.cc
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/process_util.h"
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/extensions/component_loader.h"
diff --git a/chrome/browser/extensions/extension_web_ui_override_registrar.cc b/chrome/browser/extensions/extension_web_ui_override_registrar.cc
index aab0a03..8ce1f8b 100644
--- a/chrome/browser/extensions/extension_web_ui_override_registrar.cc
+++ b/chrome/browser/extensions/extension_web_ui_override_registrar.cc
@@ -35,8 +35,10 @@
profile_, URLOverrides::GetChromeURLOverrides(extension));
} else if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) {
+ if (content::Details<UnloadedExtensionInfo>(details)->already_disabled)
+ return;
const Extension* extension =
- content::Details<const UnloadedExtensionInfo>(details)->extension;
+ content::Details<UnloadedExtensionInfo>(details)->extension;
ExtensionWebUI::UnregisterChromeURLOverrides(
profile_, URLOverrides::GetChromeURLOverrides(extension));
}
diff --git a/chrome/browser/extensions/extensions_quota_service_unittest.cc b/chrome/browser/extensions/extensions_quota_service_unittest.cc
index 9cb6fdc..a0438ff 100644
--- a/chrome/browser/extensions/extensions_quota_service_unittest.cc
+++ b/chrome/browser/extensions/extensions_quota_service_unittest.cc
@@ -3,7 +3,7 @@
// found in the LICENSE file.
#include "base/message_loop/message_loop.h"
-#include "base/process.h"
+#include "base/process/process.h"
#include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "chrome/browser/extensions/extension_function.h"
diff --git a/chrome/browser/extensions/external_loader.cc b/chrome/browser/extensions/external_loader.cc
index e64d51a..c706a43 100644
--- a/chrome/browser/extensions/external_loader.cc
+++ b/chrome/browser/extensions/external_loader.cc
@@ -14,8 +14,7 @@
namespace extensions {
ExternalLoader::ExternalLoader()
- : owner_(NULL),
- running_(false) {
+ : owner_(NULL) {
}
void ExternalLoader::Init(ExternalProviderImpl* owner) {
@@ -40,7 +39,6 @@
void ExternalLoader::LoadFinished() {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- running_ = false;
if (owner_) {
owner_->SetPrefs(prefs_.release());
}
diff --git a/chrome/browser/extensions/external_loader.h b/chrome/browser/extensions/external_loader.h
index 1215836..86ffee3 100644
--- a/chrome/browser/extensions/external_loader.h
+++ b/chrome/browser/extensions/external_loader.h
@@ -71,10 +71,6 @@
ExternalProviderImpl* owner_; // weak
- // Set to true if loading the extensions is already running. New requests
- // are ignored while this is set true.
- bool running_;
-
DISALLOW_COPY_AND_ASSIGN(ExternalLoader);
};
diff --git a/chrome/browser/extensions/gtalk_extension_browsertest.cc b/chrome/browser/extensions/gtalk_extension_browsertest.cc
index 94a5ecd..42e4ecc 100644
--- a/chrome/browser/extensions/gtalk_extension_browsertest.cc
+++ b/chrome/browser/extensions/gtalk_extension_browsertest.cc
@@ -3,7 +3,6 @@
// found in the LICENSE file.
#include "base/bind.h"
-#include "base/process_util.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/extension_browsertest.h"
diff --git a/chrome/browser/extensions/platform_app_launcher.cc b/chrome/browser/extensions/platform_app_launcher.cc
index 66d1133..19356ee 100644
--- a/chrome/browser/extensions/platform_app_launcher.cc
+++ b/chrome/browser/extensions/platform_app_launcher.cc
@@ -288,9 +288,8 @@
// On Windows 8's single window Metro mode we can not launch platform apps.
// Offer to switch Chrome to desktop mode.
if (win8::IsSingleWindowMetroMode()) {
- chrome::AppMetroInfoBarDelegateWin::Create(
- profile,
- chrome::AppMetroInfoBarDelegateWin::LAUNCH_PACKAGED_APP,
+ AppMetroInfoBarDelegateWin::Create(
+ profile, AppMetroInfoBarDelegateWin::LAUNCH_PACKAGED_APP,
extension->id());
return;
}
diff --git a/chrome/browser/first_run/first_run_internal_win.cc b/chrome/browser/first_run/first_run_internal_win.cc
index 5cb5228..e87ba72 100644
--- a/chrome/browser/first_run/first_run_internal_win.cc
+++ b/chrome/browser/first_run/first_run_internal_win.cc
@@ -13,8 +13,9 @@
#include "base/file_util.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
-#include "base/process.h"
-#include "base/process_util.h"
+#include "base/process/kill.h"
+#include "base/process/launch.h"
+#include "base/process/process.h"
#include "base/threading/sequenced_worker_pool.h"
#include "base/time/time.h"
#include "base/win/metro.h"
diff --git a/chrome/browser/first_run/upgrade_util_linux.cc b/chrome/browser/first_run/upgrade_util_linux.cc
index 22b252c..8d6d8a9 100644
--- a/chrome/browser/first_run/upgrade_util_linux.cc
+++ b/chrome/browser/first_run/upgrade_util_linux.cc
@@ -11,7 +11,7 @@
#include "base/logging.h"
#include "base/path_service.h"
#include "base/platform_file.h"
-#include "base/process_util.h"
+#include "base/process/launch.h"
#include "chrome/browser/first_run/upgrade_util_linux.h"
namespace {
diff --git a/chrome/browser/first_run/upgrade_util_win.cc b/chrome/browser/first_run/upgrade_util_win.cc
index c669aa0..5361146 100644
--- a/chrome/browser/first_run/upgrade_util_win.cc
+++ b/chrome/browser/first_run/upgrade_util_win.cc
@@ -17,7 +17,8 @@
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/path_service.h"
-#include "base/process_util.h"
+#include "base/process/launch.h"
+#include "base/process/process_handle.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
diff --git a/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc b/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc
index 7a1c0e5..a7687c2 100644
--- a/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc
+++ b/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc
@@ -406,7 +406,7 @@
ConfirmInfoBarDelegate* infobar_delegate =
infobar_service()->infobar_at(0)->AsConfirmInfoBarDelegate();
ASSERT_TRUE(infobar_delegate);
- // Accept the frame
+ // Accept the frame.
infobar_delegate->Accept();
CheckTabContentsState(requesting_frame, CONTENT_SETTING_ALLOW);
CheckPermissionMessageSent(0, true);
@@ -613,9 +613,7 @@
RequestGeolocationPermission(RequestID(1), requesting_frame_1);
// Ensure only one infobar is created.
ASSERT_EQ(1U, infobar_service()->infobar_count());
- ConfirmInfoBarDelegate* infobar =
- infobar_service()->infobar_at(0)->AsConfirmInfoBarDelegate();
- ASSERT_TRUE(infobar);
+ InfoBarDelegate* infobar = infobar_service()->infobar_at(0);
// Delete the tab contents.
DeleteContents();
diff --git a/chrome/browser/google_apis/base_requests.cc b/chrome/browser/google_apis/base_requests.cc
index 8963eb9..2dbadde 100644
--- a/chrome/browser/google_apis/base_requests.cc
+++ b/chrome/browser/google_apis/base_requests.cc
@@ -490,8 +490,9 @@
scoped_ptr<base::Value>());
OnProcessURLFetchResultsComplete(true);
- } else {
- // There might be explanation of unexpected error code in response.
+ } else if (code == HTTP_CREATED || code == HTTP_SUCCESS) {
+ // The upload is successfully done. Parse the response which should be
+ // the entry's metadata.
std::string response_content;
source->GetResponseAsString(&response_content);
@@ -500,16 +501,21 @@
base::Bind(&UploadRangeRequestBase::OnDataParsed,
weak_ptr_factory_.GetWeakPtr(),
code));
+ } else {
+ // Failed to upload. Run callbacks to notify the error.
+ OnRangeRequestComplete(
+ UploadRangeResponse(code, -1, -1), scoped_ptr<base::Value>());
+ OnProcessURLFetchResultsComplete(false);
}
}
void UploadRangeRequestBase::OnDataParsed(GDataErrorCode code,
scoped_ptr<base::Value> value) {
DCHECK(CalledOnValidThread());
+ DCHECK(code == HTTP_CREATED || code == HTTP_SUCCESS);
OnRangeRequestComplete(UploadRangeResponse(code, -1, -1), value.Pass());
- OnProcessURLFetchResultsComplete(
- code == HTTP_CREATED || code == HTTP_SUCCESS);
+ OnProcessURLFetchResultsComplete(true);
}
void UploadRangeRequestBase::RunCallbackOnPrematureFailure(
diff --git a/chrome/browser/google_apis/drive_api_requests_unittest.cc b/chrome/browser/google_apis/drive_api_requests_unittest.cc
index 050e757..bdba3d8 100644
--- a/chrome/browser/google_apis/drive_api_requests_unittest.cc
+++ b/chrome/browser/google_apis/drive_api_requests_unittest.cc
@@ -68,6 +68,9 @@
base::Bind(&DriveApiRequestsTest::HandleDataFileRequest,
base::Unretained(this)));
test_server_.RegisterRequestHandler(
+ base::Bind(&DriveApiRequestsTest::HandlePreconditionFailedRequest,
+ base::Unretained(this)));
+ test_server_.RegisterRequestHandler(
base::Bind(&DriveApiRequestsTest::HandleResumeUploadRequest,
base::Unretained(this)));
test_server_.RegisterRequestHandler(
@@ -105,6 +108,10 @@
// for initiating file uploading.
std::string expected_upload_path_;
+ // This is a path to the file which contains expected response for
+ // PRECONDITION_FAILED response.
+ base::FilePath expected_precondition_failed_file_path_;
+
// These are content and its type in the expected response from the server.
// See also HandleContentResponse below.
std::string expected_content_type_;
@@ -162,6 +169,33 @@
expected_data_file_path_).PassAs<net::test_server::HttpResponse>();
}
+ // Returns PRECONDITION_FAILED response for ETag mismatching with error JSON
+ // content specified by |expected_precondition_failed_file_path_|.
+ // To use this method, it is necessary to set the variable to the appropriate
+ // file path before sending the request to the server.
+ scoped_ptr<net::test_server::HttpResponse> HandlePreconditionFailedRequest(
+ const net::test_server::HttpRequest& request) {
+ if (expected_precondition_failed_file_path_.empty()) {
+ // The file is not specified. Delegate the process to the next handler.
+ return scoped_ptr<net::test_server::HttpResponse>();
+ }
+
+ http_request_ = request;
+
+ scoped_ptr<net::test_server::BasicHttpResponse> response(
+ new net::test_server::BasicHttpResponse);
+ response->set_code(net::HTTP_PRECONDITION_FAILED);
+
+ std::string content;
+ if (file_util::ReadFileToString(expected_precondition_failed_file_path_,
+ &content)) {
+ response->set_content(content);
+ response->set_content_type("application/json");
+ }
+
+ return response.PassAs<net::test_server::HttpResponse>();
+ }
+
// Returns the response based on set expected upload url.
// The response contains the url in its "Location: " header. Also, it doesn't
// have any content.
@@ -181,19 +215,10 @@
scoped_ptr<net::test_server::BasicHttpResponse> response(
new net::test_server::BasicHttpResponse);
- // Check an ETag.
- std::map<std::string, std::string>::const_iterator found =
- request.headers.find("If-Match");
- if (found != request.headers.end() &&
- found->second != "*" &&
- found->second != kTestETag) {
- response->set_code(net::HTTP_PRECONDITION_FAILED);
- return response.PassAs<net::test_server::HttpResponse>();
- }
-
// Check if the X-Upload-Content-Length is present. If yes, store the
// length of the file.
- found = request.headers.find("X-Upload-Content-Length");
+ std::map<std::string, std::string>::const_iterator found =
+ request.headers.find("X-Upload-Content-Length");
if (found == request.headers.end() ||
!base::StringToInt64(found->second, &content_length_)) {
return scoped_ptr<net::test_server::HttpResponse>();
@@ -1314,6 +1339,11 @@
// Set an expected url for uploading.
expected_upload_path_ = kTestUploadExistingFilePath;
+ // If it turned out that the etag is conflicting, PRECONDITION_FAILED should
+ // be returned.
+ expected_precondition_failed_file_path_ =
+ test_util::GetTestFilePath("drive/error.json");
+
const char kTestContentType[] = "text/plain";
const std::string kTestContent(100, 'a');
@@ -1351,6 +1381,102 @@
EXPECT_TRUE(http_request_.content.empty());
}
+TEST_F(DriveApiRequestsTest,
+ UploadExistingFileRequestWithETagConflictOnResumeUpload) {
+ // Set an expected url for uploading.
+ expected_upload_path_ = kTestUploadExistingFilePath;
+
+ const char kTestContentType[] = "text/plain";
+ const std::string kTestContent(100, 'a');
+ const base::FilePath kTestFilePath =
+ temp_dir_.path().AppendASCII("upload_file.txt");
+ ASSERT_TRUE(test_util::WriteStringToFile(kTestFilePath, kTestContent));
+
+ GDataErrorCode error = GDATA_OTHER_ERROR;
+ GURL upload_url;
+
+ // Initiate uploading a new file to the directory with "parent_resource_id".
+ {
+ base::RunLoop run_loop;
+ drive::InitiateUploadExistingFileRequest* request =
+ new drive::InitiateUploadExistingFileRequest(
+ request_sender_.get(),
+ *url_generator_,
+ kTestContentType,
+ kTestContent.size(),
+ "resource_id", // The resource id of the file to be overwritten.
+ kTestETag,
+ test_util::CreateQuitCallback(
+ &run_loop,
+ test_util::CreateCopyResultCallback(&error, &upload_url)));
+ request_sender_->StartRequestWithRetry(request);
+ run_loop.Run();
+ }
+
+ EXPECT_EQ(HTTP_SUCCESS, error);
+ EXPECT_EQ(kTestUploadExistingFilePath, upload_url.path());
+ EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]);
+ EXPECT_EQ(base::Int64ToString(kTestContent.size()),
+ http_request_.headers["X-Upload-Content-Length"]);
+ EXPECT_EQ(kTestETag, http_request_.headers["If-Match"]);
+
+ EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method);
+ EXPECT_EQ("/upload/drive/v2/files/resource_id?uploadType=resumable",
+ http_request_.relative_url);
+ EXPECT_TRUE(http_request_.has_content);
+ EXPECT_TRUE(http_request_.content.empty());
+
+ // Set PRECONDITION_FAILED to the server. This is the emulation of the
+ // confliction during uploading.
+ expected_precondition_failed_file_path_ =
+ test_util::GetTestFilePath("drive/error.json");
+
+ // Upload the content to the upload URL.
+ UploadRangeResponse response;
+ scoped_ptr<FileResource> new_entry;
+
+ {
+ base::RunLoop run_loop;
+ drive::ResumeUploadRequest* resume_request =
+ new drive::ResumeUploadRequest(
+ request_sender_.get(),
+ upload_url,
+ 0, // start_position
+ kTestContent.size(), // end_position (exclusive)
+ kTestContent.size(), // content_length,
+ kTestContentType,
+ kTestFilePath,
+ test_util::CreateQuitCallback(
+ &run_loop,
+ test_util::CreateCopyResultCallback(&response, &new_entry)),
+ ProgressCallback());
+ request_sender_->StartRequestWithRetry(resume_request);
+ run_loop.Run();
+ }
+
+ // METHOD_PUT should be used to upload data.
+ EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method);
+ // Request should go to the upload URL.
+ EXPECT_EQ(upload_url.path(), http_request_.relative_url);
+ // Content-Range header should be added.
+ EXPECT_EQ("bytes 0-" +
+ base::Int64ToString(kTestContent.size() - 1) + "/" +
+ base::Int64ToString(kTestContent.size()),
+ http_request_.headers["Content-Range"]);
+ // The upload content should be set in the HTTP request.
+ EXPECT_TRUE(http_request_.has_content);
+ EXPECT_EQ(kTestContent, http_request_.content);
+
+ // Check the response.
+ EXPECT_EQ(HTTP_PRECONDITION, response.code);
+ // The start and end positions should be set to -1 for error.
+ EXPECT_EQ(-1, response.start_position_received);
+ EXPECT_EQ(-1, response.end_position_received);
+
+ // New entry should be NULL.
+ EXPECT_FALSE(new_entry.get());
+}
+
TEST_F(DriveApiRequestsTest, DownloadFileRequest) {
const base::FilePath kDownloadedFilePath =
temp_dir_.path().AppendASCII("cache_file");
diff --git a/chrome/browser/google_apis/drive_common_callbacks.h b/chrome/browser/google_apis/drive_common_callbacks.h
index d39e43c..fb6d760 100644
--- a/chrome/browser/google_apis/drive_common_callbacks.h
+++ b/chrome/browser/google_apis/drive_common_callbacks.h
@@ -27,15 +27,18 @@
scoped_ptr<ResourceEntry> entry)>
GetResourceEntryCallback;
-// Callback used for gettign AboutResource.
+// Callback used for getting AboutResource.
typedef base::Callback<void(GDataErrorCode error,
scoped_ptr<AboutResource> about_resource)>
GetAboutResourceCallback;
+// Callback used for getting ShareUrl.
+typedef base::Callback<void(GDataErrorCode error,
+ const GURL& share_url)> GetShareUrlCallback;
+
// Callback used for getting AppList.
typedef base::Callback<void(GDataErrorCode error,
- scoped_ptr<AppList> app_list)>
- GetAppListCallback;
+ scoped_ptr<AppList> app_list)> GetAppListCallback;
// Callback used for handling UploadRangeResponse.
typedef base::Callback<void(
diff --git a/chrome/browser/google_apis/gdata_wapi_requests.cc b/chrome/browser/google_apis/gdata_wapi_requests.cc
index 0b22d34..1141db2 100644
--- a/chrome/browser/google_apis/gdata_wapi_requests.cc
+++ b/chrome/browser/google_apis/gdata_wapi_requests.cc
@@ -217,17 +217,20 @@
RequestSender* sender,
const GDataWapiUrlGenerator& url_generator,
const std::string& resource_id,
+ const GURL& embed_origin,
const GetDataCallback& callback)
: GetDataRequest(sender, callback),
url_generator_(url_generator),
- resource_id_(resource_id) {
+ resource_id_(resource_id),
+ embed_origin_(embed_origin) {
DCHECK(!callback.is_null());
}
GetResourceEntryRequest::~GetResourceEntryRequest() {}
GURL GetResourceEntryRequest::GetURL() const {
- return url_generator_.GenerateEditUrl(resource_id_);
+ return url_generator_.GenerateEditUrlWithEmbedOrigin(
+ resource_id_, embed_origin_);
}
//========================= GetAccountMetadataRequest ========================
diff --git a/chrome/browser/google_apis/gdata_wapi_requests.h b/chrome/browser/google_apis/gdata_wapi_requests.h
index fa6c6d9..e646b75 100644
--- a/chrome/browser/google_apis/gdata_wapi_requests.h
+++ b/chrome/browser/google_apis/gdata_wapi_requests.h
@@ -105,6 +105,7 @@
GetResourceEntryRequest(RequestSender* sender,
const GDataWapiUrlGenerator& url_generator,
const std::string& resource_id,
+ const GURL& embed_origin,
const GetDataCallback& callback);
virtual ~GetResourceEntryRequest();
@@ -116,6 +117,8 @@
const GDataWapiUrlGenerator url_generator_;
// Resource id of the requested entry.
const std::string resource_id_;
+ // Embed origin for an url to the sharing dialog. Can be empty.
+ const GURL& embed_origin_;
DISALLOW_COPY_AND_ASSIGN(GetResourceEntryRequest);
};
diff --git a/chrome/browser/google_apis/gdata_wapi_requests_unittest.cc b/chrome/browser/google_apis/gdata_wapi_requests_unittest.cc
index 2283b41..609eb05 100644
--- a/chrome/browser/google_apis/gdata_wapi_requests_unittest.cc
+++ b/chrome/browser/google_apis/gdata_wapi_requests_unittest.cc
@@ -481,6 +481,7 @@
request_sender_.get(),
*url_generator_,
"file:2_file_resource_id", // resource ID
+ GURL(), // embed origin
test_util::CreateQuitCallback(
&run_loop,
test_util::CreateCopyResultCallback(&result_code, &result_data)));
@@ -508,6 +509,7 @@
request_sender_.get(),
*url_generator_,
"<invalid>", // resource ID
+ GURL(), // embed origin
test_util::CreateQuitCallback(
&run_loop,
test_util::CreateCopyResultCallback(&result_code, &result_data)));
diff --git a/chrome/browser/google_apis/gdata_wapi_url_generator.cc b/chrome/browser/google_apis/gdata_wapi_url_generator.cc
index f4956a8..9d09bf1 100644
--- a/chrome/browser/google_apis/gdata_wapi_url_generator.cc
+++ b/chrome/browser/google_apis/gdata_wapi_url_generator.cc
@@ -162,6 +162,24 @@
return base_url_.Resolve(kGetEditURLPrefix + net::EscapePath(resource_id));
}
+GURL GDataWapiUrlGenerator::GenerateEditUrlWithEmbedOrigin(
+ const std::string& resource_id, const GURL& embed_origin) const {
+ GURL url = GenerateEditUrl(resource_id);
+ if (!embed_origin.is_empty()) {
+ // Construct a valid serialized embed origin from an url, according to
+ // WD-html5-20110525. Such string has to be built manually, since
+ // GURL::spec() always adds the trailing slash. Moreover, ports are
+ // currently not supported.
+ DCHECK(!embed_origin.has_port());
+ DCHECK(!embed_origin.has_path() || embed_origin.path() == "/");
+ const std::string serialized_embed_origin =
+ embed_origin.scheme() + "://" + embed_origin.host();
+ url = net::AppendOrReplaceQueryParameter(
+ url, "embedOrigin", serialized_embed_origin);
+ }
+ return url;
+}
+
GURL GDataWapiUrlGenerator::GenerateContentUrl(
const std::string& resource_id) const {
if (resource_id.empty()) {
diff --git a/chrome/browser/google_apis/gdata_wapi_url_generator.h b/chrome/browser/google_apis/gdata_wapi_url_generator.h
index 31d17f9..4e23c69 100644
--- a/chrome/browser/google_apis/gdata_wapi_url_generator.h
+++ b/chrome/browser/google_apis/gdata_wapi_url_generator.h
@@ -94,6 +94,13 @@
// edit urls.
GURL GenerateEditUrlWithoutParams(const std::string& resource_id) const;
+ // Generates a URL for getting or editing the resource entry of the given
+ // resource ID with additionally passed embed origin. This is used to fetch
+ // share urls for the sharing dialog to be embedded with the |embed_origin|
+ // origin.
+ GURL GenerateEditUrlWithEmbedOrigin(const std::string& resource_id,
+ const GURL& embed_origin) const;
+
// Generates a URL for editing the contents in the directory specified
// by the given resource ID.
GURL GenerateContentUrl(const std::string& resource_id) const;
diff --git a/chrome/browser/google_apis/gdata_wapi_url_generator_unittest.cc b/chrome/browser/google_apis/gdata_wapi_url_generator_unittest.cc
index ef8f1da..8dd60dc 100644
--- a/chrome/browser/google_apis/gdata_wapi_url_generator_unittest.cc
+++ b/chrome/browser/google_apis/gdata_wapi_url_generator_unittest.cc
@@ -147,6 +147,21 @@
url_generator_.GenerateEditUrlWithoutParams("XXX").spec());
}
+TEST_F(GDataWapiUrlGeneratorTest, GenerateEditUrlWithEmbedOrigin) {
+ EXPECT_EQ(
+ "https://docs.google.com/feeds/default/private/full/XXX?v=3&alt=json"
+ "&showroot=true&embedOrigin=chrome-extension%3A%2F%2Ftest",
+ url_generator_.GenerateEditUrlWithEmbedOrigin(
+ "XXX",
+ GURL("chrome-extension://test")).spec());
+ EXPECT_EQ(
+ "https://docs.google.com/feeds/default/private/full/XXX?v=3&alt=json"
+ "&showroot=true",
+ url_generator_.GenerateEditUrlWithEmbedOrigin(
+ "XXX",
+ GURL()).spec());
+}
+
TEST_F(GDataWapiUrlGeneratorTest, GenerateContentUrl) {
EXPECT_EQ(
"https://docs.google.com/feeds/default/private/full/"
diff --git a/chrome/browser/history/android/android_history_provider_service_unittest.cc b/chrome/browser/history/android/android_history_provider_service_unittest.cc
index 7919849..6b882f5 100644
--- a/chrome/browser/history/android/android_history_provider_service_unittest.cc
+++ b/chrome/browser/history/android/android_history_provider_service_unittest.cc
@@ -53,7 +53,7 @@
testing_profile_->CreateBookmarkModel(true);
ui_test_utils::WaitForBookmarkModelToLoad(testing_profile_);
- testing_profile_->CreateHistoryService(true, false);
+ ASSERT_TRUE(testing_profile_->CreateHistoryService(true, false));
service_.reset(new AndroidHistoryProviderService(testing_profile_));
}
diff --git a/chrome/browser/history/android/sqlite_cursor_unittest.cc b/chrome/browser/history/android/sqlite_cursor_unittest.cc
index 7491cd1..fc98bcb 100644
--- a/chrome/browser/history/android/sqlite_cursor_unittest.cc
+++ b/chrome/browser/history/android/sqlite_cursor_unittest.cc
@@ -63,7 +63,7 @@
ui_test_utils::WaitForBookmarkModelToLoad(testing_profile_);
testing_profile_->CreateFaviconService();
- testing_profile_->CreateHistoryService(true, false);
+ ASSERT_TRUE(testing_profile_->CreateHistoryService(true, false));
service_.reset(new AndroidHistoryProviderService(testing_profile_));
hs_ = HistoryServiceFactory::GetForProfile(testing_profile_,
Profile::EXPLICIT_ACCESS);
diff --git a/chrome/browser/history/expire_history_backend.cc b/chrome/browser/history/expire_history_backend.cc
index 5c33897..370a62b 100644
--- a/chrome/browser/history/expire_history_backend.cc
+++ b/chrome/browser/history/expire_history_backend.cc
@@ -19,8 +19,6 @@
#include "chrome/browser/history/archived_database.h"
#include "chrome/browser/history/history_database.h"
#include "chrome/browser/history/history_notifications.h"
-#include "chrome/browser/history/text_database.h"
-#include "chrome/browser/history/text_database_manager.h"
#include "chrome/browser/history/thumbnail_database.h"
using base::Time;
@@ -172,10 +170,6 @@
// The list of all favicon urls that were actually deleted from the thumbnail
// db.
std::set<GURL> expired_favicons;
-
- // Tracks the set of databases that have changed so we can optimize when
- // when we're done.
- TextDatabaseManager::ChangeSet text_db_changes;
};
ExpireHistoryBackend::ExpireHistoryBackend(
@@ -185,7 +179,6 @@
main_db_(NULL),
archived_db_(NULL),
thumb_db_(NULL),
- text_db_(NULL),
weak_factory_(this),
bookmark_service_(bookmark_service) {
}
@@ -195,12 +188,10 @@
void ExpireHistoryBackend::SetDatabases(HistoryDatabase* main_db,
ArchivedDatabase* archived_db,
- ThumbnailDatabase* thumb_db,
- TextDatabaseManager* text_db) {
+ ThumbnailDatabase* thumb_db) {
main_db_ = main_db;
archived_db_ = archived_db;
thumb_db_ = thumb_db;
- text_db_ = text_db;
}
void ExpireHistoryBackend::DeleteURL(const GURL& url) {
@@ -242,9 +233,6 @@
DeleteFaviconsIfPossible(dependencies.affected_favicons,
&dependencies.expired_favicons);
- if (text_db_)
- text_db_->OptimizeChangedDatabases(dependencies.text_db_changes);
-
BroadcastDeleteNotifications(&dependencies, DELETION_USER_INITIATED);
}
@@ -253,10 +241,6 @@
if (!main_db_)
return;
- // There may be stuff in the text database manager's temporary cache.
- if (text_db_)
- text_db_->DeleteFromUncommitted(restrict_urls, begin_time, end_time);
-
// Find the affected visits and delete them.
// TODO(brettw): bug 1171164: We should query the archived database here, too.
VisitVector visits;
@@ -290,10 +274,6 @@
if (!main_db_)
return;
- // There may be stuff in the text database manager's temporary cache.
- if (text_db_)
- text_db_->DeleteFromUncommittedForTimes(times);
-
// Find the affected visits and delete them.
// TODO(brettw): bug 1171164: We should query the archived database here, too.
VisitVector visits;
@@ -368,7 +348,6 @@
// Initialize the queue with all tasks for the first set of iterations.
InitWorkQueue();
ScheduleArchive();
- ScheduleExpireHistoryIndexFiles();
}
void ExpireHistoryBackend::DeleteFaviconsIfPossible(
@@ -422,21 +401,11 @@
// Add the URL row to the affected URL list.
std::map<URLID, URLRow>::const_iterator found =
dependencies->affected_urls.find(visits[i].url_id);
- const URLRow* cur_row = NULL;
if (found == dependencies->affected_urls.end()) {
URLRow row;
if (!main_db_->GetURLRow(visits[i].url_id, &row))
continue;
dependencies->affected_urls[visits[i].url_id] = row;
- cur_row = &dependencies->affected_urls[visits[i].url_id];
- } else {
- cur_row = &found->second;
- }
-
- // Delete any associated full-text indexed data.
- if (visits[i].is_indexed && text_db_) {
- text_db_->DeletePageData(visits[i].visit_time, cur_row->url(),
- &dependencies->text_db_changes);
}
}
}
@@ -447,13 +416,6 @@
DeleteDependencies* dependencies) {
main_db_->DeleteSegmentForURL(url_row.id());
- // The URL may be in the text database manager's temporary cache.
- if (text_db_) {
- std::set<GURL> restrict_urls;
- restrict_urls.insert(url_row.url());
- text_db_->DeleteFromUncommitted(restrict_urls, base::Time(), base::Time());
- }
-
if (!is_bookmarked) {
dependencies->deleted_urls.push_back(url_row);
@@ -722,48 +684,6 @@
// TODO(brettw): Bug 1067331: write this to clean up any errors.
}
-void ExpireHistoryBackend::ScheduleExpireHistoryIndexFiles() {
- if (!text_db_) {
- // Can't expire old history index files because we
- // don't know where they're located.
- return;
- }
-
- TimeDelta delay = TimeDelta::FromMinutes(kIndexExpirationDelayMin);
- base::MessageLoop::current()->PostDelayedTask(
- FROM_HERE,
- base::Bind(&ExpireHistoryBackend::DoExpireHistoryIndexFiles,
- weak_factory_.GetWeakPtr()),
- delay);
-}
-
-void ExpireHistoryBackend::DoExpireHistoryIndexFiles() {
- if (!text_db_) {
- // The text database may have been closed since the task was scheduled.
- return;
- }
-
- Time::Exploded exploded;
- Time::Now().LocalExplode(&exploded);
- int cutoff_month =
- exploded.year * 12 + exploded.month - kStoreHistoryIndexesForMonths;
- TextDatabase::DBIdent cutoff_id =
- (cutoff_month / 12) * 100 + (cutoff_month % 12);
-
- base::FilePath::StringType history_index_files_pattern =
- TextDatabase::file_base();
- history_index_files_pattern.append(FILE_PATH_LITERAL("*"));
- base::FileEnumerator file_enumerator(
- text_db_->GetDir(), false, base::FileEnumerator::FILES,
- history_index_files_pattern);
- for (base::FilePath file = file_enumerator.Next(); !file.empty();
- file = file_enumerator.Next()) {
- TextDatabase::DBIdent file_id = TextDatabase::FileNameToID(file);
- if (file_id < cutoff_id)
- sql::Connection::Delete(file);
- }
-}
-
BookmarkService* ExpireHistoryBackend::GetBookmarkService() {
// We use the bookmark service to determine if a URL is bookmarked. The
// bookmark service is loaded on a separate thread and may not be done by the
diff --git a/chrome/browser/history/expire_history_backend.h b/chrome/browser/history/expire_history_backend.h
index 626ad12..2e3d27e 100644
--- a/chrome/browser/history/expire_history_backend.h
+++ b/chrome/browser/history/expire_history_backend.h
@@ -25,7 +25,6 @@
class ArchivedDatabase;
class HistoryDatabase;
struct HistoryDetails;
-class TextDatabaseManager;
class ThumbnailDatabase;
// Delegate used to broadcast notifications to the main thread.
@@ -76,8 +75,7 @@
// Completes initialization by setting the databases that this class will use.
void SetDatabases(HistoryDatabase* main_db,
ArchivedDatabase* archived_db,
- ThumbnailDatabase* thumb_db,
- TextDatabaseManager* text_db);
+ ThumbnailDatabase* thumb_db);
// Begins periodic expiration of history older than the given threshold. This
// will continue until the object is deleted.
@@ -128,9 +126,6 @@
// Deletes the visit-related stuff for all the visits in the given list, and
// adds the rows for unique URLs affected to the affected_urls list in
// the dependencies structure.
- //
- // Deleted information is the visits themselves and the full-text index
- // entries corresponding to them.
void DeleteVisitRelatedInfo(const VisitVector& visits,
DeleteDependencies* dependencies);
@@ -138,8 +133,7 @@
void ArchiveVisits(const VisitVector& visits);
// Finds or deletes dependency information for the given URL. Information that
- // is specific to this URL (URL row, thumbnails, full text indexed stuff,
- // etc.) is deleted.
+ // is specific to this URL (URL row, thumbnails, etc.) is deleted.
//
// This does not affect the visits! This is used for expiration as well as
// deleting from the UI, and they handle visits differently.
@@ -240,12 +234,6 @@
// and deletes items. For example, URLs with no visits.
void ParanoidExpireHistory();
- // Schedules a call to DoExpireHistoryIndexFiles.
- void ScheduleExpireHistoryIndexFiles();
-
- // Deletes old history index files.
- void DoExpireHistoryIndexFiles();
-
// Returns the BookmarkService, blocking until it is loaded. This may return
// NULL.
BookmarkService* GetBookmarkService();
@@ -269,7 +257,6 @@
HistoryDatabase* main_db_; // Main history database.
ArchivedDatabase* archived_db_; // Old history.
ThumbnailDatabase* thumb_db_; // Thumbnails and favicons.
- TextDatabaseManager* text_db_; // Full text index.
// Used to generate runnable methods to do timers on this class. They will be
// automatically canceled when this class is deleted.
diff --git a/chrome/browser/history/expire_history_backend_unittest.cc b/chrome/browser/history/expire_history_backend_unittest.cc
index d36a6a1..59852a1 100644
--- a/chrome/browser/history/expire_history_backend_unittest.cc
+++ b/chrome/browser/history/expire_history_backend_unittest.cc
@@ -23,7 +23,6 @@
#include "chrome/browser/history/expire_history_backend.h"
#include "chrome/browser/history/history_database.h"
#include "chrome/browser/history/history_notifications.h"
-#include "chrome/browser/history/text_database_manager.h"
#include "chrome/browser/history/thumbnail_database.h"
#include "chrome/browser/history/top_sites.h"
#include "chrome/common/thumbnail_score.h"
@@ -77,10 +76,6 @@
chrome::FaviconID GetFavicon(const GURL& page_url,
chrome::IconType icon_type);
- // Returns the number of text matches for the given URL in the example data
- // added by AddExampleData.
- int CountTextMatchesForURL(const GURL& url);
-
// EXPECTs that each URL-specific history thing (basically, everything but
// favicons) is gone.
void EnsureURLInfoGone(const URLRow& row);
@@ -114,7 +109,6 @@
scoped_ptr<HistoryDatabase> main_db_;
scoped_ptr<ArchivedDatabase> archived_db_;
scoped_ptr<ThumbnailDatabase> thumb_db_;
- scoped_ptr<TextDatabaseManager> text_db_;
TestingProfile profile_;
scoped_refptr<TopSites> top_sites_;
@@ -147,13 +141,7 @@
if (thumb_db_->Init(thumb_name, NULL, main_db_.get()) != sql::INIT_OK)
thumb_db_.reset();
- text_db_.reset(new TextDatabaseManager(path(),
- main_db_.get(), main_db_.get()));
- if (!text_db_->Init(NULL))
- text_db_.reset();
-
- expirer_.SetDatabases(main_db_.get(), archived_db_.get(), thumb_db_.get(),
- text_db_.get());
+ expirer_.SetDatabases(main_db_.get(), archived_db_.get(), thumb_db_.get());
profile_.CreateTopSites();
profile_.BlockUntilTopSitesLoaded();
top_sites_ = profile_.GetTopSites();
@@ -164,12 +152,11 @@
ClearLastNotifications();
- expirer_.SetDatabases(NULL, NULL, NULL, NULL);
+ expirer_.SetDatabases(NULL, NULL, NULL);
main_db_.reset();
archived_db_.reset();
thumb_db_.reset();
- text_db_.reset();
}
// BroadcastNotificationDelegate implementation.
@@ -199,7 +186,7 @@
// The IDs of the added URLs, and the times of the four added visits will be
// added to the given arrays.
void ExpireHistoryTest::AddExampleData(URLID url_ids[3], Time visit_times[4]) {
- if (!main_db_.get() || !text_db_)
+ if (!main_db_.get())
return;
// Four times for each visit.
@@ -251,45 +238,23 @@
VisitRow visit_row1;
visit_row1.url_id = url_ids[0];
visit_row1.visit_time = visit_times[0];
- visit_row1.is_indexed = true;
main_db_->AddVisit(&visit_row1, SOURCE_BROWSED);
VisitRow visit_row2;
visit_row2.url_id = url_ids[1];
visit_row2.visit_time = visit_times[1];
- visit_row2.is_indexed = true;
main_db_->AddVisit(&visit_row2, SOURCE_BROWSED);
VisitRow visit_row3;
visit_row3.url_id = url_ids[1];
visit_row3.visit_time = visit_times[2];
- visit_row3.is_indexed = true;
visit_row3.transition = content::PAGE_TRANSITION_TYPED;
main_db_->AddVisit(&visit_row3, SOURCE_BROWSED);
VisitRow visit_row4;
visit_row4.url_id = url_ids[2];
visit_row4.visit_time = visit_times[3];
- visit_row4.is_indexed = true;
main_db_->AddVisit(&visit_row4, SOURCE_BROWSED);
-
- // Full text index for each visit.
- text_db_->AddPageData(url_row1.url(), visit_row1.url_id, visit_row1.visit_id,
- visit_row1.visit_time, UTF8ToUTF16("title"),
- UTF8ToUTF16("body"));
-
- text_db_->AddPageData(url_row2.url(), visit_row2.url_id, visit_row2.visit_id,
- visit_row2.visit_time, UTF8ToUTF16("title"),
- UTF8ToUTF16("body"));
- text_db_->AddPageData(url_row2.url(), visit_row3.url_id, visit_row3.visit_id,
- visit_row3.visit_time, UTF8ToUTF16("title"),
- UTF8ToUTF16("body"));
-
- // Note the special text in this URL. We'll search the file for this string
- // to make sure it doesn't hang around after the delete.
- text_db_->AddPageData(url_row3.url(), visit_row4.url_id, visit_row4.visit_id,
- visit_row4.visit_time, UTF8ToUTF16("title"),
- UTF8ToUTF16("goats body"));
}
void ExpireHistoryTest::AddExampleSourceData(const GURL& url, URLID* id) {
@@ -349,33 +314,11 @@
return top_sites_->GetPageThumbnail(url, &data);
}
-int ExpireHistoryTest::CountTextMatchesForURL(const GURL& url) {
- if (!text_db_)
- return 0;
-
- // "body" should match all pages in the example data.
- std::vector<TextDatabase::Match> results;
- QueryOptions options;
- Time first_time;
- text_db_->GetTextMatches(UTF8ToUTF16("body"), options,
- &results, &first_time);
-
- int count = 0;
- for (size_t i = 0; i < results.size(); i++) {
- if (results[i].url == url)
- count++;
- }
- return count;
-}
-
void ExpireHistoryTest::EnsureURLInfoGone(const URLRow& row) {
// Verify the URL no longer exists.
URLRow temp_row;
EXPECT_FALSE(main_db_->GetURLRow(row.id(), &temp_row));
- // The indexed data should be gone.
- EXPECT_EQ(0, CountTextMatchesForURL(row.url()));
-
// There should be no visits.
VisitVector visits;
main_db_->GetVisitsForURL(row.id(), &visits);
@@ -471,46 +414,10 @@
VisitVector visits;
main_db_->GetVisitsForURL(url_ids[2], &visits);
ASSERT_EQ(1U, visits.size());
- EXPECT_EQ(1, CountTextMatchesForURL(last_row.url()));
-
- // In this test we also make sure that any pending entries in the text
- // database manager are removed.
- text_db_->AddPageURL(last_row.url(), last_row.id(), visits[0].visit_id,
- visits[0].visit_time);
-
- // Compute the text DB filename.
- base::FilePath fts_filename = path().Append(
- TextDatabase::IDToFileName(text_db_->TimeToID(visit_times[3])));
-
- // When checking the file, the database must be closed. We then re-initialize
- // it just like the test set-up did.
- text_db_.reset();
- EXPECT_TRUE(IsStringInFile(fts_filename, "goats"));
- text_db_.reset(new TextDatabaseManager(path(),
- main_db_.get(), main_db_.get()));
- ASSERT_TRUE(text_db_->Init(NULL));
- expirer_.SetDatabases(main_db_.get(), archived_db_.get(), thumb_db_.get(),
- text_db_.get());
// Delete the URL and its dependencies.
expirer_.DeleteURL(last_row.url());
- // The string should be removed from the file. FTS can mark it as gone but
- // doesn't remove it from the file, we want to be sure we're doing the latter.
- text_db_.reset();
- EXPECT_FALSE(IsStringInFile(fts_filename, "goats"));
- text_db_.reset(new TextDatabaseManager(path(),
- main_db_.get(), main_db_.get()));
- ASSERT_TRUE(text_db_->Init(NULL));
- expirer_.SetDatabases(main_db_.get(), archived_db_.get(), thumb_db_.get(),
- text_db_.get());
-
- // Run the text database expirer. This will flush any pending entries so we
- // can check that nothing was committed. We use a time far in the future so
- // that anything added recently will get flushed.
- TimeTicks expiration_time = TimeTicks::Now() + TimeDelta::FromDays(1);
- text_db_->FlushOldChangesForTime(expiration_time);
-
// All the normal data + the favicon should be gone.
EnsureURLInfoGone(last_row);
EXPECT_FALSE(GetFavicon(last_row.url(), chrome::FAVICON));
@@ -535,7 +442,6 @@
VisitVector visits;
main_db_->GetVisitsForURL(url_ids[1], &visits);
EXPECT_EQ(2U, visits.size());
- EXPECT_EQ(1, CountTextMatchesForURL(last_row.url()));
// Delete the URL and its dependencies.
expirer_.DeleteURL(last_row.url());
@@ -568,9 +474,6 @@
chrome::FaviconID favicon_id = GetFavicon(url_row.url(), chrome::FAVICON);
EXPECT_TRUE(HasFavicon(favicon_id));
- // But there should be no fts.
- ASSERT_EQ(0, CountTextMatchesForURL(url_row.url()));
-
// And no visits.
VisitVector visits;
main_db_->GetVisitsForURL(url_row.id(), &visits);
@@ -637,29 +540,18 @@
ASSERT_TRUE(main_db_->GetURLRow(url_ids[1], &url_row1));
ASSERT_TRUE(main_db_->GetURLRow(url_ids[2], &url_row2));
- // In this test we also make sure that any pending entries in the text
- // database manager are removed.
VisitVector visits;
main_db_->GetVisitsForURL(url_ids[2], &visits);
ASSERT_EQ(1U, visits.size());
- text_db_->AddPageURL(url_row2.url(), url_row2.id(), visits[0].visit_id,
- visits[0].visit_time);
// This should delete the last two visits.
std::set<GURL> restrict_urls;
expirer_.ExpireHistoryBetween(restrict_urls, visit_times[2], Time());
- // Run the text database expirer. This will flush any pending entries so we
- // can check that nothing was committed. We use a time far in the future so
- // that anything added recently will get flushed.
- TimeTicks expiration_time = TimeTicks::Now() + TimeDelta::FromDays(1);
- text_db_->FlushOldChangesForTime(expiration_time);
-
// Verify that the middle URL had its last visit deleted only.
visits.clear();
main_db_->GetVisitsForURL(url_ids[1], &visits);
EXPECT_EQ(1U, visits.size());
- EXPECT_EQ(0, CountTextMatchesForURL(url_row1.url()));
// Verify that the middle URL visit time and visit counts were updated.
URLRow temp_row;
@@ -693,13 +585,9 @@
ASSERT_TRUE(main_db_->GetURLRow(url_ids[1], &url_row1));
ASSERT_TRUE(main_db_->GetURLRow(url_ids[2], &url_row2));
- // In this test we also make sure that any pending entries in the text
- // database manager are removed.
VisitVector visits;
main_db_->GetVisitsForURL(url_ids[2], &visits);
ASSERT_EQ(1U, visits.size());
- text_db_->AddPageURL(url_row2.url(), url_row2.id(), visits[0].visit_id,
- visits[0].visit_time);
// This should delete the last two visits.
std::vector<base::Time> times;
@@ -707,17 +595,10 @@
times.push_back(visit_times[2]);
expirer_.ExpireHistoryForTimes(times);
- // Run the text database expirer. This will flush any pending entries so we
- // can check that nothing was committed. We use a time far in the future so
- // that anything added recently will get flushed.
- TimeTicks expiration_time = TimeTicks::Now() + TimeDelta::FromDays(1);
- text_db_->FlushOldChangesForTime(expiration_time);
-
// Verify that the middle URL had its last visit deleted only.
visits.clear();
main_db_->GetVisitsForURL(url_ids[1], &visits);
EXPECT_EQ(1U, visits.size());
- EXPECT_EQ(0, CountTextMatchesForURL(url_row1.url()));
// Verify that the middle URL visit time and visit counts were updated.
URLRow temp_row;
@@ -753,30 +634,19 @@
ASSERT_TRUE(main_db_->GetURLRow(url_ids[1], &url_row1));
ASSERT_TRUE(main_db_->GetURLRow(url_ids[2], &url_row2));
- // In this test we also make sure that any pending entries in the text
- // database manager are removed.
VisitVector visits;
main_db_->GetVisitsForURL(url_ids[2], &visits);
ASSERT_EQ(1U, visits.size());
- text_db_->AddPageURL(url_row2.url(), url_row2.id(), visits[0].visit_id,
- visits[0].visit_time);
// This should delete the last two visits.
std::set<GURL> restrict_urls;
restrict_urls.insert(url_row1.url());
expirer_.ExpireHistoryBetween(restrict_urls, visit_times[2], Time());
- // Run the text database expirer. This will flush any pending entries so we
- // can check that nothing was committed. We use a time far in the future so
- // that anything added recently will get flushed.
- TimeTicks expiration_time = TimeTicks::Now() + TimeDelta::FromDays(1);
- text_db_->FlushOldChangesForTime(expiration_time);
-
// Verify that the middle URL had its last visit deleted only.
visits.clear();
main_db_->GetVisitsForURL(url_ids[1], &visits);
EXPECT_EQ(1U, visits.size());
- EXPECT_EQ(0, CountTextMatchesForURL(url_row1.url()));
// Verify that the middle URL visit time and visit counts were updated.
URLRow temp_row;
diff --git a/chrome/browser/history/history_backend.cc b/chrome/browser/history/history_backend.cc
index adaff5a..83a2afd 100644
--- a/chrome/browser/history/history_backend.cc
+++ b/chrome/browser/history/history_backend.cc
@@ -14,6 +14,7 @@
#include "base/basictypes.h"
#include "base/bind.h"
#include "base/compiler_specific.h"
+#include "base/files/file_enumerator.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "base/message_loop/message_loop.h"
@@ -68,10 +69,6 @@
(this does not store visit segments as they expire after 3 mos.)
- TextDatabaseManager (manages multiple text database for different times)
- TextDatabase (represents a single month of full-text index).
- ...more TextDatabase objects...
-
ExpireHistoryBackend (manages moving things from HistoryDatabase to
the ArchivedDatabase and deleting)
*/
@@ -168,53 +165,6 @@
scoped_refptr<HistoryBackend> history_backend_;
};
-// Handles querying first the main database, then the full text database if that
-// fails. It will optionally keep track of all URLs seen so duplicates can be
-// eliminated. This is used by the querying sub-functions.
-//
-// TODO(brettw): This class may be able to be simplified or eliminated. After
-// this was written, QueryResults can efficiently look up by URL, so the need
-// for this extra set of previously queried URLs is less important.
-class HistoryBackend::URLQuerier {
- public:
- URLQuerier(URLDatabase* main_db, URLDatabase* archived_db, bool track_unique)
- : main_db_(main_db),
- archived_db_(archived_db),
- track_unique_(track_unique) {
- }
-
- // When we're tracking unique URLs, returns true if this URL has been
- // previously queried. Only call when tracking unique URLs.
- bool HasURL(const GURL& url) {
- DCHECK(track_unique_);
- return unique_urls_.find(url) != unique_urls_.end();
- }
-
- bool GetRowForURL(const GURL& url, URLRow* row) {
- if (!main_db_->GetRowForURL(url, row)) {
- if (!archived_db_ || !archived_db_->GetRowForURL(url, row)) {
- // This row is neither in the main nor the archived DB.
- return false;
- }
- }
-
- if (track_unique_)
- unique_urls_.insert(url);
- return true;
- }
-
- private:
- URLDatabase* main_db_; // Guaranteed non-NULL.
- URLDatabase* archived_db_; // Possibly NULL.
-
- bool track_unique_;
-
- // When track_unique_ is set, this is updated with every URL seen so far.
- std::set<GURL> unique_urls_;
-
- DISALLOW_COPY_AND_ASSIGN(URLQuerier);
-};
-
// HistoryBackend --------------------------------------------------------------
HistoryBackend::HistoryBackend(const base::FilePath& history_dir,
@@ -582,7 +532,7 @@
}
// Last, save this redirect chain for later so we can set titles & favicons
- // on the redirected pages properly. It is indexed by the destination page.
+ // on the redirected pages properly.
recent_redirects_.Put(request.url, redirects);
}
@@ -600,11 +550,6 @@
last_ids.second);
}
- if (text_database_) {
- text_database_->AddPageURL(request.url, last_ids.first, last_ids.second,
- request.time);
- }
-
ScheduleCommit();
}
@@ -617,12 +562,14 @@
TimeTicks beginning_time = TimeTicks::Now();
- // Compute the file names. Note that the index file can be removed when the
- // text db manager is finished being hooked up.
+ // Compute the file names.
base::FilePath history_name = history_dir_.Append(chrome::kHistoryFilename);
base::FilePath thumbnail_name = GetThumbnailFileName();
base::FilePath archived_name = GetArchivedFileName();
+ // Delete the old index database files which are no longer used.
+ DeleteFTSIndexDatabases();
+
// History database.
db_.reset(new HistoryDatabase());
@@ -662,8 +609,8 @@
delete mem_backend; // Error case, run without the in-memory DB.
db_->BeginExclusiveMode(); // Must be after the mem backend read the data.
- // Create the history publisher which needs to be passed on to the text and
- // thumbnail databases for publishing history.
+ // Create the history publisher which needs to be passed on to the thumbnail
+ // database for publishing history.
history_publisher_.reset(new HistoryPublisher());
if (!history_publisher_->Init()) {
// The init may fail when there are no indexers wanting our history.
@@ -671,22 +618,6 @@
history_publisher_.reset();
}
- // Full-text database. This has to be first so we can pass it to the
- // HistoryDatabase for migration.
- text_database_.reset(new TextDatabaseManager(history_dir_,
- db_.get(), db_.get()));
- if (!text_database_->Init(history_publisher_.get())) {
- LOG(WARNING) << "Text database initialization failed, running without it.";
- text_database_.reset();
- }
- if (db_->needs_version_17_migration()) {
- // See needs_version_17_migration() decl for more. In this case, we want
- // to erase all the text database files. This must be done after the text
- // database manager has been initialized, since it knows about all the
- // files it manages.
- text_database_->DeleteAll();
- }
-
// Thumbnail database.
thumbnail_db_.reset(new ThumbnailDatabase());
if (!db_->GetNeedsThumbnailMigration()) {
@@ -739,7 +670,7 @@
// The main DB initialization should intuitively be first (not that it
// actually matters) and the expirer should be set last.
expirer_.SetDatabases(db_.get(), archived_db_.get(),
- thumbnail_db_.get(), text_database_.get());
+ thumbnail_db_.get());
// Open the long-running transaction.
db_->BeginTransaction();
@@ -747,8 +678,6 @@
thumbnail_db_->BeginTransaction();
if (archived_db_)
archived_db_->BeginTransaction();
- if (text_database_)
- text_database_->BeginTransaction();
// Get the first item in our database.
db_->GetStartDate(&first_recorded_time_);
@@ -794,10 +723,6 @@
archived_db_->CommitTransaction();
archived_db_.reset();
}
- if (text_database_) {
- text_database_->CommitTransaction();
- text_database_.reset();
- }
}
std::pair<URLID, VisitID> HistoryBackend::AddPageVisit(
@@ -861,14 +786,6 @@
return std::make_pair(0, 0);
}
url_info.id_ = url_id;
-
- // We don't actually add the URL to the full text index at this point. It
- // might be nice to do this so that even if we get no title or body, the
- // user can search for URL components and get the page.
- //
- // However, in most cases, we'll get at least a title and usually contents,
- // and this add will be redundant, slowing everything down. As a result,
- // we ignore this edge case.
}
// Add the visit with the time to the database.
@@ -938,26 +855,6 @@
}
}
- // Add the page to the full text index. This function is also used for
- // importing. Even though we don't have page contents, we can at least
- // add the title and URL to the index so they can be searched. We don't
- // bother to delete any already-existing FTS entries for the URL, since
- // this is normally called on import.
- //
- // If you ever import *after* first run (selecting import from the menu),
- // then these additional entries will "shadow" the originals when querying
- // for the most recent match only, and the user won't get snippets. This is
- // a very minor issue, and fixing it will make import slower, so we don't
- // bother.
- bool has_indexed = false;
- if (text_database_) {
- // We do not have to make it update the visit database, below, we will
- // create the visit entry with the indexed flag set.
- has_indexed = text_database_->AddPageData(i->url(), url_id, 0,
- i->last_visit(),
- i->title(), string16());
- }
-
// Sync code manages the visits itself.
if (visit_source != SOURCE_SYNCED) {
// Make up a visit to correspond to the last visit to the page.
@@ -966,7 +863,6 @@
content::PAGE_TRANSITION_LINK |
content::PAGE_TRANSITION_CHAIN_START |
content::PAGE_TRANSITION_CHAIN_END), 0);
- visit_info.is_indexed = has_indexed;
if (!visit_database->AddVisit(&visit_info, visit_source)) {
NOTREACHED() << "Adding visit failed.";
return;
@@ -1001,10 +897,6 @@
if (!db_)
return;
- // Update the full text index.
- if (text_database_)
- text_database_->AddPageTitle(url, title);
-
// Search for recent redirects which should get the same title. We make a
// dummy list containing the exact URL visited if there are no redirects so
// the processing below can be the same.
@@ -1499,59 +1391,6 @@
result->set_reached_beginning(true);
}
-void HistoryBackend::QueryHistoryFTS(const string16& text_query,
- const QueryOptions& options,
- QueryResults* result) {
- if (!text_database_)
- return;
-
- // Full text query, first get all the FTS results in the time range.
- std::vector<TextDatabase::Match> fts_matches;
- Time first_time_searched;
- text_database_->GetTextMatches(text_query, options,
- &fts_matches, &first_time_searched);
-
- URLQuerier querier(db_.get(), archived_db_.get(), true);
-
- // Now get the row and visit information for each one.
- URLResult url_result; // Declare outside loop to prevent re-construction.
- for (size_t i = 0; i < fts_matches.size(); i++) {
- if (options.max_count != 0 &&
- static_cast<int>(result->size()) >= options.max_count)
- break; // Got too many items.
-
- // Get the URL, querying the main and archived databases as necessary. If
- // this is not found, the history and full text search databases are out
- // of sync and we give up with this result.
- if (!querier.GetRowForURL(fts_matches[i].url, &url_result))
- continue;
-
- if (!url_result.url().is_valid())
- continue; // Don't report invalid URLs in case of corruption.
-
- // Copy over the FTS stuff that the URLDatabase doesn't know about.
- // We do this with swap() to avoid copying, since we know we don't
- // need the original any more. Note that we override the title with the
- // one from FTS, since that will match the title_match_positions (the
- // FTS title and the history DB title may differ).
- url_result.set_title(fts_matches[i].title);
- url_result.title_match_positions_.swap(
- fts_matches[i].title_match_positions);
- url_result.snippet_.Swap(&fts_matches[i].snippet);
-
- // The visit time also comes from the full text search database. Since it
- // has the time, we can avoid an extra query of the visits table.
- url_result.set_visit_time(fts_matches[i].time);
-
- // Add it to the vector, this will clear our |url_row| object as a
- // result of the swap.
- result->AppendURLBySwapping(&url_result);
- }
-
- if (first_time_searched <= first_recorded_time_)
- result->set_reached_beginning(true);
-}
-
// Frontend to GetMostRecentRedirectsFrom from the history thread.
void HistoryBackend::QueryRedirectsFrom(
scoped_refptr<QueryRedirectsRequest> request,
@@ -1811,14 +1650,6 @@
provider->ExecuteWithDB(this, db_.get(), params);
}
-void HistoryBackend::SetPageContents(const GURL& url,
- const string16& contents) {
- // This is histogrammed in the text database manager.
- if (!text_database_)
- return;
- text_database_->AddPageContents(url, contents);
-}
-
void HistoryBackend::SetPageThumbnail(
const GURL& url,
const gfx::Image* thumbnail,
@@ -1902,6 +1733,23 @@
}
}
+void HistoryBackend::DeleteFTSIndexDatabases() {
+ // Find files on disk matching the text databases file pattern so we can
+ // quickly test for and delete them.
+ base::FilePath::StringType filepattern =
+ FILE_PATH_LITERAL("History Index *");
+ base::FileEnumerator enumerator(
+ history_dir_, false, base::FileEnumerator::FILES, filepattern);
+ int num_databases_deleted = 0;
+ base::FilePath current_file;
+ while (!(current_file = enumerator.Next()).empty()) {
+ if (sql::Connection::Delete(current_file))
+ num_databases_deleted++;
+ }
+ UMA_HISTOGRAM_COUNTS("History.DeleteFTSIndexDatabases",
+ num_databases_deleted);
+}
+
bool HistoryBackend::GetThumbnailFromOlderRedirect(
const GURL& page_url,
std::vector<unsigned char>* data) {
@@ -2668,11 +2516,6 @@
archived_db_->CommitTransaction();
archived_db_->BeginTransaction();
}
-
- if (text_database_) {
- text_database_->CommitTransaction();
- text_database_->BeginTransaction();
- }
}
void HistoryBackend::ScheduleCommit() {
@@ -2903,7 +2746,7 @@
// The expirer keeps tabs on the active databases. Tell it about the
// databases which will be closed.
- expirer_.SetDatabases(NULL, NULL, NULL, NULL);
+ expirer_.SetDatabases(NULL, NULL, NULL);
// Reopen a new transaction for |db_| for the sake of CloseAllDatabases().
db_->BeginTransaction();
@@ -2993,15 +2836,7 @@
LOG(ERROR) << "Main history could not be cleared";
kept_urls.clear();
- // Delete FTS files & archived history.
- if (text_database_) {
- // We assume that the text database has one transaction on them that we need
- // to close & restart (the long-running history transaction).
- text_database_->CommitTransaction();
- text_database_->DeleteAll();
- text_database_->BeginTransaction();
- }
-
+ // Delete archived history.
if (archived_db_) {
// Close the database and delete the file.
archived_db_.reset();
diff --git a/chrome/browser/history/history_backend.h b/chrome/browser/history/history_backend.h
index c4010b7..fd92878 100644
--- a/chrome/browser/history/history_backend.h
+++ b/chrome/browser/history/history_backend.h
@@ -20,7 +20,6 @@
#include "chrome/browser/history/history_database.h"
#include "chrome/browser/history/history_marshaling.h"
#include "chrome/browser/history/history_types.h"
-#include "chrome/browser/history/text_database_manager.h"
#include "chrome/browser/history/thumbnail_database.h"
#include "chrome/browser/history/visit_tracker.h"
#include "chrome/browser/search_engines/template_url_id.h"
@@ -162,11 +161,6 @@
const GURL& url,
base::Time end_ts);
-
- // Indexing ------------------------------------------------------------------
-
- void SetPageContents(const GURL& url, const string16& contents);
-
// Querying ------------------------------------------------------------------
// ScheduleAutocomplete() never frees |provider| (which is globally live).
@@ -564,6 +558,7 @@
FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, QueryFilteredURLs);
FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, UpdateVisitDuration);
FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, ExpireHistoryForTimes);
+ FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteFTSIndexDatabases);
friend class ::TestingProfile;
@@ -658,9 +653,6 @@
const string16& text_query,
const QueryOptions& options,
QueryResults* result);
- void QueryHistoryFTS(const string16& text_query,
- const QueryOptions& options,
- QueryResults* result);
// Committing ----------------------------------------------------------------
@@ -843,6 +835,9 @@
// The IDs of the URLs may change.
bool ClearAllMainHistory(const URLRows& kept_urls);
+ // Deletes the FTS index database files, which are no longer used.
+ void DeleteFTSIndexDatabases();
+
// Returns the BookmarkService, blocking until it is loaded. This may return
// NULL during testing.
BookmarkService* GetBookmarkService();
@@ -875,10 +870,6 @@
// Stores old history in a larger, slower database.
scoped_ptr<ArchivedDatabase> archived_db_;
- // Full text database manager, possibly NULL if the database could not be
- // created.
- scoped_ptr<TextDatabaseManager> text_database_;
-
// Manages expiration between the various databases.
ExpireHistoryBackend expirer_;
diff --git a/chrome/browser/history/history_backend_unittest.cc b/chrome/browser/history/history_backend_unittest.cc
index 7bd2328..8bb0111 100644
--- a/chrome/browser/history/history_backend_unittest.cc
+++ b/chrome/browser/history/history_backend_unittest.cc
@@ -5,6 +5,7 @@
#include <algorithm>
#include <set>
#include <vector>
+#include <fstream>
#include "base/basictypes.h"
#include "base/bind.h"
@@ -15,6 +16,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
+#include "base/platform_file.h"
#include "base/strings/string16.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
@@ -504,12 +506,10 @@
VisitVector visits;
backend_->db_->GetVisitsForURL(row1_id, &visits);
ASSERT_EQ(1U, visits.size());
- VisitID visit1_id = visits[0].visit_id;
visits.clear();
backend_->db_->GetVisitsForURL(row2_id, &visits);
ASSERT_EQ(1U, visits.size());
- VisitID visit2_id = visits[0].visit_id;
// The in-memory backend should have been set and it should have gotten the
// typed URL.
@@ -539,16 +539,6 @@
bookmark_model_.AddURL(
bookmark_model_.bookmark_bar_node(), 0, string16(), row1.url());
- // Set full text index for each one.
- backend_->text_database_->AddPageData(row1.url(), row1_id, visit1_id,
- row1.last_visit(),
- UTF8ToUTF16("Title 1"),
- UTF8ToUTF16("Body 1"));
- backend_->text_database_->AddPageData(row2.url(), row2_id, visit2_id,
- row2.last_visit(),
- UTF8ToUTF16("Title 2"),
- UTF8ToUTF16("Body 2"));
-
// Now finally clear all history.
backend_->DeleteAllHistory();
@@ -615,15 +605,6 @@
// The first URL should still be bookmarked.
EXPECT_TRUE(bookmark_model_.IsBookmarked(row1.url()));
-
- // The full text database should have no data.
- std::vector<TextDatabase::Match> text_matches;
- Time first_time_searched;
- backend_->text_database_->GetTextMatches(UTF8ToUTF16("Body"),
- QueryOptions(),
- &text_matches,
- &first_time_searched);
- EXPECT_EQ(0U, text_matches.size());
}
// Checks that adding a visit, then calling DeleteAll, and then trying to add
@@ -659,9 +640,8 @@
backend_->db_->GetAllVisitsInRange(Time(), Time(), 0, &all_visits);
ASSERT_EQ(0U, all_visits.size());
- // Try and set the full text index.
+ // Try and set the title.
backend_->SetPageTitle(url, UTF8ToUTF16("Title"));
- backend_->SetPageContents(url, UTF8ToUTF16("Body"));
// The row should still be deleted.
EXPECT_FALSE(backend_->db_->GetRowForURL(url, &outrow));
@@ -669,15 +649,6 @@
// The visit should still be deleted.
backend_->db_->GetAllVisitsInRange(Time(), Time(), 0, &all_visits);
ASSERT_EQ(0U, all_visits.size());
-
- // The full text database should have no data.
- std::vector<TextDatabase::Match> text_matches;
- Time first_time_searched;
- backend_->text_database_->GetTextMatches(UTF8ToUTF16("Body"),
- QueryOptions(),
- &text_matches,
- &first_time_searched);
- EXPECT_EQ(0U, text_matches.size());
}
TEST_F(HistoryBackendTest, URLsNoLongerBookmarked) {
@@ -2791,7 +2762,7 @@
TEST_F(HistoryBackendTest, RemoveNotification) {
scoped_ptr<TestingProfile> profile(new TestingProfile());
- profile->CreateHistoryService(false, false);
+ ASSERT_TRUE(profile->CreateHistoryService(false, false));
profile->CreateBookmarkModel(true);
BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile.get());
ui_test_utils::WaitForBookmarkModelToLoad(model);
@@ -2812,4 +2783,42 @@
service->DeleteURL(url);
}
+// Simple function to create a new dummy file.
+void CreateDummyFile(const base::FilePath& filename) {
+ std::wofstream file;
+ file.open(filename.value().c_str());
+ ASSERT_TRUE(file.is_open());
+ file << L"Dummy";
+ file.close();
+}
+
+// Test DeleteFTSIndexDatabases deletes expected files.
+TEST_F(HistoryBackendTest, DeleteFTSIndexDatabases) {
+ ASSERT_TRUE(backend_.get());
+
+ base::FilePath history_path(getTestDir());
+ base::FilePath db1(history_path.AppendASCII("History Index 2013-05"));
+ base::FilePath db1_journal(db1.InsertBeforeExtensionASCII("-journal"));
+ base::FilePath db1_wal(db1.InsertBeforeExtensionASCII("-wal"));
+ base::FilePath db2_symlink(history_path.AppendASCII("History Index 2013-06"));
+ base::FilePath db2_actual(history_path.AppendASCII("Underlying DB"));
+
+ // Setup dummy index database files.
+ CreateDummyFile(db1);
+ CreateDummyFile(db1_journal);
+ CreateDummyFile(db1_wal);
+ CreateDummyFile(db2_actual);
+#if defined(OS_POSIX)
+ EXPECT_TRUE(file_util::CreateSymbolicLink(db2_actual, db2_symlink));
+#endif
+
+ // Delete all DTS index databases.
+ backend_->DeleteFTSIndexDatabases();
+ EXPECT_FALSE(base::PathExists(db1));
+ EXPECT_FALSE(base::PathExists(db1_wal));
+ EXPECT_FALSE(base::PathExists(db1_journal));
+ EXPECT_FALSE(base::PathExists(db2_symlink));
+ EXPECT_TRUE(base::PathExists(db2_actual)); // Symlinks shouldn't be followed.
+}
+
} // namespace history
diff --git a/chrome/browser/history/history_database.cc b/chrome/browser/history/history_database.cc
index 3db7acd..20cb023 100644
--- a/chrome/browser/history/history_database.cc
+++ b/chrome/browser/history/history_database.cc
@@ -441,15 +441,13 @@
#if !defined(OS_WIN)
void HistoryDatabase::MigrateTimeEpoch() {
// Update all the times in the URLs and visits table in the main database.
- // For visits, clear the indexed flag since we'll delete the FTS databases in
- // the next step.
ignore_result(db_.Execute(
"UPDATE urls "
"SET last_visit_time = last_visit_time + 11644473600000000 "
"WHERE id IN (SELECT id FROM urls WHERE last_visit_time > 0);"));
ignore_result(db_.Execute(
"UPDATE visits "
- "SET visit_time = visit_time + 11644473600000000, is_indexed = 0 "
+ "SET visit_time = visit_time + 11644473600000000 "
"WHERE id IN (SELECT id FROM visits WHERE visit_time > 0);"));
ignore_result(db_.Execute(
"UPDATE segment_usage "
diff --git a/chrome/browser/history/history_service.cc b/chrome/browser/history/history_service.cc
index b697f37..644dc85 100644
--- a/chrome/browser/history/history_service.cc
+++ b/chrome/browser/history/history_service.cc
@@ -14,10 +14,6 @@
// -> SQLite connection to History
// -> ArchivedDatabase
// -> SQLite connection to Archived History
-// -> TextDatabaseManager
-// -> SQLite connection to one month's data
-// -> SQLite connection to one month's data
-// ...
// -> ThumbnailDatabase
// -> SQLite connection to Thumbnails
// (and favicons)
@@ -597,16 +593,6 @@
&HistoryBackend::AddPagesWithDetails, info, visit_source);
}
-void HistoryService::SetPageContents(const GURL& url,
- const string16& contents) {
- DCHECK(thread_checker_.CalledOnValidThread());
- if (!CanAddURL(url))
- return;
-
- ScheduleAndForget(PRIORITY_LOW, &HistoryBackend::SetPageContents,
- url, contents);
-}
-
HistoryService::Handle HistoryService::GetPageThumbnail(
const GURL& page_url,
CancelableRequestConsumerBase* consumer,
diff --git a/chrome/browser/history/history_service.h b/chrome/browser/history/history_service.h
index 060614d..1662571 100644
--- a/chrome/browser/history/history_service.h
+++ b/chrome/browser/history/history_service.h
@@ -236,13 +236,6 @@
const GURL& url,
base::Time end_ts);
- // Indexing ------------------------------------------------------------------
-
- // Notifies history of the body text of the given recently-visited URL.
- // If the URL was not visited "recently enough," the history system may
- // discard it.
- void SetPageContents(const GURL& url, const string16& contents);
-
// Querying ------------------------------------------------------------------
// Returns the information about the requested URL. If the URL is found,
diff --git a/chrome/browser/history/history_tab_helper.cc b/chrome/browser/history/history_tab_helper.cc
index f0285ab..96c545e 100644
--- a/chrome/browser/history/history_tab_helper.cc
+++ b/chrome/browser/history/history_tab_helper.cc
@@ -81,16 +81,6 @@
return add_page_args;
}
-bool HistoryTabHelper::OnMessageReceived(const IPC::Message& message) {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(HistoryTabHelper, message)
- IPC_MESSAGE_HANDLER(ChromeViewHostMsg_PageContents, OnPageContents)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
-
- return handled;
-}
-
void HistoryTabHelper::DidNavigateMainFrame(
const content::LoadCommittedDetails& details,
const content::FrameNavigateParams& params) {
@@ -154,26 +144,6 @@
}
}
-void HistoryTabHelper::OnPageContents(const GURL& url,
- int32 page_id,
- const string16& contents) {
- // Don't index any https pages. People generally don't want their bank
- // accounts, etc. indexed on their computer, especially since some of these
- // things are not marked cachable.
- // TODO(brettw) we may want to consider more elaborate heuristics such as
- // the cachability of the page. We may also want to consider subframes (this
- // test will still index subframes if the subframe is SSL).
- // TODO(zelidrag) bug chromium-os:2808 - figure out if we want to reenable
- // content indexing for chromeos in some future releases.
-#if !defined(OS_CHROMEOS)
- if (!url.SchemeIsSecure()) {
- HistoryService* hs = GetHistoryService();
- if (hs)
- hs->SetPageContents(url, contents);
- }
-#endif
-}
-
HistoryService* HistoryTabHelper::GetHistoryService() {
Profile* profile =
Profile::FromBrowserContext(web_contents()->GetBrowserContext());
diff --git a/chrome/browser/history/history_tab_helper.h b/chrome/browser/history/history_tab_helper.h
index 95c4ee0..2f613fa 100644
--- a/chrome/browser/history/history_tab_helper.h
+++ b/chrome/browser/history/history_tab_helper.h
@@ -46,7 +46,6 @@
friend class content::WebContentsUserData<HistoryTabHelper>;
// content::WebContentsObserver implementation.
- virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
virtual void DidNavigateMainFrame(
const content::LoadCommittedDetails& details,
const content::FrameNavigateParams& params) OVERRIDE;
diff --git a/chrome/browser/history/history_types.cc b/chrome/browser/history/history_types.cc
index f0e6439..f766a0b 100644
--- a/chrome/browser/history/history_types.cc
+++ b/chrome/browser/history/history_types.cc
@@ -69,8 +69,7 @@
url_id(0),
referring_visit(0),
transition(content::PAGE_TRANSITION_LINK),
- segment_id(0),
- is_indexed(false) {
+ segment_id(0) {
}
VisitRow::VisitRow(URLID arg_url_id,
@@ -83,8 +82,7 @@
visit_time(arg_visit_time),
referring_visit(arg_referring_visit),
transition(arg_transition),
- segment_id(arg_segment_id),
- is_indexed(false) {
+ segment_id(arg_segment_id) {
}
VisitRow::~VisitRow() {
@@ -246,7 +244,6 @@
QueryOptions::QueryOptions()
: max_count(0),
- body_only(false),
duplicate_policy(QueryOptions::REMOVE_ALL_DUPLICATES) {
}
diff --git a/chrome/browser/history/history_types.h b/chrome/browser/history/history_types.h
index 7fd1295..f23a310 100644
--- a/chrome/browser/history/history_types.h
+++ b/chrome/browser/history/history_types.h
@@ -246,13 +246,6 @@
// If 0, the segment id is null in the table.
SegmentID segment_id;
- // True when this visit has indexed data for it. We try to keep this in sync
- // with the full text index: when we add or remove things from there, we will
- // update the visit table as well. However, that file could get deleted, or
- // out of sync in various ways, so this flag should be false when things
- // change.
- bool is_indexed;
-
// Record how much time a user has this visit starting from the user
// opened this visit to the user closed or ended this visit.
// This includes both active and inactive time as long as
@@ -460,10 +453,6 @@
// enough room. When 0, this will return everything (the default).
int max_count;
- // Only search within the page body if true, otherwise search all columns
- // including url and time. Defaults to false.
- bool body_only;
-
enum DuplicateHandling {
// Omit visits for which there is a more recent visit to the same URL.
// Each URL in the results will appear only once.
diff --git a/chrome/browser/history/in_memory_url_index_unittest.cc b/chrome/browser/history/in_memory_url_index_unittest.cc
index 1e0f72e..4556665 100644
--- a/chrome/browser/history/in_memory_url_index_unittest.cc
+++ b/chrome/browser/history/in_memory_url_index_unittest.cc
@@ -186,7 +186,7 @@
void InMemoryURLIndexTest::SetUp() {
// We cannot access the database until the backend has been loaded.
- profile_.CreateHistoryService(true, false);
+ ASSERT_TRUE(profile_.CreateHistoryService(true, false));
profile_.CreateBookmarkModel(true);
ui_test_utils::WaitForBookmarkModelToLoad(&profile_);
profile_.BlockUntilHistoryProcessesPendingRequests();
diff --git a/chrome/browser/history/text_database.cc b/chrome/browser/history/text_database.cc
deleted file mode 100644
index 0f5db89..0000000
--- a/chrome/browser/history/text_database.cc
+++ /dev/null
@@ -1,353 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <limits>
-#include <set>
-#include <string>
-
-#include "chrome/browser/history/text_database.h"
-
-#include "base/file_util.h"
-#include "base/logging.h"
-#include "base/metrics/histogram.h"
-#include "base/strings/string_number_conversions.h"
-#include "base/strings/stringprintf.h"
-#include "base/strings/utf_string_conversions.h"
-#include "sql/statement.h"
-#include "sql/transaction.h"
-
-// There are two tables in each database, one full-text search (FTS) table which
-// indexes the contents and title of the pages. The other is a regular SQLITE
-// table which contains non-indexed information about the page. All columns of
-// a FTS table are indexed using the text search algorithm, which isn't what we
-// want for things like times. If this were in the FTS table, there would be
-// different words in the index for each time number.
-//
-// "pages" FTS table:
-// url URL of the page so searches will match the URL.
-// title Title of the page.
-// body Body of the page.
-//
-// "info" regular table:
-// time Time the corresponding FTS entry was visited.
-//
-// We do joins across these two tables by using their internal rowids, which we
-// keep in sync between the two tables. The internal rowid is the only part of
-// an FTS table that is indexed like a normal table, and the index over it is
-// free since sqlite always indexes the internal rowid.
-
-namespace history {
-
-namespace {
-
-// Version 1 uses FTS2 for index files.
-// Version 2 uses FTS3.
-static const int kCurrentVersionNumber = 2;
-static const int kCompatibleVersionNumber = 2;
-
-// Snippet computation relies on the index of the columns in the original
-// create statement. These are the 0-based indices (as strings) of the
-// corresponding columns.
-const char kTitleColumnIndex[] = "1";
-const char kBodyColumnIndex[] = "2";
-
-// The string prepended to the database identifier to generate the filename.
-const base::FilePath::CharType kFilePrefix[] =
- FILE_PATH_LITERAL("History Index ");
-
-} // namespace
-
-TextDatabase::Match::Match() {}
-
-TextDatabase::Match::~Match() {}
-
-TextDatabase::TextDatabase(const base::FilePath& path,
- DBIdent id,
- bool allow_create)
- : path_(path),
- ident_(id),
- allow_create_(allow_create) {
- // Compute the file name.
- file_name_ = path_.Append(IDToFileName(ident_));
-}
-
-TextDatabase::~TextDatabase() {
-}
-
-// static
-const base::FilePath::CharType* TextDatabase::file_base() {
- return kFilePrefix;
-}
-
-// static
-base::FilePath TextDatabase::IDToFileName(DBIdent id) {
- // Identifiers are intended to be a combination of the year and month, for
- // example, 200801 for January 2008. We convert this to
- // "History Index 2008-01". However, we don't make assumptions about this
- // scheme: the caller should assign IDs as it feels fit with the knowledge
- // that they will apppear on disk in this form.
- base::FilePath::StringType filename(file_base());
- base::StringAppendF(&filename, FILE_PATH_LITERAL("%d-%02d"),
- id / 100, id % 100);
- return base::FilePath(filename);
-}
-
-// static
-TextDatabase::DBIdent TextDatabase::FileNameToID(
- const base::FilePath& file_path) {
- base::FilePath::StringType file_name = file_path.BaseName().value();
-
- // We don't actually check the prefix here. Since the file system could
- // be case insensitive in ways we can't predict (NTFS), checking could
- // potentially be the wrong thing to do. Instead, we just look for a suffix.
- static const size_t kIDStringLength = 7; // Room for "xxxx-xx".
- if (file_name.length() < kIDStringLength)
- return 0;
- const base::FilePath::StringType suffix(
- &file_name[file_name.length() - kIDStringLength]);
-
- if (suffix.length() != kIDStringLength ||
- suffix[4] != FILE_PATH_LITERAL('-')) {
- return 0;
- }
-
- // TODO: Once StringPiece supports a templated interface over the
- // underlying string type, use it here instead of substr, since that
- // will avoid needless string copies. StringPiece cannot be used
- // right now because base::FilePath::StringType could use either 8 or 16 bit
- // characters, depending on the OS.
- int year, month;
- base::StringToInt(suffix.substr(0, 4), &year);
- base::StringToInt(suffix.substr(5, 2), &month);
-
- return year * 100 + month;
-}
-
-bool TextDatabase::Init() {
- // Make sure, if we're not allowed to create the file, that it exists.
- if (!allow_create_) {
- if (!base::PathExists(file_name_))
- return false;
- }
-
- db_.set_histogram_tag("Text");
-
- // Set the database page size to something a little larger to give us
- // better performance (we're typically seek rather than bandwidth limited).
- // This only has an effect before any tables have been created, otherwise
- // this is a NOP. Must be a power of 2 and a max of 8192.
- db_.set_page_size(4096);
-
- // The default cache size is 2000 which give >8MB of data. Since we will often
- // have 2-3 of these objects, each with their own 8MB, this adds up very fast.
- // We therefore reduce the size so when there are multiple objects, we're not
- // too big.
- db_.set_cache_size(512);
-
- // Run the database in exclusive mode. Nobody else should be accessing the
- // database while we're running, and this will give somewhat improved perf.
- db_.set_exclusive_locking();
-
- // Attach the database to our index file.
- if (!db_.Open(file_name_))
- return false;
-
- // Meta table tracking version information.
- if (!meta_table_.Init(&db_, kCurrentVersionNumber, kCompatibleVersionNumber))
- return false;
- if (meta_table_.GetCompatibleVersionNumber() > kCurrentVersionNumber) {
- // This version is too new. We don't bother notifying the user on this
- // error, and just fail to use the file. Normally if they have version skew,
- // they will get it for the main history file and it won't be necessary
- // here. If that's not the case, since this is only indexed data, it's
- // probably better to just not give FTS results than strange errors when
- // everything else is working OK.
- LOG(WARNING) << "Text database is too new.";
- return false;
- }
-
- return CreateTables();
-}
-
-void TextDatabase::BeginTransaction() {
- db_.BeginTransaction();
-}
-
-void TextDatabase::CommitTransaction() {
- db_.CommitTransaction();
-}
-
-bool TextDatabase::CreateTables() {
- // FTS table of page contents.
- if (!db_.DoesTableExist("pages")) {
- if (!db_.Execute("CREATE VIRTUAL TABLE pages USING fts3("
- "TOKENIZE icu,"
- "url LONGVARCHAR,"
- "title LONGVARCHAR,"
- "body LONGVARCHAR)"))
- return false;
- }
-
- // Non-FTS table containing URLs and times so we can efficiently find them
- // using a regular index (all FTS columns are special and are treated as
- // full-text-search, which is not what we want when retrieving this data).
- if (!db_.DoesTableExist("info")) {
- // Note that there is no point in creating an index over time. Since
- // we must always query the entire FTS table (it can not efficiently do
- // subsets), we will always end up doing that first, and joining the info
- // table off of that.
- if (!db_.Execute("CREATE TABLE info(time INTEGER NOT NULL)"))
- return false;
- }
-
- // Create the index.
- return db_.Execute("CREATE INDEX IF NOT EXISTS info_time ON info(time)");
-}
-
-bool TextDatabase::AddPageData(base::Time time,
- const std::string& url,
- const std::string& title,
- const std::string& contents) {
- sql::Transaction committer(&db_);
- if (!committer.Begin())
- return false;
-
- // Add to the pages table.
- sql::Statement add_to_pages(db_.GetCachedStatement(SQL_FROM_HERE,
- "INSERT INTO pages (url, title, body) VALUES (?,?,?)"));
- add_to_pages.BindString(0, url);
- add_to_pages.BindString(1, title);
- add_to_pages.BindString(2, contents);
- if (!add_to_pages.Run())
- return false;
-
- int64 rowid = db_.GetLastInsertRowId();
-
- // Add to the info table with the same rowid.
- sql::Statement add_to_info(db_.GetCachedStatement(SQL_FROM_HERE,
- "INSERT INTO info (rowid, time) VALUES (?,?)"));
- add_to_info.BindInt64(0, rowid);
- add_to_info.BindInt64(1, time.ToInternalValue());
-
- if (!add_to_info.Run())
- return false;
-
- return committer.Commit();
-}
-
-void TextDatabase::DeletePageData(base::Time time, const std::string& url) {
- // First get all rows that match. Selecing on time (which has an index) allows
- // us to avoid brute-force searches on the full-text-index table (there will
- // generally be only one match per time).
- sql::Statement select_ids(db_.GetCachedStatement(SQL_FROM_HERE,
- "SELECT info.rowid "
- "FROM info JOIN pages ON info.rowid = pages.rowid "
- "WHERE info.time=? AND pages.url=?"));
- select_ids.BindInt64(0, time.ToInternalValue());
- select_ids.BindString(1, url);
-
- std::set<int64> rows_to_delete;
- while (select_ids.Step())
- rows_to_delete.insert(select_ids.ColumnInt64(0));
-
- // Delete from the pages table.
- sql::Statement delete_page(db_.GetCachedStatement(SQL_FROM_HERE,
- "DELETE FROM pages WHERE rowid=?"));
-
- for (std::set<int64>::const_iterator i = rows_to_delete.begin();
- i != rows_to_delete.end(); ++i) {
- delete_page.BindInt64(0, *i);
- if (!delete_page.Run())
- return;
- delete_page.Reset(true);
- }
-
- // Delete from the info table.
- sql::Statement delete_info(db_.GetCachedStatement(SQL_FROM_HERE,
- "DELETE FROM info WHERE rowid=?"));
-
- for (std::set<int64>::const_iterator i = rows_to_delete.begin();
- i != rows_to_delete.end(); ++i) {
- delete_info.BindInt64(0, *i);
- if (!delete_info.Run())
- return;
- delete_info.Reset(true);
- }
-}
-
-void TextDatabase::Optimize() {
- sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE,
- "SELECT OPTIMIZE(pages) FROM pages LIMIT 1"));
- statement.Run();
-}
-
-bool TextDatabase::GetTextMatches(const std::string& query,
- const QueryOptions& options,
- std::vector<Match>* results,
- URLSet* found_urls) {
- std::string sql = "SELECT url, title, time, offsets(pages), body FROM pages "
- "LEFT OUTER JOIN info ON pages.rowid = info.rowid WHERE ";
- sql += options.body_only ? "body " : "pages ";
- sql += "MATCH ? AND time >= ? AND time < ? ";
- // Times may not be unique, so also sort by rowid to ensure a stable order.
- sql += "ORDER BY time DESC, info.rowid DESC";
-
- // Generate unique IDs for the two possible variations of the statement,
- // so they don't share the same cached prepared statement.
- sql::StatementID body_only_id = SQL_FROM_HERE;
- sql::StatementID pages_id = SQL_FROM_HERE;
-
- sql::Statement statement(db_.GetCachedStatement(
- (options.body_only ? body_only_id : pages_id), sql.c_str()));
-
- statement.BindString(0, query);
- statement.BindInt64(1, options.EffectiveBeginTime());
- statement.BindInt64(2, options.EffectiveEndTime());
-
- // |results| may not be initially empty, so keep track of how many were added
- // by this call.
- int result_count = 0;
-
- while (statement.Step()) {
- // TODO(brettw) allow canceling the query in the middle.
- // if (canceled_or_something)
- // break;
-
- GURL url(statement.ColumnString(0));
- URLSet::const_iterator found_url = found_urls->find(url);
- if (found_url != found_urls->end())
- continue; // Don't add this duplicate.
-
- if (++result_count > options.EffectiveMaxCount())
- break;
-
- // Fill the results into the vector (avoid copying the URL with Swap()).
- results->resize(results->size() + 1);
- Match& match = results->at(results->size() - 1);
- match.url.Swap(&url);
-
- match.title = statement.ColumnString16(1);
- match.time = base::Time::FromInternalValue(statement.ColumnInt64(2));
-
- // Extract any matches in the title.
- std::string offsets_str = statement.ColumnString(3);
- Snippet::ExtractMatchPositions(offsets_str, kTitleColumnIndex,
- &match.title_match_positions);
- Snippet::ConvertMatchPositionsToWide(statement.ColumnString(1),
- &match.title_match_positions);
-
- // Extract the matches in the body.
- Snippet::MatchPositions match_positions;
- Snippet::ExtractMatchPositions(offsets_str, kBodyColumnIndex,
- &match_positions);
-
- // Compute the snippet based on those matches.
- std::string body = statement.ColumnString(4);
- match.snippet.ComputeSnippet(match_positions, body);
- }
- statement.Reset(true);
- return result_count > options.EffectiveMaxCount();
-}
-
-} // namespace history
diff --git a/chrome/browser/history/text_database.h b/chrome/browser/history/text_database.h
deleted file mode 100644
index ddb247b..0000000
--- a/chrome/browser/history/text_database.h
+++ /dev/null
@@ -1,165 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_HISTORY_TEXT_DATABASE_H_
-#define CHROME_BROWSER_HISTORY_TEXT_DATABASE_H_
-
-#include <set>
-#include <vector>
-
-#include "base/basictypes.h"
-#include "base/files/file_path.h"
-#include "base/strings/string16.h"
-#include "chrome/browser/history/history_types.h"
-#include "sql/connection.h"
-#include "sql/meta_table.h"
-#include "url/gurl.h"
-
-namespace history {
-
-// Encapsulation of a full-text indexed database file.
-class TextDatabase {
- public:
- typedef int DBIdent;
-
- typedef std::set<GURL> URLSet;
-
- // Returned from the search function.
- struct Match {
- Match();
- ~Match();
-
- // URL of the match.
- GURL url;
-
- // The title is returned because the title in the text database and the URL
- // database may differ. This happens because we capture the title when the
- // body is captured, and don't update it later.
- string16 title;
-
- // Time the page that was returned was visited.
- base::Time time;
-
- // Identifies any found matches in the title of the document. These are not
- // included in the snippet.
- Snippet::MatchPositions title_match_positions;
-
- // Snippet of the match we generated from the body.
- Snippet snippet;
- };
-
- // Note: You must call init which must succeed before using this class.
- //
- // Computes the matches for the query, returning results in decreasing order
- // of visit time.
- //
- // This function will attach the new database to the given database
- // connection. This allows one sqlite3 object to share many TextDatabases,
- // meaning that they will all share the same cache, which allows us to limit
- // the total size that text indexing databasii can take up.
- //
- // |file_name| is the name of the file on disk.
- //
- // ID is the identifier for the database. It should uniquely identify it among
- // other databases on disk and in the sqlite connection.
- //
- // |allow_create| indicates if we want to allow creation of the file if it
- // doesn't exist. For files associated with older time periods, we don't want
- // to create them if they don't exist, so this flag would be false.
- TextDatabase(const base::FilePath& path,
- DBIdent id,
- bool allow_create);
- ~TextDatabase();
-
- // Initializes the database connection and creates the file if the class
- // was created with |allow_create|. If the file couldn't be opened or
- // created, this will return false. No other functions should be called
- // after this.
- bool Init();
-
- // Allows updates to be batched. This gives higher performance when multiple
- // updates are happening because every insert doesn't require a sync to disk.
- // Transactions can be nested, only the outermost one will actually count.
- void BeginTransaction();
- void CommitTransaction();
-
- // For testing, returns the file name of the database so it can be deleted
- // after the test. This is valid even before Init() is called.
- const base::FilePath& file_name() const { return file_name_; }
-
- // Returns a NULL-terminated string that is the base of history index files,
- // which is the part before the database identifier. For example
- // "History Index *". This is for finding existing database files.
- static const base::FilePath::CharType* file_base();
-
- // Converts a filename on disk (optionally including a path) to a database
- // identifier. If the filename doesn't have the correct format, returns 0.
- static DBIdent FileNameToID(const base::FilePath& file_path);
-
- // Changing operations -------------------------------------------------------
-
- // Adds the given data to the page. Returns true on success. The data should
- // already be converted to UTF-8.
- bool AddPageData(base::Time time,
- const std::string& url,
- const std::string& title,
- const std::string& contents);
-
- // Deletes the indexed data exactly matching the given URL/time pair.
- void DeletePageData(base::Time time, const std::string& url);
-
- // Optimizes the tree inside the database. This will, in addition to making
- // access faster, remove any deleted data from the database (normally it is
- // added again as "removed" and it is manually cleaned up when it decides to
- // optimize it naturally). It is bad for privacy if a user is deleting a
- // page from history but it still exists in the full text database in some
- // form. This function will clean that up.
- void Optimize();
-
- // Querying ------------------------------------------------------------------
-
- // Executes the given query. See QueryOptions for more info on input.
- //
- // The results are appended to any existing ones in |*results|.
- //
- // Any URLs found will be added to |unique_urls|. If a URL is already in the
- // set, additional results will not be added (giving the ability to uniquify
- // URL results).
- //
- // Callers must run QueryParser on the user text and pass the results of the
- // QueryParser to this method as the query string.
- //
- // Returns true if there are more results available, i.e. if the number of
- // results was restricted by |options.max_count|.
- bool GetTextMatches(const std::string& query,
- const QueryOptions& options,
- std::vector<Match>* results,
- URLSet* unique_urls);
-
- // Converts the given database identifier to a filename. This does not include
- // the path, just the file and extension.
- static base::FilePath IDToFileName(DBIdent id);
-
- private:
- // Ensures that the tables and indices are created. Returns true on success.
- bool CreateTables();
-
- // The sql database. Not valid until Init is called.
- sql::Connection db_;
-
- const base::FilePath path_;
- const DBIdent ident_;
- const bool allow_create_;
-
- // Full file name of the file on disk, computed in Init().
- base::FilePath file_name_;
-
- sql::MetaTable meta_table_;
-
- DISALLOW_COPY_AND_ASSIGN(TextDatabase);
-};
-
-} // namespace history
-
-#endif // CHROME_BROWSER_HISTORY_TEXT_DATABASE_H_
diff --git a/chrome/browser/history/text_database_manager.cc b/chrome/browser/history/text_database_manager.cc
deleted file mode 100644
index c43a5fc..0000000
--- a/chrome/browser/history/text_database_manager.cc
+++ /dev/null
@@ -1,586 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/history/text_database_manager.h"
-
-#include <algorithm>
-#include <functional>
-
-#include "base/bind.h"
-#include "base/compiler_specific.h"
-#include "base/files/file_enumerator.h"
-#include "base/logging.h"
-#include "base/message_loop/message_loop.h"
-#include "base/metrics/histogram.h"
-#include "base/strings/string_util.h"
-#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/history/history_publisher.h"
-#include "chrome/browser/history/visit_database.h"
-
-using base::Time;
-using base::TimeDelta;
-using base::TimeTicks;
-
-namespace history {
-
-namespace {
-
-// The number of database files we will be attached to at once.
-const int kCacheDBSize = 5;
-
-std::string ConvertStringForIndexer(const string16& input) {
- // TODO(evanm): other transformations here?
- return UTF16ToUTF8(CollapseWhitespace(input, false));
-}
-
-// Data older than this will be committed to the full text index even if we
-// haven't gotten a title and/or body.
-const int kExpirationSeconds = 20;
-
-} // namespace
-
-// TextDatabaseManager::ChangeSet ----------------------------------------------
-
-TextDatabaseManager::ChangeSet::ChangeSet() {}
-
-TextDatabaseManager::ChangeSet::~ChangeSet() {}
-
-// TextDatabaseManager::PageInfo -----------------------------------------------
-
-TextDatabaseManager::PageInfo::PageInfo(URLID url_id,
- VisitID visit_id,
- Time visit_time)
- : url_id_(url_id),
- visit_id_(visit_id),
- visit_time_(visit_time) {
- added_time_ = TimeTicks::Now();
-}
-
-TextDatabaseManager::PageInfo::~PageInfo() {}
-
-void TextDatabaseManager::PageInfo::set_title(const string16& ttl) {
- if (ttl.empty()) // Make the title nonempty when we set it for EverybodySet.
- title_ = ASCIIToUTF16(" ");
- else
- title_ = ttl;
-}
-
-void TextDatabaseManager::PageInfo::set_body(const string16& bdy) {
- if (bdy.empty()) // Make the body nonempty when we set it for EverybodySet.
- body_ = ASCIIToUTF16(" ");
- else
- body_ = bdy;
-}
-
-bool TextDatabaseManager::PageInfo::Expired(TimeTicks now) const {
- return now - added_time_ > base::TimeDelta::FromSeconds(kExpirationSeconds);
-}
-
-// TextDatabaseManager ---------------------------------------------------------
-
-TextDatabaseManager::TextDatabaseManager(const base::FilePath& dir,
- URLDatabase* url_database,
- VisitDatabase* visit_database)
- : dir_(dir),
- url_database_(url_database),
- visit_database_(visit_database),
- recent_changes_(RecentChangeList::NO_AUTO_EVICT),
- transaction_nesting_(0),
- db_cache_(DBCache::NO_AUTO_EVICT),
- present_databases_loaded_(false),
- weak_factory_(this),
- history_publisher_(NULL) {
-}
-
-TextDatabaseManager::~TextDatabaseManager() {
- if (transaction_nesting_)
- CommitTransaction();
-}
-
-// static
-TextDatabase::DBIdent TextDatabaseManager::TimeToID(Time time) {
- Time::Exploded exploded;
- time.UTCExplode(&exploded);
-
- // We combine the month and year into a 6-digit number (200801 for
- // January, 2008). The month is 1-based.
- return exploded.year * 100 + exploded.month;
-}
-
-// static
-Time TextDatabaseManager::IDToTime(TextDatabase::DBIdent id) {
- Time::Exploded exploded;
- memset(&exploded, 0, sizeof(Time::Exploded));
- exploded.year = id / 100;
- exploded.month = id % 100;
- return Time::FromUTCExploded(exploded);
-}
-
-bool TextDatabaseManager::Init(const HistoryPublisher* history_publisher) {
- history_publisher_ = history_publisher;
-
- // Start checking recent changes and committing them.
- ScheduleFlushOldChanges();
- return true;
-}
-
-void TextDatabaseManager::BeginTransaction() {
- transaction_nesting_++;
-}
-
-void TextDatabaseManager::CommitTransaction() {
- DCHECK(transaction_nesting_);
- transaction_nesting_--;
- if (transaction_nesting_)
- return; // Still more nesting of transactions before committing.
-
- // Commit all databases with open transactions on them.
- for (DBIdentSet::const_iterator i = open_transactions_.begin();
- i != open_transactions_.end(); ++i) {
- DBCache::iterator iter = db_cache_.Get(*i);
- if (iter == db_cache_.end()) {
- NOTREACHED() << "All open transactions should be cached.";
- continue;
- }
- iter->second->CommitTransaction();
- }
- open_transactions_.clear();
-
- // Now that the transaction is over, we can expire old connections.
- db_cache_.ShrinkToSize(kCacheDBSize);
-}
-
-void TextDatabaseManager::InitDBList() {
- if (present_databases_loaded_)
- return;
-
- present_databases_loaded_ = true;
-
- // Find files on disk matching our pattern so we can quickly test for them.
- base::FilePath::StringType filepattern(TextDatabase::file_base());
- filepattern.append(FILE_PATH_LITERAL("*"));
- base::FileEnumerator enumerator(
- dir_, false, base::FileEnumerator::FILES, filepattern);
- base::FilePath cur_file;
- while (!(cur_file = enumerator.Next()).empty()) {
- // Convert to the number representing this file.
- TextDatabase::DBIdent id = TextDatabase::FileNameToID(cur_file);
- if (id) // Will be 0 on error.
- present_databases_.insert(id);
- }
-}
-
-void TextDatabaseManager::AddPageURL(const GURL& url,
- URLID url_id,
- VisitID visit_id,
- Time time) {
- // Delete any existing page info.
- RecentChangeList::iterator found = recent_changes_.Peek(url);
- if (found != recent_changes_.end())
- recent_changes_.Erase(found);
-
- // Just save this info for later. We will save it when it expires or when all
- // the data is complete.
- recent_changes_.Put(url, PageInfo(url_id, visit_id, time));
-}
-
-void TextDatabaseManager::AddPageTitle(const GURL& url,
- const string16& title) {
- RecentChangeList::iterator found = recent_changes_.Peek(url);
- if (found == recent_changes_.end()) {
- // This page is not in our cache of recent pages. This is very much an edge
- // case as normally a title will come in <20 seconds after the page commits,
- // and WebContents will avoid spamming us with >1 title per page. However,
- // it could come up if your connection is unhappy, and we don't want to
- // miss anything.
- //
- // To solve this problem, we'll just associate the most recent visit with
- // the new title and index that using the regular code path.
- URLRow url_row;
- if (!url_database_->GetRowForURL(url, &url_row))
- return; // URL is unknown, give up.
- VisitRow visit;
- if (!visit_database_->GetMostRecentVisitForURL(url_row.id(), &visit))
- return; // No recent visit, give up.
-
- if (visit.is_indexed) {
- // If this page was already indexed, we could have a body that came in
- // first and we don't want to overwrite it. We could go query for the
- // current body, or have a special setter for only the title, but this is
- // not worth it for this edge case.
- //
- // It will be almost impossible for the title to take longer than
- // kExpirationSeconds yet we got a body in less than that time, since
- // the title should always come in first.
- return;
- }
-
- AddPageData(url, url_row.id(), visit.visit_id, visit.visit_time,
- title, string16());
- return; // We don't know about this page, give up.
- }
-
- PageInfo& info = found->second;
- if (info.has_body()) {
- // This info is complete, write to the database.
- AddPageData(url, info.url_id(), info.visit_id(), info.visit_time(),
- title, info.body());
- recent_changes_.Erase(found);
- return;
- }
-
- info.set_title(title);
-}
-
-void TextDatabaseManager::AddPageContents(const GURL& url,
- const string16& body) {
- RecentChangeList::iterator found = recent_changes_.Peek(url);
- if (found == recent_changes_.end()) {
- // This page is not in our cache of recent pages. This means that the page
- // took more than kExpirationSeconds to load. Often, this will be the result
- // of a very slow iframe or other resource on the page that makes us think
- // it's still loading.
- //
- // As a fallback, set the most recent visit's contents using the input, and
- // use the last set title in the URL table as the title to index.
- URLRow url_row;
- if (!url_database_->GetRowForURL(url, &url_row))
- return; // URL is unknown, give up.
- VisitRow visit;
- if (!visit_database_->GetMostRecentVisitForURL(url_row.id(), &visit))
- return; // No recent visit, give up.
-
- // Use the title from the URL row as the title for the indexing.
- AddPageData(url, url_row.id(), visit.visit_id, visit.visit_time,
- url_row.title(), body);
- return;
- }
-
- PageInfo& info = found->second;
- if (info.has_title()) {
- // This info is complete, write to the database.
- AddPageData(url, info.url_id(), info.visit_id(), info.visit_time(),
- info.title(), body);
- recent_changes_.Erase(found);
- return;
- }
-
- info.set_body(body);
-}
-
-bool TextDatabaseManager::AddPageData(const GURL& url,
- URLID url_id,
- VisitID visit_id,
- Time visit_time,
- const string16& title,
- const string16& body) {
- TextDatabase* db = GetDBForTime(visit_time, true);
- if (!db)
- return false;
-
- TimeTicks beginning_time = TimeTicks::Now();
-
- // First delete any recently-indexed data for this page. This will delete
- // anything in the main database, but we don't bother looking through the
- // archived database.
- VisitVector visits;
- visit_database_->GetIndexedVisitsForURL(url_id, &visits);
- for (size_t i = 0; i < visits.size(); i++) {
- visits[i].is_indexed = false;
- visit_database_->UpdateVisitRow(visits[i]);
- DeletePageData(visits[i].visit_time, url, NULL);
- }
-
- if (visit_id) {
- // We're supposed to update the visit database, so load the visit.
- VisitRow row;
- if (!visit_database_->GetRowForVisit(visit_id, &row)) {
- // This situation can occur if Chrome's history is in the process of
- // being updated, and then the browsing history is deleted before all
- // updates have been completely performed. In this case, a stale update
- // to the database is attempted, leading to the warning below.
- DLOG(WARNING) << "Could not find requested visit #" << visit_id;
- return false;
- }
-
- DCHECK(visit_time == row.visit_time);
-
- // Update the visit database to reference our addition.
- row.is_indexed = true;
- if (!visit_database_->UpdateVisitRow(row))
- return false;
- }
-
- // Now index the data.
- std::string url_str = URLDatabase::GURLToDatabaseURL(url);
- bool success = db->AddPageData(visit_time, url_str,
- ConvertStringForIndexer(title),
- ConvertStringForIndexer(body));
-
- UMA_HISTOGRAM_TIMES("History.AddFTSData",
- TimeTicks::Now() - beginning_time);
-
- if (history_publisher_)
- history_publisher_->PublishPageContent(visit_time, url, title, body);
-
- return success;
-}
-
-void TextDatabaseManager::DeletePageData(Time time, const GURL& url,
- ChangeSet* change_set) {
- TextDatabase::DBIdent db_ident = TimeToID(time);
-
- // We want to open the database for writing, but only if it exists. To
- // achieve this, we check whether it exists by saying we're not going to
- // write to it (avoiding the autocreation code normally called when writing)
- // and then access it for writing only if it succeeds.
- TextDatabase* db = GetDB(db_ident, false);
- if (!db)
- return;
- db = GetDB(db_ident, true);
-
- if (change_set)
- change_set->Add(db_ident);
-
- db->DeletePageData(time, URLDatabase::GURLToDatabaseURL(url));
-}
-
-void TextDatabaseManager::DeleteFromUncommitted(
- const std::set<GURL>& restrict_urls, Time begin, Time end) {
- // First find the beginning of the range to delete. Recall that the list
- // has the most recent item at the beginning. There won't normally be very
- // many items, so a brute-force search is fine.
- RecentChangeList::iterator cur = recent_changes_.begin();
- if (!end.is_null()) {
- // Walk from the beginning of the list backwards in time to find the newest
- // entry that should be deleted.
- while (cur != recent_changes_.end() && cur->second.visit_time() >= end)
- ++cur;
- }
-
- // Now delete all visits up to the oldest one we were supposed to delete.
- // Note that if begin is_null, it will be less than or equal to any other
- // time.
- if (restrict_urls.empty()) {
- while (cur != recent_changes_.end() && cur->second.visit_time() >= begin)
- cur = recent_changes_.Erase(cur);
- } else {
- while (cur != recent_changes_.end() && cur->second.visit_time() >= begin) {
- if (restrict_urls.find(cur->first) != restrict_urls.end())
- cur = recent_changes_.Erase(cur);
- else
- ++cur;
- }
- }
-}
-
-void TextDatabaseManager::DeleteFromUncommittedForTimes(
- const std::vector<base::Time>& times) {
- // |times| must be in reverse chronological order, i.e. each member
- // must be earlier than or the same as the one before it.
- DCHECK(
- std::adjacent_find(
- times.begin(), times.end(), std::less<base::Time>()) ==
- times.end());
-
- // Both |recent_changes_| and |times| are in reverse chronological order.
- RecentChangeList::iterator it = recent_changes_.begin();
- std::vector<base::Time>::const_iterator time_it = times.begin();
- while (it != recent_changes_.end() && time_it != times.end()) {
- base::Time visit_time = it->second.visit_time();
- if (visit_time == *time_it) {
- it = recent_changes_.Erase(it);
- } else if (visit_time < *time_it) {
- ++time_it;
- } else /* if (visit_time > *time_it) */ {
- ++it;
- }
- }
-}
-
-void TextDatabaseManager::DeleteAll() {
- DCHECK_EQ(0, transaction_nesting_) << "Calling deleteAll in a transaction.";
-
- InitDBList();
-
- // Delete uncommitted entries.
- recent_changes_.Clear();
-
- // Close all open databases.
- db_cache_.Clear();
-
- // Now go through and delete all the files.
- for (DBIdentSet::iterator i = present_databases_.begin();
- i != present_databases_.end(); ++i) {
- base::FilePath file_name = dir_.Append(TextDatabase::IDToFileName(*i));
- sql::Connection::Delete(file_name);
- }
-}
-
-void TextDatabaseManager::OptimizeChangedDatabases(
- const ChangeSet& change_set) {
- for (ChangeSet::DBSet::const_iterator i =
- change_set.changed_databases_.begin();
- i != change_set.changed_databases_.end(); ++i) {
- // We want to open the database for writing, but only if it exists. To
- // achieve this, we check whether it exists by saying we're not going to
- // write to it (avoiding the autocreation code normally called when writing)
- // and then access it for writing only if it succeeds.
- TextDatabase* db = GetDB(*i, false);
- if (!db)
- continue;
- db = GetDB(*i, true);
- if (!db)
- continue; // The file may have changed or something.
- db->Optimize();
- }
-}
-
-void TextDatabaseManager::GetTextMatches(
- const string16& query,
- const QueryOptions& options,
- std::vector<TextDatabase::Match>* results,
- Time* first_time_searched) {
- results->clear();
-
- *first_time_searched = options.begin_time;
-
- InitDBList();
- if (present_databases_.empty())
- return; // Nothing to search.
-
- // Get the query into the proper format for the individual DBs.
- string16 fts_query16;
- query_parser_.ParseQuery(query, &fts_query16);
- std::string fts_query = UTF16ToUTF8(fts_query16);
-
- // Need a copy of the options so we can modify the max count for each call
- // to the individual databases.
- QueryOptions cur_options(options);
-
- // Compute the minimum and maximum values for the identifiers that could
- // encompass the input time range.
- TextDatabase::DBIdent min_ident = options.begin_time.is_null() ?
- *present_databases_.begin() :
- TimeToID(options.begin_time);
- TextDatabase::DBIdent max_ident = options.end_time.is_null() ?
- *present_databases_.rbegin() :
- TimeToID(options.end_time);
-
- // Iterate over the databases from the most recent backwards.
- TextDatabase::URLSet found_urls;
- for (DBIdentSet::reverse_iterator i = present_databases_.rbegin();
- i != present_databases_.rend();
- ++i) {
- // TODO(brettw) allow canceling the query in the middle.
- // if (canceled_or_something)
- // break;
-
- // This code is stupid, we just loop until we find the correct starting
- // time range rather than search in an intelligent way. Users will have a
- // few dozen files at most, so this should not be an issue.
- if (*i > max_ident)
- continue; // Haven't gotten to the time range yet.
- if (*i < min_ident)
- break; // Covered all the time range.
-
- TextDatabase* cur_db = GetDB(*i, false);
- if (!cur_db)
- continue;
-
- // Adjust the max count according to how many results we've already got.
- if (options.max_count) {
- cur_options.max_count = options.max_count -
- static_cast<int>(results->size());
- }
-
- bool has_more_results = cur_db->GetTextMatches(
- fts_query, cur_options, results, &found_urls);
-
- DCHECK(static_cast<int>(results->size()) <= options.EffectiveMaxCount());
-
- if (has_more_results ||
- static_cast<int>(results->size()) == options.EffectiveMaxCount()) {
- // Since the search proceeds backwards in time, the last result we have
- // gives the first time searched.
- *first_time_searched = results->back().time;
- break;
- }
- }
-}
-
-size_t TextDatabaseManager::GetUncommittedEntryCountForTest() const {
- return recent_changes_.size();
-}
-
-TextDatabase* TextDatabaseManager::GetDB(TextDatabase::DBIdent id,
- bool for_writing) {
- DBCache::iterator found_db = db_cache_.Get(id);
- if (found_db != db_cache_.end()) {
- if (transaction_nesting_ && for_writing &&
- open_transactions_.find(id) == open_transactions_.end()) {
- // If we currently have an open transaction, that database is not yet
- // part of the transaction, and the database will be written to, it needs
- // to be part of our transaction.
- found_db->second->BeginTransaction();
- open_transactions_.insert(id);
- }
- return found_db->second;
- }
-
- // Need to make the database.
- TextDatabase* new_db = new TextDatabase(dir_, id, for_writing);
- if (!new_db->Init()) {
- delete new_db;
- return NULL;
- }
- db_cache_.Put(id, new_db);
- present_databases_.insert(id);
-
- if (transaction_nesting_ && for_writing) {
- // If we currently have an open transaction and the new database will be
- // written to, it needs to be part of our transaction.
- new_db->BeginTransaction();
- open_transactions_.insert(id);
- }
-
- // When no transaction is open, allow this new one to kick out an old one.
- if (!transaction_nesting_)
- db_cache_.ShrinkToSize(kCacheDBSize);
-
- return new_db;
-}
-
-TextDatabase* TextDatabaseManager::GetDBForTime(Time time,
- bool create_if_necessary) {
- return GetDB(TimeToID(time), create_if_necessary);
-}
-
-void TextDatabaseManager::ScheduleFlushOldChanges() {
- weak_factory_.InvalidateWeakPtrs();
- base::MessageLoop::current()->PostDelayedTask(
- FROM_HERE,
- base::Bind(&TextDatabaseManager::FlushOldChanges,
- weak_factory_.GetWeakPtr()),
- base::TimeDelta::FromSeconds(kExpirationSeconds));
-}
-
-void TextDatabaseManager::FlushOldChanges() {
- FlushOldChangesForTime(TimeTicks::Now());
-}
-
-void TextDatabaseManager::FlushOldChangesForTime(TimeTicks now) {
- // The end of the list is the oldest, so we just start from there committing
- // things until we get something too new.
- RecentChangeList::reverse_iterator i = recent_changes_.rbegin();
- while (i != recent_changes_.rend() && i->second.Expired(now)) {
- AddPageData(i->first, i->second.url_id(), i->second.visit_id(),
- i->second.visit_time(), i->second.title(), i->second.body());
- i = recent_changes_.Erase(i);
- }
-
- ScheduleFlushOldChanges();
-}
-
-} // namespace history
diff --git a/chrome/browser/history/text_database_manager.h b/chrome/browser/history/text_database_manager.h
deleted file mode 100644
index 986274c..0000000
--- a/chrome/browser/history/text_database_manager.h
+++ /dev/null
@@ -1,320 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_HISTORY_TEXT_DATABASE_MANAGER_H_
-#define CHROME_BROWSER_HISTORY_TEXT_DATABASE_MANAGER_H_
-
-#include <cstddef>
-#include <set>
-#include <vector>
-
-#include "base/basictypes.h"
-#include "base/containers/mru_cache.h"
-#include "base/files/file_path.h"
-#include "base/gtest_prod_util.h"
-#include "base/memory/weak_ptr.h"
-#include "base/strings/string16.h"
-#include "chrome/browser/history/history_types.h"
-#include "chrome/browser/history/query_parser.h"
-#include "chrome/browser/history/text_database.h"
-#include "chrome/browser/history/url_database.h"
-
-namespace history {
-
-class HistoryPublisher;
-class VisitDatabase;
-
-// Manages a set of text databases representing different time periods. This
-// will page them in and out as necessary, and will manage queries for times
-// spanning multiple databases.
-//
-// It will also keep a list of partial changes, such as page adds and title and
-// body sets, all of which come in at different times for a given page. When
-// all data is received or enough time has elapsed since adding, the indexed
-// data will be committed.
-//
-// This allows us to minimize inserts and modifications, which are slow for the
-// full text database, since each page's information is added exactly once.
-//
-// Note: be careful to delete the relevant entries from this uncommitted list
-// when clearing history or this information may get added to the database soon
-// after the clear.
-class TextDatabaseManager {
- public:
- // Tracks a set of changes (only deletes need to be supported now) to the
- // databases. This is opaque to the caller, but allows it to pass back a list
- // of all database that it has caused a change to.
- //
- // This is necessary for the feature where we optimize full text databases
- // which have changed as a result of the user deleting history via
- // OptimizeChangedDatabases. We want to do each affected database only once at
- // the end of the delete, but we don't want the caller to have to worry about
- // our internals.
- class ChangeSet {
- public:
- ChangeSet();
- ~ChangeSet();
-
- private:
- friend class TextDatabaseManager;
-
- typedef std::set<TextDatabase::DBIdent> DBSet;
-
- void Add(TextDatabase::DBIdent id) { changed_databases_.insert(id); }
-
- DBSet changed_databases_;
- };
-
- // You must call Init() to complete initialization.
- //
- // |dir| is the directory that will hold the full text database files (there
- // will be many files named by their date ranges).
- //
- // The visit database is a pointer owned by the caller for the main database
- // (of recent visits). The visit database will be updated to refer to the
- // added text database entries.
- TextDatabaseManager(const base::FilePath& dir,
- URLDatabase* url_database,
- VisitDatabase* visit_database);
- ~TextDatabaseManager();
-
- // Must call before using other functions. If it returns false, no other
- // functions should be called.
- bool Init(const HistoryPublisher* history_publisher);
-
- // Returns the directory that holds the full text database files.
- const base::FilePath& GetDir() { return dir_; }
-
- // Allows scoping updates. This also allows things to go faster since every
- // page add doesn't need to be committed to disk (slow). Note that files will
- // still get created during a transaction.
- void BeginTransaction();
- void CommitTransaction();
-
- // Sets specific information for the given page to be added to the database.
- // In normal operation, URLs will be added as the user visits them, the titles
- // and bodies will come in some time after that. These changes will be
- // automatically coalesced and added to the database some time in the future
- // using AddPageData().
- //
- // AddPageURL must be called for a given URL (+ its corresponding ID) before
- // either the title or body set. The visit ID specifies the visit that will
- // get updated to refer to the full text indexed information. The visit time
- // should be the time corresponding to that visit in the database.
- void AddPageURL(const GURL& url, URLID url_id, VisitID visit_id,
- base::Time visit_time);
- void AddPageTitle(const GURL& url, const string16& title);
- void AddPageContents(const GURL& url, const string16& body);
-
- // Adds the given data to the appropriate database file, returning true on
- // success. The visit database row identified by |visit_id| will be updated
- // to refer to the full text index entry. If the visit ID is 0, the visit
- // database will not be updated.
- bool AddPageData(const GURL& url,
- URLID url_id,
- VisitID visit_id,
- base::Time visit_time,
- const string16& title,
- const string16& body);
-
- // Deletes the instance of indexed data identified by the given time and URL.
- // Any changes will be tracked in the optional change set for use when calling
- // OptimizeChangedDatabases later. change_set can be NULL.
- void DeletePageData(base::Time time, const GURL& url,
- ChangeSet* change_set);
-
- // The text database manager keeps a list of changes that are made to the
- // file AddPageURL/Title/Body that may not be committed to the database yet.
- // This function removes entries from this list happening between the given
- // time range. It is called when the user clears their history for a time
- // range, and we don't want any of our data to "leak." If restrict_urls is
- // not empty, only changes on those URLs are deleted.
- //
- // Either or both times my be is_null to be unbounded in that direction. When
- // non-null, the range is [begin, end).
- void DeleteFromUncommitted(const std::set<GURL>& restrict_urls,
- base::Time begin, base::Time end);
-
- // This function removes entries from the same list as
- // DeleteFromUncommitted() with times belonging to the given list of
- // times, which must be in reverse chronological order.
- void DeleteFromUncommittedForTimes(const std::vector<base::Time>& times);
-
- // Deletes all full text search data by removing the files from the disk.
- // This must be called OUTSIDE of a transaction since it actually deletes the
- // files rather than messing with the database.
- void DeleteAll();
-
- // Calls optimize on all the databases identified in a given change set (see
- // the definition of ChangeSet above for more). Optimizing means that old data
- // will be removed rather than marked unused.
- void OptimizeChangedDatabases(const ChangeSet& change_set);
-
- // Executes the given query. See QueryOptions for more info on input.
- //
- // The results are filled into |results|, and the first time considered for
- // the output is in |first_time_searched| (see QueryResults for more).
- //
- // This function will return more than one match per URL if there is more than
- // one entry for that URL in the database.
- void GetTextMatches(const string16& query,
- const QueryOptions& options,
- std::vector<TextDatabase::Match>* results,
- base::Time* first_time_searched);
-
- size_t GetUncommittedEntryCountForTest() const;
-
- private:
- // These tests call ExpireRecentChangesForTime to force expiration.
- FRIEND_TEST_ALL_PREFIXES(TextDatabaseManagerTest, InsertPartial);
- FRIEND_TEST_ALL_PREFIXES(TextDatabaseManagerTest, PartialComplete);
- FRIEND_TEST_ALL_PREFIXES(ExpireHistoryTest, DeleteURLAndFavicon);
- FRIEND_TEST_ALL_PREFIXES(ExpireHistoryTest, FlushRecentURLsUnstarred);
- FRIEND_TEST_ALL_PREFIXES(ExpireHistoryTest, FlushURLsForTimes);
- FRIEND_TEST_ALL_PREFIXES(ExpireHistoryTest,
- FlushRecentURLsUnstarredRestricted);
-
- // Stores "recent stuff" that has happened with the page, since the page
- // visit, title, and body all come in at different times.
- class PageInfo {
- public:
- PageInfo(URLID url_id, VisitID visit_id, base::Time visit_time);
- ~PageInfo();
-
- // Getters.
- URLID url_id() const { return url_id_; }
- VisitID visit_id() const { return visit_id_; }
- base::Time visit_time() const { return visit_time_; }
- const string16& title() const { return title_; }
- const string16& body() const { return body_; }
-
- // Setters, we can only update the title and body.
- void set_title(const string16& ttl);
- void set_body(const string16& bdy);
-
- // Returns true if both the title or body of the entry has been set. Since
- // both the title and body setters will "fix" empty strings to be a space,
- // these indicate if the setter was ever called.
- bool has_title() const { return !title_.empty(); }
- bool has_body() { return !body_.empty(); }
-
- // Returns true if this entry was added too long ago and we should give up
- // waiting for more data. The current time is passed in as an argument so we
- // can check many without re-querying the timer.
- bool Expired(base::TimeTicks now) const;
-
- private:
- URLID url_id_;
- VisitID visit_id_;
-
- // Time of the visit of the URL. This will be the value stored in the URL
- // and visit tables for the entry.
- base::Time visit_time_;
-
- // When this page entry was created. We have a cap on the maximum time that
- // an entry will be in the queue before being flushed to the database.
- base::TimeTicks added_time_;
-
- // Will be the string " " when they are set to distinguish set and unset.
- string16 title_;
- string16 body_;
- };
-
- // Converts the given time to a database identifier or vice-versa.
- static TextDatabase::DBIdent TimeToID(base::Time time);
- static base::Time IDToTime(TextDatabase::DBIdent id);
-
- // Returns a text database for the given identifier or time. This file will
- // be created if it doesn't exist and |for_writing| is set. On error,
- // including the case where the file doesn't exist and |for_writing|
- // is false, it will return NULL.
- //
- // When |for_writing| is set, a transaction on the database will be opened
- // if there is a transaction open on this manager.
- //
- // The pointer will be tracked in the cache. The caller should not store it
- // or delete it since it will get automatically deleted as necessary.
- TextDatabase* GetDB(TextDatabase::DBIdent id, bool for_writing);
- TextDatabase* GetDBForTime(base::Time time, bool for_writing);
-
- // Populates the present_databases_ list based on which files are on disk.
- // When the list is already initialized, this will do nothing, so you can
- // call it whenever you want to ensure the present_databases_ set is filled.
- void InitDBList();
-
- // Schedules a call to ExpireRecentChanges in the future.
- void ScheduleFlushOldChanges();
-
- // Checks the recent_changes_ list and commits partial data that has been
- // around too long.
- void FlushOldChanges();
-
- // Given "now," this will expire old things from the recent_changes_ list.
- // This is used as the backend for FlushOldChanges and is called directly
- // by the unit tests with fake times.
- void FlushOldChangesForTime(base::TimeTicks now);
-
- // Directory holding our index files.
- const base::FilePath dir_;
-
- // Non-owning pointers to the recent history databases for URLs and visits.
- URLDatabase* url_database_;
- VisitDatabase* visit_database_;
-
- // Lists recent additions that we have not yet filled out with the title and
- // body. Sorted by time, we will flush them when they are complete or have
- // been in the queue too long without modification.
- //
- // We kind of abuse the MRUCache because we never move things around in it
- // using Get. Instead, we keep them in the order they were inserted, since
- // this is the metric we use to measure age. The MRUCache gives us an ordered
- // list with fast lookup by URL.
- typedef base::MRUCache<GURL, PageInfo> RecentChangeList;
- RecentChangeList recent_changes_;
-
- // Nesting levels of transactions. Since sqlite only allows one open
- // transaction, we simulate nested transactions by mapping the outermost one
- // to a real transaction. Since this object never needs to do ROLLBACK, losing
- // the ability for all transactions to rollback is inconsequential.
- int transaction_nesting_;
-
- // The cache owns the TextDatabase pointers, they will be automagically
- // deleted when the cache entry is removed or expired.
- typedef base::OwningMRUCache<TextDatabase::DBIdent, TextDatabase*> DBCache;
- DBCache db_cache_;
-
- // Tells us about the existence of database files on disk. All existing
- // databases will be in here, and non-existent ones will not, so we don't
- // have to check the disk every time.
- //
- // This set is populated LAZILY by InitDBList(), you should call that function
- // before accessing the list.
- //
- // Note that iterators will work on the keys in-order. Normally, reverse
- // iterators will be used to iterate the keys in reverse-order.
- typedef std::set<TextDatabase::DBIdent> DBIdentSet;
- DBIdentSet present_databases_;
- bool present_databases_loaded_; // Set by InitDBList when populated.
-
- // Lists all databases with open transactions. These will have to be closed
- // when the transaction is committed.
- DBIdentSet open_transactions_;
-
- QueryParser query_parser_;
-
- // Generates tasks for our periodic checking of expired "recent changes".
- base::WeakPtrFactory<TextDatabaseManager> weak_factory_;
-
- // This object is created and managed by the history backend. We maintain an
- // opaque pointer to the object for our use.
- // This can be NULL if there are no indexers registered to receive indexing
- // data from us.
- const HistoryPublisher* history_publisher_;
-
- DISALLOW_COPY_AND_ASSIGN(TextDatabaseManager);
-};
-
-} // namespace history
-
-#endif // CHROME_BROWSER_HISTORY_TEXT_DATABASE_MANAGER_H_
diff --git a/chrome/browser/history/text_database_manager_unittest.cc b/chrome/browser/history/text_database_manager_unittest.cc
deleted file mode 100644
index 0ea76f6..0000000
--- a/chrome/browser/history/text_database_manager_unittest.cc
+++ /dev/null
@@ -1,598 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <set>
-
-#include "base/file_util.h"
-#include "base/files/file_path.h"
-#include "base/message_loop/message_loop.h"
-#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/history/text_database_manager.h"
-#include "chrome/browser/history/visit_database.h"
-#include "sql/connection.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-using base::Time;
-using base::TimeDelta;
-using base::TimeTicks;
-
-namespace history {
-
-namespace {
-
-const char* kURL1 = "http://www.google.com/asdf";
-const char* kTitle1 = "Google A";
-const char* kBody1 = "FOO page one.";
-
-const char* kURL2 = "http://www.google.com/qwer";
-const char* kTitle2 = "Google B";
-const char* kBody2 = "FOO two.";
-
-const char* kURL3 = "http://www.google.com/zxcv";
-const char* kTitle3 = "Google C";
-const char* kBody3 = "FOO drei";
-
-const char* kURL4 = "http://www.google.com/hjkl";
-const char* kTitle4 = "Google D";
-const char* kBody4 = "FOO lalala four.";
-
-const char* kURL5 = "http://www.google.com/uiop";
-const char* kTitle5 = "Google cinq";
-const char* kBody5 = "FOO page one.";
-
-// This provides a simple implementation of a URL+VisitDatabase using an
-// in-memory sqlite connection. The text database manager expects to be able to
-// update the visit database to keep in sync.
-class InMemDB : public URLDatabase, public VisitDatabase {
- public:
- InMemDB() {
- EXPECT_TRUE(db_.OpenInMemory());
- CreateURLTable(false);
- InitVisitTable();
- }
- virtual ~InMemDB() {
- }
-
- private:
- virtual sql::Connection& GetDB() OVERRIDE { return db_; }
-
- sql::Connection db_;
-
- DISALLOW_COPY_AND_ASSIGN(InMemDB);
-};
-
-// Adds all the pages once, and the first page once more in the next month.
-// The times of all the pages will be filled into |*times|.
-void AddAllPages(TextDatabaseManager& manager, VisitDatabase* visit_db,
- std::vector<Time>* times) {
- Time::Exploded exploded;
- memset(&exploded, 0, sizeof(Time::Exploded));
-
- // Put the visits in two different months so it will query across databases.
- exploded.year = 2008;
- exploded.month = 1;
- exploded.day_of_month = 3;
-
- VisitRow visit_row;
- visit_row.url_id = 1;
- visit_row.visit_time = Time::FromUTCExploded(exploded);
- visit_row.referring_visit = 0;
- visit_row.transition = content::PageTransitionFromInt(0);
- visit_row.segment_id = 0;
- visit_row.is_indexed = false;
- visit_db->AddVisit(&visit_row, SOURCE_BROWSED);
-
- times->push_back(visit_row.visit_time);
- manager.AddPageData(GURL(kURL1), visit_row.url_id, visit_row.visit_id,
- visit_row.visit_time, UTF8ToUTF16(kTitle1),
- UTF8ToUTF16(kBody1));
-
- exploded.day_of_month++;
- visit_row.url_id = 2;
- visit_row.visit_time = Time::FromUTCExploded(exploded);
- visit_db->AddVisit(&visit_row, SOURCE_BROWSED);
- times->push_back(visit_row.visit_time);
- manager.AddPageData(GURL(kURL2), visit_row.url_id, visit_row.visit_id,
- visit_row.visit_time, UTF8ToUTF16(kTitle2),
- UTF8ToUTF16(kBody2));
-
- exploded.day_of_month++;
- visit_row.url_id = 2;
- visit_row.visit_time = Time::FromUTCExploded(exploded);
- visit_db->AddVisit(&visit_row, SOURCE_BROWSED);
- times->push_back(visit_row.visit_time);
- manager.AddPageData(GURL(kURL3), visit_row.url_id, visit_row.visit_id,
- visit_row.visit_time, UTF8ToUTF16(kTitle3),
- UTF8ToUTF16(kBody3));
-
- // Put the next ones in the next month.
- exploded.month++;
- visit_row.url_id = 2;
- visit_row.visit_time = Time::FromUTCExploded(exploded);
- visit_db->AddVisit(&visit_row, SOURCE_BROWSED);
- times->push_back(visit_row.visit_time);
- manager.AddPageData(GURL(kURL4), visit_row.url_id, visit_row.visit_id,
- visit_row.visit_time, UTF8ToUTF16(kTitle4),
- UTF8ToUTF16(kBody4));
-
- exploded.day_of_month++;
- visit_row.url_id = 2;
- visit_row.visit_time = Time::FromUTCExploded(exploded);
- visit_db->AddVisit(&visit_row, SOURCE_BROWSED);
- times->push_back(visit_row.visit_time);
- manager.AddPageData(GURL(kURL5), visit_row.url_id, visit_row.visit_id,
- visit_row.visit_time, UTF8ToUTF16(kTitle5),
- UTF8ToUTF16(kBody5));
-
- // Put the first one in again in the second month.
- exploded.day_of_month++;
- visit_row.url_id = 2;
- visit_row.visit_time = Time::FromUTCExploded(exploded);
- visit_db->AddVisit(&visit_row, SOURCE_BROWSED);
- times->push_back(visit_row.visit_time);
- manager.AddPageData(GURL(kURL1), visit_row.url_id, visit_row.visit_id,
- visit_row.visit_time, UTF8ToUTF16(kTitle1),
- UTF8ToUTF16(kBody1));
-}
-
-bool ResultsHaveURL(const std::vector<TextDatabase::Match>& results,
- const char* url) {
- GURL gurl(url);
- for (size_t i = 0; i < results.size(); i++) {
- if (results[i].url == gurl)
- return true;
- }
- return false;
-}
-
-} // namespace
-
-class TextDatabaseManagerTest : public testing::Test {
- public:
- // Called manually by the test so it can report failure to initialize.
- bool Init() {
- return file_util::CreateNewTempDirectory(
- FILE_PATH_LITERAL("TestSearchTest"), &dir_);
- }
-
- protected:
- virtual void SetUp() {
- }
-
- virtual void TearDown() {
- base::DeleteFile(dir_, true);
- }
-
- base::MessageLoop message_loop_;
-
- // Directory containing the databases.
- base::FilePath dir_;
-};
-
-// Tests basic querying.
-TEST_F(TextDatabaseManagerTest, InsertQuery) {
- ASSERT_TRUE(Init());
- InMemDB visit_db;
- TextDatabaseManager manager(dir_, &visit_db, &visit_db);
- ASSERT_TRUE(manager.Init(NULL));
-
- std::vector<Time> times;
- AddAllPages(manager, &visit_db, ×);
-
- QueryOptions options;
- options.begin_time = times[0] - TimeDelta::FromDays(100);
- options.end_time = times[times.size() - 1] + TimeDelta::FromDays(100);
- std::vector<TextDatabase::Match> results;
- Time first_time_searched;
- manager.GetTextMatches(UTF8ToUTF16("FOO"), options,
- &results, &first_time_searched);
-
- // We should have matched every page.
- EXPECT_EQ(6U, results.size());
- EXPECT_TRUE(ResultsHaveURL(results, kURL1));
- EXPECT_TRUE(ResultsHaveURL(results, kURL2));
- EXPECT_TRUE(ResultsHaveURL(results, kURL3));
- EXPECT_TRUE(ResultsHaveURL(results, kURL4));
- EXPECT_TRUE(ResultsHaveURL(results, kURL5));
-
- // The first time searched should have been the first page's time or before
- // (it could have eliminated some time for us).
- EXPECT_TRUE(first_time_searched <= times[0]);
-}
-
-// Tests that adding page components piecemeal will get them added properly.
-// This does not supply a visit to update, this mode is used only by the unit
-// tests right now, but we test it anyway.
-TEST_F(TextDatabaseManagerTest, InsertCompleteNoVisit) {
- ASSERT_TRUE(Init());
- InMemDB visit_db;
- TextDatabaseManager manager(dir_, &visit_db, &visit_db);
- ASSERT_TRUE(manager.Init(NULL));
-
- // First add one without a visit.
- const GURL url(kURL1);
- manager.AddPageURL(url, 0, 0, Time::Now());
- manager.AddPageTitle(url, UTF8ToUTF16(kTitle1));
- manager.AddPageContents(url, UTF8ToUTF16(kBody1));
-
- // Check that the page got added.
- QueryOptions options;
- std::vector<TextDatabase::Match> results;
- Time first_time_searched;
-
- manager.GetTextMatches(UTF8ToUTF16("FOO"), options,
- &results, &first_time_searched);
- ASSERT_EQ(1U, results.size());
- EXPECT_EQ(kTitle1, UTF16ToUTF8(results[0].title));
-}
-
-// Like InsertCompleteNoVisit but specifies a visit to update. We check that the
-// visit was updated properly.
-TEST_F(TextDatabaseManagerTest, InsertCompleteVisit) {
- ASSERT_TRUE(Init());
- InMemDB visit_db;
- TextDatabaseManager manager(dir_, &visit_db, &visit_db);
- ASSERT_TRUE(manager.Init(NULL));
-
- // First add a visit to a page. We can just make up a URL ID since there is
- // not actually any URL database around.
- VisitRow visit;
- visit.url_id = 1;
- visit.visit_time = Time::Now();
- visit.referring_visit = 0;
- visit.transition = content::PAGE_TRANSITION_LINK;
- visit.segment_id = 0;
- visit.is_indexed = false;
- visit_db.AddVisit(&visit, SOURCE_BROWSED);
-
- // Add a full text indexed entry for that visit.
- const GURL url(kURL2);
- manager.AddPageURL(url, visit.url_id, visit.visit_id, visit.visit_time);
- manager.AddPageContents(url, UTF8ToUTF16(kBody2));
- manager.AddPageTitle(url, UTF8ToUTF16(kTitle2));
-
- // Check that the page got added.
- QueryOptions options;
- std::vector<TextDatabase::Match> results;
- Time first_time_searched;
-
- manager.GetTextMatches(UTF8ToUTF16("FOO"), options,
- &results, &first_time_searched);
- ASSERT_EQ(1U, results.size());
- EXPECT_EQ(kTitle2, UTF16ToUTF8(results[0].title));
-
- // Check that the visit got updated for its new indexed state.
- VisitRow out_visit;
- ASSERT_TRUE(visit_db.GetRowForVisit(visit.visit_id, &out_visit));
- EXPECT_TRUE(out_visit.is_indexed);
-}
-
-// Tests that partial inserts that expire are added to the database.
-TEST_F(TextDatabaseManagerTest, InsertPartial) {
- ASSERT_TRUE(Init());
- InMemDB visit_db;
- TextDatabaseManager manager(dir_, &visit_db, &visit_db);
- ASSERT_TRUE(manager.Init(NULL));
-
- // Add the first one with just a URL.
- GURL url1(kURL1);
- manager.AddPageURL(url1, 0, 0, Time::Now());
-
- // Now add a second one with a URL and title.
- GURL url2(kURL2);
- manager.AddPageURL(url2, 0, 0, Time::Now());
- manager.AddPageTitle(url2, UTF8ToUTF16(kTitle2));
-
- // The third one has a URL and body.
- GURL url3(kURL3);
- manager.AddPageURL(url3, 0, 0, Time::Now());
- manager.AddPageContents(url3, UTF8ToUTF16(kBody3));
-
- // Expire stuff very fast. This assumes that the time between the first
- // AddPageURL and this line is less than the expiration time (20 seconds).
- TimeTicks added_time = TimeTicks::Now();
- TimeTicks expire_time = added_time + TimeDelta::FromSeconds(5);
- manager.FlushOldChangesForTime(expire_time);
-
- // Do a query, nothing should be added yet.
- QueryOptions options;
- std::vector<TextDatabase::Match> results;
- Time first_time_searched;
- manager.GetTextMatches(UTF8ToUTF16("google"), options,
- &results, &first_time_searched);
- ASSERT_EQ(0U, results.size());
-
- // Compute a time threshold that will cause everything to be flushed, and
- // poke at the manager's internals to cause this to happen.
- expire_time = added_time + TimeDelta::FromDays(1);
- manager.FlushOldChangesForTime(expire_time);
-
- // Now we should have all 3 URLs added.
- manager.GetTextMatches(UTF8ToUTF16("google"), options,
- &results, &first_time_searched);
- ASSERT_EQ(3U, results.size());
- EXPECT_TRUE(ResultsHaveURL(results, kURL1));
- EXPECT_TRUE(ResultsHaveURL(results, kURL2));
- EXPECT_TRUE(ResultsHaveURL(results, kURL3));
-}
-
-// Tests that partial inserts (due to timeouts) will still get updated if the
-// data comes in later.
-TEST_F(TextDatabaseManagerTest, PartialComplete) {
- ASSERT_TRUE(Init());
- InMemDB visit_db;
- TextDatabaseManager manager(dir_, &visit_db, &visit_db);
- ASSERT_TRUE(manager.Init(NULL));
-
- Time added_time = Time::Now();
- GURL url(kURL1);
-
- // We have to have the URL in the URL and visit databases for this test to
- // work.
- URLRow url_row(url);
- url_row.set_title(UTF8ToUTF16("chocolate"));
- URLID url_id = visit_db.AddURL(url_row);
- ASSERT_TRUE(url_id);
- VisitRow visit_row;
- visit_row.url_id = url_id;
- visit_row.visit_time = added_time;
- visit_db.AddVisit(&visit_row, SOURCE_BROWSED);
-
- // Add a URL with no title or body, and say that it expired.
- manager.AddPageURL(url, 0, 0, added_time);
- TimeTicks expire_time = TimeTicks::Now() + TimeDelta::FromDays(1);
- manager.FlushOldChangesForTime(expire_time);
-
- // Add the title. We should be able to query based on that. The title in the
- // URL row we set above should not come into the picture.
- manager.AddPageTitle(url, UTF8ToUTF16("Some unique title"));
- Time first_time_searched;
- QueryOptions options;
- std::vector<TextDatabase::Match> results;
- manager.GetTextMatches(UTF8ToUTF16("unique"), options,
- &results, &first_time_searched);
- EXPECT_EQ(1U, results.size());
- manager.GetTextMatches(UTF8ToUTF16("chocolate"), options,
- &results, &first_time_searched);
- EXPECT_EQ(0U, results.size());
-
- // Now add the body, which should be queryable.
- manager.AddPageContents(url, UTF8ToUTF16("Very awesome body"));
- manager.GetTextMatches(UTF8ToUTF16("awesome"), options, &results, &first_time_searched);
- EXPECT_EQ(1U, results.size());
-
- // Adding the body will actually copy the title from the URL table rather
- // than the previously indexed row (we made them not match above). This isn't
- // necessarily what we want, but it's how it's implemented, and we don't want
- // to regress it.
- manager.GetTextMatches(UTF8ToUTF16("chocolate"), options, &results, &first_time_searched);
- EXPECT_EQ(1U, results.size());
-}
-
-// Tests that changes get properly committed to disk.
-TEST_F(TextDatabaseManagerTest, Writing) {
- ASSERT_TRUE(Init());
-
- QueryOptions options;
- std::vector<TextDatabase::Match> results;
- Time first_time_searched;
-
- InMemDB visit_db;
-
- // Create the manager and write some stuff to it.
- {
- TextDatabaseManager manager(dir_, &visit_db, &visit_db);
- ASSERT_TRUE(manager.Init(NULL));
-
- std::vector<Time> times;
- AddAllPages(manager, &visit_db, ×);
-
- // We should have matched every page.
- manager.GetTextMatches(UTF8ToUTF16("FOO"), options, &results, &first_time_searched);
- EXPECT_EQ(6U, results.size());
- }
- results.clear();
-
- // Recreate the manager and make sure it finds the written stuff.
- {
- TextDatabaseManager manager(dir_, &visit_db, &visit_db);
- ASSERT_TRUE(manager.Init(NULL));
-
- // We should have matched every page again.
- manager.GetTextMatches(UTF8ToUTF16("FOO"), options,
- &results, &first_time_searched);
- EXPECT_EQ(6U, results.size());
- }
-}
-
-// Tests that changes get properly committed to disk, as in the Writing test
-// above, but when there is a transaction around the adds.
-TEST_F(TextDatabaseManagerTest, WritingTransaction) {
- ASSERT_TRUE(Init());
-
- QueryOptions options;
- std::vector<TextDatabase::Match> results;
- Time first_time_searched;
-
- InMemDB visit_db;
-
- // Create the manager and write some stuff to it.
- {
- TextDatabaseManager manager(dir_, &visit_db, &visit_db);
- ASSERT_TRUE(manager.Init(NULL));
-
- std::vector<Time> times;
- manager.BeginTransaction();
- AddAllPages(manager, &visit_db, ×);
- // "Forget" to commit, it should be autocommittedd for us.
-
- // We should have matched every page.
- manager.GetTextMatches(UTF8ToUTF16("FOO"), options,
- &results, &first_time_searched);
- EXPECT_EQ(6U, results.size());
- }
- results.clear();
-
- // Recreate the manager and make sure it finds the written stuff.
- {
- TextDatabaseManager manager(dir_, &visit_db, &visit_db);
- ASSERT_TRUE(manager.Init(NULL));
-
- // We should have matched every page again.
- manager.GetTextMatches(UTF8ToUTF16("FOO"), options,
- &results, &first_time_searched);
- EXPECT_EQ(6U, results.size());
- }
-}
-
-// Tests querying where the maximum number of items is met.
-TEST_F(TextDatabaseManagerTest, QueryMax) {
- ASSERT_TRUE(Init());
- InMemDB visit_db;
- TextDatabaseManager manager(dir_, &visit_db, &visit_db);
- ASSERT_TRUE(manager.Init(NULL));
-
- std::vector<Time> times;
- AddAllPages(manager, &visit_db, ×);
-
- string16 foo = UTF8ToUTF16("FOO");
-
- QueryOptions options;
- options.begin_time = times[0] - TimeDelta::FromDays(100);
- options.end_time = times[times.size() - 1] + TimeDelta::FromDays(100);
- options.max_count = 2;
- std::vector<TextDatabase::Match> results;
- Time first_time_searched;
- manager.GetTextMatches(foo, options, &results, &first_time_searched);
-
- // We should have gotten the last two pages as results (the first page is
- // also the last).
- EXPECT_EQ(2U, results.size());
- EXPECT_TRUE(first_time_searched <= times[4]);
- EXPECT_TRUE(ResultsHaveURL(results, kURL5));
- EXPECT_TRUE(ResultsHaveURL(results, kURL1));
-
- // Asking for 4 pages, the first one should be in another DB.
- options.max_count = 4;
- manager.GetTextMatches(foo, options, &results, &first_time_searched);
-
- EXPECT_EQ(4U, results.size());
- EXPECT_TRUE(first_time_searched <= times[4]);
- EXPECT_TRUE(ResultsHaveURL(results, kURL3));
- EXPECT_TRUE(ResultsHaveURL(results, kURL4));
- EXPECT_TRUE(ResultsHaveURL(results, kURL5));
- EXPECT_TRUE(ResultsHaveURL(results, kURL1));
-}
-
-// Tests querying backwards in time in chunks.
-TEST_F(TextDatabaseManagerTest, QueryBackwards) {
- ASSERT_TRUE(Init());
- InMemDB visit_db;
- TextDatabaseManager manager(dir_, &visit_db, &visit_db);
- ASSERT_TRUE(manager.Init(NULL));
-
- std::vector<Time> times;
- AddAllPages(manager, &visit_db, ×);
-
- string16 foo = UTF8ToUTF16("FOO");
-
- // First do a query for all time, but with a max of 2. This will give us the
- // last two results and will tell us where to start searching when we want
- // to go back in time.
- QueryOptions options;
- options.begin_time = times[0] - TimeDelta::FromDays(100);
- options.end_time = times[times.size() - 1] + TimeDelta::FromDays(100);
- options.max_count = 2;
- std::vector<TextDatabase::Match> results;
- Time first_time_searched;
- manager.GetTextMatches(foo, options, &results, &first_time_searched);
-
- // Check that we got the last two results.
- EXPECT_EQ(2U, results.size());
- EXPECT_TRUE(first_time_searched <= times[4]);
- EXPECT_TRUE(ResultsHaveURL(results, kURL5));
- EXPECT_TRUE(ResultsHaveURL(results, kURL1));
-
- // Query the previous two URLs and make sure we got the correct ones.
- options.end_time = first_time_searched;
- manager.GetTextMatches(foo, options, &results, &first_time_searched);
- EXPECT_EQ(2U, results.size());
- EXPECT_TRUE(first_time_searched <= times[2]);
- EXPECT_TRUE(ResultsHaveURL(results, kURL3));
- EXPECT_TRUE(ResultsHaveURL(results, kURL4));
-
- // Query the previous two URLs...
- options.end_time = first_time_searched;
- manager.GetTextMatches(foo, options, &results, &first_time_searched);
- EXPECT_EQ(2U, results.size());
- EXPECT_TRUE(first_time_searched <= times[0]);
- EXPECT_TRUE(ResultsHaveURL(results, kURL2));
- EXPECT_TRUE(ResultsHaveURL(results, kURL1));
-
- // Try to query some more, there should be no results.
- options.end_time = first_time_searched;
- manager.GetTextMatches(foo, options, &results, &first_time_searched);
- EXPECT_EQ(0U, results.size());
-}
-
-// Tests deletion of uncommitted entries.
-TEST_F(TextDatabaseManagerTest, DeleteUncommitted) {
- ASSERT_TRUE(Init());
- InMemDB visit_db;
- TextDatabaseManager manager(dir_, &visit_db, &visit_db);
- ASSERT_TRUE(manager.Init(NULL));
-
- manager.AddPageURL(GURL(kURL1), 0, 0, Time::FromInternalValue(1));
- manager.AddPageURL(GURL(kURL2), 0, 0, Time::FromInternalValue(2));
- manager.AddPageURL(GURL(kURL3), 0, 0, Time::FromInternalValue(3));
- manager.AddPageURL(GURL(kURL4), 0, 0, Time::FromInternalValue(4));
- manager.AddPageURL(GURL(kURL5), 0, 0, Time::FromInternalValue(5));
-
- EXPECT_EQ(5u, manager.GetUncommittedEntryCountForTest());
-
- // Should delete the first two entries.
- manager.DeleteFromUncommitted(std::set<GURL>(),
- Time::FromInternalValue(1),
- Time::FromInternalValue(3));
-
- EXPECT_EQ(3u, manager.GetUncommittedEntryCountForTest());
-
- // Should delete the third entry.
- {
- std::set<GURL> urls;
- urls.insert(GURL(kURL3));
- manager.DeleteFromUncommitted(urls, Time(), Time());
- }
-
- EXPECT_EQ(2u, manager.GetUncommittedEntryCountForTest());
-}
-
-// Tests deletion of uncommitted entries by time.
-TEST_F(TextDatabaseManagerTest, DeleteUncommittedForTimes) {
- ASSERT_TRUE(Init());
- InMemDB visit_db;
- TextDatabaseManager manager(dir_, &visit_db, &visit_db);
- ASSERT_TRUE(manager.Init(NULL));
-
- manager.AddPageURL(GURL(kURL1), 0, 0, Time::FromInternalValue(2));
- manager.AddPageURL(GURL(kURL2), 0, 0, Time::FromInternalValue(3));
- manager.AddPageURL(GURL(kURL3), 0, 0, Time::FromInternalValue(4));
- manager.AddPageURL(GURL(kURL4), 0, 0, Time::FromInternalValue(5));
- manager.AddPageURL(GURL(kURL5), 0, 0, Time::FromInternalValue(6));
-
- EXPECT_EQ(5u, manager.GetUncommittedEntryCountForTest());
-
- std::vector<base::Time> times;
- times.push_back(Time::FromInternalValue(9));
- times.push_back(Time::FromInternalValue(7));
- times.push_back(Time::FromInternalValue(5));
- times.push_back(Time::FromInternalValue(5));
- times.push_back(Time::FromInternalValue(3));
- times.push_back(Time::FromInternalValue(1));
- manager.DeleteFromUncommittedForTimes(times);
-
- EXPECT_EQ(3u, manager.GetUncommittedEntryCountForTest());
-}
-
-} // namespace history
diff --git a/chrome/browser/history/top_sites_impl_unittest.cc b/chrome/browser/history/top_sites_impl_unittest.cc
index 251accb..a0b9f22 100644
--- a/chrome/browser/history/top_sites_impl_unittest.cc
+++ b/chrome/browser/history/top_sites_impl_unittest.cc
@@ -149,7 +149,7 @@
virtual void SetUp() {
profile_.reset(new TestingProfile);
if (CreateHistoryAndTopSites()) {
- profile_->CreateHistoryService(false, false);
+ ASSERT_TRUE(profile_->CreateHistoryService(false, false));
profile_->CreateTopSites();
profile_->BlockUntilTopSitesLoaded();
}
@@ -360,7 +360,7 @@
data_path.AppendASCII("thumbnails.3.sql"),
profile()->GetPath().Append(chrome::kThumbnailsFilename)));
- profile()->CreateHistoryService(false, false);
+ ASSERT_TRUE(profile()->CreateHistoryService(false, false));
profile()->CreateTopSites();
profile()->BlockUntilTopSitesLoaded();
}
@@ -914,7 +914,7 @@
profile()->GetPath().Append(chrome::kThumbnailsFilename)));
// Recreate top sites and make sure everything is still there.
- profile()->CreateHistoryService(false, false);
+ ASSERT_TRUE(profile()->CreateHistoryService(false, false));
RecreateTopSitesAndBlock();
ASSERT_NO_FATAL_FAILURE(MigrationAssertions());
@@ -1207,7 +1207,7 @@
EXPECT_FALSE(IsTopSitesLoaded());
// Load history, which should make TopSites finish loading too.
- profile()->CreateHistoryService(false, false);
+ ASSERT_TRUE(profile()->CreateHistoryService(false, false));
profile()->BlockUntilTopSitesLoaded();
EXPECT_TRUE(IsTopSitesLoaded());
}
@@ -1227,7 +1227,7 @@
// Makes sure if history is unloaded after topsites is loaded we don't hit any
// assertions.
TEST_F(TopSitesUnloadTest, UnloadHistoryTest) {
- profile()->CreateHistoryService(false, false);
+ ASSERT_TRUE(profile()->CreateHistoryService(false, false));
profile()->CreateTopSites();
profile()->BlockUntilTopSitesLoaded();
HistoryServiceFactory::GetForProfile(
@@ -1250,7 +1250,7 @@
profile()->GetPath().Append(chrome::kThumbnailsFilename)));
// Create history and block until it's loaded.
- profile()->CreateHistoryService(false, false);
+ ASSERT_TRUE(profile()->CreateHistoryService(false, false));
profile()->BlockUntilHistoryProcessesPendingRequests();
// Create top sites and unload history.
diff --git a/chrome/browser/history/top_sites_likely_impl_unittest.cc b/chrome/browser/history/top_sites_likely_impl_unittest.cc
index 8ef73a2..01a9504 100644
--- a/chrome/browser/history/top_sites_likely_impl_unittest.cc
+++ b/chrome/browser/history/top_sites_likely_impl_unittest.cc
@@ -149,7 +149,7 @@
virtual void SetUp() {
profile_.reset(new TestingProfile);
if (CreateHistoryAndTopSites()) {
- profile_->CreateHistoryService(false, false);
+ ASSERT_TRUE(profile_->CreateHistoryService(false, false));
profile_->CreateTopSites();
profile_->BlockUntilTopSitesLoaded();
}
@@ -361,7 +361,7 @@
data_path.AppendASCII("thumbnails.3.sql"),
profile()->GetPath().Append(chrome::kThumbnailsFilename)));
- profile()->CreateHistoryService(false, false);
+ ASSERT_TRUE(profile()->CreateHistoryService(false, false));
profile()->CreateTopSites();
profile()->BlockUntilTopSitesLoaded();
}
@@ -915,7 +915,7 @@
profile()->GetPath().Append(chrome::kThumbnailsFilename)));
// Recreate top sites and make sure everything is still there.
- profile()->CreateHistoryService(false, false);
+ ASSERT_TRUE(profile()->CreateHistoryService(false, false));
RecreateTopSitesAndBlock();
ASSERT_NO_FATAL_FAILURE(MigrationAssertions());
@@ -1208,7 +1208,7 @@
EXPECT_FALSE(IsTopSitesLoaded());
// Load history, which should make TopSites finish loading too.
- profile()->CreateHistoryService(false, false);
+ ASSERT_TRUE(profile()->CreateHistoryService(false, false));
profile()->BlockUntilTopSitesLoaded();
EXPECT_TRUE(IsTopSitesLoaded());
}
@@ -1228,7 +1228,7 @@
// Makes sure if history is unloaded after topsites is loaded we don't hit any
// assertions.
TEST_F(TopSitesLikelyUnloadTest, UnloadHistoryTest) {
- profile()->CreateHistoryService(false, false);
+ ASSERT_TRUE(profile()->CreateHistoryService(false, false));
profile()->CreateTopSites();
profile()->BlockUntilTopSitesLoaded();
HistoryServiceFactory::GetForProfile(
@@ -1251,7 +1251,7 @@
profile()->GetPath().Append(chrome::kThumbnailsFilename)));
// Create history and block until it's loaded.
- profile()->CreateHistoryService(false, false);
+ ASSERT_TRUE(profile()->CreateHistoryService(false, false));
profile()->BlockUntilHistoryProcessesPendingRequests();
// Create top sites and unload history.
diff --git a/chrome/browser/history/visit_database.cc b/chrome/browser/history/visit_database.cc
index 883fe6f..5e04c02 100644
--- a/chrome/browser/history/visit_database.cc
+++ b/chrome/browser/history/visit_database.cc
@@ -34,19 +34,10 @@
"from_visit INTEGER,"
"transition INTEGER DEFAULT 0 NOT NULL,"
"segment_id INTEGER,"
- // True when we have indexed data for this visit.
- "is_indexed BOOLEAN,"
+ // Some old DBs may have an "is_indexed" field here, but this is no
+ // longer used and should NOT be read or written from any longer.
"visit_duration INTEGER DEFAULT 0 NOT NULL)"))
return false;
- } else if (!GetDB().DoesColumnExist("visits", "is_indexed")) {
- // Old versions don't have the is_indexed column, we can just add that and
- // not worry about different database revisions, since old ones will
- // continue to work.
- //
- // TODO(brettw) this should be removed once we think everybody has been
- // updated (added early Mar 2008).
- if (!GetDB().Execute("ALTER TABLE visits ADD COLUMN is_indexed BOOLEAN"))
- return false;
}
// Visit source table contains the source information for all the visits. To
@@ -98,9 +89,8 @@
visit->referring_visit = statement.ColumnInt64(3);
visit->transition = content::PageTransitionFromInt(statement.ColumnInt(4));
visit->segment_id = statement.ColumnInt64(5);
- visit->is_indexed = !!statement.ColumnInt(6);
visit->visit_duration =
- base::TimeDelta::FromInternalValue(statement.ColumnInt64(7));
+ base::TimeDelta::FromInternalValue(statement.ColumnInt64(6));
}
// static
@@ -154,15 +144,14 @@
VisitID VisitDatabase::AddVisit(VisitRow* visit, VisitSource source) {
sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE,
"INSERT INTO visits "
- "(url, visit_time, from_visit, transition, segment_id, is_indexed, "
- "visit_duration) VALUES (?,?,?,?,?,?,?)"));
+ "(url, visit_time, from_visit, transition, segment_id, "
+ "visit_duration) VALUES (?,?,?,?,?,?)"));
statement.BindInt64(0, visit->url_id);
statement.BindInt64(1, visit->visit_time.ToInternalValue());
statement.BindInt64(2, visit->referring_visit);
statement.BindInt64(3, visit->transition);
statement.BindInt64(4, visit->segment_id);
- statement.BindInt64(5, visit->is_indexed);
- statement.BindInt64(6, visit->visit_duration.ToInternalValue());
+ statement.BindInt64(5, visit->visit_duration.ToInternalValue());
if (!statement.Run()) {
VLOG(0) << "Failed to execute visit insert statement: "
@@ -241,16 +230,15 @@
sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE,
"UPDATE visits SET "
- "url=?,visit_time=?,from_visit=?,transition=?,segment_id=?,is_indexed=?,"
+ "url=?,visit_time=?,from_visit=?,transition=?,segment_id=?,"
"visit_duration=? WHERE id=?"));
statement.BindInt64(0, visit.url_id);
statement.BindInt64(1, visit.visit_time.ToInternalValue());
statement.BindInt64(2, visit.referring_visit);
statement.BindInt64(3, visit.transition);
statement.BindInt64(4, visit.segment_id);
- statement.BindInt64(5, visit.is_indexed);
- statement.BindInt64(6, visit.visit_duration.ToInternalValue());
- statement.BindInt64(7, visit.visit_id);
+ statement.BindInt64(5, visit.visit_duration.ToInternalValue());
+ statement.BindInt64(6, visit.visit_id);
return statement.Run();
}
@@ -267,17 +255,6 @@
return FillVisitVector(statement, visits);
}
-bool VisitDatabase::GetIndexedVisitsForURL(URLID url_id, VisitVector* visits) {
- visits->clear();
-
- sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE,
- "SELECT" HISTORY_VISIT_ROW_FIELDS
- "FROM visits "
- "WHERE url=? AND is_indexed=1"));
- statement.BindInt64(0, url_id);
- return FillVisitVector(statement, visits);
-}
-
bool VisitDatabase::GetVisitsForURLWithOptions(URLID url_id,
const QueryOptions& options,
VisitVector* visits) {
diff --git a/chrome/browser/history/visit_database.h b/chrome/browser/history/visit_database.h
index effaa8f..f196c88 100644
--- a/chrome/browser/history/visit_database.h
+++ b/chrome/browser/history/visit_database.h
@@ -58,11 +58,6 @@
// may still be no matches).
bool GetVisitsForURL(URLID url_id, VisitVector* visits);
- // Fills in the given vector with all of the visits for the given page ID that
- // have the |is_indexed| field set to true, in no particular order.
- // Returns true on success (although there may still be no matches).
- bool GetIndexedVisitsForURL(URLID url_id, VisitVector* visits);
-
// Fills in the given vector with the visits for the given page ID which
// match the set of options passed, sorted in ascending order of date.
//
@@ -230,8 +225,7 @@
// Rows, in order, of the visit table.
#define HISTORY_VISIT_ROW_FIELDS \
- " id,url,visit_time,from_visit,transition,segment_id,is_indexed," \
- "visit_duration "
+ " id,url,visit_time,from_visit,transition,segment_id,visit_duration "
} // namespace history
diff --git a/chrome/browser/history/visit_database_unittest.cc b/chrome/browser/history/visit_database_unittest.cc
index a6146b4..df8075e 100644
--- a/chrome/browser/history/visit_database_unittest.cc
+++ b/chrome/browser/history/visit_database_unittest.cc
@@ -29,8 +29,7 @@
a.url_id == b.url_id &&
a.visit_time == b.visit_time &&
a.referring_visit == b.referring_visit &&
- a.transition == b.transition &&
- a.is_indexed == b.is_indexed;
+ a.transition == b.transition;
}
} // namespace
@@ -148,7 +147,6 @@
modification.transition = content::PAGE_TRANSITION_TYPED;
modification.visit_time = Time::Now() + TimeDelta::FromDays(1);
modification.referring_visit = 9292;
- modification.is_indexed = true;
UpdateVisitRow(modification);
// Check that the mutated version was written.
@@ -387,31 +385,4 @@
EXPECT_EQ(SOURCE_EXTENSION, sources[matches[0].visit_id]);
}
-TEST_F(VisitDatabaseTest, GetIndexedVisits) {
- // Add non-indexed visits.
- int url_id = 111;
- VisitRow visit_info1(
- url_id, Time::Now(), 0, content::PAGE_TRANSITION_LINK, 0);
- ASSERT_TRUE(AddVisit(&visit_info1, SOURCE_BROWSED));
-
- VisitRow visit_info2(
- url_id, Time::Now(), 0, content::PAGE_TRANSITION_TYPED, 0);
- ASSERT_TRUE(AddVisit(&visit_info2, SOURCE_SYNCED));
-
- std::vector<VisitRow> visits;
- EXPECT_TRUE(GetVisitsForURL(url_id, &visits));
- EXPECT_EQ(static_cast<size_t>(2), visits.size());
- EXPECT_TRUE(GetIndexedVisitsForURL(url_id, &visits));
- EXPECT_EQ(static_cast<size_t>(0), visits.size());
-
- VisitRow visit_info3(
- url_id, Time::Now(), 2, content::PAGE_TRANSITION_TYPED, 0);
- visit_info3.is_indexed = true;
- ASSERT_TRUE(AddVisit(&visit_info3, SOURCE_SYNCED));
- EXPECT_TRUE(GetVisitsForURL(url_id, &visits));
- EXPECT_EQ(static_cast<size_t>(3), visits.size());
- EXPECT_TRUE(GetIndexedVisitsForURL(url_id, &visits));
- EXPECT_EQ(static_cast<size_t>(1), visits.size());
-}
-
} // namespace history
diff --git a/chrome/browser/importer/firefox_profile_lock_unittest.cc b/chrome/browser/importer/firefox_profile_lock_unittest.cc
index 95a4b4b..c93d987 100644
--- a/chrome/browser/importer/firefox_profile_lock_unittest.cc
+++ b/chrome/browser/importer/firefox_profile_lock_unittest.cc
@@ -5,7 +5,6 @@
#include "base/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/path_service.h"
-#include "base/process_util.h"
#include "base/strings/string_util.h"
#include "build/build_config.h"
#include "chrome/browser/importer/firefox_profile_lock.h"
diff --git a/chrome/browser/importer/profile_writer_unittest.cc b/chrome/browser/importer/profile_writer_unittest.cc
index 2f6334b..4641e83 100644
--- a/chrome/browser/importer/profile_writer_unittest.cc
+++ b/chrome/browser/importer/profile_writer_unittest.cc
@@ -194,7 +194,7 @@
// Verify that history entires are not duplicated when added twice.
TEST_F(ProfileWriterTest, CheckHistoryAfterWritingDataTwice) {
TestingProfile profile;
- profile.CreateHistoryService(true, false);
+ ASSERT_TRUE(profile.CreateHistoryService(true, false));
profile.BlockUntilHistoryProcessesPendingRequests();
CreateHistoryPageEntries();
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc
index 44cd6cd..46586a1 100644
--- a/chrome/browser/io_thread.cc
+++ b/chrome/browser/io_thread.cc
@@ -96,6 +96,7 @@
const char kQuicFieldTrialName[] = "QUIC";
const char kQuicFieldTrialEnabledGroupName[] = "Enabled";
+const char kQuicFieldTrialHttpsEnabledGroupName[] = "HttpsEnabled";
#if defined(OS_MACOSX) && !defined(OS_IOS)
void ObserveKeychainEvents() {
@@ -550,8 +551,8 @@
}
bool enable_quic = ShouldEnableQuic(command_line);
globals_->enable_quic.set(enable_quic);
- if (enable_quic && command_line.HasSwitch(switches::kEnableQuicHttps))
- globals_->enable_quic_https.set(true);
+ if (enable_quic)
+ globals_->enable_quic_https.set(ShouldEnableQuicHttps(command_line));
if (command_line.HasSwitch(switches::kOriginToForceQuicOn)) {
net::HostPortPair quic_origin =
net::HostPortPair::FromString(
@@ -974,9 +975,28 @@
if (command_line.HasSwitch(switches::kDisableQuic))
return false;
- if (command_line.HasSwitch(switches::kEnableQuic)) {
+ if (command_line.HasSwitch(switches::kEnableQuic))
return true;
- }
- return quic_trial_group == kQuicFieldTrialEnabledGroupName;
+ // QUIC should be enabled if we are in either field trial group.
+ return quic_trial_group == kQuicFieldTrialEnabledGroupName ||
+ quic_trial_group == kQuicFieldTrialHttpsEnabledGroupName;
+}
+
+bool IOThread::ShouldEnableQuicHttps(const CommandLine& command_line) {
+ // Always fetch the field trial group to ensure it is reported correctly.
+ // The command line flags will be associated with a group that is reported
+ // so long as trial is actually queried.
+ std::string quic_trial_group =
+ base::FieldTrialList::FindFullName(kQuicFieldTrialName);
+
+ if (command_line.HasSwitch(switches::kDisableQuicHttps))
+ return false;
+
+ if (command_line.HasSwitch(switches::kEnableQuicHttps))
+ return true;
+
+ // HTTPS over QUIC should only be enabled if we are in the https
+ // field trial group.
+ return quic_trial_group == kQuicFieldTrialHttpsEnabledGroupName;
}
diff --git a/chrome/browser/io_thread.h b/chrome/browser/io_thread.h
index 4408a50..9901afd 100644
--- a/chrome/browser/io_thread.h
+++ b/chrome/browser/io_thread.h
@@ -262,6 +262,10 @@
// of a field trial or a command line flag.
bool ShouldEnableQuic(const CommandLine& command_line);
+ // Returns true if HTTPS over QUIC should be enabled, either as a result
+ // of a field trial or a command line flag.
+ bool ShouldEnableQuicHttps(const CommandLine& command_line);
+
// The NetLog is owned by the browser process, to allow logging from other
// threads during shutdown, but is used most frequently on the IOThread.
ChromeNetLog* net_log_;
diff --git a/chrome/browser/local_discovery/service_discovery_host_client.cc b/chrome/browser/local_discovery/service_discovery_host_client.cc
index 3a2c172..74aeb81 100644
--- a/chrome/browser/local_discovery/service_discovery_host_client.cc
+++ b/chrome/browser/local_discovery/service_discovery_host_client.cc
@@ -87,6 +87,41 @@
bool started_;
};
+class ServiceDiscoveryHostClient::LocalDomainResolverProxy
+ : public LocalDomainResolver {
+ public:
+ LocalDomainResolverProxy(ServiceDiscoveryHostClient* host,
+ const std::string& domain,
+ net::AddressFamily address_family,
+ const LocalDomainResolver::IPAddressCallback& callback)
+ : host_(host),
+ domain_(domain),
+ address_family_(address_family),
+ id_(host->RegisterLocalDomainResolverCallback(callback)),
+ started_(false) {
+ }
+
+ virtual ~LocalDomainResolverProxy() {
+ host_->UnregisterLocalDomainResolverCallback(id_);
+ if (started_)
+ host_->Send(new LocalDiscoveryMsg_DestroyLocalDomainResolver(id_));
+ }
+
+ virtual void Start() OVERRIDE {
+ DCHECK(!started_);
+ host_->Send(new LocalDiscoveryMsg_ResolveLocalDomain(id_, domain_,
+ address_family_));
+ started_ = true;
+ }
+
+ private:
+ scoped_refptr<ServiceDiscoveryHostClient> host_;
+ std::string domain_;
+ net::AddressFamily address_family_;
+ const uint64 id_;
+ bool started_;
+};
+
ServiceDiscoveryHostClient::ServiceDiscoveryHostClient() : current_id_(0) {
callback_runner_ = base::MessageLoop::current()->message_loop_proxy();
}
@@ -118,8 +153,9 @@
const std::string& domain,
net::AddressFamily address_family,
const LocalDomainResolver::IPAddressCallback& callback) {
- NOTIMPLEMENTED(); // TODO(noamsml): Multiprocess domain resolver
- return scoped_ptr<LocalDomainResolver>();
+ DCHECK(CalledOnValidThread());
+ return scoped_ptr<LocalDomainResolver>(new LocalDomainResolverProxy(
+ this, domain, address_family, callback));
}
uint64 ServiceDiscoveryHostClient::RegisterWatcherCallback(
@@ -138,6 +174,14 @@
return current_id_;
}
+uint64 ServiceDiscoveryHostClient::RegisterLocalDomainResolverCallback(
+ const LocalDomainResolver::IPAddressCallback& callback) {
+ DCHECK(CalledOnValidThread());
+ DCHECK(!ContainsKey(domain_resolver_callbacks_, current_id_ + 1));
+ domain_resolver_callbacks_[++current_id_] = callback;
+ return current_id_;
+}
+
void ServiceDiscoveryHostClient::UnregisterWatcherCallback(uint64 id) {
DCHECK(CalledOnValidThread());
DCHECK(ContainsKey(service_watcher_callbacks_, id));
@@ -150,6 +194,13 @@
service_resolver_callbacks_.erase(id);
}
+void ServiceDiscoveryHostClient::UnregisterLocalDomainResolverCallback(
+ uint64 id) {
+ DCHECK(CalledOnValidThread());
+ DCHECK(ContainsKey(domain_resolver_callbacks_, id));
+ domain_resolver_callbacks_.erase(id);
+}
+
void ServiceDiscoveryHostClient::Start() {
DCHECK(CalledOnValidThread());
BrowserThread::PostTask(
@@ -205,6 +256,8 @@
OnWatcherCallback)
IPC_MESSAGE_HANDLER(LocalDiscoveryHostMsg_ResolverCallback,
OnResolverCallback)
+ IPC_MESSAGE_HANDLER(LocalDiscoveryHostMsg_LocalDomainResolverCallback,
+ OnLocalDomainResolverCallback)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
@@ -232,6 +285,17 @@
status, description));
}
+void ServiceDiscoveryHostClient::OnLocalDomainResolverCallback(
+ uint64 id,
+ bool success,
+ const net::IPAddressNumber& ip_address) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ callback_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&ServiceDiscoveryHostClient::RunLocalDomainResolverCallback,
+ this, id, success, ip_address));
+}
+
void ServiceDiscoveryHostClient::RunWatcherCallback(
uint64 id,
ServiceWatcher::UpdateType update,
@@ -252,4 +316,14 @@
it->second.Run(status, description);
}
+void ServiceDiscoveryHostClient::RunLocalDomainResolverCallback(
+ uint64 id,
+ bool success,
+ const net::IPAddressNumber& ip_address) {
+ DCHECK(CalledOnValidThread());
+ DomainResolverCallbacks::iterator it = domain_resolver_callbacks_.find(id);
+ if (it != domain_resolver_callbacks_.end() && !it->second.is_null())
+ it->second.Run(success, ip_address);
+}
+
} // namespace local_discovery
diff --git a/chrome/browser/local_discovery/service_discovery_host_client.h b/chrome/browser/local_discovery/service_discovery_host_client.h
index 28cdcce..302b660 100644
--- a/chrome/browser/local_discovery/service_discovery_host_client.h
+++ b/chrome/browser/local_discovery/service_discovery_host_client.h
@@ -57,10 +57,13 @@
private:
class ServiceWatcherProxy;
class ServiceResolverProxy;
+ class LocalDomainResolverProxy;
typedef std::map<uint64, ServiceWatcher::UpdatedCallback> WatcherCallbacks;
typedef std::map<uint64, ServiceResolver::ResolveCompleteCallback>
ResolverCallbacks;
+ typedef std::map<uint64, LocalDomainResolver::IPAddressCallback>
+ DomainResolverCallbacks;
void StartOnIOThread();
void ShutdownOnIOThread();
@@ -72,8 +75,12 @@
const ServiceWatcher::UpdatedCallback& callback);
uint64 RegisterResolverCallback(
const ServiceResolver::ResolveCompleteCallback& callback);
+ uint64 RegisterLocalDomainResolverCallback(
+ const LocalDomainResolver::IPAddressCallback& callback);
+
void UnregisterWatcherCallback(uint64 id);
void UnregisterResolverCallback(uint64 id);
+ void UnregisterLocalDomainResolverCallback(uint64 id);
// IPC Message handlers.
void OnWatcherCallback(uint64 id,
@@ -82,6 +89,10 @@
void OnResolverCallback(uint64 id,
ServiceResolver::RequestStatus status,
const ServiceDescription& description);
+ void OnLocalDomainResolverCallback(uint64 id,
+ bool success,
+ const net::IPAddressNumber& address);
+
// Runs watcher callback on owning thread.
void RunWatcherCallback(uint64 id,
@@ -91,6 +102,11 @@
void RunResolverCallback(uint64 id,
ServiceResolver::RequestStatus status,
const ServiceDescription& description);
+ // Runs local domain resolver callback on owning thread.
+ void RunLocalDomainResolverCallback(uint64 id,
+ bool success,
+ const net::IPAddressNumber& address);
+
base::WeakPtr<content::UtilityProcessHost> utility_host_;
@@ -98,6 +114,7 @@
uint64 current_id_;
WatcherCallbacks service_watcher_callbacks_;
ResolverCallbacks service_resolver_callbacks_;
+ DomainResolverCallbacks domain_resolver_callbacks_;
scoped_refptr<base::TaskRunner> callback_runner_;
DISALLOW_COPY_AND_ASSIGN(ServiceDiscoveryHostClient);
diff --git a/chrome/browser/mac/relauncher.cc b/chrome/browser/mac/relauncher.cc
index aa4794f..5d8357f 100644
--- a/chrome/browser/mac/relauncher.cc
+++ b/chrome/browser/mac/relauncher.cc
@@ -25,7 +25,7 @@
#include "base/mac/scoped_cftyperef.h"
#include "base/path_service.h"
#include "base/posix/eintr_wrapper.h"
-#include "base/process_util.h"
+#include "base/process/launch.h"
#include "base/strings/stringprintf.h"
#include "base/strings/sys_string_conversions.h"
#include "chrome/browser/mac/install_from_dmg.h"
diff --git a/chrome/browser/managed_mode/managed_mode_navigation_observer.cc b/chrome/browser/managed_mode/managed_mode_navigation_observer.cc
index 0366bab..ff32fe7 100644
--- a/chrome/browser/managed_mode/managed_mode_navigation_observer.cc
+++ b/chrome/browser/managed_mode/managed_mode_navigation_observer.cc
@@ -74,8 +74,8 @@
class ManagedModeWarningInfoBarDelegate : public ConfirmInfoBarDelegate {
public:
- // Creates a managed mode warning delegate and adds it to |infobar_service|.
- // Returns the delegate if it was successfully added.
+ // Creates a managed mode warning infobar delegate and adds it to
+ // |infobar_service|. Returns the delegate if it was successfully added.
static InfoBarDelegate* Create(InfoBarService* infobar_service);
private:
@@ -153,7 +153,7 @@
ManagedModeNavigationObserver::ManagedModeNavigationObserver(
content::WebContents* web_contents)
: WebContentsObserver(web_contents),
- warn_infobar_delegate_(NULL) {
+ warn_infobar_(NULL) {
Profile* profile =
Profile::FromBrowserContext(web_contents->GetBrowserContext());
managed_user_service_ = ManagedUserServiceFactory::GetForProfile(profile);
@@ -161,8 +161,8 @@
}
void ManagedModeNavigationObserver::WarnInfoBarDismissed() {
- DCHECK(warn_infobar_delegate_);
- warn_infobar_delegate_ = NULL;
+ DCHECK(warn_infobar_);
+ warn_infobar_ = NULL;
}
void ManagedModeNavigationObserver::ProvisionalChangeToMainFrameUrl(
@@ -171,14 +171,12 @@
ManagedModeURLFilter::FilteringBehavior behavior =
url_filter_->GetFilteringBehaviorForURL(url);
- if (behavior == ManagedModeURLFilter::WARN || !warn_infobar_delegate_)
+ if (behavior == ManagedModeURLFilter::WARN || !warn_infobar_)
return;
// If we shouldn't have a warn infobar remove it here.
- InfoBarService* infobar_service =
- InfoBarService::FromWebContents(web_contents());
- infobar_service->RemoveInfoBar(warn_infobar_delegate_);
- warn_infobar_delegate_ = NULL;
+ InfoBarService::FromWebContents(web_contents())->RemoveInfoBar(warn_infobar_);
+ warn_infobar_ = NULL;
}
void ManagedModeNavigationObserver::DidCommitProvisionalLoadForFrame(
@@ -194,8 +192,8 @@
ManagedModeURLFilter::FilteringBehavior behavior =
url_filter_->GetFilteringBehaviorForURL(url);
- if (behavior == ManagedModeURLFilter::WARN && !warn_infobar_delegate_) {
- warn_infobar_delegate_ = ManagedModeWarningInfoBarDelegate::Create(
+ if (behavior == ManagedModeURLFilter::WARN && !warn_infobar_) {
+ warn_infobar_ = ManagedModeWarningInfoBarDelegate::Create(
InfoBarService::FromWebContents(web_contents()));
}
}
diff --git a/chrome/browser/managed_mode/managed_mode_navigation_observer.h b/chrome/browser/managed_mode/managed_mode_navigation_observer.h
index 59015e4..292255e 100644
--- a/chrome/browser/managed_mode/managed_mode_navigation_observer.h
+++ b/chrome/browser/managed_mode/managed_mode_navigation_observer.h
@@ -66,7 +66,7 @@
const ManagedModeURLFilter* url_filter_;
// Owned by the InfoBarService, which has the same lifetime as this object.
- InfoBarDelegate* warn_infobar_delegate_;
+ InfoBarDelegate* warn_infobar_;
ScopedVector<const content::NavigationEntry> blocked_navigations_;
diff --git a/chrome/browser/media/chrome_media_stream_infobar_browsertest.cc b/chrome/browser/media/chrome_media_stream_infobar_browsertest.cc
index a0aada7..10827b0 100644
--- a/chrome/browser/media/chrome_media_stream_infobar_browsertest.cc
+++ b/chrome/browser/media/chrome_media_stream_infobar_browsertest.cc
@@ -4,7 +4,6 @@
#include "base/file_util.h"
#include "base/path_service.h"
-#include "base/process_util.h"
#include "base/strings/stringprintf.h"
#include "base/test/test_timeouts.h"
#include "base/time/time.h"
diff --git a/chrome/browser/media/chrome_webrtc_browsertest.cc b/chrome/browser/media/chrome_webrtc_browsertest.cc
index b9c6b51..16b1421 100644
--- a/chrome/browser/media/chrome_webrtc_browsertest.cc
+++ b/chrome/browser/media/chrome_webrtc_browsertest.cc
@@ -5,7 +5,7 @@
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/path_service.h"
-#include "base/process_util.h"
+#include "base/process/launch.h"
#include "base/strings/string_split.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/waitable_event.h"
@@ -122,7 +122,7 @@
infobar_added.Wait();
content::Details<InfoBarAddedDetails> details(infobar_added.details());
MediaStreamInfoBarDelegate* media_infobar =
- details.ptr()->AsMediaStreamInfoBarDelegate();
+ details->AsMediaStreamInfoBarDelegate();
media_infobar->Accept();
// Wait for WebRTC to call the success callback.
diff --git a/chrome/browser/media/chrome_webrtc_video_quality_browsertest.cc b/chrome/browser/media/chrome_webrtc_video_quality_browsertest.cc
index f6c5a97..e911a6e 100644
--- a/chrome/browser/media/chrome_webrtc_video_quality_browsertest.cc
+++ b/chrome/browser/media/chrome_webrtc_video_quality_browsertest.cc
@@ -5,7 +5,7 @@
#include "base/environment.h"
#include "base/file_util.h"
#include "base/path_service.h"
-#include "base/process_util.h"
+#include "base/process/launch.h"
#include "base/strings/string_split.h"
#include "base/strings/stringprintf.h"
#include "base/test/test_timeouts.h"
@@ -194,7 +194,7 @@
infobar_added.Wait();
content::Details<InfoBarAddedDetails> details(infobar_added.details());
MediaStreamInfoBarDelegate* media_infobar =
- details.ptr()->AsMediaStreamInfoBarDelegate();
+ details->AsMediaStreamInfoBarDelegate();
media_infobar->Accept();
// Wait for WebRTC to call the success callback.
diff --git a/chrome/browser/media_galleries/fileapi/device_media_async_file_util.cc b/chrome/browser/media_galleries/fileapi/device_media_async_file_util.cc
index 9f4b4a0..24f749b 100644
--- a/chrome/browser/media_galleries/fileapi/device_media_async_file_util.cc
+++ b/chrome/browser/media_galleries/fileapi/device_media_async_file_util.cc
@@ -13,12 +13,9 @@
#include "chrome/browser/media_galleries/fileapi/mtp_device_async_delegate.h"
#include "chrome/browser/media_galleries/fileapi/mtp_device_map_service.h"
#include "chrome/browser/media_galleries/fileapi/native_media_file_util.h"
-#include "webkit/browser/fileapi/file_system_context.h"
+#include "content/public/browser/browser_thread.h"
#include "webkit/browser/fileapi/file_system_operation_context.h"
-#include "webkit/browser/fileapi/file_system_task_runners.h"
#include "webkit/browser/fileapi/file_system_url.h"
-#include "webkit/browser/fileapi/isolated_context.h"
-#include "webkit/browser/fileapi/native_file_util.h"
#include "webkit/common/blob/shareable_file_reference.h"
using fileapi::FileSystemOperationContext;
@@ -29,19 +26,12 @@
namespace {
-const base::FilePath::CharType kDeviceMediaAsyncFileUtilTempDir[] =
- FILE_PATH_LITERAL("DeviceMediaFileSystem");
-
-// Returns true if the current thread is IO thread.
-bool IsOnIOThread(FileSystemOperationContext* context) {
- return context->file_system_context()->task_runners()->
- io_task_runner()->RunsTasksOnCurrentThread();
-}
+const char kDeviceMediaAsyncFileUtilTempDir[] = "DeviceMediaFileSystem";
// Called on the IO thread.
MTPDeviceAsyncDelegate* GetMTPDeviceDelegate(
FileSystemOperationContext* context) {
- DCHECK(IsOnIOThread(context));
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
return MTPDeviceMapService::GetInstance()->GetMTPDeviceAsyncDelegate(
context->GetUserValue<std::string>(
MediaFileSystemBackend::kMTPDeviceDelegateURLKey));
@@ -59,7 +49,7 @@
base::FilePath* snapshot_file_path) {
DCHECK(snapshot_file_path);
base::FilePath isolated_media_file_system_dir_path =
- profile_path.Append(kDeviceMediaAsyncFileUtilTempDir);
+ profile_path.AppendASCII(kDeviceMediaAsyncFileUtilTempDir);
if (!file_util::CreateDirectory(isolated_media_file_system_dir_path) ||
!file_util::CreateTemporaryFileInDir(isolated_media_file_system_dir_path,
snapshot_file_path)) {
@@ -86,7 +76,7 @@
const FileSystemURL& url,
int file_flags,
const CreateOrOpenCallback& callback) {
- DCHECK(IsOnIOThread(context.get()));
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
NOTIMPLEMENTED();
base::PlatformFile invalid_file = base::kInvalidPlatformFileValue;
callback.Run(base::PLATFORM_FILE_ERROR_SECURITY,
@@ -98,7 +88,7 @@
scoped_ptr<FileSystemOperationContext> context,
const FileSystemURL& url,
const EnsureFileExistsCallback& callback) {
- DCHECK(IsOnIOThread(context.get()));
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
NOTIMPLEMENTED();
callback.Run(base::PLATFORM_FILE_ERROR_SECURITY, false);
}
@@ -109,7 +99,7 @@
bool exclusive,
bool recursive,
const StatusCallback& callback) {
- DCHECK(IsOnIOThread(context.get()));
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
NOTIMPLEMENTED();
callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
}
@@ -118,30 +108,27 @@
scoped_ptr<FileSystemOperationContext> context,
const FileSystemURL& url,
const GetFileInfoCallback& callback) {
- DCHECK(IsOnIOThread(context.get()));
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(context.get());
if (!delegate) {
- OnGetFileInfoError(callback, url.path(),
- base::PLATFORM_FILE_ERROR_NOT_FOUND);
+ OnGetFileInfoError(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND);
return;
}
delegate->GetFileInfo(
url.path(),
base::Bind(&DeviceMediaAsyncFileUtil::OnDidGetFileInfo,
weak_ptr_factory_.GetWeakPtr(),
- callback,
- url.path()),
+ callback),
base::Bind(&DeviceMediaAsyncFileUtil::OnGetFileInfoError,
weak_ptr_factory_.GetWeakPtr(),
- callback,
- url.path()));
+ callback));
}
void DeviceMediaAsyncFileUtil::ReadDirectory(
scoped_ptr<FileSystemOperationContext> context,
const FileSystemURL& url,
const ReadDirectoryCallback& callback) {
- DCHECK(IsOnIOThread(context.get()));
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(context.get());
if (!delegate) {
OnReadDirectoryError(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND);
@@ -163,7 +150,7 @@
const base::Time& last_access_time,
const base::Time& last_modified_time,
const StatusCallback& callback) {
- DCHECK(IsOnIOThread(context.get()));
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
NOTIMPLEMENTED();
callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
}
@@ -173,7 +160,7 @@
const FileSystemURL& url,
int64 length,
const StatusCallback& callback) {
- DCHECK(IsOnIOThread(context.get()));
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
NOTIMPLEMENTED();
callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
}
@@ -183,7 +170,7 @@
const FileSystemURL& src_url,
const FileSystemURL& dest_url,
const StatusCallback& callback) {
- DCHECK(IsOnIOThread(context.get()));
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
NOTIMPLEMENTED();
callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
}
@@ -193,7 +180,7 @@
const FileSystemURL& src_url,
const FileSystemURL& dest_url,
const StatusCallback& callback) {
- DCHECK(IsOnIOThread(context.get()));
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
NOTIMPLEMENTED();
callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
}
@@ -203,7 +190,7 @@
const base::FilePath& src_file_path,
const FileSystemURL& dest_url,
const StatusCallback& callback) {
- DCHECK(IsOnIOThread(context.get()));
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
NOTIMPLEMENTED();
callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
}
@@ -212,7 +199,7 @@
scoped_ptr<FileSystemOperationContext> context,
const FileSystemURL& url,
const StatusCallback& callback) {
- DCHECK(IsOnIOThread(context.get()));
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
NOTIMPLEMENTED();
callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
}
@@ -221,7 +208,7 @@
scoped_ptr<FileSystemOperationContext> context,
const FileSystemURL& url,
const StatusCallback& callback) {
- DCHECK(IsOnIOThread(context.get()));
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
NOTIMPLEMENTED();
callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
}
@@ -230,7 +217,7 @@
scoped_ptr<FileSystemOperationContext> context,
const FileSystemURL& url,
const StatusCallback& callback) {
- DCHECK(IsOnIOThread(context.get()));
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
}
@@ -238,7 +225,7 @@
scoped_ptr<FileSystemOperationContext> context,
const FileSystemURL& url,
const CreateSnapshotFileCallback& callback) {
- DCHECK(IsOnIOThread(context.get()));
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(context.get());
if (!delegate) {
OnCreateSnapshotFileError(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND);
@@ -269,16 +256,12 @@
void DeviceMediaAsyncFileUtil::OnDidGetFileInfo(
const AsyncFileUtil::GetFileInfoCallback& callback,
- // TODO(thestig): remove this.
- const base::FilePath& platform_path,
const base::PlatformFileInfo& file_info) {
callback.Run(base::PLATFORM_FILE_OK, file_info);
}
void DeviceMediaAsyncFileUtil::OnGetFileInfoError(
const AsyncFileUtil::GetFileInfoCallback& callback,
- // TODO(thestig): remove this.
- const base::FilePath& platform_path,
base::PlatformFileError error) {
callback.Run(error, base::PlatformFileInfo());
}
@@ -338,7 +321,7 @@
const AsyncFileUtil::CreateSnapshotFileCallback& callback,
const base::FilePath& device_file_path,
base::FilePath* snapshot_file_path) {
- DCHECK(IsOnIOThread(context.get()));
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
if (!snapshot_file_path || snapshot_file_path->empty()) {
OnCreateSnapshotFileError(callback, base::PLATFORM_FILE_ERROR_FAILED);
return;
diff --git a/chrome/browser/media_galleries/fileapi/device_media_async_file_util.h b/chrome/browser/media_galleries/fileapi/device_media_async_file_util.h
index f6e2e9f..cb4c6a8 100644
--- a/chrome/browser/media_galleries/fileapi/device_media_async_file_util.h
+++ b/chrome/browser/media_galleries/fileapi/device_media_async_file_util.h
@@ -104,20 +104,18 @@
// Use Create() to get an instance of DeviceMediaAsyncFileUtil.
explicit DeviceMediaAsyncFileUtil(const base::FilePath& profile_path);
- // Called when GetFileInfo method call succeeds. |file_info|
- // contains the |platform_path| file details. |callback| is invoked
- // to complete the GetFileInfo request.
+ // Called when GetFileInfo method call succeeds. |file_info| contains the
+ // file details of the requested url. |callback| is invoked to complete the
+ // GetFileInfo request.
void OnDidGetFileInfo(
const AsyncFileUtil::GetFileInfoCallback& callback,
- const base::FilePath& platform_path,
const base::PlatformFileInfo& file_info);
// Called when GetFileInfo method call failed to get the details of file
- // specified by the |platform_path|. |callback| is invoked to notify the
+ // specified by the requested url. |callback| is invoked to notify the
// caller about the platform file |error|.
void OnGetFileInfoError(
const AsyncFileUtil::GetFileInfoCallback& callback,
- const base::FilePath& platform_path,
base::PlatformFileError error);
// Called when ReadDirectory method call succeeds. |callback| is invoked to
diff --git a/chrome/browser/media_galleries/fileapi/media_file_system_backend.cc b/chrome/browser/media_galleries/fileapi/media_file_system_backend.cc
index 308b252..59809bb 100644
--- a/chrome/browser/media_galleries/fileapi/media_file_system_backend.cc
+++ b/chrome/browser/media_galleries/fileapi/media_file_system_backend.cc
@@ -103,12 +103,14 @@
}
}
-void MediaFileSystemBackend::InitializeFileSystem(
+void MediaFileSystemBackend::Initialize(fileapi::FileSystemContext* context) {
+}
+
+void MediaFileSystemBackend::OpenFileSystem(
const GURL& origin_url,
fileapi::FileSystemType type,
fileapi::OpenFileSystemMode mode,
- fileapi::FileSystemContext* context,
- const InitializeFileSystemCallback& callback) {
+ const OpenFileSystemCallback& callback) {
// We never allow opening a new isolated FileSystem via usual OpenFileSystem.
base::MessageLoopProxy::current()->PostTask(
FROM_HERE,
diff --git a/chrome/browser/media_galleries/fileapi/media_file_system_backend.h b/chrome/browser/media_galleries/fileapi/media_file_system_backend.h
index 3026664..e1763a8 100644
--- a/chrome/browser/media_galleries/fileapi/media_file_system_backend.h
+++ b/chrome/browser/media_galleries/fileapi/media_file_system_backend.h
@@ -39,12 +39,12 @@
// FileSystemBackend implementation.
virtual bool CanHandleType(fileapi::FileSystemType type) const OVERRIDE;
- virtual void InitializeFileSystem(
+ virtual void Initialize(fileapi::FileSystemContext* context) OVERRIDE;
+ virtual void OpenFileSystem(
const GURL& origin_url,
fileapi::FileSystemType type,
fileapi::OpenFileSystemMode mode,
- fileapi::FileSystemContext* context,
- const InitializeFileSystemCallback& callback) OVERRIDE;
+ const OpenFileSystemCallback& callback) OVERRIDE;
virtual fileapi::FileSystemFileUtil* GetFileUtil(
fileapi::FileSystemType type) OVERRIDE;
virtual fileapi::AsyncFileUtil* GetAsyncFileUtil(
diff --git a/chrome/browser/media_galleries/fileapi/native_media_file_util.cc b/chrome/browser/media_galleries/fileapi/native_media_file_util.cc
index c9e1d6f..85f111e 100644
--- a/chrome/browser/media_galleries/fileapi/native_media_file_util.cc
+++ b/chrome/browser/media_galleries/fileapi/native_media_file_util.cc
@@ -330,10 +330,8 @@
const GetFileInfoCallback& callback) {
DCHECK(IsOnTaskRunnerThread(context.get()));
base::PlatformFileInfo file_info;
- // TODO(thestig): remove this.
- base::FilePath platform_path;
base::PlatformFileError error =
- GetFileInfoSync(context.get(), url, &file_info, &platform_path);
+ GetFileInfoSync(context.get(), url, &file_info, NULL);
content::BrowserThread::PostTask(
content::BrowserThread::IO,
FROM_HERE,
diff --git a/chrome/browser/memory_details.cc b/chrome/browser/memory_details.cc
index 1dad6f9..48d2d0a 100644
--- a/chrome/browser/memory_details.cc
+++ b/chrome/browser/memory_details.cc
@@ -7,7 +7,6 @@
#include "base/bind.h"
#include "base/file_version_info.h"
#include "base/metrics/histogram.h"
-#include "base/process_util.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
diff --git a/chrome/browser/memory_details.h b/chrome/browser/memory_details.h
index be4d51f..cfbd68e 100644
--- a/chrome/browser/memory_details.h
+++ b/chrome/browser/memory_details.h
@@ -8,7 +8,7 @@
#include <vector>
#include "base/memory/ref_counted.h"
-#include "base/process_util.h"
+#include "base/process/process_metrics.h"
#include "base/strings/string16.h"
#include "chrome/browser/site_details.h"
#include "content/public/common/process_type.h"
diff --git a/chrome/browser/memory_details_android.cc b/chrome/browser/memory_details_android.cc
index c524a2b..9be87ae 100644
--- a/chrome/browser/memory_details_android.cc
+++ b/chrome/browser/memory_details_android.cc
@@ -9,7 +9,6 @@
#include <vector>
#include "base/bind.h"
-#include "base/process_util.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/common/chrome_constants.h"
#include "content/public/browser/browser_thread.h"
diff --git a/chrome/browser/memory_details_linux.cc b/chrome/browser/memory_details_linux.cc
index 31bed8d..cbb9f4c 100644
--- a/chrome/browser/memory_details_linux.cc
+++ b/chrome/browser/memory_details_linux.cc
@@ -12,7 +12,8 @@
#include "base/bind.h"
#include "base/file_util.h"
-#include "base/process_util.h"
+#include "base/process/process_iterator.h"
+#include "base/process/process_metrics.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
diff --git a/chrome/browser/memory_details_mac.cc b/chrome/browser/memory_details_mac.cc
index a7ba52c..56158bf 100644
--- a/chrome/browser/memory_details_mac.cc
+++ b/chrome/browser/memory_details_mac.cc
@@ -12,7 +12,7 @@
#include "base/file_version_info.h"
#include "base/files/file_path.h"
#include "base/mac/mac_util.h"
-#include "base/process_util.h"
+#include "base/process/process_iterator.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread.h"
diff --git a/chrome/browser/memory_details_win.cc b/chrome/browser/memory_details_win.cc
index 5ce6032..ab9d36b 100644
--- a/chrome/browser/memory_details_win.cc
+++ b/chrome/browser/memory_details_win.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/memory_details.h"
#include <psapi.h>
+#include <TlHelp32.h>
#include "base/bind.h"
#include "base/file_version_info.h"
diff --git a/chrome/browser/metrics/metrics_service.h b/chrome/browser/metrics/metrics_service.h
index b84172a..27437ec 100644
--- a/chrome/browser/metrics/metrics_service.h
+++ b/chrome/browser/metrics/metrics_service.h
@@ -17,7 +17,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/metrics/field_trial.h"
-#include "base/process_util.h"
+#include "base/process/kill.h"
#include "chrome/browser/metrics/metrics_log.h"
#include "chrome/browser/metrics/tracking_synchronizer_observer.h"
#include "chrome/common/metrics/metrics_service_base.h"
diff --git a/chrome/browser/metrics/perf_provider_chromeos.cc b/chrome/browser/metrics/perf_provider_chromeos.cc
index 623033d..f3a1625 100644
--- a/chrome/browser/metrics/perf_provider_chromeos.cc
+++ b/chrome/browser/metrics/perf_provider_chromeos.cc
@@ -10,7 +10,6 @@
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/metrics/histogram.h"
-#include "base/process_util.h"
#include "base/rand_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/threading/sequenced_worker_pool.h"
diff --git a/chrome/browser/metrics/tracking_synchronizer.cc b/chrome/browser/metrics/tracking_synchronizer.cc
index aeda223..fd4505a 100644
--- a/chrome/browser/metrics/tracking_synchronizer.cc
+++ b/chrome/browser/metrics/tracking_synchronizer.cc
@@ -6,7 +6,6 @@
#include "base/bind.h"
#include "base/metrics/histogram.h"
-#include "base/process_util.h"
#include "base/threading/thread.h"
#include "base/tracked_objects.h"
#include "chrome/browser/metrics/tracking_synchronizer_observer.h"
diff --git a/chrome/browser/nacl_host/nacl_broker_host_win.h b/chrome/browser/nacl_host/nacl_broker_host_win.h
index 30bc88d..80f2303 100644
--- a/chrome/browser/nacl_host/nacl_broker_host_win.h
+++ b/chrome/browser/nacl_host/nacl_broker_host_win.h
@@ -9,7 +9,7 @@
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
-#include "base/process.h"
+#include "base/process/process.h"
#include "content/public/browser/browser_child_process_host_delegate.h"
namespace content {
diff --git a/chrome/browser/nacl_host/nacl_process_host.cc b/chrome/browser/nacl_host/nacl_process_host.cc
index 59879e4..21754ba 100644
--- a/chrome/browser/nacl_host/nacl_process_host.cc
+++ b/chrome/browser/nacl_host/nacl_process_host.cc
@@ -15,7 +15,7 @@
#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram.h"
#include "base/path_service.h"
-#include "base/process_util.h"
+#include "base/process/process_iterator.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
diff --git a/chrome/browser/nacl_host/nacl_process_host.h b/chrome/browser/nacl_host/nacl_process_host.h
index 808a274..f2133a1 100644
--- a/chrome/browser/nacl_host/nacl_process_host.h
+++ b/chrome/browser/nacl_host/nacl_process_host.h
@@ -12,7 +12,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop.h"
-#include "base/process.h"
+#include "base/process/process.h"
#include "components/nacl/common/nacl_types.h"
#include "content/public/browser/browser_child_process_host_delegate.h"
#include "content/public/browser/browser_child_process_host_iterator.h"
diff --git a/chrome/browser/nacl_host/test/gdb_debug_stub_browsertest.cc b/chrome/browser/nacl_host/test/gdb_debug_stub_browsertest.cc
index a522dce..03b5894 100644
--- a/chrome/browser/nacl_host/test/gdb_debug_stub_browsertest.cc
+++ b/chrome/browser/nacl_host/test/gdb_debug_stub_browsertest.cc
@@ -5,7 +5,8 @@
#include "base/command_line.h"
#include "base/environment.h"
#include "base/path_service.h"
-#include "base/process_util.h"
+#include "base/process/kill.h"
+#include "base/process/launch.h"
#include "base/strings/string_number_conversions.h"
#include "chrome/browser/nacl_host/nacl_browser.h"
#include "chrome/test/ppapi/ppapi_test.h"
diff --git a/chrome/browser/nacl_host/test/mock_nacl_gdb.cc b/chrome/browser/nacl_host/test/mock_nacl_gdb.cc
index 4635aa4..097f1f9 100644
--- a/chrome/browser/nacl_host/test/mock_nacl_gdb.cc
+++ b/chrome/browser/nacl_host/test/mock_nacl_gdb.cc
@@ -10,7 +10,6 @@
#include "base/file_util.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
-#include "base/process_util.h"
static const char kEvalCommand[] = "--eval-command";
static const char kCommand[] = "--command";
diff --git a/chrome/browser/notifications/notification_browsertest.cc b/chrome/browser/notifications/notification_browsertest.cc
index 496147c..f015843 100644
--- a/chrome/browser/notifications/notification_browsertest.cc
+++ b/chrome/browser/notifications/notification_browsertest.cc
@@ -221,7 +221,7 @@
void AllowOrigin(const GURL& origin);
void AllowAllOrigins();
- void VerifyInfobar(const Browser* browser, int index);
+ void VerifyInfoBar(const Browser* browser, int index);
std::string CreateNotification(Browser* browser,
bool wait_for_new_balloon,
const char* icon,
@@ -232,9 +232,9 @@
bool wait_for_new_balloon);
bool RequestPermissionAndWait(Browser* browser);
bool CancelNotification(const char* notification_id, Browser* browser);
- bool PerformActionOnInfobar(Browser* browser,
+ bool PerformActionOnInfoBar(Browser* browser,
InfobarAction action,
- int infobar_index,
+ size_t infobar_index,
int tab_index);
void GetPrefsByContentSetting(ContentSetting setting,
ContentSettingsForOneType* settings);
@@ -319,13 +319,13 @@
CONTENT_SETTING_ALLOW);
}
-void NotificationsTest::VerifyInfobar(const Browser* browser, int index) {
+void NotificationsTest::VerifyInfoBar(const Browser* browser, int index) {
InfoBarService* infobar_service = InfoBarService::FromWebContents(
browser->tab_strip_model()->GetWebContentsAt(index));
ASSERT_EQ(1U, infobar_service->infobar_count());
- InfoBarDelegate* infobar = infobar_service->infobar_at(0);
- ConfirmInfoBarDelegate* confirm_infobar = infobar->AsConfirmInfoBarDelegate();
+ ConfirmInfoBarDelegate* confirm_infobar =
+ infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate();
ASSERT_TRUE(confirm_infobar);
int buttons = confirm_infobar->GetButtons();
EXPECT_TRUE(buttons & ConfirmInfoBarDelegate::BUTTON_OK);
@@ -399,33 +399,44 @@
return observer->Wait();
}
-bool NotificationsTest::PerformActionOnInfobar(
+bool NotificationsTest::PerformActionOnInfoBar(
Browser* browser,
InfobarAction action,
- int infobar_index,
+ size_t infobar_index,
int tab_index) {
InfoBarService* infobar_service = InfoBarService::FromWebContents(
browser->tab_strip_model()->GetWebContentsAt(tab_index));
+ if (infobar_index >= infobar_service->infobar_count()) {
+ ADD_FAILURE();
+ return false;
+ }
- InfoBarDelegate* infobar = infobar_service->infobar_at(infobar_index);
+ InfoBarDelegate* infobar_delegate =
+ infobar_service->infobar_at(infobar_index);
switch (action) {
case DISMISS:
- infobar->InfoBarDismissed();
- infobar_service->RemoveInfoBar(infobar);
+ infobar_delegate->InfoBarDismissed();
+ infobar_service->RemoveInfoBar(infobar_delegate);
return true;
case ALLOW: {
- ConfirmInfoBarDelegate* confirm_bar = infobar->AsConfirmInfoBarDelegate();
- if (confirm_bar->Accept()) {
- infobar_service->RemoveInfoBar(infobar);
+ ConfirmInfoBarDelegate* confirm_infobar_delegate =
+ infobar_delegate->AsConfirmInfoBarDelegate();
+ if (!confirm_infobar_delegate) {
+ ADD_FAILURE();
+ } else if (confirm_infobar_delegate->Accept()) {
+ infobar_service->RemoveInfoBar(infobar_delegate);
return true;
}
}
case DENY: {
- ConfirmInfoBarDelegate* confirm_bar = infobar->AsConfirmInfoBarDelegate();
- if (confirm_bar->Cancel()) {
- infobar_service->RemoveInfoBar(infobar);
+ ConfirmInfoBarDelegate* confirm_infobar_delegate =
+ infobar_delegate->AsConfirmInfoBarDelegate();
+ if (!confirm_infobar_delegate) {
+ ADD_FAILURE();
+ } else if (confirm_infobar_delegate->Cancel()) {
+ infobar_service->RemoveInfoBar(infobar_delegate);
return true;
}
}
@@ -602,7 +613,7 @@
ASSERT_TRUE(RequestPermissionAndWait(browser()));
ASSERT_EQ(0, GetNotificationCount());
- VerifyInfobar(browser(), 0);
+ ASSERT_NO_FATAL_FAILURE(VerifyInfoBar(browser(), 0));
}
IN_PROC_BROWSER_TEST_F(NotificationsTest, TestAllowOnPermissionInfobar) {
@@ -621,7 +632,7 @@
ASSERT_EQ(0, GetNotificationCount());
ASSERT_TRUE(RequestPermissionAndWait(browser()));
- ASSERT_TRUE(PerformActionOnInfobar(browser(), ALLOW, 0, 0));
+ ASSERT_TRUE(PerformActionOnInfoBar(browser(), ALLOW, 0, 0));
CreateSimpleNotification(browser(), true);
EXPECT_EQ(1, GetNotificationCount());
@@ -634,7 +645,7 @@
// when Deny is chosen from permission infobar.
ui_test_utils::NavigateToURL(browser(), GetTestPageURL());
ASSERT_TRUE(RequestPermissionAndWait(browser()));
- PerformActionOnInfobar(browser(), DENY, 0, 0);
+ PerformActionOnInfoBar(browser(), DENY, 0, 0);
CreateSimpleNotification(browser(), false);
ASSERT_EQ(0, GetNotificationCount());
ContentSettingsForOneType settings;
@@ -648,7 +659,7 @@
// Test that no notification is created when permission infobar is dismissed.
ui_test_utils::NavigateToURL(browser(), GetTestPageURL());
ASSERT_TRUE(RequestPermissionAndWait(browser()));
- PerformActionOnInfobar(browser(), DISMISS, 0, 0);
+ PerformActionOnInfoBar(browser(), DISMISS, 0, 0);
CreateSimpleNotification(browser(), false);
ASSERT_EQ(0, GetNotificationCount());
ContentSettingsForOneType settings;
@@ -800,13 +811,13 @@
Browser* incognito = CreateIncognitoBrowser();
ui_test_utils::NavigateToURL(incognito, GetTestPageURL());
ASSERT_TRUE(RequestPermissionAndWait(incognito));
- PerformActionOnInfobar(incognito, DENY, 0, 0);
+ PerformActionOnInfoBar(incognito, DENY, 0, 0);
CloseBrowserWindow(incognito);
incognito = CreateIncognitoBrowser();
ui_test_utils::NavigateToURL(incognito, GetTestPageURL());
ASSERT_TRUE(RequestPermissionAndWait(incognito));
- PerformActionOnInfobar(incognito, ALLOW, 0, 0);
+ PerformActionOnInfoBar(incognito, ALLOW, 0, 0);
CreateSimpleNotification(incognito, true);
ASSERT_EQ(1, GetNotificationCount());
CloseBrowserWindow(incognito);
@@ -893,7 +904,7 @@
ui_test_utils::NavigateToURL(browser, GetTestPageURL());
browser->tab_strip_model()->ActivateTabAt(0, true);
ASSERT_TRUE(RequestPermissionAndWait(browser));
- PerformActionOnInfobar(browser, ALLOW, 0, 0);
+ PerformActionOnInfoBar(browser, ALLOW, 0, 0);
CreateSimpleNotification(browser, true);
ASSERT_EQ(1, GetNotificationCount());
}
@@ -941,7 +952,7 @@
ASSERT_TRUE(RequestPermissionAndWait(browser()));
ui_test_utils::NavigateToURL(browser(), GetTestPageURL());
ASSERT_TRUE(RequestPermissionAndWait(browser()));
- PerformActionOnInfobar(browser(), ALLOW, 0, 0);
+ PerformActionOnInfoBar(browser(), ALLOW, 0, 0);
CreateSimpleNotification(browser(), true);
ASSERT_EQ(1, GetNotificationCount());
}
diff --git a/chrome/browser/page_cycler/page_cycler.cc b/chrome/browser/page_cycler/page_cycler.cc
index 7fcf078..51e1eb8 100644
--- a/chrome/browser/page_cycler/page_cycler.cc
+++ b/chrome/browser/page_cycler/page_cycler.cc
@@ -8,7 +8,6 @@
#include "base/file_util.h"
#include "base/files/file_path.h"
#include "base/message_loop/message_loop.h"
-#include "base/process_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/utf_string_conversions.h"
diff --git a/chrome/browser/performance_monitor/performance_monitor.cc b/chrome/browser/performance_monitor/performance_monitor.cc
index 1886a2d..5ed870f 100644
--- a/chrome/browser/performance_monitor/performance_monitor.cc
+++ b/chrome/browser/performance_monitor/performance_monitor.cc
@@ -10,7 +10,7 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "base/logging.h"
-#include "base/process_util.h"
+#include "base/process/process_iterator.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/threading/worker_pool.h"
diff --git a/chrome/browser/performance_monitor/performance_monitor.h b/chrome/browser/performance_monitor/performance_monitor.h
index d8cd74e..a054f58 100644
--- a/chrome/browser/performance_monitor/performance_monitor.h
+++ b/chrome/browser/performance_monitor/performance_monitor.h
@@ -13,8 +13,7 @@
#include "base/memory/linked_ptr.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
-#include "base/process.h"
-#include "base/process_util.h"
+#include "base/process/process_metrics.h"
#include "base/timer/timer.h"
#include "chrome/browser/performance_monitor/database.h"
#include "chrome/browser/performance_monitor/event.h"
diff --git a/chrome/browser/platform_util_linux.cc b/chrome/browser/platform_util_linux.cc
index 6f88b16..60d4467 100644
--- a/chrome/browser/platform_util_linux.cc
+++ b/chrome/browser/platform_util_linux.cc
@@ -6,7 +6,8 @@
#include "base/bind.h"
#include "base/file_util.h"
-#include "base/process_util.h"
+#include "base/process/kill.h"
+#include "base/process/launch.h"
#include "base/strings/utf_string_conversions.h"
#include "content/public/browser/browser_thread.h"
#include "url/gurl.h"
diff --git a/chrome/browser/plugins/plugin_finder_unittest.cc b/chrome/browser/plugins/plugin_finder_unittest.cc
index 726b146..a6317a6 100644
--- a/chrome/browser/plugins/plugin_finder_unittest.cc
+++ b/chrome/browser/plugins/plugin_finder_unittest.cc
@@ -69,4 +69,5 @@
<< "Invalid security status \"" << status_str << "\"";
}
}
+ delete version;
}
diff --git a/chrome/browser/plugins/plugin_installer.cc b/chrome/browser/plugins/plugin_installer.cc
index 653d129..69864ad 100644
--- a/chrome/browser/plugins/plugin_installer.cc
+++ b/chrome/browser/plugins/plugin_installer.cc
@@ -6,7 +6,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
-#include "base/process.h"
+#include "base/process/process.h"
#include "base/strings/stringprintf.h"
#include "chrome/browser/download/download_service.h"
#include "chrome/browser/download/download_service_factory.h"
diff --git a/chrome/browser/plugins/plugin_observer.cc b/chrome/browser/plugins/plugin_observer.cc
index 7c9cd67..7668168 100644
--- a/chrome/browser/plugins/plugin_observer.cc
+++ b/chrome/browser/plugins/plugin_observer.cc
@@ -8,7 +8,6 @@
#include "base/bind.h"
#include "base/debug/crash_logging.h"
#include "base/metrics/histogram.h"
-#include "base/process_util.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
diff --git a/chrome/browser/policy/configuration_policy_pref_store.cc b/chrome/browser/policy/configuration_policy_pref_store.cc
index 8b7d10a..c054471 100644
--- a/chrome/browser/policy/configuration_policy_pref_store.cc
+++ b/chrome/browser/policy/configuration_policy_pref_store.cc
@@ -88,6 +88,16 @@
void ConfigurationPolicyPrefStore::OnPolicyServiceInitialized(
PolicyDomain domain) {
if (domain == POLICY_DOMAIN_CHROME) {
+ // Subtle: the current implementation of PolicyServiceImpl sends out this
+ // notification before invoking OnPolicyUpdated(), which gets posted to
+ // execute "soon" after on the current message loop.
+ // But the PrefService will start reading the preferences published by
+ // this store once OnInitializationCompleted() is sent out, so make sure
+ // this is reading the current policies before doing so.
+ // TODO(joaodasilva): remove this, and fix the order of notifications from
+ // the PolicyService instead. http://crbug.com/263728
+ Refresh();
+
FOR_EACH_OBSERVER(PrefStore::Observer, observers_,
OnInitializationCompleted(true));
}
diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc
index 869c9bf..b5667a4 100644
--- a/chrome/browser/policy/policy_browsertest.cc
+++ b/chrome/browser/policy/policy_browsertest.cc
@@ -1160,8 +1160,7 @@
ui_test_utils::NavigateToURL(browser(), url);
// This should have triggered the dangerous plugin infobar.
ASSERT_EQ(1u, infobar_service->infobar_count());
- InfoBarDelegate* infobar_delegate = infobar_service->infobar_at(0);
- EXPECT_TRUE(infobar_delegate->AsConfirmInfoBarDelegate());
+ EXPECT_TRUE(infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate());
// And the plugin isn't running.
EXPECT_EQ(0, CountPlugins());
diff --git a/chrome/browser/policy/policy_loader_win_unittest.cc b/chrome/browser/policy/policy_loader_win_unittest.cc
index a6492de..3417d9f 100644
--- a/chrome/browser/policy/policy_loader_win_unittest.cc
+++ b/chrome/browser/policy/policy_loader_win_unittest.cc
@@ -19,7 +19,7 @@
#include "base/files/scoped_temp_dir.h"
#include "base/json/json_writer.h"
#include "base/path_service.h"
-#include "base/process.h"
+#include "base/process/process.h"
#include "base/strings/string16.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
diff --git a/chrome/browser/predictors/autocomplete_action_predictor_unittest.cc b/chrome/browser/predictors/autocomplete_action_predictor_unittest.cc
index 921ba20..c13641b 100644
--- a/chrome/browser/predictors/autocomplete_action_predictor_unittest.cc
+++ b/chrome/browser/predictors/autocomplete_action_predictor_unittest.cc
@@ -102,7 +102,7 @@
switches::kPrerenderFromOmniboxSwitchValueEnabled);
predictor_->CreateLocalCachesFromDatabase();
- profile_->CreateHistoryService(true, false);
+ ASSERT_TRUE(profile_->CreateHistoryService(true, false));
profile_->BlockUntilHistoryProcessesPendingRequests();
ASSERT_TRUE(predictor_->initialized_);
diff --git a/chrome/browser/predictors/resource_prefetch_predictor_unittest.cc b/chrome/browser/predictors/resource_prefetch_predictor_unittest.cc
index 56d90c6..b0d7fe3 100644
--- a/chrome/browser/predictors/resource_prefetch_predictor_unittest.cc
+++ b/chrome/browser/predictors/resource_prefetch_predictor_unittest.cc
@@ -186,7 +186,7 @@
void ResourcePrefetchPredictorTest::SetUp() {
InitializeSampleData();
- profile_->CreateHistoryService(true, false);
+ ASSERT_TRUE(profile_->CreateHistoryService(true, false));
profile_->BlockUntilHistoryProcessesPendingRequests();
EXPECT_TRUE(HistoryServiceFactory::GetForProfile(profile_.get(),
Profile::EXPLICIT_ACCESS));
diff --git a/chrome/browser/prefs/pref_metrics_service.cc b/chrome/browser/prefs/pref_metrics_service.cc
new file mode 100644
index 0000000..ed1d538
--- /dev/null
+++ b/chrome/browser/prefs/pref_metrics_service.cc
@@ -0,0 +1,67 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/prefs/pref_metrics_service.h"
+
+#include "base/metrics/histogram.h"
+#include "base/prefs/pref_service.h"
+#include "chrome/browser/profiles/incognito_helpers.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/pref_names.h"
+#include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
+
+PrefMetricsService::PrefMetricsService(Profile* profile)
+ : profile_(profile) {
+ RecordLaunchPrefs();
+}
+
+PrefMetricsService::~PrefMetricsService() {
+}
+
+void PrefMetricsService::RecordLaunchPrefs() {
+ UMA_HISTOGRAM_BOOLEAN("Settings.ShowHomeButton",
+ profile_->GetPrefs()->GetBoolean(prefs::kShowHomeButton));
+ UMA_HISTOGRAM_BOOLEAN("Settings.HomePageIsNewTabPage",
+ profile_->GetPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage));
+}
+
+// static
+PrefMetricsService::Factory* PrefMetricsService::Factory::GetInstance() {
+ return Singleton<PrefMetricsService::Factory>::get();
+}
+
+// static
+PrefMetricsService* PrefMetricsService::Factory::GetForProfile(
+ Profile* profile) {
+ return static_cast<PrefMetricsService*>(
+ GetInstance()->GetServiceForBrowserContext(profile, true));
+}
+
+PrefMetricsService::Factory::Factory()
+ : BrowserContextKeyedServiceFactory(
+ "PrefMetricsService",
+ BrowserContextDependencyManager::GetInstance()) {
+}
+
+PrefMetricsService::Factory::~Factory() {
+}
+
+BrowserContextKeyedService*
+PrefMetricsService::Factory::BuildServiceInstanceFor(
+ content::BrowserContext* profile) const {
+ return new PrefMetricsService(static_cast<Profile*>(profile));
+}
+
+bool PrefMetricsService::Factory::ServiceIsCreatedWithBrowserContext() const {
+ return true;
+}
+
+bool PrefMetricsService::Factory::ServiceIsNULLWhileTesting() const {
+ return false;
+}
+
+content::BrowserContext* PrefMetricsService::Factory::GetBrowserContextToUse(
+ content::BrowserContext* context) const {
+ return chrome::GetBrowserContextRedirectedInIncognito(context);
+}
diff --git a/chrome/browser/prefs/pref_metrics_service.h b/chrome/browser/prefs/pref_metrics_service.h
new file mode 100644
index 0000000..647cd94
--- /dev/null
+++ b/chrome/browser/prefs/pref_metrics_service.h
@@ -0,0 +1,44 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_PREFS_PREF_METRICS_SERVICE_H_
+#define CHROME_BROWSER_PREFS_PREF_METRICS_SERVICE_H_
+
+#include "base/memory/singleton.h"
+#include "chrome/browser/profiles/profile.h"
+#include "components/browser_context_keyed_service/browser_context_keyed_service.h"
+#include "components/browser_context_keyed_service/browser_context_keyed_service_factory.h"
+
+// PrefMetricsService is responsible for recording prefs-related UMA stats.
+class PrefMetricsService : public BrowserContextKeyedService {
+ public:
+ explicit PrefMetricsService(Profile* profile);
+ virtual ~PrefMetricsService();
+
+ class Factory : public BrowserContextKeyedServiceFactory {
+ public:
+ static Factory* GetInstance();
+ static PrefMetricsService* GetForProfile(Profile* profile);
+ private:
+ friend struct DefaultSingletonTraits<Factory>;
+
+ Factory();
+ virtual ~Factory();
+
+ // BrowserContextKeyedServiceFactory implementation
+ virtual BrowserContextKeyedService* BuildServiceInstanceFor(
+ content::BrowserContext* profile) const OVERRIDE;
+ virtual bool ServiceIsCreatedWithBrowserContext() const OVERRIDE;
+ virtual bool ServiceIsNULLWhileTesting() const OVERRIDE;
+ virtual content::BrowserContext* GetBrowserContextToUse(
+ content::BrowserContext* context) const OVERRIDE;
+ };
+ private:
+ // Record prefs state on browser context creation.
+ void RecordLaunchPrefs();
+
+ Profile* profile_;
+};
+
+#endif // CHROME_BROWSER_PREFS_PREF_METRICS_SERVICE_H_
diff --git a/chrome/browser/printing/cloud_print/test/cloud_print_policy_browsertest.cc b/chrome/browser/printing/cloud_print/test/cloud_print_policy_browsertest.cc
index eb238e5..d298a2d 100644
--- a/chrome/browser/printing/cloud_print/test/cloud_print_policy_browsertest.cc
+++ b/chrome/browser/printing/cloud_print/test/cloud_print_policy_browsertest.cc
@@ -4,7 +4,8 @@
#include "base/command_line.h"
#include "base/path_service.h"
-#include "base/process_util.h"
+#include "base/process/kill.h"
+#include "base/process/launch.h"
#include "base/test/test_timeouts.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/common/chrome_result_codes.h"
diff --git a/chrome/browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc b/chrome/browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc
index 7064156..4336fc3 100644
--- a/chrome/browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc
+++ b/chrome/browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc
@@ -9,7 +9,7 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "base/message_loop/message_loop.h"
-#include "base/process_util.h"
+#include "base/process/kill.h"
#include "base/rand_util.h"
#include "base/synchronization/waitable_event.h"
#include "base/test/multiprocess_test.h"
diff --git a/chrome/browser/printing/printer_manager_dialog_linux.cc b/chrome/browser/printing/printer_manager_dialog_linux.cc
index 87bacba..fec3b02 100644
--- a/chrome/browser/printing/printer_manager_dialog_linux.cc
+++ b/chrome/browser/printing/printer_manager_dialog_linux.cc
@@ -9,7 +9,8 @@
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/nix/xdg_util.h"
-#include "base/process_util.h"
+#include "base/process/kill.h"
+#include "base/process/launch.h"
#include "content/public/browser/browser_thread.h"
using base::Environment;
diff --git a/chrome/browser/printing/printing_layout_browsertest.cc b/chrome/browser/printing/printing_layout_browsertest.cc
index d653031..1d80518 100644
--- a/chrome/browser/printing/printing_layout_browsertest.cc
+++ b/chrome/browser/printing/printing_layout_browsertest.cc
@@ -8,7 +8,6 @@
#include "base/files/file_path.h"
#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
-#include "base/process_util.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/test_file_util.h"
diff --git a/chrome/browser/printing/printing_message_filter.cc b/chrome/browser/printing/printing_message_filter.cc
index 09ad68f..e0e2036 100644
--- a/chrome/browser/printing/printing_message_filter.cc
+++ b/chrome/browser/printing/printing_message_filter.cc
@@ -7,7 +7,6 @@
#include <string>
#include "base/bind.h"
-#include "base/process_util.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/printing/printer_query.h"
#include "chrome/browser/printing/print_job_manager.h"
diff --git a/chrome/browser/process_info_snapshot.h b/chrome/browser/process_info_snapshot.h
index 62cd134..575fbe2 100644
--- a/chrome/browser/process_info_snapshot.h
+++ b/chrome/browser/process_info_snapshot.h
@@ -11,7 +11,8 @@
#include <string>
#include <vector>
-#include "base/process_util.h"
+#include "base/process/process_handle.h"
+#include "base/process/process_metrics.h"
// A class which captures process information at a given point in time when its
// |Sample()| method is called. This information can then be probed by PID.
diff --git a/chrome/browser/process_info_snapshot_mac.cc b/chrome/browser/process_info_snapshot_mac.cc
index 7f27d0c..94a1bc0 100644
--- a/chrome/browser/process_info_snapshot_mac.cc
+++ b/chrome/browser/process_info_snapshot_mac.cc
@@ -9,7 +9,9 @@
#include <sstream>
#include "base/command_line.h"
+#include "base/files/file_path.h"
#include "base/logging.h"
+#include "base/process/launch.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/threading/thread.h"
diff --git a/chrome/browser/process_info_snapshot_mac_unittest.cc b/chrome/browser/process_info_snapshot_mac_unittest.cc
index 980dc91..c30a883 100644
--- a/chrome/browser/process_info_snapshot_mac_unittest.cc
+++ b/chrome/browser/process_info_snapshot_mac_unittest.cc
@@ -13,8 +13,10 @@
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/posix/eintr_wrapper.h"
-#include "base/process_util.h"
-
+#include "base/process/kill.h"
+#include "base/process/launch.h"
+#include "base/process/process_handle.h"
+#include "base/process/process_metrics.h"
#include "testing/gtest/include/gtest/gtest.h"
typedef testing::Test ProcessInfoSnapshotMacTest;
diff --git a/chrome/browser/process_singleton.h b/chrome/browser/process_singleton.h
index a584147..1594cd5 100644
--- a/chrome/browser/process_singleton.h
+++ b/chrome/browser/process_singleton.h
@@ -20,7 +20,7 @@
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
-#include "base/process.h"
+#include "base/process/process.h"
#include "base/threading/non_thread_safe.h"
#include "ui/gfx/native_widget_types.h"
diff --git a/chrome/browser/process_singleton_browsertest.cc b/chrome/browser/process_singleton_browsertest.cc
index d5dc29d..ad09a1c 100644
--- a/chrome/browser/process_singleton_browsertest.cc
+++ b/chrome/browser/process_singleton_browsertest.cc
@@ -16,7 +16,9 @@
#include "base/files/scoped_temp_dir.h"
#include "base/memory/ref_counted.h"
#include "base/path_service.h"
-#include "base/process_util.h"
+#include "base/process/kill.h"
+#include "base/process/launch.h"
+#include "base/process/process_iterator.h"
#include "base/synchronization/waitable_event.h"
#include "base/test/test_timeouts.h"
#include "base/threading/thread.h"
diff --git a/chrome/browser/process_singleton_linux.cc b/chrome/browser/process_singleton_linux.cc
index 4aea4fd..fbba09f 100644
--- a/chrome/browser/process_singleton_linux.cc
+++ b/chrome/browser/process_singleton_linux.cc
@@ -65,7 +65,6 @@
#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
#include "base/posix/eintr_wrapper.h"
-#include "base/process_util.h"
#include "base/rand_util.h"
#include "base/safe_strerror_posix.h"
#include "base/sequenced_task_runner_helpers.h"
diff --git a/chrome/browser/process_singleton_linux_unittest.cc b/chrome/browser/process_singleton_linux_unittest.cc
index 5e62996..df20e0e 100644
--- a/chrome/browser/process_singleton_linux_unittest.cc
+++ b/chrome/browser/process_singleton_linux_unittest.cc
@@ -17,7 +17,6 @@
#include "base/files/file_path.h"
#include "base/files/scoped_temp_dir.h"
#include "base/message_loop/message_loop.h"
-#include "base/process_util.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/waitable_event.h"
#include "base/test/test_timeouts.h"
diff --git a/chrome/browser/process_singleton_win.cc b/chrome/browser/process_singleton_win.cc
index 94647c7..e82bf79 100644
--- a/chrome/browser/process_singleton_win.cc
+++ b/chrome/browser/process_singleton_win.cc
@@ -11,8 +11,8 @@
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
-#include "base/process_info.h"
-#include "base/process_util.h"
+#include "base/process/kill.h"
+#include "base/process/process_info.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
diff --git a/chrome/browser/profiles/profile_manager_unittest.cc b/chrome/browser/profiles/profile_manager_unittest.cc
index ca66dba..3b49eac 100644
--- a/chrome/browser/profiles/profile_manager_unittest.cc
+++ b/chrome/browser/profiles/profile_manager_unittest.cc
@@ -215,14 +215,14 @@
ASSERT_TRUE(profile2);
// Force lazy-init of some profile services to simulate use.
- profile1->CreateHistoryService(true, false);
+ ASSERT_TRUE(profile1->CreateHistoryService(true, false));
EXPECT_TRUE(HistoryServiceFactory::GetForProfile(profile1,
Profile::EXPLICIT_ACCESS));
profile1->CreateBookmarkModel(true);
EXPECT_TRUE(BookmarkModelFactory::GetForProfile(profile1));
profile2->CreateBookmarkModel(true);
EXPECT_TRUE(BookmarkModelFactory::GetForProfile(profile2));
- profile2->CreateHistoryService(true, false);
+ ASSERT_TRUE(profile2->CreateHistoryService(true, false));
EXPECT_TRUE(HistoryServiceFactory::GetForProfile(profile2,
Profile::EXPLICIT_ACCESS));
diff --git a/chrome/browser/renderer_host/pepper/pepper_flash_drm_host.cc b/chrome/browser/renderer_host/pepper/pepper_flash_drm_host.cc
index 98870a1..22f79d9 100644
--- a/chrome/browser/renderer_host/pepper/pepper_flash_drm_host.cc
+++ b/chrome/browser/renderer_host/pepper/pepper_flash_drm_host.cc
@@ -50,7 +50,6 @@
render_id_(render_id),
monitor_(NULL),
request_sent_(0) {
- GetMonitor();
}
int64_t GetMonitor() {
@@ -131,6 +130,7 @@
fetcher_ = new DeviceIDFetcher(render_process_id);
monitor_finder_ = new MonitorFinder(render_process_id, render_view_id);
+ monitor_finder_->GetMonitor();
}
PepperFlashDRMHost::~PepperFlashDRMHost() {
diff --git a/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc b/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc
index 2034b13..f48f404 100644
--- a/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc
+++ b/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc
@@ -3,7 +3,6 @@
// found in the LICENSE file.
#include "base/command_line.h"
-#include "base/process_util.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/devtools/devtools_window.h"
#include "chrome/browser/ui/browser.h"
diff --git a/chrome/browser/renderer_host/web_cache_manager_browsertest.cc b/chrome/browser/renderer_host/web_cache_manager_browsertest.cc
index 575a54d..a917ed5 100644
--- a/chrome/browser/renderer_host/web_cache_manager_browsertest.cc
+++ b/chrome/browser/renderer_host/web_cache_manager_browsertest.cc
@@ -5,7 +5,6 @@
#include <string>
#include "base/message_loop/message_loop.h"
-#include "base/process_util.h"
#include "chrome/browser/renderer_host/web_cache_manager.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
diff --git a/chrome/browser/resources/extensions/extensions.js b/chrome/browser/resources/extensions/extensions.js
index 10d092c..89bfa71 100644
--- a/chrome/browser/resources/extensions/extensions.js
+++ b/chrome/browser/resources/extensions/extensions.js
@@ -54,12 +54,16 @@
var toSend = null;
// Files lack a check if they're a directory, but we can find out through
// its item entry.
- var fileIndex = e.dataTransfer.types.indexOf('Files');
- if (e.dataTransfer.items[fileIndex].webkitGetAsEntry().isDirectory)
- toSend = 'installDroppedDirectory';
+ for (var i = 0; i < e.dataTransfer.items.length; ++i) {
+ if (e.dataTransfer.items[i].kind == 'file' &&
+ e.dataTransfer.items[i].webkitGetAsEntry().isDirectory) {
+ toSend = 'installDroppedDirectory';
+ break;
+ }
+ }
// Only process files that look like extensions. Other files should
// navigate the browser normally.
- else if (/\.(crx|user\.js)$/i.test(e.dataTransfer.files[0].name))
+ if (!toSend && /\.(crx|user\.js)$/i.test(e.dataTransfer.files[0].name))
toSend = 'installDroppedFile';
if (toSend) {
diff --git a/chrome/browser/resources/feedback.html b/chrome/browser/resources/feedback.html
index f25910c..b5ea6cc 100644
--- a/chrome/browser/resources/feedback.html
+++ b/chrome/browser/resources/feedback.html
@@ -7,8 +7,11 @@
<link rel="stylesheet" href="chrome://resources/css/chrome_shared.css">
<link rel="stylesheet" href="feedback.css">
+<script src="chrome://resources/js/cr.js"></script>
<script src="chrome://resources/js/load_time_data.js"></script>
<script src="chrome://resources/js/util.js"></script>
+<script src="chrome://resources/js/cr/ui.js"></script>
+<script src="chrome://resources/js/cr/ui/focus_manager.js"></script>
<script src="chrome://feedback/feedback.js"></script>
<script src="chrome://feedback/strings.js"></script>
</head>
diff --git a/chrome/browser/resources/feedback.js b/chrome/browser/resources/feedback.js
index 15d37ec..6cb16f6 100644
--- a/chrome/browser/resources/feedback.js
+++ b/chrome/browser/resources/feedback.js
@@ -280,6 +280,7 @@
* Window onload handler, sets up the page.
*/
function load() {
+ cr.ui.FocusManager.disableMouseFocusOnButtons();
if ($('attach-file'))
$('attach-file').addEventListener('change', onFileSelected);
diff --git a/chrome/browser/resources/file_manager/js/file_copy_manager.js b/chrome/browser/resources/file_manager/js/file_copy_manager.js
index fccce39..9fe76ce 100644
--- a/chrome/browser/resources/file_manager/js/file_copy_manager.js
+++ b/chrome/browser/resources/file_manager/js/file_copy_manager.js
@@ -746,12 +746,7 @@
}
self.sendProgressEvent_('PROGRESS');
-
- // We yield a few ms between copies to give the browser a chance to service
- // events (like perhaps the user clicking to cancel the copy, for example).
- setTimeout(function() {
- self.serviceNextCopyTaskEntry_(task, onEntryServiced, errorCallback);
- }, 10);
+ self.serviceNextCopyTaskEntry_(task, onEntryServiced, errorCallback);
};
this.serviceNextCopyTaskEntry_(task, onEntryServiced, errorCallback);
@@ -831,58 +826,12 @@
onError('FILESYSTEM_ERROR', err);
};
- /**
- * Resolves the immediate parent directory entry and the file name of a
- * given path, where the path is specified by a directory (not necessarily
- * the immediate parent) and a path (not necessarily the file name) related
- * to that directory. For instance,
- * Given:
- * |dirEntry| = DirectoryEntry('/root/dir1')
- * |relativePath| = 'dir2/file'
- *
- * Return:
- * |parentDirEntry| = DirectoryEntry('/root/dir1/dir2')
- * |fileName| = 'file'
- *
- * @param {DirectoryEntry} dirEntry A directory entry.
- * @param {string} relativePath A path relative to |dirEntry|.
- * @param {function(Entry,string)} successCallback A callback for returning
- * the |parentDirEntry| and |fileName| upon success.
- * @param {function(FileError)} errorCallback An error callback when there is
- * an error getting |parentDirEntry|.
- */
- var resolveDirAndBaseName = function(dirEntry, relativePath,
- successCallback, errorCallback) {
- // |intermediatePath| contains the intermediate path components
- // that are appended to |dirEntry| to form |parentDirEntry|.
- var intermediatePath = '';
- var fileName = relativePath;
-
- // Extract the file name component from |relativePath|.
- var index = relativePath.lastIndexOf('/');
- if (index != -1) {
- intermediatePath = relativePath.substr(0, index);
- fileName = relativePath.substr(index + 1);
- }
-
- if (intermediatePath == '') {
- successCallback(dirEntry, fileName);
- } else {
- dirEntry.getDirectory(intermediatePath,
- {create: false},
- function(entry) {
- successCallback(entry, fileName);
- },
- errorCallback);
- }
- };
-
var onDeduplicated = function(targetRelativePath) {
if (task.move) {
- resolveDirAndBaseName(
- targetDirEntry, targetRelativePath,
- function(dirEntry, fileName) {
- sourceEntry.moveTo(dirEntry, fileName,
+ targetDirEntry.getDirectory(
+ PathUtil.dirname(targetRelativePath), {create: false},
+ function(dirEntry) {
+ sourceEntry.moveTo(dirEntry, PathUtil.basename(targetRelativePath),
onFilesystemMoveComplete.bind(self, sourceEntry),
onFilesystemError);
},
@@ -960,12 +909,13 @@
};
if (task.sourceOnDrive && task.targetOnDrive) {
- resolveDirAndBaseName(
- targetDirEntry, targetRelativePath,
- function(dirEntry, fileName) {
+ targetDirEntry.getDirectory(
+ PathUtil.dirname(targetRelativePath), {create: false},
+ function(dirEntry) {
onStartTransfer();
- sourceEntry.copyTo(dirEntry, fileName, onSuccessTransfer,
- onFailTransfer);
+ sourceEntry.copyTo(
+ dirEntry, PathUtil.basename(targetRelativePath),
+ onSuccessTransfer, onFailTransfer);
},
onFilesystemError);
return;
diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js
index 029af9c..66cb272 100644
--- a/chrome/browser/resources/file_manager/js/file_manager.js
+++ b/chrome/browser/resources/file_manager/js/file_manager.js
@@ -637,13 +637,13 @@
var doc = this.document_;
- CommandUtil.registerCommand(doc, 'newfolder',
+ CommandUtil.registerCommand(this.dialogContainer_, 'newfolder',
Commands.newFolderCommand, this, this.directoryModel_);
- CommandUtil.registerCommand(doc, 'newwindow',
+ CommandUtil.registerCommand(this.dialogContainer_, 'newwindow',
Commands.newWindowCommand, this, this.directoryModel_);
- CommandUtil.registerCommand(doc, 'change-default-app',
+ CommandUtil.registerCommand(this.dialogContainer_, 'change-default-app',
Commands.changeDefaultAppCommand, this);
CommandUtil.registerCommand(this.volumeList_, 'unmount',
@@ -652,52 +652,58 @@
CommandUtil.registerCommand(this.volumeList_, 'import-photos',
Commands.importCommand, this.volumeList_);
- CommandUtil.registerCommand(doc, 'format',
+ CommandUtil.registerCommand(this.dialogContainer_, 'format',
Commands.formatCommand, this.volumeList_, this,
this.directoryModel_);
- CommandUtil.registerCommand(doc, 'delete',
+ CommandUtil.registerCommand(this.dialogContainer_, 'delete',
Commands.deleteFileCommand, this);
- CommandUtil.registerCommand(doc, 'rename',
+ CommandUtil.registerCommand(this.dialogContainer_, 'rename',
Commands.renameFileCommand, this);
- CommandUtil.registerCommand(doc, 'volume-help',
+ CommandUtil.registerCommand(this.dialogContainer_, 'volume-help',
Commands.volumeHelpCommand, this);
- CommandUtil.registerCommand(doc, 'drive-buy-more-space',
+ CommandUtil.registerCommand(this.dialogContainer_, 'drive-buy-more-space',
Commands.driveBuySpaceCommand, this);
- CommandUtil.registerCommand(doc, 'drive-clear-local-cache',
- Commands.driveClearCacheCommand, this);
+ CommandUtil.registerCommand(this.dialogContainer_,
+ 'drive-clear-local-cache', Commands.driveClearCacheCommand, this);
- CommandUtil.registerCommand(doc, 'drive-go-to-drive',
+ CommandUtil.registerCommand(this.dialogContainer_, 'drive-go-to-drive',
Commands.driveGoToDriveCommand, this);
- CommandUtil.registerCommand(doc, 'paste',
+ CommandUtil.registerCommand(this.dialogContainer_, 'paste',
Commands.pasteFileCommand, doc, this.fileTransferController_);
- CommandUtil.registerCommand(doc, 'open-with',
+ CommandUtil.registerCommand(this.dialogContainer_, 'open-with',
Commands.openWithCommand, this);
- CommandUtil.registerCommand(doc, 'toggle-pinned',
+ CommandUtil.registerCommand(this.dialogContainer_, 'toggle-pinned',
Commands.togglePinnedCommand, this);
- CommandUtil.registerCommand(doc, 'zip-selection',
+ CommandUtil.registerCommand(this.dialogContainer_, 'zip-selection',
Commands.zipSelectionCommand, this, this.directoryModel_);
- CommandUtil.registerCommand(doc, 'share', Commands.shareCommand, this);
- CommandUtil.registerCommand(doc, 'pin', Commands.pinCommand, this);
- CommandUtil.registerCommand(doc, 'unpin',
- Commands.unpinCommand, this, this.volumeList_);
+ CommandUtil.registerCommand(this.dialogContainer_, 'share',
+ Commands.shareCommand, this);
- CommandUtil.registerCommand(doc, 'search', Commands.searchCommand, this,
+ CommandUtil.registerCommand(this.dialogContainer_,
+ 'create-folder-shortcut', Commands.createFolderShortcutCommand, this);
+
+ CommandUtil.registerCommand(this.dialogContainer_,
+ 'remove-folder-shortcut', Commands.removeFolderShortcutCommand, this,
+ this.volumeList_);
+
+ CommandUtil.registerCommand(this.dialogContainer_, 'search',
+ Commands.searchCommand, this,
this.dialogDom_.querySelector('#search-box'));
// Register commands with CTRL-1..9 shortcuts for switching between
// volumes.
for (var i = 1; i <= 9; i++) {
- CommandUtil.registerCommand(doc,
+ CommandUtil.registerCommand(this.dialogContainer_,
'volume-switch-' + i,
Commands.volumeSwitchCommand,
this.volumeList_,
@@ -901,7 +907,7 @@
this.alert = new d.AlertDialog(this.dialogDom_);
this.confirm = new d.ConfirmDialog(this.dialogDom_);
this.prompt = new d.PromptDialog(this.dialogDom_);
- this.shareDialog_ = new ShareDialog(this.dialogDom_, this.metadataCache_);
+ this.shareDialog_ = new ShareDialog(this.dialogDom_);
this.defaultTaskPicker =
new cr.filebrowser.DefaultActionDialog(this.dialogDom_);
};
@@ -2241,31 +2247,30 @@
};
/**
- * Pin the selected folder.
+ * Creates a folder shortcut.
+ * @param {string} path A shortcut which refers to |path| to be created.
*/
- FileManager.prototype.pinSelection = function() {
- var entries = this.getSelection().entries;
- var entry = entries[0];
+ FileManager.prototype.createFolderShortcut = function(path) {
// Duplicate entry.
- if (this.isFolderPinned(entry.fullPath))
+ if (this.folderShortcutExists(path))
return;
- this.folderShortcutsModel_.add(entry.fullPath);
+ this.folderShortcutsModel_.add(path);
};
/**
- * Checkes if the folder is pinned or not.
+ * Checkes if the shortcut which refers to the given folder exists or not.
* @param {string} path Path of the folder to be checked.
*/
- FileManager.prototype.isFolderPinned = function(path) {
+ FileManager.prototype.folderShortcutExists = function(path) {
return this.folderShortcutsModel_.exists(path);
};
/**
- * Unpins the pinned folder.
- * @param {string} path Path of the pinned folder to be unpinnned.
+ * Removes the folder shortcut.
+ * @param {string} path The shortcut which refers to |path| is to be removed.
*/
- FileManager.prototype.unpinFolder = function(path) {
+ FileManager.prototype.removeFolderShortcut = function(path) {
this.folderShortcutsModel_.remove(path);
};
diff --git a/chrome/browser/resources/file_manager/js/file_manager_commands.js b/chrome/browser/resources/file_manager/js/file_manager_commands.js
index f8c8b8d..1cd279e 100644
--- a/chrome/browser/resources/file_manager/js/file_manager_commands.js
+++ b/chrome/browser/resources/file_manager/js/file_manager_commands.js
@@ -175,6 +175,7 @@
event.canExecute = (rootType == RootType.ARCHIVE ||
rootType == RootType.REMOVABLE);
+ event.command.setHidden(!event.canExecute);
event.command.label = rootType == RootType.ARCHIVE ?
str('CLOSE_ARCHIVE_BUTTON_LABEL') :
str('UNMOUNT_DEVICE_BUTTON_LABEL');
@@ -537,22 +538,22 @@
var selection = fileManager.getSelection();
event.canExecute = fileManager.isOnDrive() &&
!fileManager.isDriveOffline() &&
- selection && selection.totalCount == 1 &&
- selection.directoryCount == 0;
+ selection && selection.totalCount == 1;
event.command.setHidden(!fileManager.isOnDrive());
}
};
/**
- * Pins the selected folder (single only).
+ * Creates a shortcut of the selected folder (single only).
*/
-Commands.pinCommand = {
+Commands.createFolderShortcutCommand = {
/**
* @param {Event} event Command event.
* @param {FileManager} fileManager The file manager instance.
*/
execute: function(event, fileManager) {
- fileManager.pinSelection();
+ var entries = fileManager.getSelection().entries;
+ fileManager.createFolderShortcut(entries[0].fullPath);
},
/**
* @param {Event} event Command event.
@@ -570,15 +571,15 @@
var onlyOneFolderSelected =
selection && selection.directoryCount == 1 && selection.fileCount == 0;
event.canExecute = onlyOneFolderSelected &&
- !fileManager.isFolderPinned(selectionEntries[0].fullPath);
+ !fileManager.folderShortcutExists(selectionEntries[0].fullPath);
event.command.setHidden(!onlyOneFolderSelected);
}
};
/**
- * Unpin the pinned folder.
+ * Removes the folder shortcut.
*/
-Commands.unpinCommand = {
+Commands.removeFolderShortcutCommand = {
/**
* @param {Event} event Command event.
* @param {FileManager} fileManager The file manager instance.
@@ -588,7 +589,7 @@
var path = CommandUtil.getCommandRoot(event, directoryTree);
if (path)
- fileManager.unpinFolder(path);
+ fileManager.removeFolderShortcut(path);
},
/**
* @param {Event} event Command event.
@@ -603,9 +604,9 @@
}
var path = CommandUtil.getCommandRoot(event, directoryTree);
- var isPinned = path && !PathUtil.isRootPath(path);
- event.canExecute = isPinned;
- event.command.setHidden(!isPinned);
+ var isShortcut = path && fileManager.folderShortcutExists(path);
+ event.canExecute = isShortcut;
+ event.command.setHidden(!isShortcut);
}
};
diff --git a/chrome/browser/resources/file_manager/js/path_util.js b/chrome/browser/resources/file_manager/js/path_util.js
index db97d8f..d6561d4 100644
--- a/chrome/browser/resources/file_manager/js/path_util.js
+++ b/chrome/browser/resources/file_manager/js/path_util.js
@@ -114,6 +114,54 @@
};
/**
+ * Returns a directory part of the given |path|. In other words, the path
+ * without its base name.
+ *
+ * Examples:
+ * PathUtil.dirname('abc') -> ''
+ * PathUtil.dirname('a/b') -> 'a'
+ * PathUtil.dirname('a/b/') -> 'a/b'
+ * PathUtil.dirname('a/b/c') -> 'a/b'
+ * PathUtil.dirname('/') -> '/'
+ * PathUtil.dirname('/abc') -> '/'
+ * PathUtil.dirname('/abc/def') -> '/abc'
+ * PathUtil.dirname('') -> ''
+ *
+ * @param {string} path The path to be parsed.
+ * @return {string} The directory path.
+ */
+PathUtil.dirname = function(path) {
+ var index = path.lastIndexOf('/');
+ if (index < 0)
+ return '';
+ if (index == 0)
+ return '/';
+ return path.substring(0, index);
+};
+
+/**
+ * Returns the base name (the last component) of the given |path|. If the
+ * |path| ends with '/', returns an empty component.
+ *
+ * Examples:
+ * PathUtil.basename('abc') -> 'abc'
+ * PathUtil.basename('a/b') -> 'b'
+ * PathUtil.basename('a/b/') -> ''
+ * PathUtil.basename('a/b/c') -> 'c'
+ * PathUtil.basename('/') -> ''
+ * PathUtil.basename('/abc') -> 'abc'
+ * PathUtil.basename('/abc/def') -> 'def'
+ * PathUtil.basename('') -> ''
+ *
+ * @param {string} path The path to be parsed.
+ * @return {string} The base name.
+ */
+PathUtil.basename = function(path) {
+ var index = path.lastIndexOf('/');
+ return index >= 0 ? path.substring(index + 1) : path;
+};
+
+/**
* Join path components into a single path. Can be called either with a list of
* components as arguments, or with an array of components as the only argument.
*
diff --git a/chrome/browser/resources/file_manager/js/share_dialog.js b/chrome/browser/resources/file_manager/js/share_dialog.js
index 852912e..e05e0c5 100644
--- a/chrome/browser/resources/file_manager/js/share_dialog.js
+++ b/chrome/browser/resources/file_manager/js/share_dialog.js
@@ -6,15 +6,13 @@
/**
* @param {HTMLElement} parentNode Node to be parent for this dialog.
- * @param {MetadataCache} metadataCache Metadata cache.
* @constructor
* @extends {cr.ui.dialogs.BaseDialog}
* @implements {ShareClient.Observer}
*/
-function ShareDialog(parentNode, metadataCache) {
+function ShareDialog(parentNode) {
this.queue_ = new AsyncUtil.Queue();
this.onQueueTaskFinished_ = null;
- this.metadataCache_ = metadataCache;
this.shareClient_ = null;
this.spinner_ = null;
this.spinnerWrapper_ = null;
@@ -218,28 +216,44 @@
this.webView_.setAttribute('tabIndex', '-1');
this.webViewAuthorizer_ = new ShareDialog.WebViewAuthorizer(
ShareClient.SHARE_TARGET, this.webView_);
+ this.webView_.addEventListener('newwindow', function(e) {
+ // Discard the window object and reopen in an external window.
+ e.window.discard();
+ chrome.windows.create({url: e.targetUrl});
+ e.preventDefault();
+ });
cr.ui.dialogs.BaseDialog.prototype.show.call(this, '', null, null, null);
// Initialize and authorize the Web View tag asynchronously.
var group = new AsyncUtil.Group();
+
+ // Fetches an url to the sharing dialog.
+ var shareUrl;
+ var getShareUrlClosure = function(callback) {
+ chrome.fileBrowserPrivate.getShareUrl(
+ entry.toURL(),
+ function(inShareUrl) {
+ if (!chrome.runtime.lastError)
+ shareUrl = inShareUrl;
+ callback();
+ });
+ };
+
+ group.add(getShareUrlClosure);
group.add(this.webViewAuthorizer_.initialize.bind(this.webViewAuthorizer_));
group.add(this.webViewAuthorizer_.authorize.bind(this.webViewAuthorizer_));
+ // Loads the share widget once all the previous async calls are finished.
group.run(function() {
- // Loads the metadata and later the share widget.
- this.metadataCache_.get(entry, 'drive', function(metadata) {
- if (!metadata.shareUrl) {
- onError();
- return;
- }
- var shareUrl = metadata.shareUrl + '&embedOrigin=' +
- ShareClient.SHARE_ORIGIN;
- this.shareClient_ = new ShareClient(this.webView_,
- shareUrl,
- this);
- this.shareClient_.load();
- }.bind(this));
+ if (!shareUrl) {
+ onError();
+ return;
+ }
+ this.shareClient_ = new ShareClient(this.webView_,
+ shareUrl,
+ this);
+ this.shareClient_.load();
}.bind(this));
}.bind(this));
};
diff --git a/chrome/browser/resources/file_manager/main.html b/chrome/browser/resources/file_manager/main.html
index 91ac96d..91e3e46 100644
--- a/chrome/browser/resources/file_manager/main.html
+++ b/chrome/browser/resources/file_manager/main.html
@@ -133,8 +133,10 @@
<command id="rename" i18n-values="label:RENAME_BUTTON_LABEL"
shortcut="Enter-Ctrl">
<command id="delete" shortcut="U+007F">
- <command id="pin" i18n-values="label:PIN_FOLDER_BUTTON_LABEL">
- <command id="unpin" i18n-values="label:UNPIN_FOLDER_BUTTON_LABEL">
+ <command id="create-folder-shortcut"
+ i18n-values="label:CREATE_FOLDER_SHORTCUT_BUTTON_LABEL">
+ <command id="remove-folder-shortcut"
+ i18n-values="label:REMOVE_FOLDER_SHORTCUT_BUTTON_LABEL">
<command id="newfolder" i18n-values="label:NEW_FOLDER_BUTTON_LABEL"
shortcut="U+0045-Ctrl">
<command id="newwindow" i18n-values="label:NEW_WINDOW_BUTTON_LABEL">
@@ -186,7 +188,7 @@
<hr id="default-action-separator" visibleif="full-page" hidden>
<menuitem command="#toggle-pinned" checkable></menuitem>
<menuitem command="#share"></menuitem>
- <menuitem command="#pin"></menuitem>
+ <menuitem command="#create-folder-shortcut"></menuitem>
<hr command="#share">
<menuitem command="#cut" visibleif="full-page"></menuitem>
<menuitem command="#copy" visibleif="full-page"></menuitem>
@@ -203,7 +205,7 @@
<menuitem command="#import-photos"></menuitem>
<menuitem command="#unmount"></menuitem>
<menuitem command="#format"></menuitem>
- <menuitem command="#unpin"></menuitem>
+ <menuitem command="#remove-folder-shortcut"></menuitem>
</menu>
<menu id="gear-menu" class="chrome-menu" showShortcuts>
diff --git a/chrome/browser/resources/help/help.html b/chrome/browser/resources/help/help.html
index 40658fd..8e34d84 100644
--- a/chrome/browser/resources/help/help.html
+++ b/chrome/browser/resources/help/help.html
@@ -15,8 +15,9 @@
<script src="chrome://resources/js/cr.js"></script>
<script src="chrome://resources/js/load_time_data.js"></script>
<script src="chrome://resources/js/util.js"></script>
-<if expr="pp_ifdef('chromeos')">
<script src="chrome://resources/js/cr/ui.js"></script>
+ <script src="chrome://resources/js/cr/ui/focus_manager.js"></script>
+<if expr="pp_ifdef('chromeos')">
<script src="chrome://resources/js/cr/ui/bubble.js"></script>
<script src="chrome://resources/js/cr/ui/overlay.js"></script>
<script src="chrome://resources/js/event_tracker.js"></script>
diff --git a/chrome/browser/resources/help/help.js b/chrome/browser/resources/help/help.js
index a8f61bd..a7cb70e 100644
--- a/chrome/browser/resources/help/help.js
+++ b/chrome/browser/resources/help/help.js
@@ -143,6 +143,8 @@
};
}
+ cr.ui.FocusManager.disableMouseFocusOnButtons();
+
// Attempt to update.
chrome.send('onPageLoaded');
},
diff --git a/chrome/browser/resources/history/history.html b/chrome/browser/resources/history/history.html
index df5d8ea..6c82921 100644
--- a/chrome/browser/resources/history/history.html
+++ b/chrome/browser/resources/history/history.html
@@ -62,6 +62,12 @@
<body i18n-values=".style.fontFamily:fontfamily">
</if>
+<if expr="not is_android and not pp_ifdef('ios')">
+<div id="overlay" class="overlay" hidden>
+ <include src="alert_overlay.html">
+</div>
+</if>
+
<div id="history-page" class="page">
<header>
<h1 i18n-content="history"></h1>
@@ -139,11 +145,5 @@
<script src="chrome://history-frame/strings.js"></script>
<script src="chrome://resources/js/i18n_template2.js"></script>
-
-<if expr="not is_android and not pp_ifdef('ios')">
-<div id="overlay" class="overlay" hidden>
- <include src="alert_overlay.html">
-</div>
-</if>
</body>
</html>
diff --git a/chrome/browser/resources/history/history.js b/chrome/browser/resources/history/history.js
index b6eb19a..637dc78 100644
--- a/chrome/browser/resources/history/history.js
+++ b/chrome/browser/resources/history/history.js
@@ -3,6 +3,7 @@
// found in the LICENSE file.
<include src="../uber/uber_utils.js">
+<include src="history_focus_manager.js">
///////////////////////////////////////////////////////////////////////////////
// Globals:
@@ -1487,6 +1488,7 @@
cr.ui.overlay.setupOverlay($('overlay'));
cr.ui.overlay.globalInitialization();
}
+ HistoryFocusManager.getInstance().initialize();
var doSearch = function(e) {
recordUmaAction('HistoryPage_Search');
diff --git a/chrome/browser/resources/history/history_focus_manager.js b/chrome/browser/resources/history/history_focus_manager.js
new file mode 100644
index 0000000..540f331
--- /dev/null
+++ b/chrome/browser/resources/history/history_focus_manager.js
@@ -0,0 +1,25 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var FocusManager = cr.ui.FocusManager;
+
+/**
+ * A history-specific FocusManager implementation, which ensures that elements
+ * "background" pages (i.e., those in a dialog that is not the topmost overlay)
+ * do not receive focus.
+ * @constructor
+ */
+function HistoryFocusManager() {
+}
+
+cr.addSingletonGetter(HistoryFocusManager);
+
+HistoryFocusManager.prototype = {
+ __proto__: FocusManager.prototype,
+
+ /** @override */
+ getFocusParent: function() {
+ return document.querySelector('#overlay .showing') || $('history-page');
+ },
+};
diff --git a/chrome/browser/resources/inspect/inspect.js b/chrome/browser/resources/inspect/inspect.js
index 6920b3f..860bf67 100644
--- a/chrome/browser/resources/inspect/inspect.js
+++ b/chrome/browser/resources/inspect/inspect.js
@@ -2,15 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-function requestData() {
- var xhr = new XMLHttpRequest();
- xhr.open('GET', 'targets-data.json', false);
- xhr.send(null);
- if (xhr.status === 200)
- return JSON.parse(xhr.responseText);
- return [];
-}
-
function inspect(data) {
chrome.send('inspect', [data]);
}
@@ -38,8 +29,9 @@
tabHeader.addEventListener('click', selectTab.bind(null, tabContent.id));
$('navigation').appendChild(tabHeader);
}
- selectTab('devices-tab');
- populateLists();
+ var selectedTabName = window.location.hash.slice(1) || 'devices';
+ selectTab(selectedTabName + '-tab');
+ chrome.send('init-ui');
}
function selectTab(id) {
@@ -58,20 +50,15 @@
}
}
-function populateLists() {
- var data = requestData();
-
+function populateLists(data) {
removeChildren('pages');
removeChildren('extensions');
removeChildren('apps');
- removeChildren('workers');
removeChildren('others');
for (var i = 0; i < data.length; i++) {
if (data[i].type === 'page')
addToPagesList(data[i]);
- else if (data[i].type === 'worker')
- addToWorkersList(data[i]);
else if (data[i].type === 'extension')
addToExtensionsList(data[i]);
else if (data[i].type === 'app')
@@ -81,6 +68,13 @@
}
}
+function populateWorkersList(data) {
+ removeChildren('workers');
+
+ for (var i = 0; i < data.length; i++)
+ addToWorkersList(data[i]);
+}
+
function populateDeviceLists(pages) {
var pagesDigest = JSON.stringify(pages);
if (!pages || pagesDigest == window.pagesDigest)
diff --git a/chrome/browser/resources/sync_setup_overlay.js b/chrome/browser/resources/sync_setup_overlay.js
index ef4f619..80ca474 100644
--- a/chrome/browser/resources/sync_setup_overlay.js
+++ b/chrome/browser/resources/sync_setup_overlay.js
@@ -81,6 +81,9 @@
chrome.send('SyncSetupStopSyncing');
self.closeOverlay_();
};
+ $('sync-configure-content').onclick = function() {
+ self.onConfigurationClicked_();
+ };
},
showOverlay_: function() {
@@ -110,6 +113,29 @@
$('sync-custom-passphrase').hidden = !visible;
},
+ onConfigurationClicked_: function() {
+ // Avoid to foucus on labeled checkboxes and radio buttons.
+ // We don't want to show focus rings for them when labels are clicked.
+ if (event.target.tagName == 'INPUT')
+ return;
+ for (var node = event.target; node; node = node.parentNode) {
+ if (node.tagName != 'LABEL')
+ continue;
+ var control = node.control;
+ if (!control || control.disabled)
+ return;
+ if (control.type == 'checkbox') {
+ control.checked = !control.checked;
+ event.preventDefault();
+ } else if (control.type == 'radio') {
+ control.checked = !control.checked;
+ this.onEncryptionRadioChanged_();
+ event.preventDefault();
+ }
+ return;
+ }
+ },
+
/**
* Sets the checked state of the individual sync data type checkboxes in the
* advanced sync settings dialog.
diff --git a/chrome/browser/resources/translate_internals/translate_internals.css b/chrome/browser/resources/translate_internals/translate_internals.css
index 85b2ca3..6952cb5 100644
--- a/chrome/browser/resources/translate_internals/translate_internals.css
+++ b/chrome/browser/resources/translate_internals/translate_internals.css
@@ -41,16 +41,16 @@
white-space: pre-wrap;
}
-#prefs ul {
+#tabpanel-prefs ul {
list-style-type: none;
padding-left: 0;
}
-#prefs ul li {
+#tabpanel-prefs ul li {
width: 100%;
}
-#prefs ul li button {
+#tabpanel-prefs ul li button {
background-color: transparent;
border-style: solid;
border-width: 1px;
diff --git a/chrome/browser/resources/translate_internals/translate_internals.html b/chrome/browser/resources/translate_internals/translate_internals.html
index 53f1427..dcff99a 100644
--- a/chrome/browser/resources/translate_internals/translate_internals.html
+++ b/chrome/browser/resources/translate_internals/translate_internals.html
@@ -32,25 +32,25 @@
</tabs>
<tabpanels>
- <tabpanel id="prefs">
+ <tabpanel id="tabpanel-prefs">
<div>
<include src="prefs.html"/>
</div>
</tabpanel>
- <tabpanel id="detection-logs">
+ <tabpanel id="tabpanel-detection-logs">
<div>
<include src="detection_logs.html"/>
</div>
</tabpanel>
- <tabpanel id="error-logs">
+ <tabpanel id="tabpanel-error-logs">
<div>
<include src="error_logs.html"/>
</div>
</tabpanel>
- <tabpanel id="event-logs">
+ <tabpanel id="tabpanel-event-logs">
<div>
<include src="event_logs.html"/>
</div>
diff --git a/chrome/browser/resources/translate_internals/translate_internals.js b/chrome/browser/resources/translate_internals/translate_internals.js
index a0553a6..2774ff3 100644
--- a/chrome/browser/resources/translate_internals/translate_internals.js
+++ b/chrome/browser/resources/translate_internals/translate_internals.js
@@ -31,6 +31,36 @@
$('prefs-blocked-languages').hidden = true;
$('prefs-language-blacklist').querySelector('h2 span').hidden = true;
}
+
+ var tabpanelNodeList = document.getElementsByTagName('tabpanel');
+ var tabpanels = Array.prototype.slice.call(tabpanelNodeList, 0);
+ var tabpanelIds = tabpanels.map(function(tab) {
+ return tab.id;
+ });
+
+ var tabNodeList = document.getElementsByTagName('tab');
+ var tabs = Array.prototype.slice.call(tabNodeList, 0);
+ tabs.forEach(function(tab) {
+ tab.onclick = function(e) {
+ var tabbox = document.querySelector('tabbox');
+ var tabpanel = tabpanels[tabbox.selectedIndex];
+ var hash = tabpanel.id.match(/(?:^tabpanel-)(.+)/)[1];
+ window.location.hash = hash;
+ };
+ });
+
+ window.onhashchange = function(e) {
+ var hash = window.location.hash;
+
+ // Remove the first character '#'.
+ hash = hash.substring(1);
+
+ var id = 'tabpanel-' + hash;
+ if (tabpanelIds.indexOf(id) == -1)
+ return;
+
+ $(id).selected = true;
+ };
}
/**
@@ -299,7 +329,8 @@
contentTD.textContent = '';
contentTD.appendChild(div);
- var tbody = $('detection-logs').getElementsByTagName('tbody')[0];
+ var tabpanel = $('tabpanel-detection-logs');
+ var tbody = tabpanel.getElementsByTagName('tbody')[0];
tbody.appendChild(tr);
}
@@ -319,7 +350,8 @@
details['error'] + ': ' + formatTranslateErrorsType(details['error']),
'error-logs-error');
- var tbody = $('error-logs').getElementsByTagName('tbody')[0];
+ var tabpanel = $('tabpanel-error-logs');
+ var tbody = tabpanel.getElementsByTagName('tbody')[0];
tbody.appendChild(tr);
}
diff --git a/chrome/browser/resources/uber/uber_utils.js b/chrome/browser/resources/uber/uber_utils.js
index 763b556..5afc7e0 100644
--- a/chrome/browser/resources/uber/uber_utils.js
+++ b/chrome/browser/resources/uber/uber_utils.js
@@ -22,6 +22,10 @@
headerElements = document.getElementsByTagName('header');
document.addEventListener('scroll', handleScroll);
+ // Prevent the navigation from being stuck in a disabled state when a
+ // content page is reloaded while an overlay is visible (crbug.com/246939).
+ invokeMethodOnParent('stopInterceptingEvents');
+
// Trigger the scroll handler to tell the navigation if our page started
// with some scroll (happens when you use tab restore).
handleScroll();
diff --git a/chrome/browser/safe_browsing/browser_feature_extractor.cc b/chrome/browser/safe_browsing/browser_feature_extractor.cc
index 6cfb98f..ed8408d 100644
--- a/chrome/browser/safe_browsing/browser_feature_extractor.cc
+++ b/chrome/browser/safe_browsing/browser_feature_extractor.cc
@@ -118,7 +118,7 @@
if (redirect_chain[i].SchemeIsSecure()) {
printable_redirect = features::kSecureRedirectValue;
}
- AddFeature(base::StringPrintf("%s%s[%"PRIuS"]=%s",
+ AddFeature(base::StringPrintf("%s%s[%" PRIuS "]=%s",
feature_prefix.c_str(),
features::kRedirect,
i,
diff --git a/chrome/browser/safe_browsing/browser_feature_extractor_unittest.cc b/chrome/browser/safe_browsing/browser_feature_extractor_unittest.cc
index dce0cf5..c54c71c 100644
--- a/chrome/browser/safe_browsing/browser_feature_extractor_unittest.cc
+++ b/chrome/browser/safe_browsing/browser_feature_extractor_unittest.cc
@@ -51,7 +51,8 @@
protected:
virtual void SetUp() {
ChromeRenderViewHostTestHarness::SetUp();
- profile()->CreateHistoryService(true /* delete_file */, false /* no_db */);
+ ASSERT_TRUE(profile()->CreateHistoryService(
+ true /* delete_file */, false /* no_db */));
service_.reset(new StrictMock<MockClientSideDetectionService>());
extractor_.reset(
new BrowserFeatureExtractor(web_contents(), service_.get()));
diff --git a/chrome/browser/safe_browsing/malware_details_unittest.cc b/chrome/browser/safe_browsing/malware_details_unittest.cc
index 3e8ee59..f093426 100644
--- a/chrome/browser/safe_browsing/malware_details_unittest.cc
+++ b/chrome/browser/safe_browsing/malware_details_unittest.cc
@@ -188,7 +188,8 @@
virtual void SetUp() OVERRIDE {
ChromeRenderViewHostTestHarness::SetUp();
- profile()->CreateHistoryService(true /* delete_file */, false /* no_db */);
+ ASSERT_TRUE(profile()->CreateHistoryService(
+ true /* delete_file */, false /* no_db */));
}
virtual void TearDown() OVERRIDE {
diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc
index 5ed1bf9..5f4d322 100644
--- a/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <list>
+
#include "base/prefs/pref_service.h"
#include "base/run_loop.h"
#include "chrome/browser/profiles/profile.h"
diff --git a/chrome/browser/safe_browsing/safe_browsing_database.cc b/chrome/browser/safe_browsing/safe_browsing_database.cc
index f1339b3..9f43ecd 100644
--- a/chrome/browser/safe_browsing/safe_browsing_database.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_database.cc
@@ -12,7 +12,7 @@
#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram.h"
#include "base/metrics/stats_counters.h"
-#include "base/process_util.h"
+#include "base/process/process_metrics.h"
#include "base/time/time.h"
#include "chrome/browser/safe_browsing/prefix_set.h"
#include "chrome/browser/safe_browsing/safe_browsing_store_file.h"
diff --git a/chrome/browser/safe_browsing/safe_browsing_test.cc b/chrome/browser/safe_browsing/safe_browsing_test.cc
index 5d0d488..2333936 100644
--- a/chrome/browser/safe_browsing/safe_browsing_test.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_test.cc
@@ -20,7 +20,6 @@
#include "base/command_line.h"
#include "base/environment.h"
#include "base/path_service.h"
-#include "base/process_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/stringprintf.h"
diff --git a/chrome/browser/search_engines/template_url_service_unittest.cc b/chrome/browser/search_engines/template_url_service_unittest.cc
index a230386..42cd071 100644
--- a/chrome/browser/search_engines/template_url_service_unittest.cc
+++ b/chrome/browser/search_engines/template_url_service_unittest.cc
@@ -1148,7 +1148,7 @@
// KEYWORD visits.
TEST_F(TemplateURLServiceTest, GenerateVisitOnKeyword) {
test_util_.VerifyLoad();
- test_util_.profile()->CreateHistoryService(true, false);
+ ASSERT_TRUE(test_util_.profile()->CreateHistoryService(true, false));
// Create a keyword.
TemplateURL* t_url = AddKeywordWithDate(
diff --git a/chrome/browser/service/service_process_control.cc b/chrome/browser/service/service_process_control.cc
index 7c17a1f..9106178 100644
--- a/chrome/browser/service/service_process_control.cc
+++ b/chrome/browser/service/service_process_control.cc
@@ -8,7 +8,7 @@
#include "base/bind_helpers.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
-#include "base/process_util.h"
+#include "base/process/launch.h"
#include "base/stl_util.h"
#include "base/threading/thread.h"
#include "base/threading/thread_restrictions.h"
diff --git a/chrome/browser/service/service_process_control.h b/chrome/browser/service/service_process_control.h
index 5f79882..901be12 100644
--- a/chrome/browser/service/service_process_control.h
+++ b/chrome/browser/service/service_process_control.h
@@ -15,7 +15,7 @@
#include "base/id_map.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
-#include "base/process.h"
+#include "base/process/process.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "ipc/ipc_channel_proxy.h"
diff --git a/chrome/browser/service/service_process_control_browsertest.cc b/chrome/browser/service/service_process_control_browsertest.cc
index 5922b46..94293f5 100644
--- a/chrome/browser/service/service_process_control_browsertest.cc
+++ b/chrome/browser/service/service_process_control_browsertest.cc
@@ -4,7 +4,9 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
-#include "base/process_util.h"
+#include "base/process/kill.h"
+#include "base/process/process_handle.h"
+#include "base/process/process_iterator.h"
#include "base/test/test_timeouts.h"
#include "chrome/browser/service/service_process_control.h"
#include "chrome/browser/ui/browser.h"
diff --git a/chrome/browser/sessions/session_restore_browsertest.cc b/chrome/browser/sessions/session_restore_browsertest.cc
index 6154185..ba9fe9d 100644
--- a/chrome/browser/sessions/session_restore_browsertest.cc
+++ b/chrome/browser/sessions/session_restore_browsertest.cc
@@ -4,6 +4,7 @@
#include "base/command_line.h"
#include "base/files/file_path.h"
+#include "base/process/launch.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "chrome/browser/browser_process.h"
diff --git a/chrome/browser/shell_integration_linux.cc b/chrome/browser/shell_integration_linux.cc
index 536be8e..ffefa81 100644
--- a/chrome/browser/shell_integration_linux.cc
+++ b/chrome/browser/shell_integration_linux.cc
@@ -26,7 +26,8 @@
#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
#include "base/posix/eintr_wrapper.h"
-#include "base/process_util.h"
+#include "base/process/kill.h"
+#include "base/process/launch.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_tokenizer.h"
#include "base/strings/string_util.h"
diff --git a/chrome/browser/ssl/ssl_browser_tests.cc b/chrome/browser/ssl/ssl_browser_tests.cc
index cd45137..f9868fc 100644
--- a/chrome/browser/ssl/ssl_browser_tests.cc
+++ b/chrome/browser/ssl/ssl_browser_tests.cc
@@ -1292,7 +1292,7 @@
// - navigate to a bad HTTPS (expect unsafe content and filtered frame), then
// back
// - navigate to HTTP (expect insecure content), then back
-IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestGoodFrameNavigation) {
+IN_PROC_BROWSER_TEST_F(SSLUITest, TestGoodFrameNavigation) {
ASSERT_TRUE(test_server()->Start());
ASSERT_TRUE(https_server_.Start());
ASSERT_TRUE(https_server_expired_.Start());
diff --git a/chrome/browser/storage_monitor/storage_monitor_linux.cc b/chrome/browser/storage_monitor/storage_monitor_linux.cc
index f2154ed..29131c5 100644
--- a/chrome/browser/storage_monitor/storage_monitor_linux.cc
+++ b/chrome/browser/storage_monitor/storage_monitor_linux.cc
@@ -15,8 +15,8 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "base/metrics/histogram.h"
-#include "base/process.h"
-#include "base/process_util.h"
+#include "base/process/kill.h"
+#include "base/process/launch.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
diff --git a/chrome/browser/sync/test/integration/sync_test.cc b/chrome/browser/sync/test/integration/sync_test.cc
index ff6ed2c..061fcad 100644
--- a/chrome/browser/sync/test/integration/sync_test.cc
+++ b/chrome/browser/sync/test/integration/sync_test.cc
@@ -11,6 +11,7 @@
#include "base/command_line.h"
#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
+#include "base/process/launch.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
diff --git a/chrome/browser/sync/test/integration/sync_test.h b/chrome/browser/sync/test/integration/sync_test.h
index 720b4d4..0aae307 100644
--- a/chrome/browser/sync/test/integration/sync_test.h
+++ b/chrome/browser/sync/test/integration/sync_test.h
@@ -12,7 +12,6 @@
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
-#include "base/process_util.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "net/dns/mock_host_resolver.h"
#include "sync/internal_api/public/base/model_type.h"
diff --git a/chrome/browser/task_manager/browser_process_resource_provider.h b/chrome/browser/task_manager/browser_process_resource_provider.h
index 3759cc3..81ae797 100644
--- a/chrome/browser/task_manager/browser_process_resource_provider.h
+++ b/chrome/browser/task_manager/browser_process_resource_provider.h
@@ -7,7 +7,6 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
-#include "base/process_util.h"
#include "chrome/browser/task_manager/resource_provider.h"
#include "content/public/browser/browser_child_process_observer.h"
#include "content/public/browser/child_process_data.h"
diff --git a/chrome/browser/task_manager/os_resource_win.h b/chrome/browser/task_manager/os_resource_win.h
index f18000c..f04e59b 100644
--- a/chrome/browser/task_manager/os_resource_win.h
+++ b/chrome/browser/task_manager/os_resource_win.h
@@ -5,7 +5,7 @@
#ifndef CHROME_BROWSER_TASK_MANAGER_OS_RESOURCE_WIN_H_
#define CHROME_BROWSER_TASK_MANAGER_OS_RESOURCE_WIN_H_
-#include "base/process_util.h"
+#include "base/process/process_handle.h"
namespace task_manager {
diff --git a/chrome/browser/task_manager/resource_provider.h b/chrome/browser/task_manager/resource_provider.h
index 243730d..7d32009 100644
--- a/chrome/browser/task_manager/resource_provider.h
+++ b/chrome/browser/task_manager/resource_provider.h
@@ -7,7 +7,7 @@
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
-#include "base/process_util.h"
+#include "base/process/process_handle.h"
#include "base/strings/string16.h"
#include "third_party/WebKit/public/web/WebCache.h"
diff --git a/chrome/browser/task_manager/task_manager.cc b/chrome/browser/task_manager/task_manager.cc
index 3dbbb7f..1a9154a 100644
--- a/chrome/browser/task_manager/task_manager.cc
+++ b/chrome/browser/task_manager/task_manager.cc
@@ -8,7 +8,7 @@
#include "base/i18n/number_formatting.h"
#include "base/i18n/rtl.h"
#include "base/prefs/pref_registry_simple.h"
-#include "base/process_util.h"
+#include "base/process/process_metrics.h"
#include "base/rand_util.h"
#include "base/stl_util.h"
#include "base/strings/string16.h"
diff --git a/chrome/browser/task_manager/task_manager.h b/chrome/browser/task_manager/task_manager.h
index 7554747..80573e1 100644
--- a/chrome/browser/task_manager/task_manager.h
+++ b/chrome/browser/task_manager/task_manager.h
@@ -13,7 +13,6 @@
#include "base/memory/ref_counted.h"
#include "base/memory/singleton.h"
#include "base/observer_list.h"
-#include "base/process_util.h"
#include "base/strings/string16.h"
#include "base/timer/timer.h"
#include "chrome/browser/renderer_host/web_cache_manager.h"
diff --git a/chrome/browser/task_manager/task_manager_unittest.cc b/chrome/browser/task_manager/task_manager_unittest.cc
index 4af9c74..6b1d39c 100644
--- a/chrome/browser/task_manager/task_manager_unittest.cc
+++ b/chrome/browser/task_manager/task_manager_unittest.cc
@@ -7,7 +7,6 @@
#include <string>
#include "base/message_loop/message_loop.h"
-#include "base/process_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/task_manager/resource_provider.h"
#include "grit/chromium_strings.h"
diff --git a/chrome/browser/task_profiler/task_profiler_data_serializer_unittest.cc b/chrome/browser/task_profiler/task_profiler_data_serializer_unittest.cc
index 6d05fb1..8067b46 100644
--- a/chrome/browser/task_profiler/task_profiler_data_serializer_unittest.cc
+++ b/chrome/browser/task_profiler/task_profiler_data_serializer_unittest.cc
@@ -6,7 +6,7 @@
#include "base/basictypes.h"
#include "base/json/json_writer.h"
-#include "base/process_util.h"
+#include "base/process/process_handle.h"
#include "base/strings/string_number_conversions.h"
#include "base/tracked_objects.h"
#include "base/values.h"
diff --git a/chrome/browser/three_d_api_observer.cc b/chrome/browser/three_d_api_observer.cc
index f3976bf..5efe5cd 100644
--- a/chrome/browser/three_d_api_observer.cc
+++ b/chrome/browser/three_d_api_observer.cc
@@ -9,18 +9,15 @@
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/tab_contents/tab_util.h"
#include "content/public/browser/gpu_data_manager.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/common/three_d_api_types.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
-#include "url/gurl.h"
-// ThreeDAPIInfoBarDelegate ---------------------------------------------
+// ThreeDAPIInfoBarDelegate ---------------------------------------------------
class ThreeDAPIInfoBarDelegate : public ConfirmInfoBarDelegate {
public:
- // Creates a 3D API delegate and adds it to |infobar_service|.
+ // Creates a 3D API infobar delegate and adds it to |infobar_service|.
static void Create(InfoBarService* infobar_service,
const GURL& url,
content::ThreeDAPIType requester);
@@ -154,7 +151,7 @@
}
-// ThreeDAPIObserver ----------------------------------------------------
+// ThreeDAPIObserver ----------------------------------------------------------
ThreeDAPIObserver::ThreeDAPIObserver() {
content::GpuDataManager::GetInstance()->AddObserver(this);
diff --git a/chrome/browser/translate/translate_browsertest.cc b/chrome/browser/translate/translate_browsertest.cc
index 440d5c4..10ec0a3 100644
--- a/chrome/browser/translate/translate_browsertest.cc
+++ b/chrome/browser/translate/translate_browsertest.cc
@@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_TRANSLATE_TRANSLATE_BROWSERTEST_H_
-#define CHROME_BROWSER_TRANSLATE_TRANSLATE_BROWSERTEST_H_
-
#include "base/files/file_path.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -102,9 +99,9 @@
infobar.Wait();
// Perform Chrome Translate.
- InfoBarDelegate* delegate = infobar_service->infobar_at(0);
- ASSERT_TRUE(delegate);
- TranslateInfoBarDelegate* translate = delegate->AsTranslateInfoBarDelegate();
+ ASSERT_EQ(1U, infobar_service->infobar_count());
+ TranslateInfoBarDelegate* translate =
+ infobar_service->infobar_at(0)->AsTranslateInfoBarDelegate();
ASSERT_TRUE(translate);
translate->Translate();
@@ -291,5 +288,3 @@
// Check there is not infobar.
EXPECT_EQ(0U, infobar_service->infobar_count());
}
-
-#endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_BROWSERTEST_H_
diff --git a/chrome/browser/translate/translate_manager.cc b/chrome/browser/translate/translate_manager.cc
index 70d9210..057084e 100644
--- a/chrome/browser/translate/translate_manager.cc
+++ b/chrome/browser/translate/translate_manager.cc
@@ -84,10 +84,6 @@
} // namespace
TranslateManager::~TranslateManager() {
- // CleanupPendingUrlFetcher should be called ahead of destructing.
- DCHECK(language_list_.get() == NULL);
- DCHECK(script_.get() == NULL);
-
weak_method_factory_.InvalidateWeakPtrs();
}
@@ -638,7 +634,7 @@
NOTREACHED();
}
-void TranslateManager::CleanupPendingUrlFetcher() {
+void TranslateManager::CleanupPendingUlrFetcher() {
language_list_.reset();
script_.reset();
}
diff --git a/chrome/browser/translate/translate_manager.h b/chrome/browser/translate/translate_manager.h
index da673f7..8355ab1 100644
--- a/chrome/browser/translate/translate_manager.h
+++ b/chrome/browser/translate/translate_manager.h
@@ -92,7 +92,7 @@
// Allows caller to cleanup pending URLFetcher objects to make sure they
// get released in the appropriate thread... Mainly for tests.
- void CleanupPendingUrlFetcher();
+ void CleanupPendingUlrFetcher();
// Translates the page contents from |source_lang| to |target_lang|.
// The actual translation might be performed asynchronously if the translate
diff --git a/chrome/browser/ui/app_list/app_list_service.cc b/chrome/browser/ui/app_list/app_list_service.cc
index 8ae72eb..8120aae 100644
--- a/chrome/browser/ui/app_list/app_list_service.cc
+++ b/chrome/browser/ui/app_list/app_list_service.cc
@@ -7,7 +7,7 @@
#include "base/command_line.h"
#include "base/metrics/histogram.h"
#include "base/prefs/pref_registry_simple.h"
-#include "base/process_info.h"
+#include "base/process/process_info.h"
#include "base/strings/string_number_conversions.h"
#include "base/time/time.h"
#include "chrome/common/chrome_switches.h"
diff --git a/chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controller.cc b/chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controller.cc
index f699b37..11bdcca 100644
--- a/chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controller.cc
+++ b/chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controller.cc
@@ -55,7 +55,10 @@
BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH);
for (BrowserList::const_iterator it = ash_browser_list->begin();
it != ash_browser_list->end(); ++it) {
- if ((*it)->window()->GetNativeWindow() == window)
+ // During browser creation it is possible that this function is called
+ // before a browser got a window (see crbug.com/263563).
+ if ((*it)->window() &&
+ (*it)->window()->GetNativeWindow() == window)
return true;
}
return false;
diff --git a/chrome/browser/ui/ash/session_state_delegate_chromeos.cc b/chrome/browser/ui/ash/session_state_delegate_chromeos.cc
index faba973..790de57 100644
--- a/chrome/browser/ui/ash/session_state_delegate_chromeos.cc
+++ b/chrome/browser/ui/ash/session_state_delegate_chromeos.cc
@@ -8,6 +8,7 @@
#include "base/logging.h"
#include "chrome/browser/chromeos/login/screen_locker.h"
#include "chrome/browser/chromeos/login/user.h"
+#include "chrome/browser/chromeos/login/user_adding_screen.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/session_manager_client.h"
@@ -54,6 +55,11 @@
NOTIMPLEMENTED();
}
+bool SessionStateDelegateChromeos::IsUserSessionBlocked() const {
+ return !IsActiveUserSessionStarted() || IsScreenLocked() ||
+ chromeos::UserAddingScreen::Get()->IsRunning();
+}
+
const base::string16 SessionStateDelegateChromeos::GetUserDisplayName(
ash::MultiProfileIndex index) const {
DCHECK_LT(index, NumberOfLoggedInUsers());
diff --git a/chrome/browser/ui/ash/session_state_delegate_chromeos.h b/chrome/browser/ui/ash/session_state_delegate_chromeos.h
index 025713f..4ed4009 100644
--- a/chrome/browser/ui/ash/session_state_delegate_chromeos.h
+++ b/chrome/browser/ui/ash/session_state_delegate_chromeos.h
@@ -30,6 +30,7 @@
virtual bool IsScreenLocked() const OVERRIDE;
virtual void LockScreen() OVERRIDE;
virtual void UnlockScreen() OVERRIDE;
+ virtual bool IsUserSessionBlocked() const OVERRIDE;
virtual const base::string16 GetUserDisplayName(
ash::MultiProfileIndex index) const OVERRIDE;
virtual const std::string GetUserEmail(
diff --git a/chrome/browser/ui/ash/session_state_delegate_views.cc b/chrome/browser/ui/ash/session_state_delegate_views.cc
index d649ff3..a1389ca 100644
--- a/chrome/browser/ui/ash/session_state_delegate_views.cc
+++ b/chrome/browser/ui/ash/session_state_delegate_views.cc
@@ -46,6 +46,10 @@
void SessionStateDelegate::UnlockScreen() {
}
+bool SessionStateDelegate::IsUserSessionBlocked() const {
+ return false;
+}
+
const base::string16 SessionStateDelegate::GetUserDisplayName(
ash::MultiProfileIndex index) const {
NOTIMPLEMENTED();
diff --git a/chrome/browser/ui/ash/session_state_delegate_views.h b/chrome/browser/ui/ash/session_state_delegate_views.h
index 614b1c2..eae117e 100644
--- a/chrome/browser/ui/ash/session_state_delegate_views.h
+++ b/chrome/browser/ui/ash/session_state_delegate_views.h
@@ -27,6 +27,7 @@
virtual bool IsScreenLocked() const OVERRIDE;
virtual void LockScreen() OVERRIDE;
virtual void UnlockScreen() OVERRIDE;
+ virtual bool IsUserSessionBlocked() const OVERRIDE;
virtual const base::string16 GetUserDisplayName(
ash::MultiProfileIndex index) const OVERRIDE;
virtual const std::string GetUserEmail(
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
index a5e4030..2fe7f2f 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
@@ -2341,6 +2341,7 @@
is_submitting_(false),
choose_another_instrument_or_address_(false),
wallet_server_validation_recoverable_(true),
+ data_was_passed_back_(false),
autocheckout_state_(AUTOCHECKOUT_NOT_STARTED),
was_ui_latency_logged_(false),
deemphasized_render_view_(false) {
@@ -3213,6 +3214,7 @@
// Callback should be called as late as possible.
callback_.Run(&form_structure_, !wallet_items_ ? std::string() :
wallet_items_->google_transaction_id());
+ data_was_passed_back_ = true;
// This might delete us.
if (GetDialogType() == DIALOG_TYPE_REQUEST_AUTOCOMPLETE)
@@ -3409,6 +3411,9 @@
}
void AutofillDialogControllerImpl::MaybeShowCreditCardBubble() {
+ if (!data_was_passed_back_)
+ return;
+
if (newly_saved_card_) {
AutofillCreditCardBubbleController::ShowNewCardSavedBubble(
web_contents(), newly_saved_card_->TypeAndLastFourDigits());
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h
index eadf103..88e7429 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h
@@ -679,6 +679,9 @@
// recoverable.
bool wallet_server_validation_recoverable_;
+ // Whether |callback_| was Run() with a filled |form_structure_|.
+ bool data_was_passed_back_;
+
typedef std::map<AutofillFieldType,
std::pair<base::string16, base::string16> > TypeErrorInputMap;
typedef std::map<DialogSection, TypeErrorInputMap> WalletValidationErrors;
diff --git a/chrome/browser/ui/bookmarks/bookmark_prompt_controller_unittest.cc b/chrome/browser/ui/bookmarks/bookmark_prompt_controller_unittest.cc
index fa79f1b..169f451 100644
--- a/chrome/browser/ui/bookmarks/bookmark_prompt_controller_unittest.cc
+++ b/chrome/browser/ui/bookmarks/bookmark_prompt_controller_unittest.cc
@@ -65,8 +65,8 @@
TestingBrowserProcess::GetGlobal()->
SetBookmarkPromptController(new BookmarkPromptController);
BrowserWithTestWindowTest::SetUp();
- static_cast<TestingProfile*>(browser()->profile())->
- CreateHistoryService(true, false);
+ ASSERT_TRUE(static_cast<TestingProfile*>(browser()->profile())->
+ CreateHistoryService(true, false));
static_cast<TestingProfile*>(browser()->profile())->
BlockUntilHistoryIndexIsRefreshed();
// Simulate browser activation.
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 852fd4d..3020251 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -19,7 +19,7 @@
#include "base/metrics/histogram.h"
#include "base/path_service.h"
#include "base/prefs/pref_service.h"
-#include "base/process_info.h"
+#include "base/process/process_info.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
@@ -1194,6 +1194,10 @@
return unload_controller_->TabsNeedBeforeUnloadFired();
}
+void Browser::OverscrollUpdate(int delta_y) {
+ window_->OverscrollUpdate(delta_y);
+}
+
bool Browser::IsMouseLocked() const {
return fullscreen_controller_->IsMouseLocked();
}
diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h
index a26587d..2093f48 100644
--- a/chrome/browser/ui/browser.h
+++ b/chrome/browser/ui/browser.h
@@ -434,6 +434,7 @@
virtual void HandleKeyboardEvent(
content::WebContents* source,
const content::NativeWebKeyboardEvent& event) OVERRIDE;
+ virtual void OverscrollUpdate(int delta_y) OVERRIDE;
bool is_type_tabbed() const { return type_ == TYPE_TABBED; }
bool is_type_popup() const { return type_ == TYPE_POPUP; }
diff --git a/chrome/browser/ui/browser_unittest.cc b/chrome/browser/ui/browser_unittest.cc
index 27cb23f..ff86091 100644
--- a/chrome/browser/ui/browser_unittest.cc
+++ b/chrome/browser/ui/browser_unittest.cc
@@ -4,7 +4,6 @@
#include "chrome/browser/ui/browser.h"
-#include "base/process_util.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "content/public/browser/site_instance.h"
diff --git a/chrome/browser/ui/browser_window.h b/chrome/browser/ui/browser_window.h
index 6ce54f2..ac21b8f 100644
--- a/chrome/browser/ui/browser_window.h
+++ b/chrome/browser/ui/browser_window.h
@@ -355,6 +355,10 @@
const content::PasswordForm& form,
autofill::PasswordGenerator* password_generator) = 0;
+ // Invoked when the amount of vertical overscroll changes. |delta_y| is the
+ // amount of overscroll that has occured in the y-direction.
+ virtual void OverscrollUpdate(int delta_y) {}
+
protected:
friend void chrome::CloseAllBrowsers();
friend class BrowserView;
diff --git a/chrome/browser/ui/cocoa/hung_renderer_controller.mm b/chrome/browser/ui/cocoa/hung_renderer_controller.mm
index dc21d44..01b1ef9 100644
--- a/chrome/browser/ui/cocoa/hung_renderer_controller.mm
+++ b/chrome/browser/ui/cocoa/hung_renderer_controller.mm
@@ -8,7 +8,6 @@
#include "base/mac/bundle_locations.h"
#include "base/mac/mac_util.h"
-#include "base/process_util.h"
#include "base/strings/sys_string_conversions.h"
#include "chrome/browser/favicon/favicon_tab_helper.h"
#include "chrome/browser/ui/browser_dialogs.h"
diff --git a/chrome/browser/ui/extensions/app_metro_infobar_delegate_win.cc b/chrome/browser/ui/extensions/app_metro_infobar_delegate_win.cc
index 79bb302..a08aa86 100644
--- a/chrome/browser/ui/extensions/app_metro_infobar_delegate_win.cc
+++ b/chrome/browser/ui/extensions/app_metro_infobar_delegate_win.cc
@@ -24,11 +24,11 @@
#include "ui/base/l10n/l10n_util.h"
#include "win8/util/win8_util.h"
-namespace chrome {
-
// static
void AppMetroInfoBarDelegateWin::Create(
- Profile* profile, Mode mode, const std::string& extension_id) {
+ Profile* profile,
+ Mode mode,
+ const std::string& extension_id) {
DCHECK(win8::IsSingleWindowMetroMode());
DCHECK_EQ(mode == SHOW_APP_LIST, extension_id.empty());
@@ -38,12 +38,9 @@
profile, chrome::HOST_DESKTOP_TYPE_NATIVE);
// Create a new tab at about:blank, and add the infobar.
- content::OpenURLParams params(GURL(content::kAboutBlankURL),
- content::Referrer(),
- NEW_FOREGROUND_TAB,
- content::PAGE_TRANSITION_LINK,
- false);
- content::WebContents* web_contents = browser->OpenURL(params);
+ content::WebContents* web_contents = browser->OpenURL(content::OpenURLParams(
+ GURL(content::kAboutBlankURL), content::Referrer(), NEW_FOREGROUND_TAB,
+ content::PAGE_TRANSITION_LINK, false));
InfoBarService* info_bar_service =
InfoBarService::FromWebContents(web_contents);
info_bar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>(
@@ -111,13 +108,10 @@
bool AppMetroInfoBarDelegateWin::LinkClicked(
WindowOpenDisposition disposition) {
- content::OpenURLParams params(
+ web_contents()->OpenURL(content::OpenURLParams(
GURL("https://support.google.com/chrome/?p=ib_redirect_to_desktop"),
content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
- content::PAGE_TRANSITION_LINK, false);
- web_contents()->OpenURL(params);
+ content::PAGE_TRANSITION_LINK, false));
return false;
}
-
-} // namespace chrome
diff --git a/chrome/browser/ui/extensions/app_metro_infobar_delegate_win.h b/chrome/browser/ui/extensions/app_metro_infobar_delegate_win.h
index 3742f31..1f625f7 100644
--- a/chrome/browser/ui/extensions/app_metro_infobar_delegate_win.h
+++ b/chrome/browser/ui/extensions/app_metro_infobar_delegate_win.h
@@ -5,19 +5,13 @@
#ifndef CHROME_BROWSER_UI_EXTENSIONS_APP_METRO_INFOBAR_DELEGATE_WIN_H_
#define CHROME_BROWSER_UI_EXTENSIONS_APP_METRO_INFOBAR_DELEGATE_WIN_H_
-#include "base/strings/string16.h"
+#include <string>
+
#include "chrome/browser/infobars/confirm_infobar_delegate.h"
-#include "chrome/browser/infobars/infobar_service.h"
-#include "ui/base/window_open_disposition.h"
+class InfoBarService;
class Profile;
-namespace gfx {
-class Image;
-}
-
-namespace chrome {
-
// This infobar operates by opening a new tab on about:blank, showing an
// infobar offering to relaunch the browser in metro mode, and then relaunching
// in Desktop mode if confirmed.
@@ -28,16 +22,16 @@
LAUNCH_PACKAGED_APP
};
- // Creates an instance of the app metro infobar delegate, adds it to a new
- // browser tab, then activates Metro mode.
+ // Creates an app metro infobar delegate, adds it to a new browser tab, then
+ // activates Metro mode.
static void Create(Profile* profile,
Mode mode,
const std::string& extension_id);
private:
- explicit AppMetroInfoBarDelegateWin(InfoBarService* infobar_service,
- Mode mode,
- const std::string& extension_id);
+ AppMetroInfoBarDelegateWin(InfoBarService* infobar_service,
+ Mode mode,
+ const std::string& extension_id);
virtual ~AppMetroInfoBarDelegateWin();
// ConfirmInfoBarDelegate overrides:
@@ -55,6 +49,4 @@
DISALLOW_COPY_AND_ASSIGN(AppMetroInfoBarDelegateWin);
};
-} // namespace chrome
-
#endif // CHROME_BROWSER_UI_EXTENSIONS_APP_METRO_INFOBAR_DELEGATE_WIN_H_
diff --git a/chrome/browser/ui/gtk/hung_renderer_dialog_gtk.cc b/chrome/browser/ui/gtk/hung_renderer_dialog_gtk.cc
index c0ea1ac..5f76454 100644
--- a/chrome/browser/ui/gtk/hung_renderer_dialog_gtk.cc
+++ b/chrome/browser/ui/gtk/hung_renderer_dialog_gtk.cc
@@ -6,7 +6,6 @@
#include <gtk/gtk.h>
-#include "base/process_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/favicon/favicon_tab_helper.h"
#include "chrome/browser/ui/gtk/gtk_util.h"
diff --git a/chrome/browser/ui/hung_plugin_tab_helper.cc b/chrome/browser/ui/hung_plugin_tab_helper.cc
index 1428d1a..da038fa 100644
--- a/chrome/browser/ui/hung_plugin_tab_helper.cc
+++ b/chrome/browser/ui/hung_plugin_tab_helper.cc
@@ -7,8 +7,7 @@
#include "base/bind.h"
#include "base/files/file_path.h"
#include "base/memory/scoped_ptr.h"
-#include "base/process.h"
-#include "base/process_util.h"
+#include "base/process/process.h"
#include "base/rand_util.h"
#include "build/build_config.h"
#include "chrome/browser/chrome_notification_types.h"
diff --git a/chrome/browser/ui/libgtk2ui/select_file_dialog_impl_kde.cc b/chrome/browser/ui/libgtk2ui/select_file_dialog_impl_kde.cc
index dd329b0..717e9d7 100644
--- a/chrome/browser/ui/libgtk2ui/select_file_dialog_impl_kde.cc
+++ b/chrome/browser/ui/libgtk2ui/select_file_dialog_impl_kde.cc
@@ -10,7 +10,7 @@
#include "base/logging.h"
#include "base/nix/mime_util_xdg.h"
#include "base/nix/xdg_util.h"
-#include "base/process_util.h"
+#include "base/process/launch.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
diff --git a/chrome/browser/ui/omnibox/alternate_nav_infobar_delegate.cc b/chrome/browser/ui/omnibox/alternate_nav_infobar_delegate.cc
index 0002aec..ba9fc0a 100644
--- a/chrome/browser/ui/omnibox/alternate_nav_infobar_delegate.cc
+++ b/chrome/browser/ui/omnibox/alternate_nav_infobar_delegate.cc
@@ -11,6 +11,7 @@
#include "grit/theme_resources.h"
#include "ui/base/l10n/l10n_util.h"
+
// static
void AlternateNavInfoBarDelegate::Create(InfoBarService* infobar_service,
const GURL& alternate_nav_url) {
diff --git a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
index 88dd32e..c110148 100644
--- a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
+++ b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
@@ -320,7 +320,6 @@
entry.visit_count,
entry.typed_count, time, false,
history::SOURCE_BROWSED);
- history_service->SetPageContents(url, UTF8ToUTF16(entry.body));
if (entry.starred)
bookmark_utils::AddIfNotBookmarked(bookmark_model, url, string16());
// Wait at least for the AddPageWithDetails() call to finish.
diff --git a/chrome/browser/ui/sad_tab.h b/chrome/browser/ui/sad_tab.h
index e2932a2..e22b149 100644
--- a/chrome/browser/ui/sad_tab.h
+++ b/chrome/browser/ui/sad_tab.h
@@ -5,7 +5,7 @@
#ifndef CHROME_BROWSER_UI_SAD_TAB_H_
#define CHROME_BROWSER_UI_SAD_TAB_H_
-#include "base/process_util.h"
+#include "base/process/kill.h"
#include "chrome/browser/ui/sad_tab_types.h"
namespace content {
diff --git a/chrome/browser/ui/search/instant_ntp.h b/chrome/browser/ui/search/instant_ntp.h
index 0505f25..93870ff 100644
--- a/chrome/browser/ui/search/instant_ntp.h
+++ b/chrome/browser/ui/search/instant_ntp.h
@@ -11,7 +11,6 @@
#include "base/compiler_specific.h"
#include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h"
-#include "base/process_util.h"
#include "chrome/browser/ui/search/instant_loader.h"
#include "chrome/browser/ui/search/instant_page.h"
diff --git a/chrome/browser/ui/startup/google_api_keys_infobar_delegate.cc b/chrome/browser/ui/startup/google_api_keys_infobar_delegate.cc
index 00ed8ab..42f1d55 100644
--- a/chrome/browser/ui/startup/google_api_keys_infobar_delegate.cc
+++ b/chrome/browser/ui/startup/google_api_keys_infobar_delegate.cc
@@ -11,6 +11,7 @@
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
+
// static
void GoogleApiKeysInfoBarDelegate::Create(InfoBarService* infobar_service) {
if (google_apis::HasKeysConfigured())
@@ -42,12 +43,10 @@
bool GoogleApiKeysInfoBarDelegate::LinkClicked(
WindowOpenDisposition disposition) {
- web_contents()->OpenURL(
- content::OpenURLParams(
- GURL("http://www.chromium.org/developers/how-tos/api-keys"),
- content::Referrer(),
- (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
- content::PAGE_TRANSITION_LINK,
- false));
+ web_contents()->OpenURL(content::OpenURLParams(
+ GURL("http://www.chromium.org/developers/how-tos/api-keys"),
+ content::Referrer(),
+ (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
+ content::PAGE_TRANSITION_LINK, false));
return false;
}
diff --git a/chrome/browser/ui/startup/google_api_keys_infobar_delegate.h b/chrome/browser/ui/startup/google_api_keys_infobar_delegate.h
index 6b01f78..dad3bf5 100644
--- a/chrome/browser/ui/startup/google_api_keys_infobar_delegate.h
+++ b/chrome/browser/ui/startup/google_api_keys_infobar_delegate.h
@@ -15,7 +15,7 @@
// An infobar that is run with a string and a "Learn More" link.
class GoogleApiKeysInfoBarDelegate : public ConfirmInfoBarDelegate {
public:
- // If Google API keys are missing, creates a missing Google API Keys info bar
+ // If Google API keys are missing, creates a missing Google API Keys infobar
// delegate and adds it to |infobar_service|.
static void Create(InfoBarService* infobar_service);
diff --git a/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc b/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc
index 1126df4..55b3633 100644
--- a/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc
+++ b/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc
@@ -180,8 +180,7 @@
StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run);
// This should create a new window, but re-use the profile from |popup|. If
// it used a NULL or invalid profile, it would crash.
- launch.OpenURLsInBrowser(popup, false, urls,
- chrome::HOST_DESKTOP_TYPE_NATIVE);
+ launch.OpenURLsInBrowser(popup, false, urls, chrome::GetActiveDesktop());
ASSERT_NE(popup, observer.added_browser_);
BrowserList::RemoveObserver(&observer);
}
diff --git a/chrome/browser/ui/sync/one_click_signin_sync_starter.cc b/chrome/browser/ui/sync/one_click_signin_sync_starter.cc
index d5c232a..298f887 100644
--- a/chrome/browser/ui/sync/one_click_signin_sync_starter.cc
+++ b/chrome/browser/ui/sync/one_click_signin_sync_starter.cc
@@ -357,24 +357,10 @@
}
void OneClickSigninSyncStarter::SigninSuccess() {
- // Before handing control back to sync setup, update the auth error state of
- // ProfileSyncService if needed. This is necessary because ProfileSyncService
- // will normally update its auth error state only after attempting a sync
- // cycle, and we do not want old auth errors to remain visible on the menu or
- // the settings page.
- // TODO(rsimha): We shouldn't have to do this here. PSS must update its auth
- // state after the backend is inititialized if it waiting_for_auth() is true.
- ProfileSyncService* profile_sync_service = GetProfileSyncService();
- if (profile_sync_service &&
- profile_sync_service->GetAuthError().state() !=
- GoogleServiceAuthError::NONE) {
- profile_sync_service->UpdateAuthErrorState(
- GoogleServiceAuthError::AuthErrorNone());
- }
-
switch (start_mode_) {
case SYNC_WITH_DEFAULT_SETTINGS: {
// Just kick off the sync machine, no need to configure it first.
+ ProfileSyncService* profile_sync_service = GetProfileSyncService();
if (profile_sync_service)
profile_sync_service->SetSyncSetupCompleted();
FinishProfileSyncServiceSetup();
diff --git a/chrome/browser/ui/sync/profile_signin_confirmation_helper_unittest.cc b/chrome/browser/ui/sync/profile_signin_confirmation_helper_unittest.cc
index e815d38..0fc79ad 100644
--- a/chrome/browser/ui/sync/profile_signin_confirmation_helper_unittest.cc
+++ b/chrome/browser/ui/sync/profile_signin_confirmation_helper_unittest.cc
@@ -138,7 +138,7 @@
profile_->CreateBookmarkModel(true);
model_ = BookmarkModelFactory::GetForProfile(profile_.get());
ui_test_utils::WaitForBookmarkModelToLoad(model_);
- profile_->CreateHistoryService(true, false);
+ ASSERT_TRUE(profile_->CreateHistoryService(true, false));
extensions::TestExtensionSystem* system =
static_cast<extensions::TestExtensionSystem*>(
extensions::ExtensionSystem::Get(profile_.get()));
diff --git a/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc b/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc
index 4f2af32..9339fbe 100644
--- a/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc
+++ b/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc
@@ -497,7 +497,7 @@
// Test asynchronous loading of favicon from history service.
TEST_F(BackFwdMenuModelTest, FaviconLoadTest) {
- profile()->CreateHistoryService(true, false);
+ ASSERT_TRUE(profile()->CreateHistoryService(true, false));
profile()->CreateFaviconService();
Browser::CreateParams native_params(profile(), chrome::GetActiveDesktop());
scoped_ptr<Browser> browser(
diff --git a/chrome/browser/ui/views/app_list/app_list_controller_win.cc b/chrome/browser/ui/views/app_list/app_list_controller_win.cc
index 6bbb595..6028f1a 100644
--- a/chrome/browser/ui/views/app_list/app_list_controller_win.cc
+++ b/chrome/browser/ui/views/app_list/app_list_controller_win.cc
@@ -513,9 +513,8 @@
if (win8::IsSingleWindowMetroMode()) {
// This request came from Windows 8 in desktop mode, but chrome is currently
// running in Metro mode.
- chrome::AppMetroInfoBarDelegateWin::Create(
- requested_profile,
- chrome::AppMetroInfoBarDelegateWin::SHOW_APP_LIST,
+ AppMetroInfoBarDelegateWin::Create(
+ requested_profile, AppMetroInfoBarDelegateWin::SHOW_APP_LIST,
std::string());
return;
}
diff --git a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
index 29dda7c..a376e94 100644
--- a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
+++ b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
@@ -78,7 +78,10 @@
const int kNotificationPadding = 14;
// Vertical padding above and below each detail section (in pixels).
-const int kDetailSectionInset = 10;
+const int kDetailSectionVerticalPadding = 10;
+
+// Horizontal padding before each detail section (in pixels).
+const int kDetailSectionIndent = 20;
const int kAutocheckoutStepsAreaPadding = 28;
const int kAutocheckoutStepInset = 20;
@@ -98,11 +101,10 @@
// A border color for the legal document view.
SkColor kSubtleBorderColor = SkColorSetARGB(10, 0, 0, 0);
-// The top padding, in pixels, for the suggestions menu dropdown arrows.
-const int kMenuButtonTopOffset = 5;
-
-// The side padding, in pixels, for the suggestions menu dropdown arrows.
-const int kMenuButtonHorizontalPadding = 20;
+// The top and bottom padding, in pixels, for the suggestions menu dropdown
+// arrows.
+const int kMenuButtonTopInset = 3;
+const int kMenuButtonBottomInset = 6;
// The padding around text in the overlay view.
const int kOverlayTextPadding = 20;
@@ -122,21 +124,6 @@
typedef ui::MultiAnimation::Part Part;
typedef ui::MultiAnimation::Parts Parts;
-views::Border* CreateLabelAlignmentBorder() {
- // TODO(estade): this should be made to match the native textfield top
- // inset. It's hard to get at, so for now it's hard-coded.
- return views::Border::CreateEmptyBorder(4, 0, 0, 0);
-}
-
-// Returns a label that describes a details section.
-views::Label* CreateDetailsSectionLabel(const string16& text) {
- views::Label* label = new views::Label(text);
- label->SetHorizontalAlignment(gfx::ALIGN_RIGHT);
- label->SetFont(label->font().DeriveFont(0, gfx::Font::BOLD));
- label->set_border(CreateLabelAlignmentBorder());
- return label;
-}
-
// Draws an arrow at the top of |canvas| pointing to |tip_x|.
void DrawArrow(gfx::Canvas* canvas, int tip_x, const SkColor& color) {
const int arrow_half_width = kArrowWidth / 2.0f;
@@ -844,31 +831,43 @@
forward_mouse_events_(false) {
set_notify_enter_exit_on_child(true);
- views::GridLayout* layout = new views::GridLayout(this);
- layout->SetInsets(kDetailSectionInset, 0, kDetailSectionInset, 0);
- SetLayoutManager(layout);
+ set_border(views::Border::CreateEmptyBorder(kDetailSectionVerticalPadding,
+ kDetailSectionIndent,
+ kDetailSectionVerticalPadding,
+ kDetailSectionIndent));
+ views::Label* label_view = new views::Label(label);
+ label_view->SetHorizontalAlignment(gfx::ALIGN_LEFT);
+
+ views::View* label_bar = new views::View();
+ views::GridLayout* label_bar_layout = new views::GridLayout(label_bar);
+ label_bar->SetLayoutManager(label_bar_layout);
const int kColumnSetId = 0;
- views::ColumnSet* column_set = layout->AddColumnSet(kColumnSetId);
- // TODO(estade): pull out these constants, and figure out better values
- // for them.
- column_set->AddColumn(views::GridLayout::FILL,
- views::GridLayout::LEADING,
- 0,
- views::GridLayout::FIXED,
- 180,
- 0);
- column_set->AddPaddingColumn(0, 30);
- column_set->AddColumn(views::GridLayout::FILL,
- views::GridLayout::LEADING,
- 0,
- views::GridLayout::FIXED,
- 300,
- 0);
+ views::ColumnSet* columns = label_bar_layout->AddColumnSet(kColumnSetId);
+ // TODO(estade): do something about this '480'.
+ columns->AddColumn(views::GridLayout::LEADING,
+ views::GridLayout::LEADING,
+ 0,
+ views::GridLayout::FIXED,
+ 480,
+ 0);
+ columns->AddColumn(views::GridLayout::LEADING,
+ views::GridLayout::LEADING,
+ 0,
+ views::GridLayout::USE_PREF,
+ 0,
+ 0);
+ label_bar_layout->StartRow(0, kColumnSetId);
+ label_bar_layout->AddView(label_view);
+ label_bar_layout->AddView(proxy_button);
+ // TODO(estade): Make this the correct color, also sometimes hide the border.
+ label_bar->set_border(
+ views::Border::CreateSolidSidedBorder(0, 0, 1, 0, SK_ColorLTGRAY));
- layout->StartRow(0, kColumnSetId);
- layout->AddView(CreateDetailsSectionLabel(label));
- layout->AddView(controls);
+ // TODO(estade): do something about this '7'.
+ SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 7));
+ AddChildView(label_bar);
+ AddChildView(controls);
}
AutofillDialogViews::SectionContainer::~SectionContainer() {}
@@ -956,7 +955,6 @@
new DecoratedTextfield(string16(), string16(), autofill_dialog)) {
// Label and icon.
label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
- label_->set_border(CreateLabelAlignmentBorder());
label_container_->AddChildView(icon_);
label_container_->AddChildView(label_);
label_container_->AddChildView(decorated_);
@@ -1725,31 +1723,11 @@
controller_->LabelForSection(section),
inputs_container,
group->suggested_button);
+ DCHECK(group->suggested_button->parent());
UpdateDetailsGroupState(*group);
}
views::View* AutofillDialogViews::CreateInputsContainer(DialogSection section) {
- views::View* inputs_container = new views::View();
- views::GridLayout* layout = new views::GridLayout(inputs_container);
- inputs_container->SetLayoutManager(layout);
-
- int kColumnSetId = 0;
- views::ColumnSet* column_set = layout->AddColumnSet(kColumnSetId);
- column_set->AddColumn(views::GridLayout::FILL,
- views::GridLayout::LEADING,
- 1,
- views::GridLayout::USE_PREF,
- 0,
- 0);
- // A column for the menu button.
- column_set->AddColumn(views::GridLayout::CENTER,
- views::GridLayout::LEADING,
- 0,
- views::GridLayout::USE_PREF,
- 0,
- 0);
- layout->StartRow(0, kColumnSetId);
-
// The |info_view| holds |manual_inputs| and |suggested_info|, allowing the
// dialog to toggle which is shown.
views::View* info_view = new views::View();
@@ -1761,8 +1739,9 @@
SuggestionView* suggested_info =
new SuggestionView(controller_->EditSuggestionText(), this);
info_view->AddChildView(suggested_info);
- layout->AddView(info_view);
+ // TODO(estade): It might be slightly more OO if this button were created
+ // and listened to by the section container.
views::ImageButton* menu_button = new views::ImageButton(this);
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
menu_button->SetImage(views::Button::STATE_NORMAL,
@@ -1774,17 +1753,16 @@
menu_button->SetImage(views::Button::STATE_DISABLED,
rb.GetImageSkiaNamed(IDR_AUTOFILL_DIALOG_MENU_BUTTON_D));
menu_button->set_border(views::Border::CreateEmptyBorder(
- kMenuButtonTopOffset,
- kMenuButtonHorizontalPadding,
- 0,
- kMenuButtonHorizontalPadding));
- layout->AddView(menu_button);
+ kMenuButtonTopInset,
+ kDetailSectionIndent,
+ kMenuButtonBottomInset,
+ 0));
DetailsGroup* group = GroupForSection(section);
group->suggested_button = menu_button;
group->manual_input = manual_inputs;
group->suggested_info = suggested_info;
- return inputs_container;
+ return info_view;
}
// TODO(estade): we should be using Chrome-style constrained window padding
diff --git a/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc b/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc
index 09951a3..11103c1 100644
--- a/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc
+++ b/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/process_util.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/chrome_notification_types.h"
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc b/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc
index 98f40fc..67491f6 100644
--- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc
+++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc
@@ -264,28 +264,50 @@
}
bool BrowserNonClientFrameViewAsh::HitTestRect(const gfx::Rect& rect) const {
+ if (!views::View::HitTestRect(rect)) {
+ // |rect| is outside BrowserNonClientFrameViewAsh's bounds.
+ return false;
+ }
// If the rect is outside the bounds of the client area, claim it.
- if (NonClientFrameView::HitTestRect(rect))
+ // TODO(tdanderson): Implement View::ConvertRectToTarget().
+ gfx::Point rect_in_client_view_coords_origin(rect.origin());
+ View::ConvertPointToTarget(this, frame()->client_view(),
+ &rect_in_client_view_coords_origin);
+ gfx::Rect rect_in_client_view_coords(
+ rect_in_client_view_coords_origin, rect.size());
+ if (!frame()->client_view()->HitTestRect(rect_in_client_view_coords))
return true;
- // Otherwise claim it only if it's in a non-tab portion of the tabstrip.
- if (!browser_view()->tabstrip())
- return false;
- gfx::Rect tabstrip_bounds(browser_view()->tabstrip()->bounds());
- gfx::Point tabstrip_origin(tabstrip_bounds.origin());
- View::ConvertPointToTarget(frame()->client_view(), this, &tabstrip_origin);
- tabstrip_bounds.set_origin(tabstrip_origin);
- if (rect.bottom() > tabstrip_bounds.bottom())
+ // Otherwise, claim |rect| only if it is above the bottom of the tabstrip in
+ // a non-tab portion.
+ TabStrip* tabstrip = browser_view()->tabstrip();
+ if (!tabstrip || !browser_view()->IsTabStripVisible())
return false;
- // We convert from our parent's coordinates since we assume we fill its bounds
- // completely. We need to do this since we're not a parent of the tabstrip,
- // meaning ConvertPointToTarget would otherwise return something bogus.
- // TODO(tdanderson): Initialize |browser_view_point| using |rect| instead of
- // its center point once GetEventHandlerForRect() is implemented.
- gfx::Point browser_view_point(rect.CenterPoint());
- View::ConvertPointToTarget(parent(), browser_view(), &browser_view_point);
- return browser_view()->IsPositionInWindowCaption(browser_view_point);
+ gfx::Point rect_in_tabstrip_coords_origin(rect.origin());
+ View::ConvertPointToTarget(this, tabstrip,
+ &rect_in_tabstrip_coords_origin);
+ gfx::Rect rect_in_tabstrip_coords(rect_in_tabstrip_coords_origin,
+ rect.size());
+
+ if (rect_in_tabstrip_coords.bottom() > tabstrip->GetLocalBounds().bottom()) {
+ // |rect| is below the tabstrip.
+ return false;
+ }
+
+ if (tabstrip->HitTestRect(rect_in_tabstrip_coords)) {
+ // Claim |rect| if it is in a non-tab portion of the tabstrip.
+ // TODO(tdanderson): Pass |rect_in_tabstrip_coords| instead of its center
+ // point to TabStrip::IsPositionInWindowCaption() once
+ // GetEventHandlerForRect() is implemented.
+ return tabstrip->IsPositionInWindowCaption(
+ rect_in_tabstrip_coords.CenterPoint());
+ }
+
+ // We claim |rect| because it is above the bottom of the tabstrip, but
+ // not in the tabstrip. In particular, the window controls are right of
+ // the tabstrip.
+ return true;
}
void BrowserNonClientFrameViewAsh::GetAccessibleState(
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index 7e7add1..5093269 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -608,17 +608,6 @@
return *GetThemeProvider()->GetImageSkiaNamed(GetOTRIconResourceID());
}
-bool BrowserView::IsPositionInWindowCaption(const gfx::Point& point) {
- if (window_switcher_button_) {
- gfx::Point window_switcher_point(point);
- views::View::ConvertPointToTarget(this, window_switcher_button_,
- &window_switcher_point);
- if (window_switcher_button_->HitTestPoint(window_switcher_point))
- return false;
- }
- return GetBrowserViewLayout()->IsPositionInWindowCaption(point);
-}
-
///////////////////////////////////////////////////////////////////////////////
// BrowserView, BrowserWindow implementation:
@@ -1791,7 +1780,7 @@
// overlapping tabs.
for (int i = 0; i < child_count(); ++i) {
View* child = child_at(i);
- if (child != infobar_container_)
+ if (child != infobar_container_ && !child->layer())
child->Paint(canvas);
}
@@ -2586,6 +2575,9 @@
bubble->GetWidget()->Show();
}
+void BrowserView::OverscrollUpdate(int delta_y) {
+}
+
void BrowserView::DoCutCopyPaste(void (content::RenderWidgetHost::*method)(),
#if defined(OS_WIN)
int windows_msg_id,
diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h
index 6d0c871..798d564 100644
--- a/chrome/browser/ui/views/frame/browser_view.h
+++ b/chrome/browser/ui/views/frame/browser_view.h
@@ -232,10 +232,6 @@
return browser_->is_type_tabbed();
}
- // Returns true if the specified point(BrowserView coordinates) is in
- // in the window caption area of the browser window.
- bool IsPositionInWindowCaption(const gfx::Point& point);
-
// See ImmersiveModeController for description.
ImmersiveModeController* immersive_mode_controller() const {
return immersive_mode_controller_.get();
@@ -374,6 +370,7 @@
const gfx::Rect& rect,
const content::PasswordForm& form,
autofill::PasswordGenerator* password_generator) OVERRIDE;
+ virtual void OverscrollUpdate(int delta_y) OVERRIDE;
// Overridden from BrowserWindowTesting:
virtual BookmarkBarView* GetBookmarkBarView() const OVERRIDE;
diff --git a/chrome/browser/ui/views/frame/browser_view_layout.cc b/chrome/browser/ui/views/frame/browser_view_layout.cc
index 0a936d2..46b140a 100644
--- a/chrome/browser/ui/views/frame/browser_view_layout.cc
+++ b/chrome/browser/ui/views/frame/browser_view_layout.cc
@@ -243,20 +243,7 @@
return bounding_box;
}
-bool BrowserViewLayout::IsPositionInWindowCaption(
- const gfx::Point& point) {
- // Tab strip may transiently have no parent between the RemoveChildView() and
- // AddChildView() caused by reparenting during an immersive mode reveal.
- // During this window report that the point didn't hit a tab.
- if (!tab_strip_->parent())
- return true;
- gfx::Point tabstrip_point(point);
- views::View::ConvertPointToTarget(browser_view_, tab_strip_, &tabstrip_point);
- return tab_strip_->IsPositionInWindowCaption(tabstrip_point);
-}
-
-int BrowserViewLayout::NonClientHitTest(
- const gfx::Point& point) {
+int BrowserViewLayout::NonClientHitTest(const gfx::Point& point) {
// Since the TabStrip only renders in some parts of the top of the window,
// the un-obscured area is considered to be part of the non-client caption
// area of the window. So we need to treat hit-tests in these regions as
@@ -282,7 +269,7 @@
// The top few pixels of the TabStrip are a drop-shadow - as we're pretty
// starved of dragable area, let's give it to window dragging (this also
// makes sense visually).
- if (!browser_view_->IsMaximized() &&
+ if (!(browser_view_->IsMaximized() || browser_view_->IsFullscreen()) &&
(point_in_browser_view_coords.y() <
(tab_strip_->y() + kTabShadowSize))) {
// We return HTNOWHERE as this is a signal to our containing
@@ -301,16 +288,27 @@
if (bv_bounds.Contains(point))
return HTCLIENT;
- // If the point's y coordinate is above the top of the toolbar, but not in
- // the tabstrip (per previous checking in this function), then we consider it
- // in the window caption (e.g. the area to the right of the tabstrip
- // underneath the window controls). However, note that we DO NOT return
- // HTCAPTION here, because when the window is maximized the window controls
- // will fall into this space (since the BrowserView is sized to entire size
- // of the window at that point), and the HTCAPTION value will cause the
- // window controls not to work. So we return HTNOWHERE so that the caller
- // will hit-test the window controls before finally falling back to
- // HTCAPTION.
+ // If the point is within the bounds of the window switcher button, the point
+ // is considered to be within the client area.
+ views::View* window_switcher_button = delegate_->GetWindowSwitcherButton();
+ if (window_switcher_button && window_switcher_button->visible()) {
+ gfx::Point window_switcher_point(point_in_browser_view_coords);
+ views::View::ConvertPointToTarget(browser_view_, window_switcher_button,
+ &window_switcher_point);
+ if (window_switcher_button->HitTestPoint(window_switcher_point))
+ return HTCLIENT;
+ }
+
+ // If the point's y coordinate is above the top of the toolbar, but neither
+ // over the tabstrip nor over the window switcher button (per previous
+ // checking in this function), then we consider it in the window caption
+ // (e.g. the area to the right of the tabstrip underneath the window
+ // controls). However, note that we DO NOT return HTCAPTION here, because
+ // when the window is maximized the window controls will fall into this
+ // space (since the BrowserView is sized to entire size of the window at that
+ // point), and the HTCAPTION value will cause the window controls not to work.
+ // So we return HTNOWHERE so that the caller will hit-test the window controls
+ // before finally falling back to HTCAPTION.
bv_bounds = browser_view_->bounds();
bv_bounds.set_height(toolbar_->y());
if (bv_bounds.Contains(point))
diff --git a/chrome/browser/ui/views/frame/browser_view_layout.h b/chrome/browser/ui/views/frame/browser_view_layout.h
index dd64a40..4019802 100644
--- a/chrome/browser/ui/views/frame/browser_view_layout.h
+++ b/chrome/browser/ui/views/frame/browser_view_layout.h
@@ -76,10 +76,6 @@
// Returns the bounding box, in widget coordinates, for the find bar.
gfx::Rect GetFindBarBoundingBox() const;
- // Returns true if the specified point(BrowserView coordinates) is in
- // in the window caption area of the browser window.
- bool IsPositionInWindowCaption(const gfx::Point& point);
-
// Tests to see if the specified |point| (in nonclient view's coordinates)
// is within the views managed by the laymanager. Returns one of
// HitTestCompat enum defined in ui/base/hit_test.h.
diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
index 3e0547b..e43a517 100644
--- a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
+++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
@@ -438,29 +438,67 @@
}
bool OpaqueBrowserFrameView::HitTestRect(const gfx::Rect& rect) const {
- // If |rect| does not intersect the bounds of the client area, claim it.
- bool in_nonclient = NonClientFrameView::HitTestRect(rect);
- if (in_nonclient)
- return in_nonclient;
-
- // Otherwise claim it only if it's in a non-tab portion of the tabstrip.
- if (!browser_view()->tabstrip())
+ if (!views::View::HitTestRect(rect)) {
+ // |rect| is outside OpaqueBrowserFrameView's bounds.
return false;
- gfx::Rect tabstrip_bounds(browser_view()->tabstrip()->bounds());
- gfx::Point tabstrip_origin(tabstrip_bounds.origin());
- View::ConvertPointToTarget(frame()->client_view(), this, &tabstrip_origin);
- tabstrip_bounds.set_origin(tabstrip_origin);
- if (rect.bottom() > tabstrip_bounds.bottom())
+ }
+
+ // If the rect is outside the bounds of the client area, claim it.
+ // TODO(tdanderson): Implement View::ConvertRectToTarget().
+ gfx::Point rect_in_client_view_coords_origin(rect.origin());
+ View::ConvertPointToTarget(this, frame()->client_view(),
+ &rect_in_client_view_coords_origin);
+ gfx::Rect rect_in_client_view_coords(
+ rect_in_client_view_coords_origin, rect.size());
+ if (!frame()->client_view()->HitTestRect(rect_in_client_view_coords))
+ return true;
+
+ // Otherwise, claim |rect| only if it is above the bottom of the tabstrip in
+ // a non-tab portion.
+ TabStrip* tabstrip = browser_view()->tabstrip();
+ if (!tabstrip || !browser_view()->IsTabStripVisible())
return false;
- // We convert from our parent's coordinates since we assume we fill its bounds
- // completely. We need to do this since we're not a parent of the tabstrip,
- // meaning ConvertPointToTarget would otherwise return something bogus.
- // TODO(tdanderson): Initialize |browser_view_point| using |rect| instead of
- // its center point once GetEventHandlerForRect() is implemented.
- gfx::Point browser_view_point(rect.CenterPoint());
- View::ConvertPointToTarget(parent(), browser_view(), &browser_view_point);
- return browser_view()->IsPositionInWindowCaption(browser_view_point);
+ gfx::Point rect_in_tabstrip_coords_origin(rect.origin());
+ View::ConvertPointToTarget(this, tabstrip,
+ &rect_in_tabstrip_coords_origin);
+ gfx::Rect rect_in_tabstrip_coords(
+ rect_in_tabstrip_coords_origin, rect.size());
+
+ if (rect_in_tabstrip_coords.bottom() > tabstrip->GetLocalBounds().bottom()) {
+ // |rect| is below the tabstrip.
+ return false;
+ }
+
+ if (tabstrip->HitTestRect(rect_in_tabstrip_coords)) {
+ // Claim |rect| if it is in a non-tab portion of the tabstrip.
+ // TODO(tdanderson): Pass |rect_in_tabstrip_coords| instead of its center
+ // point to TabStrip::IsPositionInWindowCaption() once
+ // GetEventHandlerForRect() is implemented.
+ return tabstrip->IsPositionInWindowCaption(
+ rect_in_tabstrip_coords.CenterPoint());
+ }
+
+ // The window switcher button is to the right of the tabstrip but is
+ // part of the client view.
+ views::View* window_switcher_button =
+ browser_view()->window_switcher_button();
+ if (window_switcher_button && window_switcher_button->visible()) {
+ gfx::Point rect_in_window_switcher_coords_origin(rect.origin());
+ View::ConvertPointToTarget(this, window_switcher_button,
+ &rect_in_window_switcher_coords_origin);
+ gfx::Rect rect_in_window_switcher_coords(
+ rect_in_window_switcher_coords_origin, rect.size());
+
+ if (window_switcher_button->HitTestRect(rect_in_window_switcher_coords))
+ return false;
+ }
+
+ // We claim |rect| because it is above the bottom of the tabstrip, but
+ // neither in the tabstrip nor in the window switcher button. In particular,
+ // the avatar label/button is left of the tabstrip and the window controls
+ // are right of the tabstrip.
+ return true;
}
void OpaqueBrowserFrameView::GetAccessibleState(
diff --git a/chrome/browser/ui/views/hung_renderer_view.cc b/chrome/browser/ui/views/hung_renderer_view.cc
index 665064b..7f86a71 100644
--- a/chrome/browser/ui/views/hung_renderer_view.cc
+++ b/chrome/browser/ui/views/hung_renderer_view.cc
@@ -10,7 +10,6 @@
#include "base/i18n/rtl.h"
#include "base/memory/scoped_vector.h"
-#include "base/process_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/favicon/favicon_tab_helper.h"
#include "chrome/browser/platform_util.h"
diff --git a/chrome/browser/ui/views/message_center/web_notification_tray.cc b/chrome/browser/ui/views/message_center/web_notification_tray.cc
index 655bb3a..5f25c9d 100644
--- a/chrome/browser/ui/views/message_center/web_notification_tray.cc
+++ b/chrome/browser/ui/views/message_center/web_notification_tray.cc
@@ -137,7 +137,7 @@
bool WebNotificationTray::ShowPopups() {
popup_collection_.reset(new message_center::MessagePopupCollection(
- NULL, message_center(), message_center_tray_.get()));
+ NULL, message_center(), message_center_tray_.get(), false));
return true;
}
diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
index 0a5c54f..12d34bb 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
@@ -600,15 +600,7 @@
#if defined(OS_CHROMEOS)
return ime_candidate_window_open_;
#else
- // We need const_cast here because there is no const version of
- // View::GetInputMethod(). It's because Widget::GetInputMethod(), called from
- // View::GetInputMethod(), creates a new views::InputMethod at the first-time
- // call. Except for this point, none of this method, View::GetInputMethod()
- // or Widget::GetInputMethod() modifies the state of their instances.
- // TODO(yukishiino): Make {View,Widget}::GetInputMethod() const and make the
- // underlying input method object mutable.
- const views::InputMethod* input_method =
- const_cast<OmniboxViewViews*>(this)->GetInputMethod();
+ const views::InputMethod* input_method = this->GetInputMethod();
return input_method && input_method->IsCandidatePopupOpen();
#endif
}
diff --git a/chrome/browser/ui/views/tabs/tab_renderer_data.h b/chrome/browser/ui/views/tabs/tab_renderer_data.h
index ddfe4dd..b06fea8 100644
--- a/chrome/browser/ui/views/tabs/tab_renderer_data.h
+++ b/chrome/browser/ui/views/tabs/tab_renderer_data.h
@@ -5,7 +5,7 @@
#ifndef CHROME_BROWSER_UI_VIEWS_TABS_TAB_RENDERER_DATA_H_
#define CHROME_BROWSER_UI_VIEWS_TABS_TAB_RENDERER_DATA_H_
-#include "base/process_util.h"
+#include "base/process/kill.h"
#include "base/strings/string16.h"
#include "chrome/browser/ui/views/chrome_views_export.h"
#include "ui/gfx/image/image_skia.h"
diff --git a/chrome/browser/ui/views/uninstall_view.cc b/chrome/browser/ui/views/uninstall_view.cc
index 9285109..d483098 100644
--- a/chrome/browser/ui/views/uninstall_view.cc
+++ b/chrome/browser/ui/views/uninstall_view.cc
@@ -5,7 +5,7 @@
#include "chrome/browser/ui/views/uninstall_view.h"
#include "base/message_loop/message_loop.h"
-#include "base/process_util.h"
+#include "base/process/launch.h"
#include "base/run_loop.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/shell_integration.h"
diff --git a/chrome/browser/ui/website_settings/website_settings_unittest.cc b/chrome/browser/ui/website_settings/website_settings_unittest.cc
index f599c9d..ab5cba0 100644
--- a/chrome/browser/ui/website_settings/website_settings_unittest.cc
+++ b/chrome/browser/ui/website_settings/website_settings_unittest.cc
@@ -389,7 +389,7 @@
website_settings()->OnSitePermissionChanged(
CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTING_ALLOW);
website_settings()->OnUIClosing();
- EXPECT_EQ(1u, infobar_service()->infobar_count());
+ ASSERT_EQ(1u, infobar_service()->infobar_count());
// Removing an |InfoBarDelegate| from the |InfoBarService| does not delete
// it. Hence the |delegate| must be cleaned up after it was removed from the
diff --git a/chrome/browser/ui/webui/chromeos/choose_mobile_network_ui.cc b/chrome/browser/ui/webui/chromeos/choose_mobile_network_ui.cc
index ab318e1..c5123cb 100644
--- a/chrome/browser/ui/webui/chromeos/choose_mobile_network_ui.cc
+++ b/chrome/browser/ui/webui/chromeos/choose_mobile_network_ui.cc
@@ -9,19 +9,25 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "base/location.h"
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h"
#include "base/values.h"
-#include "chrome/browser/chromeos/cros/network_library.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/url_constants.h"
+#include "chromeos/network/device_state.h"
+#include "chromeos/network/network_device_handler.h"
+#include "chromeos/network/network_event_log.h"
+#include "chromeos/network/network_state_handler.h"
+#include "chromeos/network/network_state_handler_observer.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
#include "content/public/browser/web_ui_message_handler.h"
#include "grit/browser_resources.h"
#include "grit/generated_resources.h"
+#include "third_party/cros_system_api/dbus/service_constants.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
@@ -68,9 +74,24 @@
return source;
}
+chromeos::NetworkDeviceHandler* GetNetworkDeviceHandler() {
+ return chromeos::NetworkHandler::Get()->network_device_handler();
+}
+
+chromeos::NetworkStateHandler* GetNetworkStateHandler() {
+ return chromeos::NetworkHandler::Get()->network_state_handler();
+}
+
+void NetworkOperationErrorCallback(
+ const std::string& operation_name,
+ const std::string& error_name,
+ scoped_ptr<base::DictionaryValue> error_data) {
+ NET_LOG_ERROR("Operation failed: " + error_name, operation_name);
+}
+
class ChooseMobileNetworkHandler
: public WebUIMessageHandler,
- public NetworkLibrary::NetworkDeviceObserver {
+ public NetworkStateHandlerObserver {
public:
ChooseMobileNetworkHandler();
virtual ~ChooseMobileNetworkHandler();
@@ -78,9 +99,8 @@
// WebUIMessageHandler implementation.
virtual void RegisterMessages() OVERRIDE;
- // NetworkDeviceObserver implementation.
- virtual void OnNetworkDeviceFoundNetworks(
- NetworkLibrary* cros, const NetworkDevice* device) OVERRIDE;
+ // NetworkStateHandlerObserver implementation.
+ virtual void DeviceListChanged() OVERRIDE;
private:
// Handlers for JS WebUI messages.
@@ -99,20 +119,27 @@
// ChooseMobileNetworkHandler implementation.
ChooseMobileNetworkHandler::ChooseMobileNetworkHandler()
- : is_page_ready_(false), has_pending_results_(false) {
- NetworkLibrary* cros = NetworkLibrary::Get();
- if (const NetworkDevice* cellular = cros->FindCellularDevice()) {
- device_path_ = cellular->device_path();
- cros->AddNetworkDeviceObserver(device_path_, this);
+ : is_page_ready_(false),
+ has_pending_results_(false) {
+ NetworkStateHandler* handler = GetNetworkStateHandler();
+ const DeviceState* cellular = handler->GetDeviceStateByType(
+ flimflam::kTypeCellular);
+ if (!cellular) {
+ NET_LOG_ERROR(
+ "A cellular device is not available.",
+ "Cannot initiate a cellular network scan without a cellular device.");
+ return;
}
- cros->RequestCellularScan();
+ handler->AddObserver(this, FROM_HERE);
+ device_path_ = cellular->path();
+ GetNetworkDeviceHandler()->ProposeScan(
+ device_path_,
+ base::Bind(&base::DoNothing),
+ base::Bind(&NetworkOperationErrorCallback, "ProposeScan"));
}
ChooseMobileNetworkHandler::~ChooseMobileNetworkHandler() {
- if (!device_path_.empty()) {
- NetworkLibrary* cros = NetworkLibrary::Get();
- cros->RemoveNetworkDeviceObserver(device_path_, this);
- }
+ GetNetworkStateHandler()->RemoveObserver(this, FROM_HERE);
}
void ChooseMobileNetworkHandler::RegisterMessages() {
@@ -130,14 +157,20 @@
base::Unretained(this)));
}
-void ChooseMobileNetworkHandler::OnNetworkDeviceFoundNetworks(
- NetworkLibrary* cros,
- const NetworkDevice* device) {
+void ChooseMobileNetworkHandler::DeviceListChanged() {
+ const DeviceState* cellular = GetNetworkStateHandler()->GetDeviceState(
+ device_path_);
networks_list_.Clear();
+ if (!cellular) {
+ LOG(WARNING) << "Cellular device with path '" << device_path_
+ << "' disappeared.";
+ return;
+ }
+ const DeviceState::CellularScanResults& scan_results =
+ cellular->scan_results();
std::set<std::string> network_ids;
- const CellularNetworkList& found_networks = device->found_cellular_networks();
- for (CellularNetworkList::const_iterator it = found_networks.begin();
- it != found_networks.end(); ++it) {
+ for (DeviceState::CellularScanResults::const_iterator it =
+ scan_results.begin(); it != scan_results.end(); ++it) {
// We need to remove duplicates from the list because same network with
// different technologies are listed multiple times. But ModemManager
// Register API doesn't allow technology to be specified so just show unique
@@ -173,8 +206,12 @@
}
// Switch to automatic mode.
- NetworkLibrary* cros = NetworkLibrary::Get();
- cros->RequestCellularRegister(std::string());
+ GetNetworkDeviceHandler()->RegisterCellularNetwork(
+ device_path_,
+ "", // An empty string is for registration with the home network.
+ base::Bind(&base::DoNothing),
+ base::Bind(&NetworkOperationErrorCallback,
+ "Register in automatic mode."));
}
void ChooseMobileNetworkHandler::HandleConnect(const ListValue* args) {
@@ -186,8 +223,12 @@
return;
}
- NetworkLibrary* cros = NetworkLibrary::Get();
- cros->RequestCellularRegister(network_id);
+ GetNetworkDeviceHandler()->RegisterCellularNetwork(
+ device_path_,
+ network_id,
+ base::Bind(&base::DoNothing),
+ base::Bind(&NetworkOperationErrorCallback,
+ std::string("Register to network: ") + network_id));
}
void ChooseMobileNetworkHandler::HandlePageReady(const ListValue* args) {
diff --git a/chrome/browser/ui/webui/inspect_ui.cc b/chrome/browser/ui/webui/inspect_ui.cc
index f078123..fd30b85 100644
--- a/chrome/browser/ui/webui/inspect_ui.cc
+++ b/chrome/browser/ui/webui/inspect_ui.cc
@@ -69,6 +69,7 @@
static const char kWorkerTargetType[] = "worker";
static const char kAdbTargetType[] = "adb_page";
+static const char kInitUICommand[] = "init-ui";
static const char kInspectCommand[] = "inspect";
static const char kTerminateCommand[] = "terminate";
@@ -159,66 +160,17 @@
rvh->GetRoutingID());
}
-// Appends the inspectable workers to the list of RenderViews, and sends the
-// response back to the webui system.
-void SendDescriptors(
- ListValue* rvh_list,
- const content::WebUIDataSource::GotDataCallback& callback) {
- std::vector<WorkerService::WorkerInfo> worker_info =
- WorkerService::GetInstance()->GetWorkers();
- for (size_t i = 0; i < worker_info.size(); ++i) {
- rvh_list->Append(BuildTargetDescriptor(
- kWorkerTargetType,
- false,
- worker_info[i].url,
- UTF16ToUTF8(worker_info[i].name),
- GURL(),
- worker_info[i].process_id,
- worker_info[i].route_id,
- worker_info[i].handle));
- }
-
- std::string json_string;
- base::JSONWriter::Write(rvh_list, &json_string);
- callback.Run(base::RefCountedString::TakeString(&json_string));
-}
-
-bool HandleDataRequestCallback(
- const std::string& path,
- const content::WebUIDataSource::GotDataCallback& callback) {
- std::set<RenderViewHost*> tab_rvhs;
- for (TabContentsIterator it; !it.done(); it.Next())
- tab_rvhs.insert(it->GetRenderViewHost());
-
- scoped_ptr<ListValue> rvh_list(new ListValue());
-
- std::vector<RenderViewHost*> rvh_vector =
- DevToolsAgentHost::GetValidRenderViewHosts();
-
- for (std::vector<RenderViewHost*>::iterator it(rvh_vector.begin());
- it != rvh_vector.end(); it++) {
- bool is_tab = tab_rvhs.find(*it) != tab_rvhs.end();
- rvh_list->Append(BuildTargetDescriptor(*it, is_tab));
- }
-
- BrowserThread::PostTask(
- BrowserThread::IO,
- FROM_HERE,
- base::Bind(&SendDescriptors, base::Owned(rvh_list.release()), callback));
- return true;
-}
-
class InspectMessageHandler : public WebUIMessageHandler {
public:
- explicit InspectMessageHandler(DevToolsAdbBridge* adb_bridge)
- : adb_bridge_(adb_bridge) {}
+ explicit InspectMessageHandler(InspectUI* inspect_ui)
+ : inspect_ui_(inspect_ui) {}
virtual ~InspectMessageHandler() {}
private:
// WebUIMessageHandler implementation.
virtual void RegisterMessages() OVERRIDE;
- // Callback for "openDevTools" message.
+ void HandleInitUICommand(const ListValue* args);
void HandleInspectCommand(const ListValue* args);
void HandleTerminateCommand(const ListValue* args);
@@ -226,12 +178,15 @@
int* process_id,
int* route_id);
- DevToolsAdbBridge* adb_bridge_;
+ InspectUI* inspect_ui_;
DISALLOW_COPY_AND_ASSIGN(InspectMessageHandler);
};
void InspectMessageHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(kInitUICommand,
+ base::Bind(&InspectMessageHandler::HandleInitUICommand,
+ base::Unretained(this)));
web_ui()->RegisterMessageCallback(kInspectCommand,
base::Bind(&InspectMessageHandler::HandleInspectCommand,
base::Unretained(this)));
@@ -240,7 +195,15 @@
base::Unretained(this)));
}
+void InspectMessageHandler::HandleInitUICommand(const ListValue*) {
+ inspect_ui_->InitUI();
+}
+
void InspectMessageHandler::HandleInspectCommand(const ListValue* args) {
+ Profile* profile = Profile::FromWebUI(web_ui());
+ if (!profile)
+ return;
+
int process_id;
int route_id;
if (!GetProcessAndRouteId(args, &process_id, &route_id) || process_id == 0
@@ -256,7 +219,9 @@
data->GetString(kAdbSocketField, &socket) &&
data->GetString(kAdbDebugUrlField, &debug_url) &&
data->GetString(kAdbFrontendUrlField, &frontend_url)) {
- adb_bridge_->Attach(serial, socket, debug_url, frontend_url);
+ scoped_refptr<DevToolsAdbBridge> adb_bridge =
+ DevToolsAdbBridge::Factory::GetForProfile(profile);
+ adb_bridge->Attach(serial, socket, debug_url, frontend_url);
}
return;
}
@@ -267,9 +232,6 @@
return;
}
- Profile* profile = Profile::FromWebUI(web_ui());
- if (!profile)
- return;
scoped_refptr<DevToolsAgentHost> agent_host(
DevToolsAgentHost::GetForWorker(process_id, route_id));
if (!agent_host.get())
@@ -332,6 +294,13 @@
this));
}
+ void InitUI() {
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&WorkerCreationDestructionListener::CollectWorkersData,
+ this));
+ }
+
private:
friend class base::RefCountedThreadSafe<WorkerCreationDestructionListener>;
virtual ~WorkerCreationDestructionListener() {}
@@ -341,22 +310,34 @@
const string16& name,
int process_id,
int route_id) OVERRIDE {
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&WorkerCreationDestructionListener::NotifyItemsChanged,
- this));
+ CollectWorkersData();
}
virtual void WorkerDestroyed(int process_id, int route_id) OVERRIDE {
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&WorkerCreationDestructionListener::NotifyItemsChanged,
- this));
+ CollectWorkersData();
}
- void NotifyItemsChanged() {
- if (discovery_ui_)
- discovery_ui_->RefreshUI();
+ void CollectWorkersData() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ scoped_ptr<ListValue> target_list(new ListValue());
+ std::vector<WorkerService::WorkerInfo> worker_info =
+ WorkerService::GetInstance()->GetWorkers();
+ for (size_t i = 0; i < worker_info.size(); ++i) {
+ target_list->Append(BuildTargetDescriptor(
+ kWorkerTargetType,
+ false,
+ worker_info[i].url,
+ UTF16ToUTF8(worker_info[i].name),
+ GURL(),
+ worker_info[i].process_id,
+ worker_info[i].route_id,
+ worker_info[i].handle));
+ }
+
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&WorkerCreationDestructionListener::PopulateWorkersList,
+ this, base::Owned(target_list.release())));
}
void RegisterObserver() {
@@ -367,19 +348,68 @@
WorkerService::GetInstance()->RemoveObserver(this);
}
+ void PopulateWorkersList(ListValue* target_list) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ if (discovery_ui_) {
+ discovery_ui_->web_ui()->CallJavascriptFunction(
+ "populateWorkersList", *target_list);
+ }
+ }
+
InspectUI* discovery_ui_;
};
InspectUI::InspectUI(content::WebUI* web_ui)
- : WebUIController(web_ui),
- observer_(new WorkerCreationDestructionListener()),
- weak_factory_(this) {
- observer_->Init(this);
+ : WebUIController(web_ui) {
+ web_ui->AddMessageHandler(new InspectMessageHandler(this));
Profile* profile = Profile::FromWebUI(web_ui);
+ content::WebUIDataSource::Add(profile, CreateInspectUIHTMLSource());
+}
+
+InspectUI::~InspectUI() {
+ StopListeningNotifications();
+}
+
+void InspectUI::InitUI() {
+ StartListeningNotifications();
+ PopulateLists();
+ observer_->InitUI();
+}
+
+void InspectUI::PopulateLists() {
+ std::set<RenderViewHost*> tab_rvhs;
+ for (TabContentsIterator it; !it.done(); it.Next())
+ tab_rvhs.insert(it->GetRenderViewHost());
+
+ scoped_ptr<ListValue> target_list(new ListValue());
+
+ std::vector<RenderViewHost*> rvh_vector =
+ DevToolsAgentHost::GetValidRenderViewHosts();
+
+ for (std::vector<RenderViewHost*>::iterator it(rvh_vector.begin());
+ it != rvh_vector.end(); it++) {
+ bool is_tab = tab_rvhs.find(*it) != tab_rvhs.end();
+ target_list->Append(BuildTargetDescriptor(*it, is_tab));
+ }
+ web_ui()->CallJavascriptFunction("populateLists", *target_list.get());
+}
+
+void InspectUI::Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ if (source != content::Source<WebContents>(web_ui()->GetWebContents()))
+ PopulateLists();
+ else if (type == content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED)
+ StopListeningNotifications();
+}
+
+void InspectUI::StartListeningNotifications() {
+ observer_ = new WorkerCreationDestructionListener();
+ observer_->Init(this);
+
+ Profile* profile = Profile::FromWebUI(web_ui());
adb_bridge_ = DevToolsAdbBridge::Factory::GetForProfile(profile);
adb_bridge_->AddListener(this);
- web_ui->AddMessageHandler(new InspectMessageHandler(adb_bridge_));
- content::WebUIDataSource::Add(profile, CreateInspectUIHTMLSource());
registrar_.Add(this,
content::NOTIFICATION_WEB_CONTENTS_CONNECTED,
@@ -392,33 +422,6 @@
content::NotificationService::AllSources());
}
-InspectUI::~InspectUI() {
- StopListeningNotifications();
-}
-
-void InspectUI::RefreshUI() {
- web_ui()->CallJavascriptFunction("populateLists");
-}
-
-// static
-bool InspectUI::WeakHandleRequestCallback(
- const base::WeakPtr<InspectUI>& inspect_ui,
- const std::string& path,
- const content::WebUIDataSource::GotDataCallback& callback) {
- if (!inspect_ui.get())
- return false;
- return inspect_ui->HandleRequestCallback(path, callback);
-}
-
-void InspectUI::Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- if (source != content::Source<WebContents>(web_ui()->GetWebContents()))
- RefreshUI();
- else if (type == content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED)
- StopListeningNotifications();
-}
-
void InspectUI::StopListeningNotifications()
{
if (!observer_.get())
@@ -436,19 +439,9 @@
source->AddResourcePath("inspect.css", IDR_INSPECT_CSS);
source->AddResourcePath("inspect.js", IDR_INSPECT_JS);
source->SetDefaultResource(IDR_INSPECT_HTML);
- source->SetRequestFilter(base::Bind(&InspectUI::WeakHandleRequestCallback,
- weak_factory_.GetWeakPtr()));
return source;
}
-bool InspectUI::HandleRequestCallback(
- const std::string& path,
- const content::WebUIDataSource::GotDataCallback& callback) {
- if (path == kDataFile)
- return HandleDataRequestCallback(path, callback);
- return false;
-}
-
void InspectUI::RemotePagesChanged(DevToolsAdbBridge::RemotePages* pages) {
ListValue targets;
for (DevToolsAdbBridge::RemotePages::iterator it = pages->begin();
diff --git a/chrome/browser/ui/webui/inspect_ui.h b/chrome/browser/ui/webui/inspect_ui.h
index 8220468..e2e6455 100644
--- a/chrome/browser/ui/webui/inspect_ui.h
+++ b/chrome/browser/ui/webui/inspect_ui.h
@@ -22,29 +22,23 @@
explicit InspectUI(content::WebUI* web_ui);
virtual ~InspectUI();
- void RefreshUI();
+ void InitUI();
private:
class WorkerCreationDestructionListener;
- static bool WeakHandleRequestCallback(
- const base::WeakPtr<InspectUI>& inspect_ui,
- const std::string& path,
- const content::WebUIDataSource::GotDataCallback& callback);
+ void PopulateLists();
// content::NotificationObserver overrides.
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
+ void StartListeningNotifications();
void StopListeningNotifications();
content::WebUIDataSource* CreateInspectUIHTMLSource();
- bool HandleRequestCallback(
- const std::string& path,
- const content::WebUIDataSource::GotDataCallback& callback);
-
// DevToolsAdbBridge::Listener overrides.
virtual void RemotePagesChanged(
DevToolsAdbBridge::RemotePages* pages) OVERRIDE;
@@ -55,7 +49,6 @@
content::NotificationRegistrar registrar_;
DevToolsAdbBridge* adb_bridge_;
- base::WeakPtrFactory<InspectUI> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(InspectUI);
};
diff --git a/chrome/browser/ui/webui/options/advanced_options_utils_x11.cc b/chrome/browser/ui/webui/options/advanced_options_utils_x11.cc
index bbe55c8..211f5b9 100644
--- a/chrome/browser/ui/webui/options/advanced_options_utils_x11.cc
+++ b/chrome/browser/ui/webui/options/advanced_options_utils_x11.cc
@@ -11,7 +11,7 @@
#include "base/file_util.h"
#include "base/files/file_path.h"
#include "base/nix/xdg_util.h"
-#include "base/process_util.h"
+#include "base/process/launch.h"
#include "base/strings/string_util.h"
#include "chrome/browser/tab_contents/tab_util.h"
#include "content/public/browser/browser_thread.h"
diff --git a/chrome/browser/ui/webui/translate_internals/translate_internals_handler.cc b/chrome/browser/ui/webui/translate_internals/translate_internals_handler.cc
index 9b44249..91f9e03 100644
--- a/chrome/browser/ui/webui/translate_internals/translate_internals_handler.cc
+++ b/chrome/browser/ui/webui/translate_internals/translate_internals_handler.cc
@@ -39,6 +39,9 @@
void TranslateInternalsHandler::OnLanguageDetection(
const LanguageDetectionDetails& details) {
+ if (!TranslateManager::IsTranslatableURL(details.url))
+ return;
+
base::DictionaryValue dict;
dict.Set("time",
new base::FundamentalValue(details.time.ToJsTime()));
diff --git a/chrome/browser/unload_browsertest.cc b/chrome/browser/unload_browsertest.cc
index bc95910..c6f38ad 100644
--- a/chrome/browser/unload_browsertest.cc
+++ b/chrome/browser/unload_browsertest.cc
@@ -8,7 +8,6 @@
#include "base/command_line.h"
#include "base/logging.h"
-#include "base/process_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/net/url_request_mock_util.h"
diff --git a/chrome/browser/upgrade_detector_impl.cc b/chrome/browser/upgrade_detector_impl.cc
index 436d05e..15602d4 100644
--- a/chrome/browser/upgrade_detector_impl.cc
+++ b/chrome/browser/upgrade_detector_impl.cc
@@ -34,7 +34,7 @@
#elif defined(OS_MACOSX)
#include "chrome/browser/mac/keystone_glue.h"
#elif defined(OS_POSIX)
-#include "base/process_util.h"
+#include "base/process/launch.h"
#endif
using content::BrowserThread;
diff --git a/chrome/browser/usb/usb_device_handle.cc b/chrome/browser/usb/usb_device_handle.cc
index 99faad1..b6e54f4 100644
--- a/chrome/browser/usb/usb_device_handle.cc
+++ b/chrome/browser/usb/usb_device_handle.cc
@@ -8,6 +8,7 @@
#include <vector>
#include "base/stl_util.h"
+#include "base/strings/string16.h"
#include "base/synchronization/lock.h"
#include "chrome/browser/usb/usb_interface.h"
#include "chrome/browser/usb/usb_service.h"
@@ -244,6 +245,41 @@
return libusb_reset_device(handle_) == 0;
}
+bool UsbDeviceHandle::GetSerial(base::string16* serial) {
+ PlatformUsbDevice device = libusb_get_device(handle_);
+ libusb_device_descriptor desc;
+
+ if (libusb_get_device_descriptor(device, &desc) != LIBUSB_SUCCESS)
+ return false;
+
+ if (desc.iSerialNumber == 0)
+ return false;
+
+ // Getting supported language ID.
+ uint16 langid[128] = { 0 };
+
+ int size = libusb_get_string_descriptor(
+ handle_, 0, 0,
+ reinterpret_cast<unsigned char*>(&langid[0]), sizeof(langid));
+ if (size < 0)
+ return false;
+
+ int language_count = (size - 2) / 2;
+
+ for (int i = 1; i <= language_count; ++i) {
+ // Get the string using language ID.
+ char16 text[256] = { 0 };
+ size = libusb_get_string_descriptor(
+ handle_, desc.iSerialNumber, langid[i],
+ reinterpret_cast<unsigned char*>(&text[0]), sizeof(text));
+ if (size < 0)
+ continue;
+ *serial = base::string16(text, size / 2);
+ return true;
+ }
+ return false;
+}
+
void UsbDeviceHandle::ControlTransfer(const UsbEndpointDirection direction,
const TransferRequestType request_type, const TransferRecipient recipient,
const uint8 request, const uint16 value, const uint16 index,
diff --git a/chrome/browser/usb/usb_device_handle.h b/chrome/browser/usb/usb_device_handle.h
index e46ab19..ef059d7 100644
--- a/chrome/browser/usb/usb_device_handle.h
+++ b/chrome/browser/usb/usb_device_handle.h
@@ -9,6 +9,7 @@
#include <vector>
#include "base/memory/ref_counted.h"
+#include "base/strings/string16.h"
#include "base/synchronization/lock.h"
#include "chrome/browser/usb/usb_interface.h"
#include "net/base/completion_callback.h"
@@ -70,6 +71,7 @@
const int interface_number,
const int alternate_setting);
virtual bool ResetDevice();
+ bool GetSerial(base::string16* serial);
// Async IO.
virtual void ControlTransfer(const UsbEndpointDirection direction,
diff --git a/chrome/browser/user_data_dir_extractor_win.cc b/chrome/browser/user_data_dir_extractor_win.cc
index e295885..e48c757 100644
--- a/chrome/browser/user_data_dir_extractor_win.cc
+++ b/chrome/browser/user_data_dir_extractor_win.cc
@@ -8,7 +8,7 @@
#include "base/file_util.h"
#include "base/logging.h"
#include "base/path_service.h"
-#include "base/process_util.h"
+#include "base/process/launch.h"
#include "chrome/browser/ui/user_data_dir_dialog.h"
#include "chrome/browser/user_data_dir_extractor.h"
#include "chrome/common/chrome_paths.h"
diff --git a/chrome/browser/user_data_dir_extractor_win_browsertest.cc b/chrome/browser/user_data_dir_extractor_win_browsertest.cc
index 6987b62..0adc765 100644
--- a/chrome/browser/user_data_dir_extractor_win_browsertest.cc
+++ b/chrome/browser/user_data_dir_extractor_win_browsertest.cc
@@ -6,7 +6,6 @@
#include "base/command_line.h"
#include "base/path_service.h"
-#include "base/process_util.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/ui/browser.h"
diff --git a/chrome/browser/web_applications/web_app_mac.mm b/chrome/browser/web_applications/web_app_mac.mm
index 0644302..46589ca 100644
--- a/chrome/browser/web_applications/web_app_mac.mm
+++ b/chrome/browser/web_applications/web_app_mac.mm
@@ -185,7 +185,9 @@
CommandLine command_line(CommandLine::NO_PROGRAM);
command_line.AppendSwitch(app_mode::kNoLaunchApp);
- base::mac::OpenApplicationWithPath(shim_path, command_line, NULL);
+ // Launch without activating (kLSLaunchDontSwitch).
+ base::mac::OpenApplicationWithPath(
+ shim_path, command_line, kLSLaunchDefaults | kLSLaunchDontSwitch, NULL);
}
base::FilePath GetLocalizableAppShortcutsSubdirName() {