| 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/apps/app_browsertest_util.h" | 5 #include "chrome/browser/apps/app_browsertest_util.h" |
| 6 #include "chrome/browser/extensions/extension_process_manager.h" | |
| 7 #include "chrome/browser/extensions/extension_test_message_listener.h" | 6 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/common/chrome_switches.h" | 8 #include "chrome/common/chrome_switches.h" |
| 10 #include "content/public/browser/web_contents_view.h" | 9 #include "content/public/browser/web_contents_view.h" |
| 11 #include "content/public/test/browser_test_utils.h" | 10 #include "content/public/test/browser_test_utils.h" |
| 11 #include "extensions/browser/process_manager.h" |
| 12 | 12 |
| 13 class WindowControlsTest : public extensions::PlatformAppBrowserTest { | 13 class WindowControlsTest : public extensions::PlatformAppBrowserTest { |
| 14 protected: | 14 protected: |
| 15 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 15 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 16 extensions::PlatformAppBrowserTest::SetUpCommandLine(command_line); | 16 extensions::PlatformAppBrowserTest::SetUpCommandLine(command_line); |
| 17 command_line->AppendSwitch(switches::kEnableAppWindowControls); | 17 command_line->AppendSwitch(switches::kEnableAppWindowControls); |
| 18 } | 18 } |
| 19 content::WebContents* GetWebContentsForExtensionWindow( | 19 content::WebContents* GetWebContentsForExtensionWindow( |
| 20 const extensions::Extension* extension); | 20 const extensions::Extension* extension); |
| 21 }; | 21 }; |
| 22 | 22 |
| 23 content::WebContents* WindowControlsTest::GetWebContentsForExtensionWindow( | 23 content::WebContents* WindowControlsTest::GetWebContentsForExtensionWindow( |
| 24 const extensions::Extension* extension) { | 24 const extensions::Extension* extension) { |
| 25 ExtensionProcessManager* process_manager = | 25 extensions::ProcessManager* process_manager = |
| 26 extensions::ExtensionSystem::Get(profile())->process_manager(); | 26 extensions::ExtensionSystem::Get(profile())->process_manager(); |
| 27 | 27 |
| 28 // Lookup render view host for background page. | 28 // Lookup render view host for background page. |
| 29 const extensions::ExtensionHost* extension_host = | 29 const extensions::ExtensionHost* extension_host = |
| 30 process_manager->GetBackgroundHostForExtension(extension->id()); | 30 process_manager->GetBackgroundHostForExtension(extension->id()); |
| 31 content::RenderViewHost* background_view_host = | 31 content::RenderViewHost* background_view_host = |
| 32 extension_host->render_view_host(); | 32 extension_host->render_view_host(); |
| 33 | 33 |
| 34 // Go through all active views, looking for the first window of the extension | 34 // Go through all active views, looking for the first window of the extension |
| 35 const ExtensionProcessManager::ViewSet all_views = | 35 const extensions::ProcessManager::ViewSet all_views = |
| 36 process_manager->GetAllViews(); | 36 process_manager->GetAllViews(); |
| 37 ExtensionProcessManager::ViewSet::const_iterator it = all_views.begin(); | 37 extensions::ProcessManager::ViewSet::const_iterator it = all_views.begin(); |
| 38 for (; it != all_views.end(); ++it) { | 38 for (; it != all_views.end(); ++it) { |
| 39 content::RenderViewHost* host = *it; | 39 content::RenderViewHost* host = *it; |
| 40 | 40 |
| 41 // Filter out views not part of this extension | 41 // Filter out views not part of this extension |
| 42 if (process_manager->GetExtensionForRenderViewHost(host) == extension) { | 42 if (process_manager->GetExtensionForRenderViewHost(host) == extension) { |
| 43 // Filter out the background page view | 43 // Filter out the background page view |
| 44 if (host != background_view_host) { | 44 if (host != background_view_host) { |
| 45 content::WebContents* web_contents = | 45 content::WebContents* web_contents = |
| 46 content::WebContents::FromRenderViewHost(host); | 46 content::WebContents::FromRenderViewHost(host); |
| 47 return web_contents; | 47 return web_contents; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 71 const int controlOffset = 25; | 71 const int controlOffset = 25; |
| 72 int x = web_contents->GetView()->GetContainerSize().width() - controlOffset; | 72 int x = web_contents->GetView()->GetContainerSize().width() - controlOffset; |
| 73 int y = controlOffset; | 73 int y = controlOffset; |
| 74 content::SimulateMouseClickAt(web_contents, | 74 content::SimulateMouseClickAt(web_contents, |
| 75 0, | 75 0, |
| 76 blink::WebMouseEvent::ButtonLeft, | 76 blink::WebMouseEvent::ButtonLeft, |
| 77 gfx::Point(x, y)); | 77 gfx::Point(x, y)); |
| 78 | 78 |
| 79 ASSERT_TRUE(window_closed.WaitUntilSatisfied()); | 79 ASSERT_TRUE(window_closed.WaitUntilSatisfied()); |
| 80 } | 80 } |
| OLD | NEW |