summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/ui/mobile_config_ui.cc
blob: 0d2736247b0993d27bed1a424db55d306ee3e254 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright 2014 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 "chrome/browser/chromeos/ui/mobile_config_ui.h"

#include <string>

#include "base/logging.h"
#include "chrome/browser/chromeos/mobile_config.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/host_desktop.h"
#include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
#include "chrome/browser/ui/singleton_tabs.h"

namespace chromeos {
namespace mobile_config_ui {

bool DisplayConfigDialog() {
  MobileConfig* config = MobileConfig::GetInstance();
  if (!config->IsReady()) {
    LOG(ERROR) << "MobileConfig not ready";
    return false;
  }
  const MobileConfig::LocaleConfig* locale_config = config->GetLocaleConfig();
  if (!locale_config) {
    LOG(ERROR) << "MobileConfig::LocaleConfig not available";
    return false;
  }
  std::string setup_url = locale_config->setup_url();
  if (setup_url.empty()) {
    LOG(ERROR) << "MobileConfig setup url is empty";
    return false;
  }
  // The mobile device will be managed by the primary user.
  chrome::ScopedTabbedBrowserDisplayer displayer(
      ProfileManager::GetPrimaryUserProfile(),
      chrome::HOST_DESKTOP_TYPE_ASH);
  chrome::ShowSingletonTab(displayer.browser(), GURL(setup_url));
  return true;
}

}  // namespace mobile_config_ui
}  // namespace chromeos