Rename include_incognito function to include_incognito_information.

ExtensionFunction::include_incognito() is renamed to
ExtensionFunction::include_incognito_information() to provide more
clarity on the use cases.

Bug: 845845
Change-Id: I0ba7bf58faf763a2ca8a50bf15f4c82e75ea82a0
Reviewed-on: https://chromium-review.googlesource.com/1078810
Commit-Queue: Ramin Halavati <[email protected]>
Reviewed-by: Devlin <[email protected]>
Cr-Commit-Position: refs/heads/master@{#564812}
diff --git a/chrome/browser/extensions/api/automation_internal/automation_internal_api.cc b/chrome/browser/extensions/api/automation_internal/automation_internal_api.cc
index ec36382b..62aeea05 100644
--- a/chrome/browser/extensions/api/automation_internal/automation_internal_api.cc
+++ b/chrome/browser/extensions/api/automation_internal/automation_internal_api.cc
@@ -266,7 +266,7 @@
   if (params->args.tab_id.get()) {
     int tab_id = *params->args.tab_id;
     if (!ExtensionTabUtil::GetTabById(
-            tab_id, browser_context(), include_incognito(),
+            tab_id, browser_context(), include_incognito_information(),
             NULL, /* browser out param*/
             NULL, /* tab_strip out param */
             &contents, NULL /* tab_index out param */)) {
diff --git a/chrome/browser/extensions/api/content_settings/content_settings_api.cc b/chrome/browser/extensions/api/content_settings/content_settings_api.cc
index 547f21d..4f50728 100644
--- a/chrome/browser/extensions/api/content_settings/content_settings_api.cc
+++ b/chrome/browser/extensions/api/content_settings/content_settings_api.cc
@@ -132,7 +132,7 @@
   bool incognito = false;
   if (params->details.incognito.get())
     incognito = *params->details.incognito;
-  if (incognito && !include_incognito())
+  if (incognito && !include_incognito_information())
     return RespondNow(Error(pref_keys::kIncognitoErrorMessage));
 
   HostContentSettingsMap* map;
diff --git a/chrome/browser/extensions/api/cookies/cookies_api.cc b/chrome/browser/extensions/api/cookies/cookies_api.cc
index 5a372133..98b21a2b 100644
--- a/chrome/browser/extensions/api/cookies/cookies_api.cc
+++ b/chrome/browser/extensions/api/cookies/cookies_api.cc
@@ -203,7 +203,7 @@
       parsed_args_->details.store_id.get() ? *parsed_args_->details.store_id
                                            : std::string();
   network::mojom::CookieManager* cookie_manager = ParseStoreCookieManager(
-      browser_context(), include_incognito(), &store_id, &error);
+      browser_context(), include_incognito_information(), &store_id, &error);
   if (!cookie_manager)
     return RespondNow(Error(error));
 
@@ -257,7 +257,7 @@
       parsed_args_->details.store_id.get() ? *parsed_args_->details.store_id
                                            : std::string();
   network::mojom::CookieManager* cookie_manager = ParseStoreCookieManager(
-      browser_context(), include_incognito(), &store_id, &error);
+      browser_context(), include_incognito_information(), &store_id, &error);
   if (!cookie_manager)
     return RespondNow(Error(error));
 
@@ -308,7 +308,7 @@
       parsed_args_->details.store_id.get() ? *parsed_args_->details.store_id
                                            : std::string();
   network::mojom::CookieManager* cookie_manager = ParseStoreCookieManager(
-      browser_context(), include_incognito(), &store_id, &error);
+      browser_context(), include_incognito_information(), &store_id, &error);
   if (!cookie_manager)
     return RespondNow(Error(error));
 
@@ -444,7 +444,7 @@
       parsed_args_->details.store_id.get() ? *parsed_args_->details.store_id
                                            : std::string();
   network::mojom::CookieManager* cookie_manager = ParseStoreCookieManager(
-      browser_context(), include_incognito(), &store_id, &error);
+      browser_context(), include_incognito_information(), &store_id, &error);
   if (!cookie_manager)
     return RespondNow(Error(error));
 
@@ -481,7 +481,8 @@
   std::unique_ptr<base::ListValue> original_tab_ids(new base::ListValue());
   Profile* incognito_profile = NULL;
   std::unique_ptr<base::ListValue> incognito_tab_ids;
-  if (include_incognito() && original_profile->HasOffTheRecordProfile()) {
+  if (include_incognito_information() &&
+      original_profile->HasOffTheRecordProfile()) {
     incognito_profile = original_profile->GetOffTheRecordProfile();
     if (incognito_profile)
       incognito_tab_ids.reset(new base::ListValue());
diff --git a/chrome/browser/extensions/api/debugger/debugger_api.cc b/chrome/browser/extensions/api/debugger/debugger_api.cc
index a163e77..738bae9 100644
--- a/chrome/browser/extensions/api/debugger/debugger_api.cc
+++ b/chrome/browser/extensions/api/debugger/debugger_api.cc
@@ -358,13 +358,9 @@
 bool DebuggerFunction::InitAgentHost() {
   if (debuggee_.tab_id) {
     WebContents* web_contents = NULL;
-    bool result = ExtensionTabUtil::GetTabById(*debuggee_.tab_id,
-                                               GetProfile(),
-                                               include_incognito(),
-                                               NULL,
-                                               NULL,
-                                               &web_contents,
-                                               NULL);
+    bool result = ExtensionTabUtil::GetTabById(*debuggee_.tab_id, GetProfile(),
+                                               include_incognito_information(),
+                                               NULL, NULL, &web_contents, NULL);
     if (result && web_contents) {
       // TODO(rdevlin.cronin) This should definitely be GetLastCommittedURL().
       GURL url = web_contents->GetVisibleURL();
diff --git a/chrome/browser/extensions/api/downloads/downloads_api.cc b/chrome/browser/extensions/api/downloads/downloads_api.cc
index 7d33e08..597c5d5 100644
--- a/chrome/browser/extensions/api/downloads/downloads_api.cc
+++ b/chrome/browser/extensions/api/downloads/downloads_api.cc
@@ -1004,7 +1004,11 @@
     return false;
 
   Profile* current_profile = GetProfile();
-  if (include_incognito() && GetProfile()->HasOffTheRecordProfile())
+  // TODO(https://crbug.com/845845): Remove changing current_profile. If a
+  // download request comes from a regular profile, and the incognito profile
+  // exists and extension is running in spanning mode, then we will use
+  // incognito download manager, which is not a correct decision.
+  if (include_incognito_information() && GetProfile()->HasOffTheRecordProfile())
     current_profile = GetProfile()->GetOffTheRecordProfile();
 
   content::StoragePartition* storage_partition =
@@ -1154,7 +1158,7 @@
   EXTENSION_FUNCTION_VALIDATE(params.get());
   DownloadManager* manager = NULL;
   DownloadManager* incognito_manager = NULL;
-  GetManagers(browser_context(), include_incognito(), &manager,
+  GetManagers(browser_context(), include_incognito_information(), &manager,
               &incognito_manager);
   ExtensionDownloadsEventRouter* router =
       DownloadCoreServiceFactory::GetForBrowserContext(
@@ -1199,8 +1203,8 @@
   std::unique_ptr<downloads::Pause::Params> params(
       downloads::Pause::Params::Create(*args_));
   EXTENSION_FUNCTION_VALIDATE(params.get());
-  DownloadItem* download_item =
-      GetDownload(browser_context(), include_incognito(), params->download_id);
+  DownloadItem* download_item = GetDownload(
+      browser_context(), include_incognito_information(), params->download_id);
   std::string error;
   if (InvalidId(download_item, &error) ||
       Fault(download_item->GetState() != DownloadItem::IN_PROGRESS,
@@ -1222,8 +1226,8 @@
   std::unique_ptr<downloads::Resume::Params> params(
       downloads::Resume::Params::Create(*args_));
   EXTENSION_FUNCTION_VALIDATE(params.get());
-  DownloadItem* download_item =
-      GetDownload(browser_context(), include_incognito(), params->download_id);
+  DownloadItem* download_item = GetDownload(
+      browser_context(), include_incognito_information(), params->download_id);
   std::string error;
   if (InvalidId(download_item, &error) ||
       Fault(download_item->IsPaused() && !download_item->CanResume(),
@@ -1245,8 +1249,8 @@
   std::unique_ptr<downloads::Resume::Params> params(
       downloads::Resume::Params::Create(*args_));
   EXTENSION_FUNCTION_VALIDATE(params.get());
-  DownloadItem* download_item =
-      GetDownload(browser_context(), include_incognito(), params->download_id);
+  DownloadItem* download_item = GetDownload(
+      browser_context(), include_incognito_information(), params->download_id);
   if (download_item &&
       (download_item->GetState() == DownloadItem::IN_PROGRESS))
     download_item->Cancel(true);
@@ -1266,7 +1270,7 @@
   EXTENSION_FUNCTION_VALIDATE(params.get());
   DownloadManager* manager = NULL;
   DownloadManager* incognito_manager = NULL;
-  GetManagers(browser_context(), include_incognito(), &manager,
+  GetManagers(browser_context(), include_incognito_information(), &manager,
               &incognito_manager);
   DownloadQuery::DownloadVector results;
   std::string error;
@@ -1293,8 +1297,8 @@
   std::unique_ptr<downloads::RemoveFile::Params> params(
       downloads::RemoveFile::Params::Create(*args_));
   EXTENSION_FUNCTION_VALIDATE(params.get());
-  DownloadItem* download_item =
-      GetDownload(browser_context(), include_incognito(), params->download_id);
+  DownloadItem* download_item = GetDownload(
+      browser_context(), include_incognito_information(), params->download_id);
   if (InvalidId(download_item, &error_) ||
       Fault((download_item->GetState() != DownloadItem::COMPLETE),
             errors::kNotComplete, &error_) ||
@@ -1331,8 +1335,8 @@
 }
 
 void DownloadsAcceptDangerFunction::PromptOrWait(int download_id, int retries) {
-  DownloadItem* download_item =
-      GetDownload(browser_context(), include_incognito(), download_id);
+  DownloadItem* download_item = GetDownload(
+      browser_context(), include_incognito_information(), download_id);
   content::WebContents* web_contents = dispatcher()->GetVisibleWebContents();
   if (InvalidId(download_item, &error_) ||
       Fault(download_item->GetState() != DownloadItem::IN_PROGRESS,
@@ -1374,8 +1378,8 @@
 void DownloadsAcceptDangerFunction::DangerPromptCallback(
     int download_id, DownloadDangerPrompt::Action action) {
   DCHECK_CURRENTLY_ON(BrowserThread::UI);
-  DownloadItem* download_item =
-      GetDownload(browser_context(), include_incognito(), download_id);
+  DownloadItem* download_item = GetDownload(
+      browser_context(), include_incognito_information(), download_id);
   if (InvalidId(download_item, &error_) ||
       Fault(download_item->GetState() != DownloadItem::IN_PROGRESS,
             errors::kNotInProgress, &error_))
@@ -1401,8 +1405,8 @@
   std::unique_ptr<downloads::Show::Params> params(
       downloads::Show::Params::Create(*args_));
   EXTENSION_FUNCTION_VALIDATE(params.get());
-  DownloadItem* download_item =
-      GetDownload(browser_context(), include_incognito(), params->download_id);
+  DownloadItem* download_item = GetDownload(
+      browser_context(), include_incognito_information(), params->download_id);
   std::string error;
   if (InvalidId(download_item, &error))
     return RespondNow(Error(error));
@@ -1418,7 +1422,7 @@
 ExtensionFunction::ResponseAction DownloadsShowDefaultFolderFunction::Run() {
   DownloadManager* manager = NULL;
   DownloadManager* incognito_manager = NULL;
-  GetManagers(browser_context(), include_incognito(), &manager,
+  GetManagers(browser_context(), include_incognito_information(), &manager,
               &incognito_manager);
   platform_util::OpenItem(
       Profile::FromBrowserContext(browser_context()),
@@ -1439,8 +1443,8 @@
   std::unique_ptr<downloads::Open::Params> params(
       downloads::Open::Params::Create(*args_));
   EXTENSION_FUNCTION_VALIDATE(params.get());
-  DownloadItem* download_item =
-      GetDownload(browser_context(), include_incognito(), params->download_id);
+  DownloadItem* download_item = GetDownload(
+      browser_context(), include_incognito_information(), params->download_id);
   std::string error;
   if (InvalidId(download_item, &error) ||
       Fault(!user_gesture(), errors::kUserGesture, &error) ||
@@ -1485,8 +1489,8 @@
     Respond(Error(error));
     return;
   }
-  DownloadItem* download_item =
-      GetDownload(browser_context(), include_incognito(), download_id);
+  DownloadItem* download_item = GetDownload(
+      browser_context(), include_incognito_information(), download_id);
   if (Fault(!download_item, errors::kFileAlreadyDeleted, &error)) {
     Respond(Error(error));
     return;
@@ -1503,8 +1507,8 @@
   std::unique_ptr<downloads::Drag::Params> params(
       downloads::Drag::Params::Create(*args_));
   EXTENSION_FUNCTION_VALIDATE(params.get());
-  DownloadItem* download_item =
-      GetDownload(browser_context(), include_incognito(), params->download_id);
+  DownloadItem* download_item = GetDownload(
+      browser_context(), include_incognito_information(), params->download_id);
   content::WebContents* web_contents =
       dispatcher()->GetVisibleWebContents();
   std::string error;
@@ -1541,7 +1545,7 @@
   RecordApiFunctions(DOWNLOADS_FUNCTION_SET_SHELF_ENABLED);
   DownloadManager* manager = NULL;
   DownloadManager* incognito_manager = NULL;
-  GetManagers(browser_context(), include_incognito(), &manager,
+  GetManagers(browser_context(), include_incognito_information(), &manager,
               &incognito_manager);
   DownloadCoreService* service = NULL;
   DownloadCoreService* incognito_service = NULL;
@@ -1603,8 +1607,8 @@
   int icon_size = kDefaultIconSize;
   if (options && options->size.get())
     icon_size = *options->size;
-  DownloadItem* download_item =
-      GetDownload(browser_context(), include_incognito(), params->download_id);
+  DownloadItem* download_item = GetDownload(
+      browser_context(), include_incognito_information(), params->download_id);
   if (InvalidId(download_item, &error_) ||
       Fault(download_item->GetTargetFilePath().empty(),
             errors::kEmptyFile, &error_))
diff --git a/chrome/browser/extensions/api/downloads_internal/downloads_internal_api.cc b/chrome/browser/extensions/api/downloads_internal/downloads_internal_api.cc
index db658081..b682e00 100644
--- a/chrome/browser/extensions/api/downloads_internal/downloads_internal_api.cc
+++ b/chrome/browser/extensions/api/downloads_internal/downloads_internal_api.cc
@@ -28,7 +28,7 @@
   EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &filename));
   std::string error;
   bool result = ExtensionDownloadsEventRouter::DetermineFilename(
-      browser_context(), include_incognito(), extension()->id(),
+      browser_context(), include_incognito_information(), extension()->id(),
       params->download_id, base::FilePath(filename),
       extensions::api::downloads::ParseFilenameConflictAction(
           params->conflict_action),
diff --git a/chrome/browser/extensions/api/extension_action/extension_action_api.cc b/chrome/browser/extensions/api/extension_action/extension_action_api.cc
index 0b69a15..9e4a4106 100644
--- a/chrome/browser/extensions/api/extension_action/extension_action_api.cc
+++ b/chrome/browser/extensions/api/extension_action/extension_action_api.cc
@@ -336,8 +336,8 @@
   // Find the WebContents that contains this tab id if one is required.
   if (tab_id_ != ExtensionAction::kDefaultTabId) {
     ExtensionTabUtil::GetTabById(tab_id_, browser_context(),
-                                 include_incognito(), nullptr, nullptr,
-                                 &contents_, nullptr);
+                                 include_incognito_information(), nullptr,
+                                 nullptr, &contents_, nullptr);
     if (!contents_)
       return RespondNow(Error(kNoTabError, base::IntToString(tab_id_)));
   } else {
diff --git a/chrome/browser/extensions/api/page_capture/page_capture_api.cc b/chrome/browser/extensions/api/page_capture/page_capture_api.cc
index 05f05dd5..c64ad578 100644
--- a/chrome/browser/extensions/api/page_capture/page_capture_api.cc
+++ b/chrome/browser/extensions/api/page_capture/page_capture_api.cc
@@ -265,13 +265,9 @@
   Browser* browser = NULL;
   content::WebContents* web_contents = NULL;
 
-  if (!ExtensionTabUtil::GetTabById(params_->details.tab_id,
-                                    GetProfile(),
-                                    include_incognito(),
-                                    &browser,
-                                    NULL,
-                                    &web_contents,
-                                    NULL)) {
+  if (!ExtensionTabUtil::GetTabById(params_->details.tab_id, GetProfile(),
+                                    include_incognito_information(), &browser,
+                                    NULL, &web_contents, NULL)) {
     return NULL;
   }
   return web_contents;
diff --git a/chrome/browser/extensions/api/preference/preference_api.cc b/chrome/browser/extensions/api/preference/preference_api.cc
index 8eba4e7..2450398 100644
--- a/chrome/browser/extensions/api/preference/preference_api.cc
+++ b/chrome/browser/extensions/api/preference/preference_api.cc
@@ -633,7 +633,10 @@
                                                     &incognito));
 
   // Check incognito access.
-  if (incognito && !include_incognito())
+  // TODO(https://crbug.com/845845): Update to allowing the function to read
+  // from incognito preferences iff:
+  // enabled_incognito && (!split_mode || browser_context()->IsOffTheRecord())
+  if (incognito && !include_incognito_information())
     return RespondNow(Error(keys::kIncognitoErrorMessage));
 
   // Obtain pref.
@@ -708,12 +711,17 @@
       (scope == kExtensionPrefsScopeIncognitoPersistent ||
        scope == kExtensionPrefsScopeIncognitoSessionOnly);
   if (incognito) {
-    // Regular profiles can't access incognito unless include_incognito is true.
-    if (!browser_context()->IsOffTheRecord() && !include_incognito())
+    // Regular profiles can't access incognito unless
+    // include_incognito_information is true.
+    if (!browser_context()->IsOffTheRecord() &&
+        !include_incognito_information())
       return RespondNow(Error(keys::kIncognitoErrorMessage));
   } else if (browser_context()->IsOffTheRecord()) {
-    // Incognito profiles can't access regular mode ever, they only exist in
-    // split mode.
+    // If the browser_context associated with this ExtensionFunction is off the
+    // record, it must have come from the incognito process for a split-mode
+    // extension (spanning mode extensions only run in the on-the-record
+    // process). The incognito profile of a split-mode extension should never be
+    // able to modify the on-the-record profile, so error out.
     return RespondNow(
         Error("Can't modify regular settings from an incognito context."));
   }
diff --git a/chrome/browser/extensions/api/processes/processes_api.cc b/chrome/browser/extensions/api/processes/processes_api.cc
index 84d7215..1de2474 100644
--- a/chrome/browser/extensions/api/processes/processes_api.cc
+++ b/chrome/browser/extensions/api/processes/processes_api.cc
@@ -456,12 +456,8 @@
   content::WebContents* contents = nullptr;
   int tab_index = -1;
   if (!ExtensionTabUtil::GetTabById(
-          tab_id,
-          Profile::FromBrowserContext(browser_context()),
-          include_incognito(),
-          nullptr,
-          nullptr,
-          &contents,
+          tab_id, Profile::FromBrowserContext(browser_context()),
+          include_incognito_information(), nullptr, nullptr, &contents,
           &tab_index)) {
     return RespondNow(Error(tabs_constants::kTabNotFoundError,
                             base::IntToString(tab_id)));
diff --git a/chrome/browser/extensions/api/tab_capture/tab_capture_api.cc b/chrome/browser/extensions/api/tab_capture/tab_capture_api.cc
index 2978c2b..529970f 100644
--- a/chrome/browser/extensions/api/tab_capture/tab_capture_api.cc
+++ b/chrome/browser/extensions/api/tab_capture/tab_capture_api.cc
@@ -189,8 +189,9 @@
   EXTENSION_FUNCTION_VALIDATE(params);
 
   // Figure out the active WebContents and retrieve the needed ids.
-  Browser* target_browser = chrome::FindAnyBrowser(
-      Profile::FromBrowserContext(browser_context()), include_incognito());
+  Browser* target_browser =
+      chrome::FindAnyBrowser(Profile::FromBrowserContext(browser_context()),
+                             include_incognito_information());
   if (!target_browser)
     return RespondNow(Error(kFindingTabError));
 
diff --git a/chrome/browser/extensions/api/tabs/tabs_api.cc b/chrome/browser/extensions/api/tabs/tabs_api.cc
index 8e8dd0c..fafd3bee 100644
--- a/chrome/browser/extensions/api/tabs/tabs_api.cc
+++ b/chrome/browser/extensions/api/tabs/tabs_api.cc
@@ -519,9 +519,9 @@
     // Find the tab. |source_tab_strip| and |tab_index| will later be used to
     // move the tab into the created window.
     Browser* source_browser = nullptr;
-    if (!GetTabById(*create_data->tab_id, calling_profile, include_incognito(),
-                    &source_browser, &source_tab_strip, nullptr, &tab_index,
-                    &error)) {
+    if (!GetTabById(*create_data->tab_id, calling_profile,
+                    include_incognito_information(), &source_browser,
+                    &source_tab_strip, nullptr, &tab_index, &error)) {
       return RespondNow(Error(error));
     }
 
@@ -673,7 +673,8 @@
 
   std::unique_ptr<base::Value> result;
   if (new_window->profile()->IsOffTheRecord() &&
-      !browser_context()->IsOffTheRecord() && !include_incognito()) {
+      !browser_context()->IsOffTheRecord() &&
+      !include_incognito_information()) {
     // Don't expose incognito windows if extension itself works in non-incognito
     // profile and CanCrossIncognito isn't allowed.
     result = std::make_unique<base::Value>();
@@ -944,7 +945,7 @@
   std::unique_ptr<base::ListValue> result(new base::ListValue());
   Profile* profile = Profile::FromBrowserContext(browser_context());
   Browser* last_active_browser =
-      chrome::FindAnyBrowser(profile, include_incognito());
+      chrome::FindAnyBrowser(profile, include_incognito_information());
   Browser* current_browser =
       ChromeExtensionFunctionDetails(this).GetCurrentBrowser();
   for (auto* browser : *BrowserList::GetInstance()) {
@@ -954,7 +955,7 @@
     if (!browser->window())
       continue;
 
-    if (!include_incognito() && profile != browser->profile())
+    if (!include_incognito_information() && profile != browser->profile())
       continue;
 
     if (!browser->extension_window_controller()->IsVisibleToTabsAPIForExtension(
@@ -1113,8 +1114,8 @@
   TabStripModel* tab_strip = NULL;
   int tab_index = -1;
   std::string error;
-  if (!GetTabById(tab_id, browser_context(), include_incognito(), &browser,
-                  &tab_strip, NULL, &tab_index, &error)) {
+  if (!GetTabById(tab_id, browser_context(), include_incognito_information(),
+                  &browser, &tab_strip, NULL, &tab_index, &error)) {
     return RespondNow(Error(error));
   }
 
@@ -1148,8 +1149,8 @@
   WebContents* contents = NULL;
   int tab_index = -1;
   std::string error;
-  if (!GetTabById(tab_id, browser_context(), include_incognito(), NULL,
-                  &tab_strip, &contents, &tab_index, &error)) {
+  if (!GetTabById(tab_id, browser_context(), include_incognito_information(),
+                  NULL, &tab_strip, &contents, &tab_index, &error)) {
     return RespondNow(Error(error));
   }
 
@@ -1264,8 +1265,8 @@
   TabStripModel* tab_strip = NULL;
   Browser* browser = nullptr;
   std::string error;
-  if (!GetTabById(tab_id, browser_context(), include_incognito(), &browser,
-                  &tab_strip, &contents, &tab_index, &error)) {
+  if (!GetTabById(tab_id, browser_context(), include_incognito_information(),
+                  &browser, &tab_strip, &contents, &tab_index, &error)) {
     return RespondNow(Error(error));
   }
 
@@ -1346,8 +1347,8 @@
     if (opener_id == tab_id)
       return RespondNow(Error("Cannot set a tab's opener to itself."));
     if (!ExtensionTabUtil::GetTabById(opener_id, browser_context(),
-                                      include_incognito(), nullptr, nullptr,
-                                      &opener_contents, nullptr)) {
+                                      include_incognito_information(), nullptr,
+                                      nullptr, &opener_contents, nullptr)) {
       return RespondNow(Error(ErrorUtils::FormatErrorMessage(
           keys::kTabNotFoundError, base::IntToString(opener_id))));
     }
@@ -1522,7 +1523,7 @@
   TabStripModel* source_tab_strip = NULL;
   WebContents* contents = NULL;
   int tab_index = -1;
-  if (!GetTabById(tab_id, browser_context(), include_incognito(),
+  if (!GetTabById(tab_id, browser_context(), include_incognito_information(),
                   &source_browser, &source_tab_strip, &contents, &tab_index,
                   error)) {
     return false;
@@ -1639,8 +1640,8 @@
 
     Browser* browser = NULL;
     std::string error;
-    if (!GetTabById(tab_id, browser_context(), include_incognito(), &browser,
-                    NULL, &web_contents, NULL, &error)) {
+    if (!GetTabById(tab_id, browser_context(), include_incognito_information(),
+                    &browser, NULL, &web_contents, NULL, &error)) {
       return RespondNow(Error(error));
     }
   }
@@ -1686,8 +1687,8 @@
 bool TabsRemoveFunction::RemoveTab(int tab_id, std::string* error) {
   Browser* browser = NULL;
   WebContents* contents = NULL;
-  if (!GetTabById(tab_id, browser_context(), include_incognito(), &browser,
-                  nullptr, &contents, nullptr, error)) {
+  if (!GetTabById(tab_id, browser_context(), include_incognito_information(),
+                  &browser, nullptr, &contents, nullptr, error)) {
     return false;
   }
 
@@ -1835,8 +1836,8 @@
   std::string error;
   if (params->tab_id.get()) {
     tab_id = *params->tab_id;
-    if (!GetTabById(tab_id, browser_context(), include_incognito(), &browser,
-                    nullptr, &contents, nullptr, &error)) {
+    if (!GetTabById(tab_id, browser_context(), include_incognito_information(),
+                    &browser, nullptr, &contents, nullptr, &error)) {
       return RespondNow(Error(error));
     }
     // TODO(devlin): Can this happen? GetTabById() should return false if
@@ -1971,8 +1972,9 @@
   // If |tab_id| is specified, look for the tab. Otherwise default to selected
   // tab in the current window.
   CHECK_GE(execute_tab_id_, 0);
-  if (!GetTabById(execute_tab_id_, browser_context(), include_incognito(),
-                  nullptr, nullptr, &contents, nullptr, error)) {
+  if (!GetTabById(execute_tab_id_, browser_context(),
+                  include_incognito_information(), nullptr, nullptr, &contents,
+                  nullptr, error)) {
     return false;
   }
 
@@ -2028,10 +2030,10 @@
   Browser* browser = nullptr;
   content::WebContents* contents = nullptr;
 
-  bool success =
-      GetTabById(execute_tab_id_, browser_context(), include_incognito(),
-                 &browser, nullptr, &contents, nullptr, error) &&
-      contents && browser;
+  bool success = GetTabById(execute_tab_id_, browser_context(),
+                            include_incognito_information(), &browser, nullptr,
+                            &contents, nullptr, error) &&
+                 contents && browser;
 
   if (!success)
     return nullptr;
@@ -2060,7 +2062,7 @@
   content::WebContents* web_contents = NULL;
   if (tab_id != -1) {
     // We assume this call leaves web_contents unchanged if it is unsuccessful.
-    GetTabById(tab_id, browser_context(), include_incognito(),
+    GetTabById(tab_id, browser_context(), include_incognito_information(),
                nullptr /* ignore Browser* output */,
                nullptr /* ignore TabStripModel* output */, &web_contents,
                nullptr /* ignore int tab_index output */, error);
@@ -2209,8 +2211,8 @@
   if (params->tab_id) {
     int tab_id = *params->tab_id;
     std::string error;
-    if (!GetTabById(tab_id, browser_context(), include_incognito(), nullptr,
-                    nullptr, &contents, nullptr, &error)) {
+    if (!GetTabById(tab_id, browser_context(), include_incognito_information(),
+                    nullptr, nullptr, &contents, nullptr, &error)) {
       return RespondNow(Error(error));
     }
   }
diff --git a/chrome/browser/extensions/api/tabs/tabs_test.cc b/chrome/browser/extensions/api/tabs/tabs_test.cc
index 0dc983f..865866b 100644
--- a/chrome/browser/extensions/api/tabs/tabs_test.cc
+++ b/chrome/browser/extensions/api/tabs/tabs_test.cc
@@ -446,7 +446,7 @@
       new TabsUpdateFunction());
   scoped_refptr<Extension> extension(ExtensionBuilder("Test").Build());
   update_tab_function->set_extension(extension.get());
-  update_tab_function->set_include_incognito(true);
+  update_tab_function->set_include_incognito_information(true);
 
   static const char kArgsWithNonIncognitoUrl[] =
       "[null, {\"url\": \"chrome://extensions/configureCommands\"}]";
diff --git a/chrome/browser/extensions/api/tabs/windows_util.cc b/chrome/browser/extensions/api/tabs/windows_util.cc
index 3d75225..17b7831 100644
--- a/chrome/browser/extensions/api/tabs/windows_util.cc
+++ b/chrome/browser/extensions/api/tabs/windows_util.cc
@@ -85,7 +85,7 @@
   if (function->browser_context() == controller->profile())
     return true;
 
-  if (!function->include_incognito())
+  if (!function->include_incognito_information())
     return false;
 
   Profile* profile = Profile::FromBrowserContext(function->browser_context());
diff --git a/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc b/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc
index c52172b..907360f 100644
--- a/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc
+++ b/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc
@@ -477,8 +477,8 @@
 
   content::WebContents* web_contents;
   if (!ExtensionTabUtil::GetTabById(tab_id, browser_context(),
-                                    include_incognito(), nullptr, nullptr,
-                                    &web_contents, nullptr) ||
+                                    include_incognito_information(), nullptr,
+                                    nullptr, &web_contents, nullptr) ||
       !web_contents) {
     return RespondNow(OneArgument(std::make_unique<base::Value>()));
   }
@@ -517,8 +517,8 @@
 
   content::WebContents* web_contents;
   if (!ExtensionTabUtil::GetTabById(tab_id, browser_context(),
-                                    include_incognito(), nullptr, nullptr,
-                                    &web_contents, nullptr) ||
+                                    include_incognito_information(), nullptr,
+                                    nullptr, &web_contents, nullptr) ||
       !web_contents) {
     return RespondNow(OneArgument(std::make_unique<base::Value>()));
   }
diff --git a/chrome/browser/extensions/chrome_extension_function_details.cc b/chrome/browser/extensions/chrome_extension_function_details.cc
index af5501b7..d925583 100644
--- a/chrome/browser/extensions/chrome_extension_function_details.cc
+++ b/chrome/browser/extensions/chrome_extension_function_details.cc
@@ -55,8 +55,8 @@
   Profile* profile = Profile::FromBrowserContext(
       web_contents ? web_contents->GetBrowserContext()
                    : function_->browser_context());
-  Browser* browser =
-      chrome::FindAnyBrowser(profile, function_->include_incognito());
+  Browser* browser = chrome::FindAnyBrowser(
+      profile, function_->include_incognito_information());
   if (browser)
     return browser;
 
diff --git a/chrome/browser/extensions/extension_tab_util.cc b/chrome/browser/extensions/extension_tab_util.cc
index 5abb7a6..11ff12e 100644
--- a/chrome/browser/extensions/extension_tab_util.cc
+++ b/chrome/browser/extensions/extension_tab_util.cc
@@ -64,10 +64,10 @@
 // appropriate message if the window cannot be found by id.
 Browser* GetBrowserInProfileWithId(Profile* profile,
                                    const int window_id,
-                                   bool include_incognito,
+                                   bool match_incognito_profile,
                                    std::string* error_message) {
   Profile* incognito_profile =
-      include_incognito && profile->HasOffTheRecordProfile()
+      match_incognito_profile && profile->HasOffTheRecordProfile()
           ? profile->GetOffTheRecordProfile()
           : nullptr;
   for (auto* browser : *BrowserList::GetInstance()) {
@@ -143,7 +143,8 @@
 
   // Ensure the selected browser is tabbed.
   if (!browser->is_type_tabbed() && browser->IsAttemptingToCloseBrowser())
-    browser = chrome::FindTabbedBrowser(profile, function->include_incognito());
+    browser = chrome::FindTabbedBrowser(
+        profile, function->include_incognito_information());
   if (!browser || !browser->window()) {
     if (error)
       *error = keys::kNoCurrentWindowError;
@@ -158,8 +159,8 @@
     int opener_id = *params.opener_tab_id;
 
     if (!ExtensionTabUtil::GetTabById(
-            opener_id, profile, function->include_incognito(), &opener_browser,
-            nullptr, &opener, nullptr)) {
+            opener_id, profile, function->include_incognito_information(),
+            &opener_browser, nullptr, &opener, nullptr)) {
       if (error) {
         *error = ErrorUtils::FormatErrorMessage(keys::kTabNotFoundError,
                                                 base::IntToString(opener_id));
@@ -286,10 +287,9 @@
     }
     return result;
   } else {
-    return GetBrowserInProfileWithId(details.GetProfile(),
-                                     window_id,
-                                     details.function()->include_incognito(),
-                                     error);
+    return GetBrowserInProfileWithId(
+        details.GetProfile(), window_id,
+        details.function()->include_incognito_information(), error);
   }
 }
 
diff --git a/extensions/browser/api_test_utils.cc b/extensions/browser/api_test_utils.cc
index b1537b85..1dcf8236 100644
--- a/extensions/browser/api_test_utils.cc
+++ b/extensions/browser/api_test_utils.cc
@@ -233,7 +233,7 @@
   function->set_dispatcher(dispatcher->AsWeakPtr());
 
   function->set_browser_context(context);
-  function->set_include_incognito(flags & INCLUDE_INCOGNITO);
+  function->set_include_incognito_information(flags & INCLUDE_INCOGNITO);
   function->RunWithValidation()->Execute();
   response_helper.WaitForResponse();
 
diff --git a/extensions/browser/extension_function.cc b/extensions/browser/extension_function.cc
index 2c143862..38706e90 100644
--- a/extensions/browser/extension_function.cc
+++ b/extensions/browser/extension_function.cc
@@ -292,7 +292,7 @@
       profile_id_(NULL),
       name_(""),
       has_callback_(false),
-      include_incognito_(false),
+      include_incognito_information_(false),
       user_gesture_(false),
       bad_message_(false),
       histogram_value_(extensions::functions::UNKNOWN),
diff --git a/extensions/browser/extension_function.h b/extensions/browser/extension_function.h
index 0b70be6..45c7099 100644
--- a/extensions/browser/extension_function.h
+++ b/extensions/browser/extension_function.h
@@ -276,8 +276,12 @@
   void set_has_callback(bool has_callback) { has_callback_ = has_callback; }
   bool has_callback() { return has_callback_; }
 
-  void set_include_incognito(bool include) { include_incognito_ = include; }
-  bool include_incognito() const { return include_incognito_; }
+  void set_include_incognito_information(bool include) {
+    include_incognito_information_ = include;
+  }
+  bool include_incognito_information() const {
+    return include_incognito_information_;
+  }
 
   // Note: consider using ScopedUserGestureForTests instead of calling
   // set_user_gesture directly.
@@ -469,7 +473,7 @@
   // even if our profile_ is non-incognito. Note that in the case of a "split"
   // mode extension, this will always be false, and we will limit access to
   // data from within the same profile_ (either incognito or not).
-  bool include_incognito_;
+  bool include_incognito_information_;
 
   // True if the call was made in response of user gesture.
   bool user_gesture_;
diff --git a/extensions/browser/extension_function_dispatcher.cc b/extensions/browser/extension_function_dispatcher.cc
index 249fd4c..7e1c782 100644
--- a/extensions/browser/extension_function_dispatcher.cc
+++ b/extensions/browser/extension_function_dispatcher.cc
@@ -303,7 +303,9 @@
   function_io->set_ipc_sender(ipc_sender, routing_id);
   function_io->set_extension_info_map(extension_info_map);
   if (extension) {
-    function->set_include_incognito(
+    // TODO(https://crbug.com/845845): Also check if the extension is in
+    // spanning mode (CanCrossIncognito).
+    function->set_include_incognito_information(
         extension_info_map->IsIncognitoEnabled(extension->id()));
   }
 
@@ -452,7 +454,7 @@
   if (extension &&
       ExtensionsBrowserClient::Get()->CanExtensionCrossIncognito(
           extension, browser_context_)) {
-    function->set_include_incognito(true);
+    function->set_include_incognito_information(true);
   }
 
   if (!CheckPermissions(function.get(), params, callback))