diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-07-17 13:57:45 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-07-19 13:44:40 +0000 |
commit | 6ec7b8da05d21a3878bd21c691b41e675d74bb1c (patch) | |
tree | b87f250bc19413750b9bb9cdbf2da20ef5014820 /chromium/chrome/browser/extensions/api/extension_action | |
parent | ec02ee4181c49b61fce1c8fb99292dbb8139cc90 (diff) |
BASELINE: Update Chromium to 60.0.3112.70
Change-Id: I9911c2280a014d4632f254857876a395d4baed2d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/chrome/browser/extensions/api/extension_action')
3 files changed, 23 insertions, 34 deletions
diff --git a/chromium/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc b/chromium/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc index 2d57dda866e..da79d2e5d26 100644 --- a/chromium/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc +++ b/chromium/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc @@ -8,6 +8,7 @@ #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/macros.h" +#include "base/threading/thread_restrictions.h" #include "build/build_config.h" #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" #include "chrome/browser/extensions/browser_action_test_util.h" @@ -71,6 +72,7 @@ void ExecuteExtensionAction(Browser* browser, const Extension* extension) { std::unique_ptr<base::ScopedTempDir> CreateAndSetDownloadsDirectory( PrefService* pref_service) { + base::ThreadRestrictions::ScopedAllowIO allow_io; std::unique_ptr<base::ScopedTempDir> dir(new base::ScopedTempDir); if (!dir->CreateUniqueTempDir()) @@ -121,6 +123,11 @@ class BrowserActionApiTest : public ExtensionApiTest { BrowserActionApiTest() {} ~BrowserActionApiTest() override {} + void SetUpOnMainThread() override { + ExtensionApiTest::SetUpOnMainThread(); + host_resolver()->AddRule("*", "127.0.0.1"); + } + protected: BrowserActionTestUtil* GetBrowserActionsBar() { if (!browser_action_test_util_) @@ -728,11 +735,10 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, TestTriggerBrowserAction) { EXPECT_EQ(result, "red"); } -// Test that a browser action popup with a web iframe works correctly. This -// primarily targets --isolate-extensions and --site-per-process modes, where -// the iframe runs in a separate process. See https://crbug.com/546267. +// Test that a browser action popup with a web iframe works correctly. The +// iframe is expected to run in a separate process. +// See https://crbug.com/546267. IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, BrowserActionPopupWithIframe) { - host_resolver()->AddRule("*", "127.0.0.1"); ASSERT_TRUE(embedded_test_server()->Start()); ASSERT_TRUE(LoadExtension( @@ -831,7 +837,6 @@ class NavigatingExtensionPopupBrowserTest : public BrowserActionApiTest { void SetUpOnMainThread() override { BrowserActionApiTest::SetUpOnMainThread(); - host_resolver()->AddRule("*", "127.0.0.1"); ASSERT_TRUE(embedded_test_server()->Start()); // Load an extension with a pop-up. @@ -948,31 +953,12 @@ class NavigatingExtensionPopupBrowserTest : public BrowserActionApiTest { IN_PROC_BROWSER_TEST_F(NavigatingExtensionPopupBrowserTest, Webpage) { GURL web_url(embedded_test_server()->GetURL("foo.com", "/title1.html")); - // With and without --isolate-extension the GET request will be blocked in - // ExtensionViewHost::OpenURLFromTab (which silently drops navigations with - // CURRENT_TAB disposition). + // The GET request will be blocked in ExtensionViewHost::OpenURLFromTab + // (which silently drops navigations with CURRENT_TAB disposition). TestPopupNavigationViaGet(web_url, EXPECTING_NAVIGATION_FAILURE); // POST requests don't go through ExtensionViewHost::OpenURLFromTab. - // - // Without --isolate-extensions, there is no process transfer to isolate - // extensions into separate processes and therefore - // 1) navigating a popup extension to a webpage will succeed (because - // ExtensionViewHost::ShouldTransferNavigation won't get called when there - // is no transfer), - // 2) the webpage will stay in the same renderer process. - // This behavior is okay without --isolate-extensions (where webpages and - // extensions can coexist in the same process in other scenarios) - therefore - // no test verification is needed in this case. - // - // With --isolate-extensions the navigation should be blocked by - // ExtensionViewHost::ShouldTransferNavigation. Test verification is - // important in --isolate-extensions mode, because this mode is all about - // isolating extensions and webpages into separate processes and therefore we - // need to ensure the behavior described above doesn't occur (i.e. that - // instead the webpage navigation in an extension popup fails). - if (extensions::IsIsolateExtensionsEnabled()) - TestPopupNavigationViaPost(web_url, EXPECTING_NAVIGATION_FAILURE); + TestPopupNavigationViaPost(web_url, EXPECTING_NAVIGATION_FAILURE); } // Tests that an extension pop-up can be navigated to another page @@ -1012,6 +998,7 @@ IN_PROC_BROWSER_TEST_F(NavigatingExtensionPopupBrowserTest, DownloadViaPost) { // Override the default downloads directory, so that the test can cleanup // after itself. This section is based on CreateAndSetDownloadsDirectory // method defined in a few other source files with tests. + base::ThreadRestrictions::ScopedAllowIO allow_io; std::unique_ptr<base::ScopedTempDir> downloads_directory = CreateAndSetDownloadsDirectory(browser()->profile()->GetPrefs()); ASSERT_TRUE(downloads_directory); diff --git a/chromium/chrome/browser/extensions/api/extension_action/extension_action_api.cc b/chromium/chrome/browser/extensions/api/extension_action/extension_action_api.cc index 8b6976f9732..577edb34074 100644 --- a/chromium/chrome/browser/extensions/api/extension_action/extension_action_api.cc +++ b/chromium/chrome/browser/extensions/api/extension_action/extension_action_api.cc @@ -205,7 +205,8 @@ void ExtensionActionAPI::NotifyChange(ExtensionAction* extension_action, void ExtensionActionAPI::DispatchExtensionActionClicked( const ExtensionAction& extension_action, - WebContents* web_contents) { + WebContents* web_contents, + const Extension* extension) { events::HistogramValue histogram_value = events::UNKNOWN; const char* event_name = NULL; switch (extension_action.action_type()) { @@ -225,7 +226,8 @@ void ExtensionActionAPI::DispatchExtensionActionClicked( if (event_name) { std::unique_ptr<base::ListValue> args(new base::ListValue()); - args->Append(ExtensionTabUtil::CreateTabObject(web_contents)->ToValue()); + args->Append( + ExtensionTabUtil::CreateTabObject(web_contents, extension)->ToValue()); DispatchEventToExtension(web_contents->GetBrowserContext(), extension_action.extension_id(), histogram_value, @@ -272,9 +274,8 @@ void ExtensionActionAPI::DispatchEventToExtension( if (!EventRouter::Get(context)) return; - std::unique_ptr<Event> event( - new Event(histogram_value, event_name, std::move(event_args))); - event->restrict_to_browser_context = context; + auto event = base::MakeUnique<Event>(histogram_value, event_name, + std::move(event_args), context); event->user_gesture = EventRouter::USER_GESTURE_ENABLED; EventRouter::Get(context) ->DispatchEventToExtension(extension_id, std::move(event)); @@ -586,7 +587,7 @@ bool BrowserActionOpenPopupFunction::RunAsync() { // instance around until a notification is observed. base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, - base::Bind(&BrowserActionOpenPopupFunction::OpenPopupTimedOut, this), + base::BindOnce(&BrowserActionOpenPopupFunction::OpenPopupTimedOut, this), base::TimeDelta::FromSeconds(10)); return true; } diff --git a/chromium/chrome/browser/extensions/api/extension_action/extension_action_api.h b/chromium/chrome/browser/extensions/api/extension_action/extension_action_api.h index b1ad1fc0fc7..6e003ace148 100644 --- a/chromium/chrome/browser/extensions/api/extension_action/extension_action_api.h +++ b/chromium/chrome/browser/extensions/api/extension_action/extension_action_api.h @@ -93,7 +93,8 @@ class ExtensionActionAPI : public BrowserContextKeyedAPI { // Dispatches the onClicked event for extension that owns the given action. void DispatchExtensionActionClicked(const ExtensionAction& extension_action, - content::WebContents* web_contents); + content::WebContents* web_contents, + const Extension* extension); // Clears the values for all ExtensionActions for the tab associated with the // given |web_contents| (and signals that page actions changed). |