From b070e1cc073c2c78a29f2c39177140c245660169 Mon Sep 17 00:00:00 2001 From: sdefresne Date: Mon, 21 Sep 2015 06:50:38 -0700 Subject: [PATCH] Introduce way to check if there is an off-the-record session active. Introduce a new function IsOffTheRecordSessionActive() that returns true if there is an off-the-record session active. It is equivalent to chrome::IsOffTheRecordSessionActive() but for Chrome on iOS. Implement it via ChromeBrowserProvider. BUG=228186 Review URL: https://codereview.chromium.org/1360593002 Cr-Commit-Position: refs/heads/master@{#349925} --- ios/chrome/browser/ui/browser_otr_state.h | 11 +++++++++++ ios/chrome/browser/ui/browser_otr_state.mm | 14 ++++++++++++++ ios/chrome/ios_chrome.gyp | 2 ++ .../provider/chrome/browser/chrome_browser_provider.cc | 4 ++++ .../provider/chrome/browser/chrome_browser_provider.h | 2 ++ 5 files changed, 33 insertions(+) create mode 100644 ios/chrome/browser/ui/browser_otr_state.h create mode 100644 ios/chrome/browser/ui/browser_otr_state.mm diff --git a/ios/chrome/browser/ui/browser_otr_state.h b/ios/chrome/browser/ui/browser_otr_state.h new file mode 100644 index 000000000000..7a53f0fb9a92 --- /dev/null +++ b/ios/chrome/browser/ui/browser_otr_state.h @@ -0,0 +1,11 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef IOS_CHROME_BROWSER_UI_BROWSER_OTR_STATE_H_ +#define IOS_CHROME_BROWSER_UI_BROWSER_OTR_STATE_H_ + +// Returns whether there is any Off-The-Record session in progress. +bool IsOffTheRecordSessionActive(); + +#endif // IOS_CHROME_BROWSER_UI_BROWSER_OTR_STATE_H_ diff --git a/ios/chrome/browser/ui/browser_otr_state.mm b/ios/chrome/browser/ui/browser_otr_state.mm new file mode 100644 index 000000000000..38bff3298978 --- /dev/null +++ b/ios/chrome/browser/ui/browser_otr_state.mm @@ -0,0 +1,14 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ios/chrome/browser/ui/browser_otr_state.h" + +#include "ios/public/provider/chrome/browser/chrome_browser_provider.h" + +bool IsOffTheRecordSessionActive() { + ios::ChromeBrowserProvider* chrome_browser_provider = + ios::GetChromeBrowserProvider(); + return chrome_browser_provider && + chrome_browser_provider->IsOffTheRecordSessionActive(); +} diff --git a/ios/chrome/ios_chrome.gyp b/ios/chrome/ios_chrome.gyp index c91ceb04ef11..2a8922b8269b 100644 --- a/ios/chrome/ios_chrome.gyp +++ b/ios/chrome/ios_chrome.gyp @@ -408,6 +408,8 @@ 'browser/ui/autofill/autofill_client_ios.mm', 'browser/ui/background_generator.h', 'browser/ui/background_generator.mm', + 'browser/ui/browser_otr_state.h', + 'browser/ui/browser_otr_state.mm', 'browser/ui/commands/UIKit+ChromeExecuteCommand.h', 'browser/ui/commands/UIKit+ChromeExecuteCommand.mm', 'browser/ui/commands/clear_browsing_data_command.h', diff --git a/ios/public/provider/chrome/browser/chrome_browser_provider.cc b/ios/public/provider/chrome/browser/chrome_browser_provider.cc index 07bd75f56d59..9f109a6784ab 100644 --- a/ios/public/provider/chrome/browser/chrome_browser_provider.cc +++ b/ios/public/provider/chrome/browser/chrome_browser_provider.cc @@ -116,4 +116,8 @@ rappor::RapporService* ChromeBrowserProvider::GetRapporService() { return nullptr; } +bool ChromeBrowserProvider::IsOffTheRecordSessionActive() { + return false; +} + } // namespace ios diff --git a/ios/public/provider/chrome/browser/chrome_browser_provider.h b/ios/public/provider/chrome/browser/chrome_browser_provider.h index fcfa8ac09169..d120a5f99f4a 100644 --- a/ios/public/provider/chrome/browser/chrome_browser_provider.h +++ b/ios/public/provider/chrome/browser/chrome_browser_provider.h @@ -121,6 +121,8 @@ class ChromeBrowserProvider { virtual policy::BrowserPolicyConnector* GetBrowserPolicyConnector(); // Returns the RapporService. May be null. virtual rappor::RapporService* GetRapporService(); + // Returns whether there is an Off-The-Record session active. + virtual bool IsOffTheRecordSessionActive(); }; } // namespace ios -- 2.11.4.GIT