| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui/webui/options/options_browsertest.h" | 5 #include "chrome/browser/ui/webui/options/options_browsertest.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 // Includes the current entry. | 39 // Includes the current entry. |
| 40 void OptionsBrowserTest::ReportHistory(const base::ListValue* list_value) { | 40 void OptionsBrowserTest::ReportHistory(const base::ListValue* list_value) { |
| 41 const NavigationController& controller = | 41 const NavigationController& controller = |
| 42 browser()->tab_strip_model()->GetActiveWebContents()->GetController(); | 42 browser()->tab_strip_model()->GetActiveWebContents()->GetController(); |
| 43 base::ListValue history; | 43 base::ListValue history; |
| 44 const int current = controller.GetCurrentEntryIndex(); | 44 const int current = controller.GetCurrentEntryIndex(); |
| 45 for (int i = 0; i <= current; ++i) { | 45 for (int i = 0; i <= current; ++i) { |
| 46 GURL url = controller.GetEntryAtIndex(i)->GetVirtualURL(); | 46 GURL url = controller.GetEntryAtIndex(i)->GetVirtualURL(); |
| 47 history.Append(new base::StringValue(url.spec())); | 47 history.Append(new base::StringValue(url.spec())); |
| 48 } | 48 } |
| 49 web_ui()->CallJavascriptFunction( | 49 web_ui()->CallJavascriptFunctionUnsafe( |
| 50 "OptionsWebUIExtendedTest.verifyHistoryCallback", history); | 50 "OptionsWebUIExtendedTest.verifyHistoryCallback", history); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void OptionsBrowserTest::ClearPref(const char* path) { | 53 void OptionsBrowserTest::ClearPref(const char* path) { |
| 54 browser()->profile()->GetPrefs()->ClearPref(path); | 54 browser()->profile()->GetPrefs()->ClearPref(path); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void OptionsBrowserTest::HandleSetPref(const base::ListValue* args) { | 57 void OptionsBrowserTest::HandleSetPref(const base::ListValue* args) { |
| 58 ASSERT_EQ(2u, args->GetSize()); | 58 ASSERT_EQ(2u, args->GetSize()); |
| 59 | 59 |
| 60 std::string pref_name; | 60 std::string pref_name; |
| 61 ASSERT_TRUE(args->GetString(0, &pref_name)); | 61 ASSERT_TRUE(args->GetString(0, &pref_name)); |
| 62 const base::Value* pref_value; | 62 const base::Value* pref_value; |
| 63 ASSERT_TRUE(args->Get(1, &pref_value)); | 63 ASSERT_TRUE(args->Get(1, &pref_value)); |
| 64 | 64 |
| 65 browser()->profile()->GetPrefs()->Set(pref_name.c_str(), *pref_value); | 65 browser()->profile()->GetPrefs()->Set(pref_name.c_str(), *pref_value); |
| 66 } | 66 } |
| 67 | 67 |
| 68 content::WebUIMessageHandler* OptionsBrowserTest::GetMockMessageHandler() { | 68 content::WebUIMessageHandler* OptionsBrowserTest::GetMockMessageHandler() { |
| 69 return this; | 69 return this; |
| 70 } | 70 } |
| OLD | NEW |