| OLD | NEW |
| 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_util.h" | 19 #include "chrome/browser/download/download_util.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_list.h" | 24 #include "chrome/browser/ui/browser_list.h" |
| 25 #include "chrome/browser/ui/browser_window.h" | 25 #include "chrome/browser/ui/browser_window.h" |
| 26 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 26 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 27 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 27 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| 28 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" | 28 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" |
| 29 #include "chrome/browser/ui/webui/screenshot_source.h" | 29 #include "chrome/browser/ui/webui/screenshot_source.h" |
| 30 #include "chrome/browser/ui/window_snapshot/window_snapshot.h" | 30 #include "chrome/browser/ui/window_snapshot/window_snapshot.h" |
| 31 #include "chrome/common/chrome_paths.h" | 31 #include "chrome/common/chrome_paths.h" |
| 32 #include "chrome/common/url_constants.h" | 32 #include "chrome/common/url_constants.h" |
| 33 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
| 34 #include "content/public/browser/navigation_controller.h" | 34 #include "content/public/browser/navigation_controller.h" |
| 35 #include "content/public/browser/navigation_entry.h" | 35 #include "content/public/browser/navigation_entry.h" |
| 36 #include "content/public/browser/web_contents.h" | 36 #include "content/public/browser/web_contents.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 else | 102 else |
| 103 return manager->GetLoggedInUser().display_email(); | 103 return manager->GetLoggedInUser().display_email(); |
| 104 } | 104 } |
| 105 | 105 |
| 106 #endif // OS_CHROMEOS | 106 #endif // OS_CHROMEOS |
| 107 | 107 |
| 108 // Returns the index of the feedback tab if already open, -1 otherwise | 108 // Returns the index of the feedback tab if already open, -1 otherwise |
| 109 int GetIndexOfFeedbackTab(Browser* browser) { | 109 int GetIndexOfFeedbackTab(Browser* browser) { |
| 110 GURL feedback_url(chrome::kChromeUIFeedbackURL); | 110 GURL feedback_url(chrome::kChromeUIFeedbackURL); |
| 111 for (int i = 0; i < browser->tab_count(); ++i) { | 111 for (int i = 0; i < browser->tab_count(); ++i) { |
| 112 WebContents* tab = browser->GetTabContentsWrapperAt(i)->web_contents(); | 112 WebContents* tab = browser->GetWebContentsAt(i); |
| 113 if (tab && tab->GetURL().GetWithEmptyPath() == feedback_url) | 113 if (tab && tab->GetURL().GetWithEmptyPath() == feedback_url) |
| 114 return i; | 114 return i; |
| 115 } | 115 } |
| 116 | 116 |
| 117 return -1; | 117 return -1; |
| 118 } | 118 } |
| 119 | 119 |
| 120 } // namespace | 120 } // namespace |
| 121 | 121 |
| 122 | 122 |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 | 360 |
| 361 // TODO(beng): Replace GetLastActive with a more specific method of locating | 361 // TODO(beng): Replace GetLastActive with a more specific method of locating |
| 362 // the target contents. | 362 // the target contents. |
| 363 Browser* browser = BrowserList::GetLastActive(); | 363 Browser* browser = BrowserList::GetLastActive(); |
| 364 // Sanity checks. | 364 // Sanity checks. |
| 365 if (((index == 0) && (index_str != "0")) || !browser || | 365 if (((index == 0) && (index_str != "0")) || !browser || |
| 366 index >= browser->tab_count()) { | 366 index >= browser->tab_count()) { |
| 367 return false; | 367 return false; |
| 368 } | 368 } |
| 369 | 369 |
| 370 WebContents* target_tab = | 370 WebContents* target_tab = browser->GetWebContentsAt(index); |
| 371 browser->GetTabContentsWrapperAt(index)->web_contents(); | |
| 372 if (target_tab) { | 371 if (target_tab) { |
| 373 target_tab_url_ = target_tab->GetURL().spec(); | 372 target_tab_url_ = target_tab->GetURL().spec(); |
| 374 } | 373 } |
| 375 | 374 |
| 376 // Setup the screenshot source after we've verified input is legit. | 375 // Setup the screenshot source after we've verified input is legit. |
| 377 SetupScreenshotsSource(); | 376 SetupScreenshotsSource(); |
| 378 | 377 |
| 379 return true; | 378 return true; |
| 380 } | 379 } |
| 381 | 380 |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 size_t sort_size = std::min(max_saved, screenshot_filepaths.size()); | 614 size_t sort_size = std::min(max_saved, screenshot_filepaths.size()); |
| 616 std::partial_sort(screenshot_filepaths.begin(), | 615 std::partial_sort(screenshot_filepaths.begin(), |
| 617 screenshot_filepaths.begin() + sort_size, | 616 screenshot_filepaths.begin() + sort_size, |
| 618 screenshot_filepaths.end(), | 617 screenshot_filepaths.end(), |
| 619 ScreenshotTimestampComp); | 618 ScreenshotTimestampComp); |
| 620 for (size_t i = 0; i < sort_size; ++i) | 619 for (size_t i = 0; i < sort_size; ++i) |
| 621 saved_screenshots->push_back(std::string(kSavedScreenshotsUrl) + | 620 saved_screenshots->push_back(std::string(kSavedScreenshotsUrl) + |
| 622 screenshot_filepaths[i]); | 621 screenshot_filepaths[i]); |
| 623 } | 622 } |
| 624 #endif | 623 #endif |
| OLD | NEW |