Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: chrome/browser/ui/webui/settings/chromeos/android_apps_handler.cc

Issue 2702723002: Extract kArcEnabled preference from ArcSessionManager part 1. (Closed)
Patch Set: Address comments. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/ui/webui/settings/chromeos/android_apps_handler.h" 5 #include "chrome/browser/ui/webui/settings/chromeos/android_apps_handler.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/chromeos/arc/arc_session_manager.h"
9 #include "chrome/browser/chromeos/arc/arc_util.h" 8 #include "chrome/browser/chromeos/arc/arc_util.h"
10 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" // kSettingsAppId 10 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" // kSettingsAppId
12 #include "ui/events/event_constants.h" 11 #include "ui/events/event_constants.h"
13 12
14 namespace chromeos { 13 namespace chromeos {
15 namespace settings { 14 namespace settings {
16 15
17 AndroidAppsHandler::AndroidAppsHandler(Profile* profile) 16 AndroidAppsHandler::AndroidAppsHandler(Profile* profile)
18 : arc_prefs_observer_(this), profile_(profile), weak_ptr_factory_(this) {} 17 : arc_prefs_observer_(this), profile_(profile), weak_ptr_factory_(this) {}
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 void AndroidAppsHandler::OnAppChanged(const std::string& app_id) { 57 void AndroidAppsHandler::OnAppChanged(const std::string& app_id) {
59 if (app_id != arc::kSettingsAppId) 58 if (app_id != arc::kSettingsAppId)
60 return; 59 return;
61 SendAndroidAppsInfo(); 60 SendAndroidAppsInfo();
62 } 61 }
63 62
64 std::unique_ptr<base::DictionaryValue> 63 std::unique_ptr<base::DictionaryValue>
65 AndroidAppsHandler::BuildAndroidAppsInfo() { 64 AndroidAppsHandler::BuildAndroidAppsInfo() {
66 std::unique_ptr<base::DictionaryValue> info(new base::DictionaryValue); 65 std::unique_ptr<base::DictionaryValue> info(new base::DictionaryValue);
67 bool app_ready = false; 66 bool app_ready = false;
68 if (arc::ArcSessionManager::Get()->IsArcPlayStoreEnabled()) { 67 if (arc::IsArcPlayStoreEnabledForProfile(profile_)) {
69 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = 68 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info =
70 ArcAppListPrefs::Get(profile_)->GetApp(arc::kSettingsAppId); 69 ArcAppListPrefs::Get(profile_)->GetApp(arc::kSettingsAppId);
71 app_ready = app_info && app_info->ready; 70 app_ready = app_info && app_info->ready;
72 } 71 }
73 info->SetBoolean("appReady", app_ready); 72 info->SetBoolean("appReady", app_ready);
74 return info; 73 return info;
75 } 74 }
76 75
77 void AndroidAppsHandler::HandleRequestAndroidAppsInfo( 76 void AndroidAppsHandler::HandleRequestAndroidAppsInfo(
78 const base::ListValue* args) { 77 const base::ListValue* args) {
(...skipping 13 matching lines...) Expand all
92 args->GetBoolean(0, &activated_from_keyboard); 91 args->GetBoolean(0, &activated_from_keyboard);
93 int flags = activated_from_keyboard ? ui::EF_NONE : ui::EF_LEFT_MOUSE_BUTTON; 92 int flags = activated_from_keyboard ? ui::EF_NONE : ui::EF_LEFT_MOUSE_BUTTON;
94 93
95 // Settings in secondary profile cannot access ARC. 94 // Settings in secondary profile cannot access ARC.
96 CHECK(arc::IsArcAllowedForProfile(profile_)); 95 CHECK(arc::IsArcAllowedForProfile(profile_));
97 arc::LaunchAndroidSettingsApp(profile_, flags); 96 arc::LaunchAndroidSettingsApp(profile_, flags);
98 } 97 }
99 98
100 } // namespace settings 99 } // namespace settings
101 } // namespace chromeos 100 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698