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 "chrome/browser/extensions/extension_tab_util.h" | 5 #include "chrome/browser/extensions/extension_tab_util.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 | 119 |
120 } // namespace | 120 } // namespace |
121 | 121 |
122 ExtensionTabUtil::OpenTabParams::OpenTabParams() | 122 ExtensionTabUtil::OpenTabParams::OpenTabParams() |
123 : create_browser_if_needed(false) { | 123 : create_browser_if_needed(false) { |
124 } | 124 } |
125 | 125 |
126 ExtensionTabUtil::OpenTabParams::~OpenTabParams() { | 126 ExtensionTabUtil::OpenTabParams::~OpenTabParams() { |
127 } | 127 } |
128 | 128 |
129 // static | |
130 void ExtensionTabUtil::PlatformSpecificFiltering( | |
131 const std::string& extension_id, api::tabs::Tab* tab) { | |
132 if (g_delegate) | |
133 g_delegate->ScrubTabForExtension(extension_id, tab); | |
Ivan Šandrk
2017/05/03 13:00:51
PlatformSpecificFiltering vs. ScrubTabForExtension
Devlin
2017/05/03 15:14:15
I don't feel strongly on the naming, but see also
| |
134 } | |
135 | |
129 // Opens a new tab for a given extension. Returns NULL and sets |error| if an | 136 // Opens a new tab for a given extension. Returns NULL and sets |error| if an |
130 // error occurs. | 137 // error occurs. |
131 base::DictionaryValue* ExtensionTabUtil::OpenTab( | 138 base::DictionaryValue* ExtensionTabUtil::OpenTab( |
132 UIThreadExtensionFunction* function, | 139 UIThreadExtensionFunction* function, |
133 const OpenTabParams& params, | 140 const OpenTabParams& params, |
134 bool user_gesture, | 141 bool user_gesture, |
135 std::string* error) { | 142 std::string* error) { |
136 ChromeExtensionFunctionDetails chrome_details(function); | 143 ChromeExtensionFunctionDetails chrome_details(function); |
137 Profile* profile = chrome_details.GetProfile(); | 144 Profile* profile = chrome_details.GetProfile(); |
138 // windowId defaults to "current" window. | 145 // windowId defaults to "current" window. |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
481 bool host_permission = extension->permissions_data() | 488 bool host_permission = extension->permissions_data() |
482 ->active_permissions() | 489 ->active_permissions() |
483 .HasExplicitAccessToOrigin(GURL(url)); | 490 .HasExplicitAccessToOrigin(GURL(url)); |
484 has_permission = api_permission || host_permission; | 491 has_permission = api_permission || host_permission; |
485 } | 492 } |
486 if (!has_permission) { | 493 if (!has_permission) { |
487 tab->url.reset(); | 494 tab->url.reset(); |
488 tab->title.reset(); | 495 tab->title.reset(); |
489 tab->fav_icon_url.reset(); | 496 tab->fav_icon_url.reset(); |
490 } | 497 } |
491 if (g_delegate) | 498 PlatformSpecificFiltering(extension ? extension->id() : "", tab); |
492 g_delegate->ScrubTabForExtension(extension, contents, tab); | |
493 } | 499 } |
494 | 500 |
495 bool ExtensionTabUtil::GetTabStripModel(const WebContents* web_contents, | 501 bool ExtensionTabUtil::GetTabStripModel(const WebContents* web_contents, |
496 TabStripModel** tab_strip_model, | 502 TabStripModel** tab_strip_model, |
497 int* tab_index) { | 503 int* tab_index) { |
498 DCHECK(web_contents); | 504 DCHECK(web_contents); |
499 DCHECK(tab_strip_model); | 505 DCHECK(tab_strip_model); |
500 DCHECK(tab_index); | 506 DCHECK(tab_index); |
501 | 507 |
502 for (auto* browser : *BrowserList::GetInstance()) { | 508 for (auto* browser : *BrowserList::GetInstance()) { |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
715 chrome::ShowSingletonTabOverwritingNTP(browser, params); | 721 chrome::ShowSingletonTabOverwritingNTP(browser, params); |
716 return true; | 722 return true; |
717 } | 723 } |
718 | 724 |
719 // static | 725 // static |
720 bool ExtensionTabUtil::BrowserSupportsTabs(Browser* browser) { | 726 bool ExtensionTabUtil::BrowserSupportsTabs(Browser* browser) { |
721 return browser && browser->tab_strip_model() && !browser->is_devtools(); | 727 return browser && browser->tab_strip_model() && !browser->is_devtools(); |
722 } | 728 } |
723 | 729 |
724 } // namespace extensions | 730 } // namespace extensions |
OLD | NEW |