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

Unified Diff: chrome/browser/feedback/show_feedback_page.cc

Issue 225183018: Move feedback files into src/components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix deps, merge gyp targets, sync with latest Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/feedback/show_feedback_page.cc
diff --git a/chrome/browser/feedback/show_feedback_page.cc b/chrome/browser/feedback/show_feedback_page.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0641a221f7ed15deee52a4d439a70c2a431ce377
--- /dev/null
+++ b/chrome/browser/feedback/show_feedback_page.cc
@@ -0,0 +1,72 @@
+// Copyright (c) 2012 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 <string>
+
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/extensions/api/feedback_private/feedback_private_api.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/ui/browser_finder.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "content/public/browser/web_contents.h"
+#include "url/gurl.h"
+
+namespace {
+
+GURL GetTargetTabUrl(int session_id, int index) {
+ Browser* browser = chrome::FindBrowserWithID(session_id);
+ // Sanity checks.
+ if (!browser || index >= browser->tab_strip_model()->count())
+ return GURL();
+
+ if (index >= 0) {
+ content::WebContents* target_tab =
+ browser->tab_strip_model()->GetWebContentsAt(index);
+ if (target_tab)
+ return target_tab->GetURL();
+ }
+
+ return GURL();
+}
+
+} // namespace
+
+namespace chrome {
+
+extern const char kAppLauncherCategoryTag[] = "AppLauncher";
+
+void ShowFeedbackPage(Browser* browser,
+ const std::string& description_template,
+ const std::string& category_tag) {
+ GURL page_url;
+ if (browser) {
+ page_url = GetTargetTabUrl(browser->session_id().id(),
+ browser->tab_strip_model()->active_index());
+ }
+
+ Profile* profile = NULL;
+ if (browser) {
+ profile = browser->profile();
+ } else {
+ profile = ProfileManager::GetLastUsedProfileAllowedByPolicy();
+ }
+ if (!profile) {
+ LOG(ERROR) << "Cannot invoke feedback: No profile found!";
+ return;
+ }
+
+ // We do not want to launch on an OTR profile.
+ profile = profile->GetOriginalProfile();
+ DCHECK(profile);
+
+ extensions::FeedbackPrivateAPI* api =
+ extensions::FeedbackPrivateAPI::GetFactoryInstance()->Get(profile);
+
+ api->RequestFeedback(description_template,
+ category_tag,
+ page_url);
+}
+
+} // namespace chrome

Powered by Google App Engine
This is Rietveld 408576698