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

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

Issue 10702029: Move tab functions off Browser into browser_tabstrip and browser_tabrestore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/message_loop.h" 13 #include "base/message_loop.h"
14 #include "base/string_number_conversions.h" 14 #include "base/string_number_conversions.h"
15 #include "base/string_util.h" 15 #include "base/string_util.h"
16 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
17 #include "base/time.h" 17 #include "base/time.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "chrome/browser/download/download_prefs.h" 19 #include "chrome/browser/download/download_prefs.h"
20 #include "chrome/browser/feedback/feedback_data.h" 20 #include "chrome/browser/feedback/feedback_data.h"
21 #include "chrome/browser/feedback/feedback_util.h" 21 #include "chrome/browser/feedback/feedback_util.h"
22 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/browser/ui/browser.h" 23 #include "chrome/browser/ui/browser.h"
24 #include "chrome/browser/ui/browser_finder.h" 24 #include "chrome/browser/ui/browser_finder.h"
25 #include "chrome/browser/ui/browser_tabstrip.h"
25 #include "chrome/browser/ui/browser_window.h" 26 #include "chrome/browser/ui/browser_window.h"
26 #include "chrome/browser/ui/singleton_tabs.h" 27 #include "chrome/browser/ui/singleton_tabs.h"
27 #include "chrome/browser/ui/tab_contents/tab_contents.h" 28 #include "chrome/browser/ui/tab_contents/tab_contents.h"
28 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 29 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
29 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" 30 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
30 #include "chrome/browser/ui/webui/screenshot_source.h" 31 #include "chrome/browser/ui/webui/screenshot_source.h"
31 #include "chrome/browser/ui/window_snapshot/window_snapshot.h" 32 #include "chrome/browser/ui/window_snapshot/window_snapshot.h"
32 #include "chrome/common/chrome_paths.h" 33 #include "chrome/common/chrome_paths.h"
33 #include "chrome/common/url_constants.h" 34 #include "chrome/common/url_constants.h"
34 #include "content/public/browser/browser_thread.h" 35 #include "content/public/browser/browser_thread.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 else 109 else
109 return manager->GetLoggedInUser().display_email(); 110 return manager->GetLoggedInUser().display_email();
110 } 111 }
111 112
112 #endif // OS_CHROMEOS 113 #endif // OS_CHROMEOS
113 114
114 // Returns the index of the feedback tab if already open, -1 otherwise 115 // Returns the index of the feedback tab if already open, -1 otherwise
115 int GetIndexOfFeedbackTab(Browser* browser) { 116 int GetIndexOfFeedbackTab(Browser* browser) {
116 GURL feedback_url(chrome::kChromeUIFeedbackURL); 117 GURL feedback_url(chrome::kChromeUIFeedbackURL);
117 for (int i = 0; i < browser->tab_count(); ++i) { 118 for (int i = 0; i < browser->tab_count(); ++i) {
118 WebContents* tab = browser->GetWebContentsAt(i); 119 WebContents* tab = chrome::GetWebContentsAt(browser, i);
119 if (tab && tab->GetURL().GetWithEmptyPath() == feedback_url) 120 if (tab && tab->GetURL().GetWithEmptyPath() == feedback_url)
120 return i; 121 return i;
121 } 122 }
122 123
123 return -1; 124 return -1;
124 } 125 }
125 126
126 } // namespace 127 } // namespace
127 128
128 129
129 namespace browser { 130 namespace browser {
130 131
131 void ShowWebFeedbackView(Browser* browser, 132 void ShowWebFeedbackView(Browser* browser,
132 const std::string& description_template, 133 const std::string& description_template,
133 const std::string& category_tag) { 134 const std::string& category_tag) {
134 #if defined(OS_CHROMEOS) 135 #if defined(OS_CHROMEOS)
135 // Grab the timestamp before we do anything else - this is crucial to help 136 // Grab the timestamp before we do anything else - this is crucial to help
136 // diagnose some hardware issues. 137 // diagnose some hardware issues.
137 base::Time now = base::Time::Now(); 138 base::Time now = base::Time::Now();
138 std::string timestamp = base::DoubleToString(now.ToDoubleT()); 139 std::string timestamp = base::DoubleToString(now.ToDoubleT());
139 #endif 140 #endif
140 141
141 // First check if we're already open (we cannot depend on ShowSingletonTab 142 // First check if we're already open (we cannot depend on ShowSingletonTab
142 // for this functionality since we need to make *sure* we never get 143 // for this functionality since we need to make *sure* we never get
143 // instantiated again while we are open - with singleton tabs, that can 144 // instantiated again while we are open - with singleton tabs, that can
144 // happen) 145 // happen)
145 int feedback_tab_index = GetIndexOfFeedbackTab(browser); 146 int feedback_tab_index = GetIndexOfFeedbackTab(browser);
146 if (feedback_tab_index >= 0) { 147 if (feedback_tab_index >= 0) {
147 // Do not refresh screenshot, do not create a new tab 148 // Do not refresh screenshot, do not create a new tab
148 browser->ActivateTabAt(feedback_tab_index, true); 149 chrome::ActivateTabAt(browser, feedback_tab_index, true);
149 return; 150 return;
150 } 151 }
151 152
152 std::vector<unsigned char>* last_screenshot_png = 153 std::vector<unsigned char>* last_screenshot_png =
153 FeedbackUtil::GetScreenshotPng(); 154 FeedbackUtil::GetScreenshotPng();
154 last_screenshot_png->clear(); 155 last_screenshot_png->clear();
155 156
156 gfx::NativeWindow native_window; 157 gfx::NativeWindow native_window;
157 gfx::Rect snapshot_bounds; 158 gfx::Rect snapshot_bounds;
158 159
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 } 379 }
379 380
380 if (session_id == -1 || index == -1) 381 if (session_id == -1 || index == -1)
381 return false; 382 return false;
382 383
383 Browser* browser = browser::FindBrowserWithID(session_id); 384 Browser* browser = browser::FindBrowserWithID(session_id);
384 // Sanity checks. 385 // Sanity checks.
385 if (!browser || index >= browser->tab_count()) 386 if (!browser || index >= browser->tab_count())
386 return false; 387 return false;
387 388
388 WebContents* target_tab = browser->GetWebContentsAt(index); 389 WebContents* target_tab = chrome::GetWebContentsAt(browser, index);
389 if (target_tab) { 390 if (target_tab) {
390 target_tab_url_ = target_tab->GetURL().spec(); 391 target_tab_url_ = target_tab->GetURL().spec();
391 } 392 }
392 393
393 // Setup the screenshot source after we've verified input is legit. 394 // Setup the screenshot source after we've verified input is legit.
394 SetupScreenshotsSource(); 395 SetupScreenshotsSource();
395 396
396 return true; 397 return true;
397 } 398 }
398 399
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 size_t sort_size = std::min(max_saved, screenshot_filepaths.size()); 633 size_t sort_size = std::min(max_saved, screenshot_filepaths.size());
633 std::partial_sort(screenshot_filepaths.begin(), 634 std::partial_sort(screenshot_filepaths.begin(),
634 screenshot_filepaths.begin() + sort_size, 635 screenshot_filepaths.begin() + sort_size,
635 screenshot_filepaths.end(), 636 screenshot_filepaths.end(),
636 ScreenshotTimestampComp); 637 ScreenshotTimestampComp);
637 for (size_t i = 0; i < sort_size; ++i) 638 for (size_t i = 0; i < sort_size; ++i)
638 saved_screenshots->push_back(std::string(kSavedScreenshotsUrl) + 639 saved_screenshots->push_back(std::string(kSavedScreenshotsUrl) +
639 screenshot_filepaths[i]); 640 screenshot_filepaths[i]);
640 } 641 }
641 #endif 642 #endif
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc ('k') | chrome/browser/ui/webui/inspect_ui_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698