1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/extensions/api/feedback_private/feedback_private_api.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/profiles/profile_manager.h"
11 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
12 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
13 #include "chrome/browser/ui/browser_finder.h"
14 #include "chrome/browser/ui/browser_window.h"
15 #include "chrome/browser/ui/tabs/tab_strip_model.h"
16 #include "content/public/browser/web_contents.h"
21 GURL
GetTargetTabUrl(int session_id
, int index
) {
22 Browser
* browser
= chrome::FindBrowserWithID(session_id
);
24 if (!browser
|| index
>= browser
->tab_strip_model()->count())
28 content::WebContents
* target_tab
=
29 browser
->tab_strip_model()->GetWebContentsAt(index
);
31 return target_tab
->GetURL();
41 extern const char kAppLauncherCategoryTag
[] = "AppLauncher";
43 void ShowFeedbackPage(Browser
* browser
,
44 const std::string
& description_template
,
45 const std::string
& category_tag
) {
48 page_url
= GetTargetTabUrl(browser
->session_id().id(),
49 browser
->tab_strip_model()->active_index());
52 Profile
* profile
= NULL
;
54 profile
= browser
->profile();
56 profile
= ProfileManager::GetLastUsedProfileAllowedByPolicy();
59 LOG(ERROR
) << "Cannot invoke feedback: No profile found!";
63 // We do not want to launch on an OTR profile.
64 profile
= profile
->GetOriginalProfile();
67 #if defined(OS_CHROMEOS)
68 // Obtains the display profile ID on which the Feedback window should show.
69 chrome::MultiUserWindowManager
* const window_manager
=
70 chrome::MultiUserWindowManager::GetInstance();
71 const std::string display_profile_id
=
72 window_manager
&& browser
73 ? window_manager
->GetUserPresentingWindow(
74 browser
->window()->GetNativeWindow())
76 profile
= display_profile_id
.empty()
78 : multi_user_util::GetProfileFromUserID(display_profile_id
);
81 extensions::FeedbackPrivateAPI
* api
=
82 extensions::FeedbackPrivateAPI::GetFactoryInstance()->Get(profile
);
84 api
->RequestFeedback(description_template
,