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

Side by Side Diff: chrome/browser/ui/webui/feedback_ui.cc

Issue 10834107: chrome: Refactor the way to show the feedback ui and move it into chrome namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/feedback_ui.h" 5 #include "chrome/browser/ui/webui/feedback_ui.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 13 matching lines...) Expand all
24 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/browser/profiles/profile_manager.h" 25 #include "chrome/browser/profiles/profile_manager.h"
26 #include "chrome/browser/signin/signin_manager.h" 26 #include "chrome/browser/signin/signin_manager.h"
27 #include "chrome/browser/signin/signin_manager_factory.h" 27 #include "chrome/browser/signin/signin_manager_factory.h"
28 #include "chrome/browser/ui/browser.h" 28 #include "chrome/browser/ui/browser.h"
29 #include "chrome/browser/ui/browser_finder.h" 29 #include "chrome/browser/ui/browser_finder.h"
30 #include "chrome/browser/ui/browser_tabstrip.h" 30 #include "chrome/browser/ui/browser_tabstrip.h"
31 #include "chrome/browser/ui/browser_window.h" 31 #include "chrome/browser/ui/browser_window.h"
32 #include "chrome/browser/ui/singleton_tabs.h" 32 #include "chrome/browser/ui/singleton_tabs.h"
33 #include "chrome/browser/ui/tab_contents/tab_contents.h" 33 #include "chrome/browser/ui/tab_contents/tab_contents.h"
34 #include "chrome/browser/ui/web_feedback_ui.h"
34 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 35 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
35 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" 36 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
36 #include "chrome/browser/ui/webui/screenshot_source.h" 37 #include "chrome/browser/ui/webui/screenshot_source.h"
37 #include "chrome/browser/ui/window_snapshot/window_snapshot.h" 38 #include "chrome/browser/ui/window_snapshot/window_snapshot.h"
38 #include "chrome/common/chrome_paths.h" 39 #include "chrome/common/chrome_paths.h"
39 #include "chrome/common/pref_names.h" 40 #include "chrome/common/pref_names.h"
40 #include "chrome/common/url_constants.h" 41 #include "chrome/common/url_constants.h"
41 #include "content/public/browser/browser_thread.h" 42 #include "content/public/browser/browser_thread.h"
42 #include "content/public/browser/navigation_controller.h" 43 #include "content/public/browser/navigation_controller.h"
43 #include "content/public/browser/navigation_entry.h" 44 #include "content/public/browser/navigation_entry.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 WebContents* tab = chrome::GetWebContentsAt(browser, i); 141 WebContents* tab = chrome::GetWebContentsAt(browser, i);
141 if (tab && tab->GetURL().GetWithEmptyPath() == feedback_url) 142 if (tab && tab->GetURL().GetWithEmptyPath() == feedback_url)
142 return i; 143 return i;
143 } 144 }
144 145
145 return -1; 146 return -1;
146 } 147 }
147 148
148 } // namespace 149 } // namespace
149 150
151 namespace chrome {
150 152
151 namespace browser { 153 void ShowFeedbackUI(Browser* browser,
152 154 const std::string& description_template,
153 void ShowWebFeedbackView(Browser* browser, 155 const std::string& category_tag) {
154 const std::string& description_template,
155 const std::string& category_tag) {
156 #if defined(OS_CHROMEOS) 156 #if defined(OS_CHROMEOS)
157 // Grab the timestamp before we do anything else - this is crucial to help 157 // Grab the timestamp before we do anything else - this is crucial to help
158 // diagnose some hardware issues. 158 // diagnose some hardware issues.
159 base::Time now = base::Time::Now(); 159 base::Time now = base::Time::Now();
160 std::string timestamp = base::DoubleToString(now.ToDoubleT()); 160 std::string timestamp = base::DoubleToString(now.ToDoubleT());
161 #endif 161 #endif
162 162
163 // First check if we're already open (we cannot depend on ShowSingletonTab 163 // First check if we're already open (we cannot depend on ShowSingletonTab
164 // for this functionality since we need to make *sure* we never get 164 // for this functionality since we need to make *sure* we never get
165 // instantiated again while we are open - with singleton tabs, that can 165 // instantiated again while we are open - with singleton tabs, that can
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 net::EscapeUrlEncodedData(description_template, false) + "&" + 199 net::EscapeUrlEncodedData(description_template, false) + "&" +
200 kCategoryTagParameter + net::EscapeUrlEncodedData(category_tag, false); 200 kCategoryTagParameter + net::EscapeUrlEncodedData(category_tag, false);
201 201
202 #if defined(OS_CHROMEOS) 202 #if defined(OS_CHROMEOS)
203 feedback_url = feedback_url + "&" + kTimestampParameter + 203 feedback_url = feedback_url + "&" + kTimestampParameter +
204 net::EscapeUrlEncodedData(timestamp, false); 204 net::EscapeUrlEncodedData(timestamp, false);
205 #endif 205 #endif
206 chrome::ShowSingletonTab(browser, GURL(feedback_url)); 206 chrome::ShowSingletonTab(browser, GURL(feedback_url));
207 } 207 }
208 208
209 } // namespace browser 209 } // namespace chrome
210 210
211 // The handler for Javascript messages related to the "bug report" dialog 211 // The handler for Javascript messages related to the "bug report" dialog
212 class FeedbackHandler : public WebUIMessageHandler, 212 class FeedbackHandler : public WebUIMessageHandler,
213 public base::SupportsWeakPtr<FeedbackHandler> { 213 public base::SupportsWeakPtr<FeedbackHandler> {
214 public: 214 public:
215 explicit FeedbackHandler(content::WebContents* tab); 215 explicit FeedbackHandler(content::WebContents* tab);
216 virtual ~FeedbackHandler(); 216 virtual ~FeedbackHandler();
217 217
218 // Init work after Attach. Returns true on success. 218 // Init work after Attach. Returns true on success.
219 bool Init(); 219 bool Init();
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 size_t sort_size = std::min(max_saved, screenshot_filepaths.size()); 673 size_t sort_size = std::min(max_saved, screenshot_filepaths.size());
674 std::partial_sort(screenshot_filepaths.begin(), 674 std::partial_sort(screenshot_filepaths.begin(),
675 screenshot_filepaths.begin() + sort_size, 675 screenshot_filepaths.begin() + sort_size,
676 screenshot_filepaths.end(), 676 screenshot_filepaths.end(),
677 ScreenshotTimestampComp); 677 ScreenshotTimestampComp);
678 for (size_t i = 0; i < sort_size; ++i) 678 for (size_t i = 0; i < sort_size; ++i)
679 saved_screenshots->push_back(std::string(kSavedScreenshotsUrl) + 679 saved_screenshots->push_back(std::string(kSavedScreenshotsUrl) +
680 screenshot_filepaths[i]); 680 screenshot_filepaths[i]);
681 } 681 }
682 #endif 682 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698