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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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
« no previous file with comments | « chrome/browser/ui/webui/history2_ui.h ('k') | chrome/browser/ui/webui/history_ui.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/history2_ui.h" 5 #include "chrome/browser/ui/webui/history2_ui.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/i18n/time_formatting.h" 11 #include "base/i18n/time_formatting.h"
12 #include "base/memory/singleton.h" 12 #include "base/memory/singleton.h"
13 #include "base/message_loop.h" 13 #include "base/message_loop.h"
14 #include "base/string16.h" 14 #include "base/string16.h"
15 #include "base/string_number_conversions.h" 15 #include "base/string_number_conversions.h"
16 #include "base/string_piece.h" 16 #include "base/string_piece.h"
17 #include "base/threading/thread.h" 17 #include "base/threading/thread.h"
18 #include "base/time.h" 18 #include "base/time.h"
19 #include "base/utf_string_conversions.h" 19 #include "base/utf_string_conversions.h"
20 #include "base/values.h" 20 #include "base/values.h"
21 #include "chrome/browser/bookmarks/bookmark_model.h" 21 #include "chrome/browser/bookmarks/bookmark_model.h"
22 #include "chrome/browser/history/history_types.h" 22 #include "chrome/browser/history/history_types.h"
23 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/ui/browser.h" 24 #include "chrome/browser/ui/browser.h"
25 #include "chrome/browser/ui/browser_list.h" 25 #include "chrome/browser/ui/browser_list.h"
26 #include "chrome/browser/ui/webui/favicon_source.h" 26 #include "chrome/browser/ui/webui/favicon_source.h"
27 #include "chrome/common/chrome_notification_types.h"
27 #include "chrome/common/jstemplate_builder.h" 28 #include "chrome/common/jstemplate_builder.h"
28 #include "chrome/common/time_format.h" 29 #include "chrome/common/time_format.h"
29 #include "chrome/common/url_constants.h" 30 #include "chrome/common/url_constants.h"
30 #include "content/browser/browser_thread.h" 31 #include "content/browser/browser_thread.h"
31 #include "content/browser/tab_contents/tab_contents.h" 32 #include "content/browser/tab_contents/tab_contents.h"
32 #include "content/browser/tab_contents/tab_contents_delegate.h" 33 #include "content/browser/tab_contents/tab_contents_delegate.h"
33 #include "content/browser/user_metrics.h" 34 #include "content/browser/user_metrics.h"
34 #include "content/common/notification_source.h" 35 #include "content/common/notification_source.h"
35 #include "grit/browser_resources.h" 36 #include "grit/browser_resources.h"
36 #include "grit/chromium_strings.h" 37 #include "grit/chromium_strings.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 cancelable_delete_consumer_.CancelAllRequests(); 129 cancelable_delete_consumer_.CancelAllRequests();
129 } 130 }
130 131
131 WebUIMessageHandler* BrowsingHistoryHandler2::Attach(WebUI* web_ui) { 132 WebUIMessageHandler* BrowsingHistoryHandler2::Attach(WebUI* web_ui) {
132 // Create our favicon data source. 133 // Create our favicon data source.
133 Profile* profile = web_ui->GetProfile(); 134 Profile* profile = web_ui->GetProfile();
134 profile->GetChromeURLDataManager()->AddDataSource( 135 profile->GetChromeURLDataManager()->AddDataSource(
135 new FaviconSource(profile, FaviconSource::FAVICON)); 136 new FaviconSource(profile, FaviconSource::FAVICON));
136 137
137 // Get notifications when history is cleared. 138 // Get notifications when history is cleared.
138 registrar_.Add(this, NotificationType::HISTORY_URLS_DELETED, 139 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED,
139 Source<Profile>(web_ui->GetProfile()->GetOriginalProfile())); 140 Source<Profile>(web_ui->GetProfile()->GetOriginalProfile()));
140 return WebUIMessageHandler::Attach(web_ui); 141 return WebUIMessageHandler::Attach(web_ui);
141 } 142 }
142 143
143 void BrowsingHistoryHandler2::RegisterMessages() { 144 void BrowsingHistoryHandler2::RegisterMessages() {
144 web_ui_->RegisterMessageCallback("getHistory", 145 web_ui_->RegisterMessageCallback("getHistory",
145 NewCallback(this, &BrowsingHistoryHandler2::HandleGetHistory)); 146 NewCallback(this, &BrowsingHistoryHandler2::HandleGetHistory));
146 web_ui_->RegisterMessageCallback("searchHistory", 147 web_ui_->RegisterMessageCallback("searchHistory",
147 NewCallback(this, &BrowsingHistoryHandler2::HandleSearchHistory)); 148 NewCallback(this, &BrowsingHistoryHandler2::HandleSearchHistory));
148 web_ui_->RegisterMessageCallback("removeURLsOnOneDay", 149 web_ui_->RegisterMessageCallback("removeURLsOnOneDay",
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 } else { 368 } else {
368 exploded.month = 12; 369 exploded.month = 12;
369 exploded.year--; 370 exploded.year--;
370 } 371 }
371 options.begin_time = base::Time::FromLocalExploded(exploded); 372 options.begin_time = base::Time::FromLocalExploded(exploded);
372 } 373 }
373 374
374 return options; 375 return options;
375 } 376 }
376 377
377 void BrowsingHistoryHandler2::Observe(NotificationType type, 378 void BrowsingHistoryHandler2::Observe(int type,
378 const NotificationSource& source, 379 const NotificationSource& source,
379 const NotificationDetails& details) { 380 const NotificationDetails& details) {
380 if (type != NotificationType::HISTORY_URLS_DELETED) { 381 if (type != chrome::NOTIFICATION_HISTORY_URLS_DELETED) {
381 NOTREACHED(); 382 NOTREACHED();
382 return; 383 return;
383 } 384 }
384 385
385 // Some URLs were deleted from history. Reload the list. 386 // Some URLs were deleted from history. Reload the list.
386 web_ui_->CallJavascriptFunction("historyDeleted"); 387 web_ui_->CallJavascriptFunction("historyDeleted");
387 } 388 }
388 389
389 //////////////////////////////////////////////////////////////////////////////// 390 ////////////////////////////////////////////////////////////////////////////////
390 // 391 //
(...skipping 14 matching lines...) Expand all
405 const GURL HistoryUI2::GetHistoryURLWithSearchText(const string16& text) { 406 const GURL HistoryUI2::GetHistoryURLWithSearchText(const string16& text) {
406 return GURL(std::string(chrome::kChromeUIHistory2URL) + "#q=" + 407 return GURL(std::string(chrome::kChromeUIHistory2URL) + "#q=" +
407 EscapeQueryParamValue(UTF16ToUTF8(text), true)); 408 EscapeQueryParamValue(UTF16ToUTF8(text), true));
408 } 409 }
409 410
410 // static 411 // static
411 RefCountedMemory* HistoryUI2::GetFaviconResourceBytes() { 412 RefCountedMemory* HistoryUI2::GetFaviconResourceBytes() {
412 return ResourceBundle::GetSharedInstance(). 413 return ResourceBundle::GetSharedInstance().
413 LoadDataResourceBytes(IDR_HISTORY_FAVICON); 414 LoadDataResourceBytes(IDR_HISTORY_FAVICON);
414 } 415 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/history2_ui.h ('k') | chrome/browser/ui/webui/history_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698