| 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/path_service.h" |    5 #include "base/path_service.h" | 
|    6 #include "base/strings/stringprintf.h" |    6 #include "base/strings/stringprintf.h" | 
|    7 #include "chrome/browser/devtools/devtools_window.h" |    7 #include "chrome/browser/devtools/devtools_window.h" | 
|    8 #include "chrome/browser/extensions/api/developer_private/developer_private_api.
     h" |    8 #include "chrome/browser/extensions/api/developer_private/developer_private_api.
     h" | 
|    9 #include "chrome/browser/extensions/extension_apitest.h" |    9 #include "chrome/browser/extensions/extension_apitest.h" | 
|   10 #include "chrome/browser/extensions/extension_function_test_utils.h" |   10 #include "chrome/browser/extensions/extension_function_test_utils.h" | 
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   50           function.get(), base::StringPrintf("[\"%s\"]", app->id().c_str()), |   50           function.get(), base::StringPrintf("[\"%s\"]", app->id().c_str()), | 
|   51           browser())); |   51           browser())); | 
|   52   ASSERT_TRUE(result); |   52   ASSERT_TRUE(result); | 
|   53   scoped_ptr<api::developer_private::ExtensionInfo> info = |   53   scoped_ptr<api::developer_private::ExtensionInfo> info = | 
|   54       api::developer_private::ExtensionInfo::FromValue(*result); |   54       api::developer_private::ExtensionInfo::FromValue(*result); | 
|   55   ASSERT_TRUE(info); |   55   ASSERT_TRUE(info); | 
|   56  |   56  | 
|   57   // There should be two inspectable views - the background page and the app |   57   // There should be two inspectable views - the background page and the app | 
|   58   // window.  Find the app window. |   58   // window.  Find the app window. | 
|   59   ASSERT_EQ(2u, info->views.size()); |   59   ASSERT_EQ(2u, info->views.size()); | 
|   60   api::developer_private::ExtensionView* window_view = nullptr; |   60   const api::developer_private::ExtensionView* window_view = nullptr; | 
|   61   for (const auto& view : info->views) { |   61   for (const auto& view : info->views) { | 
|   62     if (view->type == api::developer_private::VIEW_TYPE_APP_WINDOW) { |   62     if (view.type == api::developer_private::VIEW_TYPE_APP_WINDOW) { | 
|   63       window_view = view.get(); |   63       window_view = &view; | 
|   64       break; |   64       break; | 
|   65     } |   65     } | 
|   66   } |   66   } | 
|   67   ASSERT_TRUE(window_view); |   67   ASSERT_TRUE(window_view); | 
|   68  |   68  | 
|   69   // Inspect the app window. |   69   // Inspect the app window. | 
|   70   function = new api::DeveloperPrivateOpenDevToolsFunction(); |   70   function = new api::DeveloperPrivateOpenDevToolsFunction(); | 
|   71   extension_function_test_utils::RunFunction( |   71   extension_function_test_utils::RunFunction( | 
|   72       function.get(), |   72       function.get(), | 
|   73       base::StringPrintf("[{\"renderViewId\": %d, \"renderProcessId\": %d}]", |   73       base::StringPrintf("[{\"renderViewId\": %d, \"renderProcessId\": %d}]", | 
| (...skipping 29 matching lines...) Expand all  Loading... | 
|  103       extension_function_test_utils::RunFunctionAndReturnSingleResult( |  103       extension_function_test_utils::RunFunctionAndReturnSingleResult( | 
|  104           function.get(), |  104           function.get(), | 
|  105           base::StringPrintf("[\"%s\"]", extension->id().c_str()), browser())); |  105           base::StringPrintf("[\"%s\"]", extension->id().c_str()), browser())); | 
|  106   ASSERT_TRUE(result); |  106   ASSERT_TRUE(result); | 
|  107   scoped_ptr<api::developer_private::ExtensionInfo> info = |  107   scoped_ptr<api::developer_private::ExtensionInfo> info = | 
|  108       api::developer_private::ExtensionInfo::FromValue(*result); |  108       api::developer_private::ExtensionInfo::FromValue(*result); | 
|  109   ASSERT_TRUE(info); |  109   ASSERT_TRUE(info); | 
|  110  |  110  | 
|  111   // The embedded options page should show up. |  111   // The embedded options page should show up. | 
|  112   ASSERT_EQ(1u, info->views.size()); |  112   ASSERT_EQ(1u, info->views.size()); | 
|  113   api::developer_private::ExtensionView* view = info->views[0].get(); |  113   const api::developer_private::ExtensionView& view = info->views[0]; | 
|  114   ASSERT_TRUE(view); |  114   ASSERT_EQ(api::developer_private::VIEW_TYPE_EXTENSION_GUEST, view.type); | 
|  115   ASSERT_EQ(api::developer_private::VIEW_TYPE_EXTENSION_GUEST, view->type); |  | 
|  116  |  115  | 
|  117   // Inspect the embedded options page. |  116   // Inspect the embedded options page. | 
|  118   function = new api::DeveloperPrivateOpenDevToolsFunction(); |  117   function = new api::DeveloperPrivateOpenDevToolsFunction(); | 
|  119   extension_function_test_utils::RunFunction( |  118   extension_function_test_utils::RunFunction( | 
|  120       function.get(), |  119       function.get(), | 
|  121       base::StringPrintf("[{\"renderViewId\": %d, \"renderProcessId\": %d}]", |  120       base::StringPrintf("[{\"renderViewId\": %d, \"renderProcessId\": %d}]", | 
|  122                          view->render_view_id, view->render_process_id), |  121                          view.render_view_id, view.render_process_id), | 
|  123       browser(), extension_function_test_utils::NONE); |  122       browser(), extension_function_test_utils::NONE); | 
|  124  |  123  | 
|  125   // Verify that dev tools opened. |  124   // Verify that dev tools opened. | 
|  126   content::RenderFrameHost* rfh = content::RenderFrameHost::FromID( |  125   content::RenderFrameHost* rfh = content::RenderFrameHost::FromID( | 
|  127       view->render_process_id, view->render_view_id); |  126       view.render_process_id, view.render_view_id); | 
|  128   ASSERT_TRUE(rfh); |  127   ASSERT_TRUE(rfh); | 
|  129   content::WebContents* wc = content::WebContents::FromRenderFrameHost(rfh); |  128   content::WebContents* wc = content::WebContents::FromRenderFrameHost(rfh); | 
|  130   ASSERT_TRUE(wc); |  129   ASSERT_TRUE(wc); | 
|  131   EXPECT_TRUE(DevToolsWindow::GetInstanceForInspectedWebContents(wc)); |  130   EXPECT_TRUE(DevToolsWindow::GetInstanceForInspectedWebContents(wc)); | 
|  132 } |  131 } | 
|  133  |  132  | 
|  134 }  // namespace extensions |  133 }  // namespace extensions | 
| OLD | NEW |