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

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

Issue 12737006: Allow feedback form to be shown in an App Launcher feedback mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: First round of feedback Created 7 years, 9 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 <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 // for this functionality since we need to make *sure* we never get 196 // for this functionality since we need to make *sure* we never get
197 // instantiated again while we are open - with singleton tabs, that can 197 // instantiated again while we are open - with singleton tabs, that can
198 // happen). 198 // happen).
199 int feedback_tab_index = GetIndexOfFeedbackTab(browser); 199 int feedback_tab_index = GetIndexOfFeedbackTab(browser);
200 if (feedback_tab_index >= 0) { 200 if (feedback_tab_index >= 0) {
201 // Do not refresh screenshot, do not create a new tab. 201 // Do not refresh screenshot, do not create a new tab.
202 browser->tab_strip_model()->ActivateTabAt(feedback_tab_index, true); 202 browser->tab_strip_model()->ActivateTabAt(feedback_tab_index, true);
203 return; 203 return;
204 } 204 }
205 205
206 std::vector<unsigned char>* last_screenshot_png = 206 if (category_tag != kAppLauncherCategoryTag) {
207 FeedbackUtil::GetScreenshotPng(); 207 std::vector<unsigned char>* last_screenshot_png =
208 last_screenshot_png->clear(); 208 FeedbackUtil::GetScreenshotPng();
209 last_screenshot_png->clear();
209 210
210 gfx::NativeWindow native_window; 211 gfx::NativeWindow native_window;
211 gfx::Rect snapshot_bounds; 212 gfx::Rect snapshot_bounds;
212 213
213 #if defined(OS_CHROMEOS) 214 #if defined(OS_CHROMEOS)
214 // For ChromeOS, don't use the browser window but the root window 215 // For ChromeOS, don't use the browser window but the root window
215 // instead to grab the screenshot. We want everything on the screen, not 216 // instead to grab the screenshot. We want everything on the screen, not
216 // just the current browser. 217 // just the current browser.
217 native_window = ash::Shell::GetPrimaryRootWindow(); 218 native_window = ash::Shell::GetPrimaryRootWindow();
218 snapshot_bounds = gfx::Rect(native_window->bounds()); 219 snapshot_bounds = gfx::Rect(native_window->bounds());
219 #else 220 #else
220 native_window = browser->window()->GetNativeWindow(); 221 native_window = browser->window()->GetNativeWindow();
221 snapshot_bounds = gfx::Rect(browser->window()->GetBounds().size()); 222 snapshot_bounds = gfx::Rect(browser->window()->GetBounds().size());
222 #endif 223 #endif
223 bool success = chrome::GrabWindowSnapshotForUser(native_window, 224 bool success = chrome::GrabWindowSnapshotForUser(native_window,
224 last_screenshot_png, 225 last_screenshot_png,
225 snapshot_bounds); 226 snapshot_bounds);
226 FeedbackUtil::SetScreenshotSize(success ? snapshot_bounds : gfx::Rect()); 227 FeedbackUtil::SetScreenshotSize(success ? snapshot_bounds : gfx::Rect());
227 228 }
228 std::string feedback_url = std::string(chrome::kChromeUIFeedbackURL) + "?" + 229 std::string feedback_url = std::string(chrome::kChromeUIFeedbackURL) + "?" +
229 kSessionIDParameter + base::IntToString(browser->session_id().id()) + 230 kSessionIDParameter + base::IntToString(browser->session_id().id()) +
230 "&" + kTabIndexParameter + 231 "&" + kTabIndexParameter +
231 base::IntToString(browser->tab_strip_model()->active_index()) + 232 base::IntToString(browser->tab_strip_model()->active_index()) +
232 "&" + kDescriptionParameter + 233 "&" + kDescriptionParameter +
233 net::EscapeUrlEncodedData(description_template, false) + "&" + 234 net::EscapeUrlEncodedData(description_template, false) + "&" +
234 kCategoryTagParameter + net::EscapeUrlEncodedData(category_tag, false); 235 kCategoryTagParameter + net::EscapeUrlEncodedData(category_tag, false);
235 236
236 #if defined(OS_CHROMEOS) 237 #if defined(OS_CHROMEOS)
237 feedback_url = feedback_url + "&" + kTimestampParameter + 238 feedback_url = feedback_url + "&" + kTimestampParameter +
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 void ClobberScreenshotsSource(); 276 void ClobberScreenshotsSource();
276 277
277 void CancelFeedbackCollection(); 278 void CancelFeedbackCollection();
278 void CloseFeedbackTab(); 279 void CloseFeedbackTab();
279 280
280 WebContents* tab_; 281 WebContents* tab_;
281 ScreenshotSource* screenshot_source_; 282 ScreenshotSource* screenshot_source_;
282 283
283 FeedbackData* feedback_data_; 284 FeedbackData* feedback_data_;
284 std::string target_tab_url_; 285 std::string target_tab_url_;
286 std::string category_tag_;
285 #if defined(OS_CHROMEOS) 287 #if defined(OS_CHROMEOS)
286 // Variables to track SyslogsProvider::RequestSyslogs. 288 // Variables to track SyslogsProvider::RequestSyslogs.
287 CancelableTaskTracker::TaskId syslogs_task_id_; 289 CancelableTaskTracker::TaskId syslogs_task_id_;
288 CancelableTaskTracker syslogs_tracker_; 290 CancelableTaskTracker syslogs_tracker_;
289 291
290 // Timestamp of when the feedback request was initiated. 292 // Timestamp of when the feedback request was initiated.
291 std::string timestamp_; 293 std::string timestamp_;
292 #endif 294 #endif
293 295
294 DISALLOW_COPY_AND_ASSIGN(FeedbackHandler); 296 DISALLOW_COPY_AND_ASSIGN(FeedbackHandler);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 #endif 335 #endif
334 source->AddLocalizedString("noscreenshot", 336 source->AddLocalizedString("noscreenshot",
335 IDS_FEEDBACK_INCLUDE_NO_SCREENSHOT); 337 IDS_FEEDBACK_INCLUDE_NO_SCREENSHOT);
336 338
337 source->AddLocalizedString("send-report", IDS_FEEDBACK_SEND_REPORT); 339 source->AddLocalizedString("send-report", IDS_FEEDBACK_SEND_REPORT);
338 source->AddLocalizedString("cancel", IDS_CANCEL); 340 source->AddLocalizedString("cancel", IDS_CANCEL);
339 341
340 source->AddLocalizedString("no-description", IDS_FEEDBACK_NO_DESCRIPTION); 342 source->AddLocalizedString("no-description", IDS_FEEDBACK_NO_DESCRIPTION);
341 source->AddLocalizedString("no-saved-screenshots", 343 source->AddLocalizedString("no-saved-screenshots",
342 IDS_FEEDBACK_NO_SAVED_SCREENSHOTS_HELP); 344 IDS_FEEDBACK_NO_SAVED_SCREENSHOTS_HELP);
343 source->AddLocalizedString("privacy-note", IDS_FEEDBACK_PRIVACY_NOTE); 345 source->AddLocalizedString("privacy-note", IDS_FEEDBACK_PRIVACY_NOTE);
Dan Beam 2013/03/15 15:29:51 ^ I guess you guy are already using i18n-keys-with
346 source->AddLocalizedString("launcher-title", IDS_FEEDBACK_LAUNCHER_TITLE);
347 source->AddLocalizedString("launcher-description",
348 IDS_FEEDBACK_LAUNCHER_DESCRIPTION_LABEL);
344 349
345 source->SetJsonPath("strings.js"); 350 source->SetJsonPath("strings.js");
346 source->AddResourcePath("feedback.js", IDR_FEEDBACK_JS); 351 source->AddResourcePath("feedback.js", IDR_FEEDBACK_JS);
347 source->SetDefaultResource( 352 source->SetDefaultResource(
348 successful_init ? IDR_FEEDBACK_HTML : IDR_FEEDBACK_HTML_INVALID); 353 successful_init ? IDR_FEEDBACK_HTML : IDR_FEEDBACK_HTML_INVALID);
349 354
350 return source; 355 return source;
351 } 356 }
352 357
353 //////////////////////////////////////////////////////////////////////////////// 358 ////////////////////////////////////////////////////////////////////////////////
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 if (!base::StringToInt(query_str, &index)) 432 if (!base::StringToInt(query_str, &index))
428 return false; 433 return false;
429 continue; 434 continue;
430 } 435 }
431 if (StartsWithASCII(*it, std::string(kCustomPageUrlParameter), true)) { 436 if (StartsWithASCII(*it, std::string(kCustomPageUrlParameter), true)) {
432 ReplaceFirstSubstringAfterOffset( 437 ReplaceFirstSubstringAfterOffset(
433 &query_str, 0, kCustomPageUrlParameter, ""); 438 &query_str, 0, kCustomPageUrlParameter, "");
434 custom_page_url = query_str; 439 custom_page_url = query_str;
435 continue; 440 continue;
436 } 441 }
442 if (StartsWithASCII(*it, std::string(kCategoryTagParameter), true)) {
443 ReplaceFirstSubstringAfterOffset(
444 &query_str, 0, kCategoryTagParameter, "");
445 category_tag_ = query_str;
446 continue;
447 }
Dan Beam 2013/03/15 15:29:51 what's the difference between if () { continue; }
benwells 2013/03/18 05:21:19 I'm not sure there is any difference. TBH I just f
437 #if defined(OS_CHROMEOS) 448 #if defined(OS_CHROMEOS)
438 if (StartsWithASCII(*it, std::string(kTimestampParameter), true)) { 449 if (StartsWithASCII(*it, std::string(kTimestampParameter), true)) {
439 ReplaceFirstSubstringAfterOffset( 450 ReplaceFirstSubstringAfterOffset(
440 &query_str, 0, kTimestampParameter, ""); 451 &query_str, 0, kTimestampParameter, "");
441 timestamp_ = query_str; 452 timestamp_ = query_str;
442 continue; 453 continue;
Dan Beam 2013/03/18 06:09:50 also, there's a continue at the very bottom of the
benwells 2013/03/19 02:39:54 It's another form of if / else. The continue at th
443 } 454 }
444 #endif 455 #endif
445 } 456 }
446 } 457 }
447 458
448 // If we don't have a page url specified, get it from the tab index. 459 // If we don't have a page url specified, get it from the tab index.
449 if (custom_page_url.empty()) { 460 if (custom_page_url.empty()) {
450 if (session_id == -1) 461 if (session_id == -1)
451 return false; 462 return false;
452 463
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 base::Unretained(this))); 507 base::Unretained(this)));
497 } 508 }
498 509
499 void FeedbackHandler::HandleGetDialogDefaults(const ListValue*) { 510 void FeedbackHandler::HandleGetDialogDefaults(const ListValue*) {
500 // Will delete itself when feedback_data_->SendReport() is called. 511 // Will delete itself when feedback_data_->SendReport() is called.
501 feedback_data_ = new FeedbackData(); 512 feedback_data_ = new FeedbackData();
502 513
503 // Send back values which the dialog js needs initially. 514 // Send back values which the dialog js needs initially.
504 DictionaryValue dialog_defaults; 515 DictionaryValue dialog_defaults;
505 516
517 if (category_tag_ == chrome::kAppLauncherCategoryTag)
518 dialog_defaults.SetBoolean("launcherFeedback", true);
519
506 // Current url. 520 // Current url.
507 dialog_defaults.SetString("currentUrl", target_tab_url_); 521 dialog_defaults.SetString("currentUrl", target_tab_url_);
508 522
509 // Are screenshots disabled? 523 // Are screenshots disabled?
510 dialog_defaults.SetBoolean( 524 dialog_defaults.SetBoolean(
511 "disableScreenshots", 525 "disableScreenshots",
512 g_browser_process->local_state()->GetBoolean(prefs::kDisableScreenshots)); 526 g_browser_process->local_state()->GetBoolean(prefs::kDisableScreenshots));
513 527
514 // User e-mail 528 // User e-mail
515 std::string user_email = GetUserEmail(); 529 std::string user_email = GetUserEmail();
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 LOG(ERROR) << "Unable to attach file: " << attached_filename; 661 LOG(ERROR) << "Unable to attach file: " << attached_filename;
648 // Clear the filename so feedback_util doesn't try to attach the file. 662 // Clear the filename so feedback_util doesn't try to attach the file.
649 attached_filename = ""; 663 attached_filename = "";
650 } 664 }
651 } 665 }
652 } 666 }
653 #endif 667 #endif
654 668
655 // Update the data in feedback_data_ so it can be sent 669 // Update the data in feedback_data_ so it can be sent
656 feedback_data_->UpdateData(Profile::FromWebUI(web_ui()) 670 feedback_data_->UpdateData(Profile::FromWebUI(web_ui())
657 , std::string() 671 , std::string()
rkc 2013/03/15 16:58:40 Might want to actually send the category tag :) L
benwells 2013/03/18 05:21:19 Woops, good catch. Done.
658 , page_url 672 , page_url
659 , description 673 , description
660 , user_email 674 , user_email
661 , image_ptr 675 , image_ptr
662 #if defined(OS_CHROMEOS) 676 #if defined(OS_CHROMEOS)
663 , send_sys_info 677 , send_sys_info
664 , false // sent_report 678 , false // sent_report
665 , timestamp_ 679 , timestamp_
666 , attached_filename 680 , attached_filename
667 , attached_filedata 681 , attached_filedata
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 screenshot_filepaths.begin() + sort_size, 775 screenshot_filepaths.begin() + sort_size,
762 screenshot_filepaths.end(), 776 screenshot_filepaths.end(),
763 ScreenshotTimestampComp); 777 ScreenshotTimestampComp);
764 for (size_t i = 0; i < sort_size; ++i) 778 for (size_t i = 0; i < sort_size; ++i)
765 saved_screenshots->push_back( 779 saved_screenshots->push_back(
766 std::string(ScreenshotSource::kScreenshotUrlRoot) + 780 std::string(ScreenshotSource::kScreenshotUrlRoot) +
767 std::string(ScreenshotSource::kScreenshotSaved) + 781 std::string(ScreenshotSource::kScreenshotSaved) +
768 screenshot_filepaths[i]); 782 screenshot_filepaths[i]);
769 } 783 }
770 #endif 784 #endif
OLDNEW
« chrome/browser/resources/feedback.js ('K') | « chrome/browser/resources/feedback.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698