| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #import "chrome/browser/ui/cocoa/location_bar/zoom_decoration.h" | 5 #import "chrome/browser/ui/cocoa/location_bar/zoom_decoration.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/threading/thread_task_runner_handle.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/browser_window.h" | 11 #include "chrome/browser/ui/browser_window.h" |
| 11 #import "chrome/browser/ui/cocoa/browser/zoom_bubble_controller.h" | 12 #import "chrome/browser/ui/cocoa/browser/zoom_bubble_controller.h" |
| 12 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 13 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 13 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | 14 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
| 14 #include "chrome/browser/ui/cocoa/run_loop_testing.h" | 15 #include "chrome/browser/ui/cocoa/run_loop_testing.h" |
| 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 16 #include "chrome/test/base/in_process_browser_test.h" | 17 #include "chrome/test/base/in_process_browser_test.h" |
| 17 #include "components/toolbar/test_toolbar_model.h" | 18 #include "components/toolbar/test_toolbar_model.h" |
| 18 #include "components/zoom/page_zoom.h" | 19 #include "components/zoom/page_zoom.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 content::WebContents* web_contents = | 59 content::WebContents* web_contents = |
| 59 browser()->tab_strip_model()->GetActiveWebContents(); | 60 browser()->tab_strip_model()->GetActiveWebContents(); |
| 60 | 61 |
| 61 base::AutoReset<bool> reset(&should_quit_on_zoom_, true); | 62 base::AutoReset<bool> reset(&should_quit_on_zoom_, true); |
| 62 zoom::PageZoom::Zoom(web_contents, zoom); | 63 zoom::PageZoom::Zoom(web_contents, zoom); |
| 63 content::RunMessageLoop(); | 64 content::RunMessageLoop(); |
| 64 } | 65 } |
| 65 | 66 |
| 66 void OnZoomChanged(const content::HostZoomMap::ZoomLevelChange& host) { | 67 void OnZoomChanged(const content::HostZoomMap::ZoomLevelChange& host) { |
| 67 if (should_quit_on_zoom_) { | 68 if (should_quit_on_zoom_) { |
| 68 base::MessageLoop::current()->PostTask( | 69 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 69 FROM_HERE, | 70 FROM_HERE, |
| 70 base::Bind(&base::MessageLoop::QuitWhenIdle, | 71 base::Bind(&base::MessageLoop::QuitWhenIdle, |
| 71 base::Unretained(base::MessageLoop::current()))); | 72 base::Unretained(base::MessageLoop::current()))); |
| 72 } | 73 } |
| 73 } | 74 } |
| 74 | 75 |
| 75 private: | 76 private: |
| 76 bool should_quit_on_zoom_; | 77 bool should_quit_on_zoom_; |
| 77 std::unique_ptr<content::HostZoomMap::Subscription> zoom_subscription_; | 78 std::unique_ptr<content::HostZoomMap::Subscription> zoom_subscription_; |
| 78 | 79 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 157 |
| 157 // Create a new browser so that it can be closed properly. | 158 // Create a new browser so that it can be closed properly. |
| 158 Browser* browser2 = CreateBrowser(browser()->profile()); | 159 Browser* browser2 = CreateBrowser(browser()->profile()); |
| 159 ZoomDecoration* zoom_decoration = GetZoomDecorationForBrowser(browser2); | 160 ZoomDecoration* zoom_decoration = GetZoomDecorationForBrowser(browser2); |
| 160 zoom_decoration->ShowBubble(true); | 161 zoom_decoration->ShowBubble(true); |
| 161 | 162 |
| 162 // Test shouldn't crash. | 163 // Test shouldn't crash. |
| 163 browser2->window()->Close(); | 164 browser2->window()->Close(); |
| 164 content::RunAllPendingInMessageLoop(); | 165 content::RunAllPendingInMessageLoop(); |
| 165 } | 166 } |
| OLD | NEW |