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

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

Issue 2858643002: PS - Filtering activeTab URL (Closed)
Patch Set: Created 3 years, 7 months 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/extensions/extension_tab_util.h" 5 #include "chrome/browser/extensions/extension_tab_util.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "chrome/common/extensions/api/tabs.h" 9 #include "chrome/common/extensions/api/tabs.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 namespace extensions { 12 namespace extensions {
13 13
14 namespace { 14 namespace {
15 15
16 const char kCustomUrl[] = "www.example.com/foo?bar=baz"; 16 const char kCustomUrl[] = "www.example.com/foo?bar=baz";
17 17
18 class ExtensionTabUtilTestDelegate : public ExtensionTabUtil::Delegate { 18 class ExtensionTabUtilTestDelegate : public ExtensionTabUtil::Delegate {
19 public: 19 public:
20 ExtensionTabUtilTestDelegate() {} 20 ExtensionTabUtilTestDelegate() {}
21 ~ExtensionTabUtilTestDelegate() override {} 21 ~ExtensionTabUtilTestDelegate() override {}
22 22
23 // ExtensionTabUtil::Delegate 23 // ExtensionTabUtil::Delegate
24 void ScrubTabForExtension(const Extension* extension, 24 void ScrubTabForExtension(const std::string& extension_id,
25 content::WebContents* contents,
26 api::tabs::Tab* tab) override { 25 api::tabs::Tab* tab) override {
27 tab->url.reset(new std::string(kCustomUrl)); 26 tab->url.reset(new std::string(kCustomUrl));
28 } 27 }
29 28
30 private: 29 private:
31 DISALLOW_COPY_AND_ASSIGN(ExtensionTabUtilTestDelegate); 30 DISALLOW_COPY_AND_ASSIGN(ExtensionTabUtilTestDelegate);
32 }; 31 };
33 32
34 } // namespace 33 } // namespace
35 34
36 // Test that the custom ScrubTabForExtension delegate works - in this test it 35 // Test that the custom ScrubTabForExtension delegate works - in this test it
37 // sets URL to a custom string. 36 // sets URL to a custom string.
38 TEST(ExtensionTabUtilTest, Delegate) { 37 TEST(ExtensionTabUtilTest, Delegate) {
39 auto test_delegate = base::MakeUnique<ExtensionTabUtilTestDelegate>(); 38 auto test_delegate = base::MakeUnique<ExtensionTabUtilTestDelegate>();
40 ExtensionTabUtil::SetPlatformDelegate(test_delegate.get()); 39 ExtensionTabUtil::SetPlatformDelegate(test_delegate.get());
41 40
42 api::tabs::Tab tab; 41 api::tabs::Tab tab;
43 ExtensionTabUtil::ScrubTabForExtension(nullptr, nullptr, &tab); 42 ExtensionTabUtil::ScrubTabForExtension(nullptr, nullptr, &tab);
44 EXPECT_EQ(kCustomUrl, *tab.url); 43 EXPECT_EQ(kCustomUrl, *tab.url);
45 44
46 // Unset the delegate. 45 // Unset the delegate.
47 ExtensionTabUtil::SetPlatformDelegate(nullptr); 46 ExtensionTabUtil::SetPlatformDelegate(nullptr);
48 } 47 }
49 48
50 } // namespace extensions 49 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698