OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/ui/browser.h" |
| 6 |
5 #include <stddef.h> | 7 #include <stddef.h> |
6 #include <stdint.h> | 8 #include <stdint.h> |
7 | 9 |
| 10 #include <memory> |
8 #include <string> | 11 #include <string> |
9 | 12 |
10 #include "base/bind.h" | 13 #include "base/bind.h" |
11 #include "base/command_line.h" | 14 #include "base/command_line.h" |
12 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
13 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
14 #include "base/location.h" | 17 #include "base/location.h" |
15 #include "base/macros.h" | 18 #include "base/macros.h" |
16 #include "base/memory/scoped_ptr.h" | |
17 #include "base/message_loop/message_loop.h" | 19 #include "base/message_loop/message_loop.h" |
18 #include "base/strings/string_split.h" | 20 #include "base/strings/string_split.h" |
19 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
20 #include "base/sys_info.h" | 22 #include "base/sys_info.h" |
21 #include "build/build_config.h" | 23 #include "build/build_config.h" |
22 #include "chrome/app/chrome_command_ids.h" | 24 #include "chrome/app/chrome_command_ids.h" |
23 #include "chrome/browser/chrome_content_browser_client.h" | 25 #include "chrome/browser/chrome_content_browser_client.h" |
24 #include "chrome/browser/chrome_notification_types.h" | 26 #include "chrome/browser/chrome_notification_types.h" |
25 #include "chrome/browser/command_updater.h" | 27 #include "chrome/browser/command_updater.h" |
26 #include "chrome/browser/defaults.h" | 28 #include "chrome/browser/defaults.h" |
27 #include "chrome/browser/devtools/devtools_window_testing.h" | 29 #include "chrome/browser/devtools/devtools_window_testing.h" |
28 #include "chrome/browser/extensions/extension_browsertest.h" | 30 #include "chrome/browser/extensions/extension_browsertest.h" |
29 #include "chrome/browser/extensions/extension_service.h" | 31 #include "chrome/browser/extensions/extension_service.h" |
30 #include "chrome/browser/extensions/extension_util.h" | 32 #include "chrome/browser/extensions/extension_util.h" |
31 #include "chrome/browser/extensions/tab_helper.h" | 33 #include "chrome/browser/extensions/tab_helper.h" |
32 #include "chrome/browser/first_run/first_run.h" | 34 #include "chrome/browser/first_run/first_run.h" |
33 #include "chrome/browser/lifetime/application_lifetime.h" | 35 #include "chrome/browser/lifetime/application_lifetime.h" |
34 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 36 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
35 #include "chrome/browser/profiles/profile.h" | 37 #include "chrome/browser/profiles/profile.h" |
36 #include "chrome/browser/profiles/profile_attributes_storage.h" | 38 #include "chrome/browser/profiles/profile_attributes_storage.h" |
37 #include "chrome/browser/profiles/profile_manager.h" | 39 #include "chrome/browser/profiles/profile_manager.h" |
38 #include "chrome/browser/search/search.h" | 40 #include "chrome/browser/search/search.h" |
39 #include "chrome/browser/sessions/session_service_factory.h" | 41 #include "chrome/browser/sessions/session_service_factory.h" |
40 #include "chrome/browser/translate/chrome_translate_client.h" | 42 #include "chrome/browser/translate/chrome_translate_client.h" |
41 #include "chrome/browser/translate/cld_data_harness.h" | 43 #include "chrome/browser/translate/cld_data_harness.h" |
42 #include "chrome/browser/translate/cld_data_harness_factory.h" | 44 #include "chrome/browser/translate/cld_data_harness_factory.h" |
43 #include "chrome/browser/ui/browser.h" | |
44 #include "chrome/browser/ui/browser_command_controller.h" | 45 #include "chrome/browser/ui/browser_command_controller.h" |
45 #include "chrome/browser/ui/browser_commands.h" | 46 #include "chrome/browser/ui/browser_commands.h" |
46 #include "chrome/browser/ui/browser_finder.h" | 47 #include "chrome/browser/ui/browser_finder.h" |
47 #include "chrome/browser/ui/browser_list.h" | 48 #include "chrome/browser/ui/browser_list.h" |
48 #include "chrome/browser/ui/browser_tabstrip.h" | 49 #include "chrome/browser/ui/browser_tabstrip.h" |
49 #include "chrome/browser/ui/browser_ui_prefs.h" | 50 #include "chrome/browser/ui/browser_ui_prefs.h" |
50 #include "chrome/browser/ui/browser_window.h" | 51 #include "chrome/browser/ui/browser_window.h" |
51 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" | 52 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" |
52 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" | 53 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" |
53 #include "chrome/browser/ui/extensions/app_launch_params.h" | 54 #include "chrome/browser/ui/extensions/app_launch_params.h" |
(...skipping 1893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1947 | 1948 |
1948 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_PageZoom) { | 1949 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_PageZoom) { |
1949 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); | 1950 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); |
1950 bool enable_plus, enable_minus; | 1951 bool enable_plus, enable_minus; |
1951 | 1952 |
1952 { | 1953 { |
1953 scoped_refptr<content::MessageLoopRunner> loop_runner( | 1954 scoped_refptr<content::MessageLoopRunner> loop_runner( |
1954 new content::MessageLoopRunner); | 1955 new content::MessageLoopRunner); |
1955 content::HostZoomMap::ZoomLevelChangedCallback callback( | 1956 content::HostZoomMap::ZoomLevelChangedCallback callback( |
1956 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure())); | 1957 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure())); |
1957 scoped_ptr<content::HostZoomMap::Subscription> sub = | 1958 std::unique_ptr<content::HostZoomMap::Subscription> sub = |
1958 content::HostZoomMap::GetDefaultForBrowserContext( | 1959 content::HostZoomMap::GetDefaultForBrowserContext(browser()->profile()) |
1959 browser()->profile())->AddZoomLevelChangedCallback(callback); | 1960 ->AddZoomLevelChangedCallback(callback); |
1960 chrome::Zoom(browser(), content::PAGE_ZOOM_IN); | 1961 chrome::Zoom(browser(), content::PAGE_ZOOM_IN); |
1961 loop_runner->Run(); | 1962 loop_runner->Run(); |
1962 sub.reset(); | 1963 sub.reset(); |
1963 EXPECT_EQ(GetZoomPercent(contents, &enable_plus, &enable_minus), 110); | 1964 EXPECT_EQ(GetZoomPercent(contents, &enable_plus, &enable_minus), 110); |
1964 EXPECT_TRUE(enable_plus); | 1965 EXPECT_TRUE(enable_plus); |
1965 EXPECT_TRUE(enable_minus); | 1966 EXPECT_TRUE(enable_minus); |
1966 } | 1967 } |
1967 | 1968 |
1968 { | 1969 { |
1969 scoped_refptr<content::MessageLoopRunner> loop_runner( | 1970 scoped_refptr<content::MessageLoopRunner> loop_runner( |
1970 new content::MessageLoopRunner); | 1971 new content::MessageLoopRunner); |
1971 content::HostZoomMap::ZoomLevelChangedCallback callback( | 1972 content::HostZoomMap::ZoomLevelChangedCallback callback( |
1972 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure())); | 1973 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure())); |
1973 scoped_ptr<content::HostZoomMap::Subscription> sub = | 1974 std::unique_ptr<content::HostZoomMap::Subscription> sub = |
1974 content::HostZoomMap::GetDefaultForBrowserContext( | 1975 content::HostZoomMap::GetDefaultForBrowserContext(browser()->profile()) |
1975 browser()->profile())->AddZoomLevelChangedCallback(callback); | 1976 ->AddZoomLevelChangedCallback(callback); |
1976 chrome::Zoom(browser(), content::PAGE_ZOOM_RESET); | 1977 chrome::Zoom(browser(), content::PAGE_ZOOM_RESET); |
1977 loop_runner->Run(); | 1978 loop_runner->Run(); |
1978 sub.reset(); | 1979 sub.reset(); |
1979 EXPECT_EQ(GetZoomPercent(contents, &enable_plus, &enable_minus), 100); | 1980 EXPECT_EQ(GetZoomPercent(contents, &enable_plus, &enable_minus), 100); |
1980 EXPECT_TRUE(enable_plus); | 1981 EXPECT_TRUE(enable_plus); |
1981 EXPECT_TRUE(enable_minus); | 1982 EXPECT_TRUE(enable_minus); |
1982 } | 1983 } |
1983 | 1984 |
1984 { | 1985 { |
1985 scoped_refptr<content::MessageLoopRunner> loop_runner( | 1986 scoped_refptr<content::MessageLoopRunner> loop_runner( |
1986 new content::MessageLoopRunner); | 1987 new content::MessageLoopRunner); |
1987 content::HostZoomMap::ZoomLevelChangedCallback callback( | 1988 content::HostZoomMap::ZoomLevelChangedCallback callback( |
1988 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure())); | 1989 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure())); |
1989 scoped_ptr<content::HostZoomMap::Subscription> sub = | 1990 std::unique_ptr<content::HostZoomMap::Subscription> sub = |
1990 content::HostZoomMap::GetDefaultForBrowserContext( | 1991 content::HostZoomMap::GetDefaultForBrowserContext(browser()->profile()) |
1991 browser()->profile())->AddZoomLevelChangedCallback(callback); | 1992 ->AddZoomLevelChangedCallback(callback); |
1992 chrome::Zoom(browser(), content::PAGE_ZOOM_OUT); | 1993 chrome::Zoom(browser(), content::PAGE_ZOOM_OUT); |
1993 loop_runner->Run(); | 1994 loop_runner->Run(); |
1994 sub.reset(); | 1995 sub.reset(); |
1995 EXPECT_EQ(GetZoomPercent(contents, &enable_plus, &enable_minus), 90); | 1996 EXPECT_EQ(GetZoomPercent(contents, &enable_plus, &enable_minus), 90); |
1996 EXPECT_TRUE(enable_plus); | 1997 EXPECT_TRUE(enable_plus); |
1997 EXPECT_TRUE(enable_minus); | 1998 EXPECT_TRUE(enable_minus); |
1998 } | 1999 } |
1999 | 2000 |
2000 chrome::Zoom(browser(), content::PAGE_ZOOM_RESET); | 2001 chrome::Zoom(browser(), content::PAGE_ZOOM_RESET); |
2001 } | 2002 } |
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3159 callback.Run(); | 3160 callback.Run(); |
3160 } | 3161 } |
3161 bool GetResult() const { | 3162 bool GetResult() const { |
3162 bool res; | 3163 bool res; |
3163 CHECK(js_result_); | 3164 CHECK(js_result_); |
3164 CHECK(js_result_->GetAsBoolean(&res)); | 3165 CHECK(js_result_->GetAsBoolean(&res)); |
3165 return res; | 3166 return res; |
3166 } | 3167 } |
3167 | 3168 |
3168 private: | 3169 private: |
3169 scoped_ptr<base::Value> js_result_; | 3170 std::unique_ptr<base::Value> js_result_; |
3170 DISALLOW_COPY_AND_ASSIGN(JSBooleanResultGetter); | 3171 DISALLOW_COPY_AND_ASSIGN(JSBooleanResultGetter); |
3171 }; | 3172 }; |
3172 | 3173 |
3173 void CheckDisplayModeMQ( | 3174 void CheckDisplayModeMQ( |
3174 const base::string16& display_mode, | 3175 const base::string16& display_mode, |
3175 content::WebContents* web_contents) { | 3176 content::WebContents* web_contents) { |
3176 base::string16 funtcion = | 3177 base::string16 funtcion = |
3177 ASCIIToUTF16("(function() {return window.matchMedia('(display-mode: ") + | 3178 ASCIIToUTF16("(function() {return window.matchMedia('(display-mode: ") + |
3178 display_mode + ASCIIToUTF16(")').matches;})();"); | 3179 display_mode + ASCIIToUTF16(")').matches;})();"); |
3179 JSBooleanResultGetter js_result_getter; | 3180 JSBooleanResultGetter js_result_getter; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3298 Browser* browser = new Browser(params); | 3299 Browser* browser = new Browser(params); |
3299 gfx::Rect bounds = browser->window()->GetBounds(); | 3300 gfx::Rect bounds = browser->window()->GetBounds(); |
3300 | 3301 |
3301 // Should be EXPECT_EQ, but this width is inconsistent across platforms. | 3302 // Should be EXPECT_EQ, but this width is inconsistent across platforms. |
3302 // See https://crbug.com/567925. | 3303 // See https://crbug.com/567925. |
3303 EXPECT_GE(bounds.width(), 100); | 3304 EXPECT_GE(bounds.width(), 100); |
3304 EXPECT_EQ(122, bounds.height()); | 3305 EXPECT_EQ(122, bounds.height()); |
3305 browser->window()->Close(); | 3306 browser->window()->Close(); |
3306 } | 3307 } |
3307 } | 3308 } |
OLD | NEW |