| Index: chrome/browser/ui/views/apps/app_info_dialog/arc_app_info_links_panel.cc
|
| diff --git a/chrome/browser/ui/views/apps/app_info_dialog/arc_app_info_links_panel.cc b/chrome/browser/ui/views/apps/app_info_dialog/arc_app_info_links_panel.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..4f7cec2fab0fc8e061956da39c55d51ed7b75dc4
|
| --- /dev/null
|
| +++ b/chrome/browser/ui/views/apps/app_info_dialog/arc_app_info_links_panel.cc
|
| @@ -0,0 +1,82 @@
|
| +// Copyright 2016 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/ui/views/apps/app_info_dialog/arc_app_info_links_panel.h"
|
| +
|
| +#include "chrome/browser/profiles/profile.h"
|
| +#include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
|
| +#include "chrome/grit/generated_resources.h"
|
| +#include "components/arc/common/app.mojom.h"
|
| +#include "ui/base/l10n/l10n_util.h"
|
| +#include "ui/views/controls/link.h"
|
| +#include "ui/views/layout/box_layout.h"
|
| +#include "ui/views/layout/layout_constants.h"
|
| +#include "ui/views/view.h"
|
| +
|
| +namespace {
|
| +char kArcChromePackageName[] = "org.chromium.arc.intent_helper";
|
| +}
|
| +
|
| +ArcAppInfoLinksPanel::ArcAppInfoLinksPanel(Profile* profile,
|
| + const extensions::Extension* app)
|
| + : AppInfoPanel(profile, app),
|
| + manage_link_(nullptr),
|
| + weak_ptr_factory_(this) {
|
| + SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0,
|
| + views::kRelatedControlVerticalSpacing));
|
| + manage_link_ = new views::Link(
|
| + l10n_util::GetStringUTF16(IDS_ARC_APPLICATION_INFO_MANAGE_LINK));
|
| + manage_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
|
| + manage_link_->set_listener(this);
|
| + AddChildView(manage_link_);
|
| +
|
| + ArcAppListPrefs* const arc_prefs = ArcAppListPrefs::Get(profile_);
|
| + DCHECK(arc_prefs);
|
| + arc_prefs->AddObserver(this);
|
| +
|
| + std::unique_ptr<ArcAppListPrefs::AppInfo> app_info =
|
| + ArcAppListPrefs::Get(profile)->GetApp(arc::kSettingsAppId);
|
| + if (app_info)
|
| + UpdateLink(app_info->ready);
|
| +}
|
| +
|
| +ArcAppInfoLinksPanel::~ArcAppInfoLinksPanel() {
|
| + ArcAppListPrefs* arc_prefs = ArcAppListPrefs::Get(profile_);
|
| + DCHECK(arc_prefs);
|
| + arc_prefs->RemoveObserver(this);
|
| +}
|
| +
|
| +void ArcAppInfoLinksPanel::LinkClicked(views::Link* source, int event_flags) {
|
| + if (source == manage_link_) {
|
| + if (arc::ShowPackageInfoOnPage(
|
| + kArcChromePackageName,
|
| + arc::mojom::ShowPackageInfoPage::MANAGE_LINKS)) {
|
| + Close();
|
| + }
|
| + } else {
|
| + NOTREACHED();
|
| + }
|
| +}
|
| +
|
| +void ArcAppInfoLinksPanel::OnAppReadyChanged(const std::string& app_id,
|
| + bool ready) {
|
| + if (app_id == arc::kSettingsAppId)
|
| + UpdateLink(ready);
|
| +}
|
| +
|
| +void ArcAppInfoLinksPanel::OnAppRemoved(const std::string& app_id) {
|
| + if (app_id == arc::kSettingsAppId)
|
| + UpdateLink(false);
|
| +}
|
| +
|
| +void ArcAppInfoLinksPanel::OnAppRegistered(
|
| + const std::string& app_id,
|
| + const ArcAppListPrefs::AppInfo& app_info) {
|
| + if (app_id == arc::kSettingsAppId)
|
| + UpdateLink(app_info.ready);
|
| +}
|
| +
|
| +void ArcAppInfoLinksPanel::UpdateLink(bool enabled) {
|
| + manage_link_->SetEnabled(enabled);
|
| +}
|
|
|