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" |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 &query_str, 0, kTimestampParameter, ""); | 379 &query_str, 0, kTimestampParameter, ""); |
380 timestamp_ = query_str; | 380 timestamp_ = query_str; |
381 continue; | 381 continue; |
382 } | 382 } |
383 #endif | 383 #endif |
384 } | 384 } |
385 } | 385 } |
386 | 386 |
387 // If we don't have a page url specified, get it from the tab index. | 387 // If we don't have a page url specified, get it from the tab index. |
388 if (custom_page_url.empty()) { | 388 if (custom_page_url.empty()) { |
389 if (session_id == -1 || index == -1) | 389 if (session_id == -1) |
390 return false; | 390 return false; |
391 | 391 |
392 Browser* browser = browser::FindBrowserWithID(session_id); | 392 Browser* browser = browser::FindBrowserWithID(session_id); |
393 // Sanity checks. | 393 // Sanity checks. |
394 if (!browser || index >= browser->tab_count()) | 394 if (!browser || index >= browser->tab_count()) |
395 return false; | 395 return false; |
396 | 396 |
397 WebContents* target_tab = chrome::GetWebContentsAt(browser, index); | 397 if (index >= 0) { |
398 if (target_tab) | 398 WebContents* target_tab = chrome::GetWebContentsAt(browser, index); |
399 target_tab_url_ = target_tab->GetURL().spec(); | 399 if (target_tab) |
| 400 target_tab_url_ = target_tab->GetURL().spec(); |
| 401 } |
400 | 402 |
401 // Note: We don't need to setup a screenshot source if we're using a | 403 // Note: We don't need to setup a screenshot source if we're using a |
402 // custom page URL since we were invoked from JS/an extension, in which | 404 // custom page URL since we were invoked from JS/an extension, in which |
403 // case we don't actually have a screenshot anyway. | 405 // case we don't actually have a screenshot anyway. |
404 SetupScreenshotsSource(); | 406 SetupScreenshotsSource(); |
405 } else { | 407 } else { |
406 target_tab_url_ = custom_page_url; | 408 target_tab_url_ = custom_page_url; |
407 } | 409 } |
408 | 410 |
409 return true; | 411 return true; |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 size_t sort_size = std::min(max_saved, screenshot_filepaths.size()); | 647 size_t sort_size = std::min(max_saved, screenshot_filepaths.size()); |
646 std::partial_sort(screenshot_filepaths.begin(), | 648 std::partial_sort(screenshot_filepaths.begin(), |
647 screenshot_filepaths.begin() + sort_size, | 649 screenshot_filepaths.begin() + sort_size, |
648 screenshot_filepaths.end(), | 650 screenshot_filepaths.end(), |
649 ScreenshotTimestampComp); | 651 ScreenshotTimestampComp); |
650 for (size_t i = 0; i < sort_size; ++i) | 652 for (size_t i = 0; i < sort_size; ++i) |
651 saved_screenshots->push_back(std::string(kSavedScreenshotsUrl) + | 653 saved_screenshots->push_back(std::string(kSavedScreenshotsUrl) + |
652 screenshot_filepaths[i]); | 654 screenshot_filepaths[i]); |
653 } | 655 } |
654 #endif | 656 #endif |
OLD | NEW |