Commit 717aac46 authored by Michael Giuffrida's avatar Michael Giuffrida Committed by Commit Bot

Feedback API: Get locale from ExtensionsBrowserClient

Have ExtensionsBrowserClient provide the application locale instead of
using g_browser_process.

Bug: 446329
Change-Id: Ibbab77cf385b2d11c1e6ee093c9118d652324635
Reviewed-on: https://chromium-review.googlesource.com/587420
Commit-Queue: Michael Giuffrida <michaelpg@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491335}
parent 415281fd
......@@ -30,6 +30,7 @@
#include "components/signin/core/browser/signin_manager.h"
#include "components/strings/grit/components_strings.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extensions_browser_client.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/webui/web_ui_util.h"
#include "url/url_util.h"
......@@ -240,7 +241,8 @@ ExtensionFunction::ResponseAction FeedbackPrivateGetStringsFunction::Run() {
IDS_FEEDBACK_SRT_PROMPT_DECLINE_BUTTON);
#undef SET_STRING
const std::string& app_locale = g_browser_process->GetApplicationLocale();
const std::string& app_locale =
ExtensionsBrowserClient::Get()->GetApplicationLocale();
webui::SetLoadTimeDataDefaults(app_locale, dict.get());
......
......@@ -9,12 +9,12 @@
#include "base/callback.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/feedback/system_logs/chrome_system_logs_fetcher.h"
#include "chrome/common/chrome_content_client.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/blob_reader.h"
#include "extensions/browser/extensions_browser_client.h"
#include "net/base/network_change_notifier.h"
using content::BrowserThread;
......@@ -31,7 +31,8 @@ FeedbackService::~FeedbackService() {
void FeedbackService::SendFeedback(content::BrowserContext* browser_context,
scoped_refptr<FeedbackData> feedback_data,
const SendFeedbackCallback& callback) {
feedback_data->set_locale(g_browser_process->GetApplicationLocale());
feedback_data->set_locale(
ExtensionsBrowserClient::Get()->GetApplicationLocale());
feedback_data->set_user_agent(GetUserAgent());
if (!feedback_data->attached_file_uuid().empty()) {
......
......@@ -462,6 +462,10 @@ bool ChromeExtensionsBrowserClient::IsLockScreenContext(
#endif
}
std::string ChromeExtensionsBrowserClient::GetApplicationLocale() {
return g_browser_process->GetApplicationLocale();
}
// static
void ChromeExtensionsBrowserClient::set_did_chrome_update_for_testing(
bool did_update) {
......
......@@ -127,6 +127,7 @@ class ChromeExtensionsBrowserClient : public ExtensionsBrowserClient {
net::URLRequest* request) override;
KioskDelegate* GetKioskDelegate() override;
bool IsLockScreenContext(content::BrowserContext* context) override;
std::string GetApplicationLocale() override;
static void set_did_chrome_update_for_testing(bool did_update);
......
......@@ -270,6 +270,9 @@ class ExtensionsBrowserClient {
// Whether the browser context is associated with Chrome OS lock screen.
virtual bool IsLockScreenContext(content::BrowserContext* context) = 0;
// Returns the locale used by the application.
virtual std::string GetApplicationLocale() = 0;
// Returns the single instance of |this|.
static ExtensionsBrowserClient* Get();
......
......@@ -10,6 +10,7 @@
#include "extensions/browser/extension_host_delegate.h"
#include "extensions/browser/test_runtime_api_delegate.h"
#include "extensions/browser/updater/null_extension_cache.h"
#include "ui/base/l10n/l10n_util.h"
#if defined(OS_CHROMEOS)
#include "chromeos/login/login_state.h"
......@@ -230,4 +231,8 @@ bool TestExtensionsBrowserClient::IsLockScreenContext(
return lock_screen_context_ && context == lock_screen_context_;
}
std::string TestExtensionsBrowserClient::GetApplicationLocale() {
return l10n_util::GetApplicationLocale(std::string());
}
} // namespace extensions
......@@ -121,6 +121,7 @@ class TestExtensionsBrowserClient : public ExtensionsBrowserClient {
scoped_refptr<update_client::UpdateClient> CreateUpdateClient(
content::BrowserContext* context) override;
bool IsLockScreenContext(content::BrowserContext* context) override;
std::string GetApplicationLocale() override;
ExtensionSystemProvider* extension_system_factory() {
return extension_system_factory_;
......
......@@ -30,6 +30,7 @@
#include "extensions/shell/browser/shell_extensions_api_client.h"
#include "extensions/shell/browser/shell_navigation_ui_data.h"
#include "extensions/shell/browser/shell_runtime_api_delegate.h"
#include "ui/base/l10n/l10n_util.h"
#if defined(OS_CHROMEOS)
#include "chromeos/login/login_state.h"
......@@ -281,4 +282,8 @@ bool ShellExtensionsBrowserClient::IsLockScreenContext(
return false;
}
std::string ShellExtensionsBrowserClient::GetApplicationLocale() {
return l10n_util::GetApplicationLocale(std::string());
}
} // namespace extensions
......@@ -98,6 +98,7 @@ class ShellExtensionsBrowserClient : public ExtensionsBrowserClient {
net::URLRequest* request) override;
KioskDelegate* GetKioskDelegate() override;
bool IsLockScreenContext(content::BrowserContext* context) override;
std::string GetApplicationLocale() override;
// Sets the API client.
void SetAPIClientForTest(ExtensionsAPIClient* api_client);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment