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/browser_finder.h"
12 #include "chrome/browser/ui/tabs/tab_strip_model.h"
13 #include "content/public/browser/web_contents.h"
18 GURL
GetTargetTabUrl(int session_id
, int index
) {
19 Browser
* browser
= chrome::FindBrowserWithID(session_id
);
21 if (!browser
|| index
>= browser
->tab_strip_model()->count())
25 content::WebContents
* target_tab
=
26 browser
->tab_strip_model()->GetWebContentsAt(index
);
28 return target_tab
->GetURL();
38 extern const char kAppLauncherCategoryTag
[] = "AppLauncher";
40 void ShowFeedbackPage(Browser
* browser
,
41 const std::string
& description_template
,
42 const std::string
& category_tag
) {
45 page_url
= GetTargetTabUrl(browser
->session_id().id(),
46 browser
->tab_strip_model()->active_index());
49 Profile
* profile
= NULL
;
51 profile
= browser
->profile();
53 profile
= ProfileManager::GetLastUsedProfileAllowedByPolicy();
56 LOG(ERROR
) << "Cannot invoke feedback: No profile found!";
60 // We do not want to launch on an OTR profile.
61 profile
= profile
->GetOriginalProfile();
64 extensions::FeedbackPrivateAPI
* api
=
65 extensions::FeedbackPrivateAPI::GetFactoryInstance()->Get(profile
);
67 api
->RequestFeedback(description_template
,