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

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

Issue 11419276: Remove tabstrip wrappers in browser_tabstrip. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: gtk Created 8 years 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/bind.h" 10 #include "base/bind.h"
(...skipping 10 matching lines...) Expand all
21 #include "chrome/browser/download/download_prefs.h" 21 #include "chrome/browser/download/download_prefs.h"
22 #include "chrome/browser/feedback/feedback_data.h" 22 #include "chrome/browser/feedback/feedback_data.h"
23 #include "chrome/browser/feedback/feedback_util.h" 23 #include "chrome/browser/feedback/feedback_util.h"
24 #include "chrome/browser/prefs/pref_service.h" 24 #include "chrome/browser/prefs/pref_service.h"
25 #include "chrome/browser/profiles/profile.h" 25 #include "chrome/browser/profiles/profile.h"
26 #include "chrome/browser/profiles/profile_manager.h" 26 #include "chrome/browser/profiles/profile_manager.h"
27 #include "chrome/browser/signin/signin_manager.h" 27 #include "chrome/browser/signin/signin_manager.h"
28 #include "chrome/browser/signin/signin_manager_factory.h" 28 #include "chrome/browser/signin/signin_manager_factory.h"
29 #include "chrome/browser/ui/browser.h" 29 #include "chrome/browser/ui/browser.h"
30 #include "chrome/browser/ui/browser_finder.h" 30 #include "chrome/browser/ui/browser_finder.h"
31 #include "chrome/browser/ui/browser_tabstrip.h"
32 #include "chrome/browser/ui/browser_window.h" 31 #include "chrome/browser/ui/browser_window.h"
33 #include "chrome/browser/ui/chrome_pages.h" 32 #include "chrome/browser/ui/chrome_pages.h"
34 #include "chrome/browser/ui/singleton_tabs.h" 33 #include "chrome/browser/ui/singleton_tabs.h"
35 #include "chrome/browser/ui/tab_contents/tab_contents.h" 34 #include "chrome/browser/ui/tab_contents/tab_contents.h"
35 #include "chrome/browser/ui/tabs/tab_strip_model.h"
36 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 36 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
37 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" 37 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
38 #include "chrome/browser/ui/webui/screenshot_source.h" 38 #include "chrome/browser/ui/webui/screenshot_source.h"
39 #include "chrome/browser/ui/window_snapshot/window_snapshot.h" 39 #include "chrome/browser/ui/window_snapshot/window_snapshot.h"
40 #include "chrome/common/chrome_paths.h" 40 #include "chrome/common/chrome_paths.h"
41 #include "chrome/common/pref_names.h" 41 #include "chrome/common/pref_names.h"
42 #include "chrome/common/url_constants.h" 42 #include "chrome/common/url_constants.h"
43 #include "content/public/browser/browser_thread.h" 43 #include "content/public/browser/browser_thread.h"
44 #include "content/public/browser/navigation_controller.h" 44 #include "content/public/browser/navigation_controller.h"
45 #include "content/public/browser/navigation_entry.h" 45 #include "content/public/browser/navigation_entry.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 162
163 return signin->GetAuthenticatedUsername(); 163 return signin->GetAuthenticatedUsername();
164 } 164 }
165 165
166 #endif // OS_CHROMEOS 166 #endif // OS_CHROMEOS
167 167
168 // Returns the index of the feedback tab if already open, -1 otherwise 168 // Returns the index of the feedback tab if already open, -1 otherwise
169 int GetIndexOfFeedbackTab(Browser* browser) { 169 int GetIndexOfFeedbackTab(Browser* browser) {
170 GURL feedback_url(chrome::kChromeUIFeedbackURL); 170 GURL feedback_url(chrome::kChromeUIFeedbackURL);
171 for (int i = 0; i < browser->tab_count(); ++i) { 171 for (int i = 0; i < browser->tab_count(); ++i) {
172 WebContents* tab = chrome::GetWebContentsAt(browser, i); 172 WebContents* tab = browser->tab_strip_model()->GetWebContentsAt(i);
173 if (tab && tab->GetURL().GetWithEmptyPath() == feedback_url) 173 if (tab && tab->GetURL().GetWithEmptyPath() == feedback_url)
174 return i; 174 return i;
175 } 175 }
176 176
177 return -1; 177 return -1;
178 } 178 }
179 179
180 } // namespace 180 } // namespace
181 181
182 namespace chrome { 182 namespace chrome {
183 183
184 void ShowFeedbackPage(Browser* browser, 184 void ShowFeedbackPage(Browser* browser,
185 const std::string& description_template, 185 const std::string& description_template,
186 const std::string& category_tag) { 186 const std::string& category_tag) {
187 #if defined(OS_CHROMEOS) 187 #if defined(OS_CHROMEOS)
188 // Grab the timestamp before we do anything else - this is crucial to help 188 // Grab the timestamp before we do anything else - this is crucial to help
189 // diagnose some hardware issues. 189 // diagnose some hardware issues.
190 base::Time now = base::Time::Now(); 190 base::Time now = base::Time::Now();
191 std::string timestamp = base::DoubleToString(now.ToDoubleT()); 191 std::string timestamp = base::DoubleToString(now.ToDoubleT());
192 #endif 192 #endif
193 193
194 // First check if we're already open (we cannot depend on ShowSingletonTab 194 // First check if we're already open (we cannot depend on ShowSingletonTab
195 // for this functionality since we need to make *sure* we never get 195 // for this functionality since we need to make *sure* we never get
196 // instantiated again while we are open - with singleton tabs, that can 196 // instantiated again while we are open - with singleton tabs, that can
197 // happen) 197 // happen).
198 int feedback_tab_index = GetIndexOfFeedbackTab(browser); 198 int feedback_tab_index = GetIndexOfFeedbackTab(browser);
199 if (feedback_tab_index >= 0) { 199 if (feedback_tab_index >= 0) {
200 // Do not refresh screenshot, do not create a new tab 200 // Do not refresh screenshot, do not create a new tab.
201 chrome::ActivateTabAt(browser, feedback_tab_index, true); 201 browser->tab_strip_model()->ActivateTabAt(feedback_tab_index, true);
202 return; 202 return;
203 } 203 }
204 204
205 std::vector<unsigned char>* last_screenshot_png = 205 std::vector<unsigned char>* last_screenshot_png =
206 FeedbackUtil::GetScreenshotPng(); 206 FeedbackUtil::GetScreenshotPng();
207 last_screenshot_png->clear(); 207 last_screenshot_png->clear();
208 208
209 gfx::NativeWindow native_window; 209 gfx::NativeWindow native_window;
210 gfx::Rect snapshot_bounds; 210 gfx::Rect snapshot_bounds;
211 211
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 if (custom_page_url.empty()) { 444 if (custom_page_url.empty()) {
445 if (session_id == -1) 445 if (session_id == -1)
446 return false; 446 return false;
447 447
448 Browser* browser = browser::FindBrowserWithID(session_id); 448 Browser* browser = browser::FindBrowserWithID(session_id);
449 // Sanity checks. 449 // Sanity checks.
450 if (!browser || index >= browser->tab_count()) 450 if (!browser || index >= browser->tab_count())
451 return false; 451 return false;
452 452
453 if (index >= 0) { 453 if (index >= 0) {
454 WebContents* target_tab = chrome::GetWebContentsAt(browser, index); 454 WebContents* target_tab =
455 browser->tab_strip_model()->GetWebContentsAt(index);
455 if (target_tab) 456 if (target_tab)
456 target_tab_url_ = target_tab->GetURL().spec(); 457 target_tab_url_ = target_tab->GetURL().spec();
457 } 458 }
458 459
459 // Note: We don't need to setup a screenshot source if we're using a 460 // Note: We don't need to setup a screenshot source if we're using a
460 // custom page URL since we were invoked from JS/an extension, in which 461 // custom page URL since we were invoked from JS/an extension, in which
461 // case we don't actually have a screenshot anyway. 462 // case we don't actually have a screenshot anyway.
462 SetupScreenshotsSource(); 463 SetupScreenshotsSource();
463 } else { 464 } else {
464 target_tab_url_ = custom_page_url; 465 target_tab_url_ = custom_page_url;
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 screenshot_filepaths.begin() + sort_size, 748 screenshot_filepaths.begin() + sort_size,
748 screenshot_filepaths.end(), 749 screenshot_filepaths.end(),
749 ScreenshotTimestampComp); 750 ScreenshotTimestampComp);
750 for (size_t i = 0; i < sort_size; ++i) 751 for (size_t i = 0; i < sort_size; ++i)
751 saved_screenshots->push_back( 752 saved_screenshots->push_back(
752 std::string(ScreenshotSource::kScreenshotUrlRoot) + 753 std::string(ScreenshotSource::kScreenshotUrlRoot) +
753 std::string(ScreenshotSource::kScreenshotSaved) + 754 std::string(ScreenshotSource::kScreenshotSaved) +
754 screenshot_filepaths[i]); 755 screenshot_filepaths[i]);
755 } 756 }
756 #endif 757 #endif
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/bookmarks_ui_browsertest.cc ('k') | chrome/browser/ui/webui/ntp/new_tab_ui_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698