OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/automation/testing_automation_provider.h" | 5 #include "chrome/browser/automation/testing_automation_provider.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/file_path.h" | 15 #include "base/file_path.h" |
16 #include "base/json/json_reader.h" | 16 #include "base/json/json_reader.h" |
17 #include "base/json/json_writer.h" | 17 #include "base/json/json_writer.h" |
18 #include "base/json/string_escape.h" | 18 #include "base/json/string_escape.h" |
19 #include "base/path_service.h" | 19 #include "base/path_service.h" |
20 #include "base/process.h" | 20 #include "base/process.h" |
21 #include "base/process_util.h" | 21 #include "base/process_util.h" |
| 22 #include "base/sequenced_task_runner.h" |
22 #include "base/stringprintf.h" | 23 #include "base/stringprintf.h" |
23 #include "base/threading/thread_restrictions.h" | 24 #include "base/threading/thread_restrictions.h" |
24 #include "base/time.h" | 25 #include "base/time.h" |
25 #include "base/utf_string_conversions.h" | 26 #include "base/utf_string_conversions.h" |
26 #include "chrome/app/chrome_command_ids.h" | 27 #include "chrome/app/chrome_command_ids.h" |
27 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" | 28 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" |
28 #include "chrome/browser/api/infobars/link_infobar_delegate.h" | 29 #include "chrome/browser/api/infobars/link_infobar_delegate.h" |
29 #include "chrome/browser/autocomplete/autocomplete_controller.h" | 30 #include "chrome/browser/autocomplete/autocomplete_controller.h" |
30 #include "chrome/browser/autocomplete/autocomplete_match.h" | 31 #include "chrome/browser/autocomplete/autocomplete_match.h" |
31 #include "chrome/browser/autocomplete/autocomplete_result.h" | 32 #include "chrome/browser/autocomplete/autocomplete_result.h" |
(...skipping 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1281 reply.SendError(error_msg); | 1282 reply.SendError(error_msg); |
1282 return; | 1283 return; |
1283 } | 1284 } |
1284 BookmarkModel* bookmark_model = | 1285 BookmarkModel* bookmark_model = |
1285 BookmarkModelFactory::GetForProfile(browser->profile()); | 1286 BookmarkModelFactory::GetForProfile(browser->profile()); |
1286 if (!bookmark_model->IsLoaded()) { | 1287 if (!bookmark_model->IsLoaded()) { |
1287 reply.SendError("Bookmark model is not loaded"); | 1288 reply.SendError("Bookmark model is not loaded"); |
1288 return; | 1289 return; |
1289 } | 1290 } |
1290 scoped_refptr<BookmarkStorage> storage( | 1291 scoped_refptr<BookmarkStorage> storage( |
1291 new BookmarkStorage(browser->profile(), bookmark_model)); | 1292 new BookmarkStorage(browser->profile(), |
| 1293 bookmark_model, |
| 1294 browser->profile()->GetIOTaskRunner())); |
1292 if (!storage->SerializeData(&bookmarks_as_json)) { | 1295 if (!storage->SerializeData(&bookmarks_as_json)) { |
1293 reply.SendError("Failed to serialize bookmarks"); | 1296 reply.SendError("Failed to serialize bookmarks"); |
1294 return; | 1297 return; |
1295 } | 1298 } |
1296 DictionaryValue dict; | 1299 DictionaryValue dict; |
1297 dict.SetString("bookmarks_as_json", bookmarks_as_json); | 1300 dict.SetString("bookmarks_as_json", bookmarks_as_json); |
1298 reply.SendSuccess(&dict); | 1301 reply.SendSuccess(&dict); |
1299 } | 1302 } |
1300 | 1303 |
1301 void TestingAutomationProvider::WaitForBookmarkModelToLoad( | 1304 void TestingAutomationProvider::WaitForBookmarkModelToLoad( |
(...skipping 5039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6341 void TestingAutomationProvider::OnRemoveProvider() { | 6344 void TestingAutomationProvider::OnRemoveProvider() { |
6342 if (g_browser_process) | 6345 if (g_browser_process) |
6343 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 6346 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
6344 } | 6347 } |
6345 | 6348 |
6346 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, | 6349 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, |
6347 WebContents* tab) { | 6350 WebContents* tab) { |
6348 if (chrome::GetActiveWebContents(browser) != tab) | 6351 if (chrome::GetActiveWebContents(browser) != tab) |
6349 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); | 6352 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); |
6350 } | 6353 } |
OLD | NEW |