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 "base/process_util.h" | 5 #include "base/process_util.h" |
6 #include "base/sys_string_conversions.h" | 6 #include "base/sys_string_conversions.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/extensions/extension_browsertest.h" | 8 #include "chrome/browser/extensions/extension_browsertest.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_tabstrip.h" |
10 #include "chrome/browser/ui/browser_window.h" | 11 #include "chrome/browser/ui/browser_window.h" |
11 #include "chrome/browser/ui/omnibox/location_bar.h" | 12 #include "chrome/browser/ui/omnibox/location_bar.h" |
12 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 13 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
13 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
14 #include "chrome/test/base/in_process_browser_test.h" | 15 #include "chrome/test/base/in_process_browser_test.h" |
15 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
16 #include "chrome/test/base/ui_test_utils.h" | 17 #include "chrome/test/base/ui_test_utils.h" |
17 #include "content/public/browser/navigation_controller.h" | 18 #include "content/public/browser/navigation_controller.h" |
18 #include "content/public/browser/navigation_entry.h" | 19 #include "content/public/browser/navigation_entry.h" |
19 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
20 #include "googleurl/src/gurl.h" | 21 #include "googleurl/src/gurl.h" |
21 | 22 |
22 using content::NavigationEntry; | 23 using content::NavigationEntry; |
23 | 24 |
24 class ExtensionURLRewriteBrowserTest : public ExtensionBrowserTest { | 25 class ExtensionURLRewriteBrowserTest : public ExtensionBrowserTest { |
25 protected: | 26 protected: |
26 std::string GetLocationBarText() const { | 27 std::string GetLocationBarText() const { |
27 return UTF16ToUTF8( | 28 return UTF16ToUTF8( |
28 browser()->window()->GetLocationBar()->GetLocationEntry()->GetText()); | 29 browser()->window()->GetLocationBar()->GetLocationEntry()->GetText()); |
29 } | 30 } |
30 | 31 |
31 GURL GetLocationBarTextAsURL() const { | 32 GURL GetLocationBarTextAsURL() const { |
32 return GURL(GetLocationBarText()); | 33 return GURL(GetLocationBarText()); |
33 } | 34 } |
34 | 35 |
35 content::NavigationController* GetNavigationController() const { | 36 content::NavigationController* GetNavigationController() const { |
36 return &browser()->GetActiveWebContents()->GetController(); | 37 return &chrome::GetActiveWebContents(browser())->GetController(); |
37 } | 38 } |
38 | 39 |
39 NavigationEntry* GetNavigationEntry() const { | 40 NavigationEntry* GetNavigationEntry() const { |
40 return GetNavigationController()->GetActiveEntry(); | 41 return GetNavigationController()->GetActiveEntry(); |
41 } | 42 } |
42 | 43 |
43 FilePath GetTestExtensionPath(const char* extension_name) const { | 44 FilePath GetTestExtensionPath(const char* extension_name) const { |
44 return test_data_dir_.AppendASCII("browsertest/url_rewrite/"). | 45 return test_data_dir_.AppendASCII("browsertest/url_rewrite/"). |
45 AppendASCII(extension_name); | 46 AppendASCII(extension_name); |
46 } | 47 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 TestExtensionURLOverride(url_with_ref); | 104 TestExtensionURLOverride(url_with_ref); |
104 } | 105 } |
105 | 106 |
106 IN_PROC_BROWSER_TEST_F(ExtensionURLRewriteBrowserTest, BookmarksURLOverride) { | 107 IN_PROC_BROWSER_TEST_F(ExtensionURLRewriteBrowserTest, BookmarksURLOverride) { |
107 // Load an extension that overrides chrome://bookmarks. | 108 // Load an extension that overrides chrome://bookmarks. |
108 LoadExtension(GetTestExtensionPath("bookmarks")); | 109 LoadExtension(GetTestExtensionPath("bookmarks")); |
109 // Navigate to chrome://bookmarks and check that the location bar URL is what | 110 // Navigate to chrome://bookmarks and check that the location bar URL is what |
110 // was entered and the internal URL uses the chrome-extension:// scheme. | 111 // was entered and the internal URL uses the chrome-extension:// scheme. |
111 TestExtensionURLOverride(GURL(chrome::kChromeUIBookmarksURL)); | 112 TestExtensionURLOverride(GURL(chrome::kChromeUIBookmarksURL)); |
112 } | 113 } |
OLD | NEW |