Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Side by Side Diff: chrome/browser/extensions/isolated_app_browsertest.cc

Issue 2527133002: Remove some WebContents::GetRenderViewHost() calls. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 5 #include <stddef.h>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "chrome/browser/extensions/extension_apitest.h" 11 #include "chrome/browser/extensions/extension_apitest.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/browser_commands.h" 13 #include "chrome/browser/ui/browser_commands.h"
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" 14 #include "chrome/browser/ui/tabs/tab_strip_model.h"
15 #include "chrome/common/url_constants.h" 15 #include "chrome/common/url_constants.h"
16 #include "chrome/test/base/ui_test_utils.h" 16 #include "chrome/test/base/ui_test_utils.h"
17 #include "content/public/browser/notification_types.h" 17 #include "content/public/browser/notification_types.h"
18 #include "content/public/browser/render_frame_host.h"
18 #include "content/public/browser/render_process_host.h" 19 #include "content/public/browser/render_process_host.h"
19 #include "content/public/browser/render_view_host.h"
20 #include "content/public/browser/site_instance.h" 20 #include "content/public/browser/site_instance.h"
21 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
22 #include "content/public/test/browser_test_utils.h" 22 #include "content/public/test/browser_test_utils.h"
23 #include "extensions/browser/extension_host.h" 23 #include "extensions/browser/extension_host.h"
24 #include "extensions/browser/extension_registry.h" 24 #include "extensions/browser/extension_registry.h"
25 #include "extensions/browser/process_map.h" 25 #include "extensions/browser/process_map.h"
26 #include "extensions/common/switches.h" 26 #include "extensions/common/switches.h"
27 #include "net/base/escape.h" 27 #include "net/base/escape.h"
28 #include "net/dns/mock_host_resolver.h" 28 #include "net/dns/mock_host_resolver.h"
29 #include "net/test/embedded_test_server/embedded_test_server.h" 29 #include "net/test/embedded_test_server/embedded_test_server.h"
30 #include "net/test/embedded_test_server/http_request.h" 30 #include "net/test/embedded_test_server/http_request.h"
31 #include "net/test/embedded_test_server/http_response.h" 31 #include "net/test/embedded_test_server/http_response.h"
32 32
33 using content::ExecuteScript; 33 using content::ExecuteScript;
34 using content::ExecuteScriptAndExtractString; 34 using content::ExecuteScriptAndExtractString;
35 using content::NavigationController; 35 using content::NavigationController;
36 using content::RenderViewHost;
37 using content::WebContents; 36 using content::WebContents;
38 37
39 namespace extensions { 38 namespace extensions {
40 39
41 namespace { 40 namespace {
42 41
43 std::string WrapForJavascriptAndExtract(const char* javascript_expression) { 42 std::string WrapForJavascriptAndExtract(const char* javascript_expression) {
44 return std::string("window.domAutomationController.send(") + 43 return std::string("window.domAutomationController.send(") +
45 javascript_expression + ")"; 44 javascript_expression + ")";
46 } 45 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 std::string actual_cookie; 111 std::string actual_cookie;
113 ui_test_utils::GetCookies(contents->GetURL(), contents, &value_size, 112 ui_test_utils::GetCookies(contents->GetURL(), contents, &value_size,
114 &actual_cookie); 113 &actual_cookie);
115 return actual_cookie.find(cookie) != std::string::npos; 114 return actual_cookie.find(cookie) != std::string::npos;
116 } 115 }
117 116
118 const Extension* GetInstalledApp(WebContents* contents) { 117 const Extension* GetInstalledApp(WebContents* contents) {
119 content::BrowserContext* browser_context = contents->GetBrowserContext(); 118 content::BrowserContext* browser_context = contents->GetBrowserContext();
120 ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context); 119 ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context);
121 std::set<std::string> extension_ids = 120 std::set<std::string> extension_ids =
122 ProcessMap::Get(browser_context)->GetExtensionsInProcess( 121 ProcessMap::Get(browser_context)
123 contents->GetRenderViewHost()->GetProcess()->GetID()); 122 ->GetExtensionsInProcess(
123 contents->GetMainFrame()->GetProcess()->GetID());
124 for (std::set<std::string>::iterator iter = extension_ids.begin(); 124 for (std::set<std::string>::iterator iter = extension_ids.begin();
125 iter != extension_ids.end(); ++iter) { 125 iter != extension_ids.end(); ++iter) {
126 const Extension* installed_app = 126 const Extension* installed_app =
127 registry->enabled_extensions().GetByID(*iter); 127 registry->enabled_extensions().GetByID(*iter);
128 if (installed_app && installed_app->is_app()) 128 if (installed_app && installed_app->is_app())
129 return installed_app; 129 return installed_app;
130 } 130 }
131 return NULL; 131 return NULL;
132 } 132 }
133 133
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 browser(), base_url.Resolve("non_app/main.html")); 564 browser(), base_url.Resolve("non_app/main.html"));
565 ASSERT_TRUE(ExecuteScriptAndExtractString( 565 ASSERT_TRUE(ExecuteScriptAndExtractString(
566 browser()->tab_strip_model()->GetWebContentsAt(0), 566 browser()->tab_strip_model()->GetWebContentsAt(0),
567 kRetrieveSessionStorage.c_str(), &result)); 567 kRetrieveSessionStorage.c_str(), &result));
568 EXPECT_EQ("ss_normal", result); 568 EXPECT_EQ("ss_normal", result);
569 } 569 }
570 570
571 } // namespace 571 } // namespace
572 572
573 } // namespace extensions 573 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698