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

Side by Side Diff: chrome/browser/chromeos/dom_ui/menu_ui.cc

Issue 6461024: Revert 74292 - Splits ChromeURLDataManager into 2 chunks:... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 10 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) 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/chromeos/dom_ui/menu_ui.h" 5 #include "chrome/browser/chromeos/dom_ui/menu_ui.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/json/json_writer.h" 11 #include "base/json/json_writer.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/singleton.h" 13 #include "base/singleton.h"
14 #include "base/string_number_conversions.h" 14 #include "base/string_number_conversions.h"
15 #include "base/string_piece.h" 15 #include "base/string_piece.h"
16 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
17 #include "base/values.h" 17 #include "base/values.h"
18 #include "base/weak_ptr.h" 18 #include "base/weak_ptr.h"
19 #include "chrome/browser/browser_thread.h" 19 #include "chrome/browser/browser_thread.h"
20 #include "chrome/browser/chromeos/views/native_menu_webui.h" 20 #include "chrome/browser/chromeos/views/native_menu_webui.h"
21 #include "chrome/browser/chromeos/views/webui_menu_widget.h" 21 #include "chrome/browser/chromeos/views/webui_menu_widget.h"
22 #include "chrome/browser/dom_ui/web_ui_util.h" 22 #include "chrome/browser/dom_ui/web_ui_util.h"
23 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/tab_contents/tab_contents.h" 23 #include "chrome/browser/tab_contents/tab_contents.h"
25 #include "chrome/browser/tab_contents/tab_contents_delegate.h" 24 #include "chrome/browser/tab_contents/tab_contents_delegate.h"
26 #include "chrome/common/url_constants.h" 25 #include "chrome/common/url_constants.h"
27 #include "chrome/common/chrome_switches.h" 26 #include "chrome/common/chrome_switches.h"
28 #include "chrome/common/jstemplate_builder.h" 27 #include "chrome/common/jstemplate_builder.h"
29 #include "grit/app_resources.h" 28 #include "grit/app_resources.h"
30 #include "grit/browser_resources.h" 29 #include "grit/browser_resources.h"
31 #include "ui/base/models/menu_model.h" 30 #include "ui/base/models/menu_model.h"
32 #include "ui/base/resource/resource_bundle.h" 31 #include "ui/base/resource/resource_bundle.h"
33 #include "ui/gfx/canvas_skia.h" 32 #include "ui/gfx/canvas_skia.h"
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 //////////////////////////////////////////////////////////////////////////////// 524 ////////////////////////////////////////////////////////////////////////////////
526 // 525 //
527 // MenuUI 526 // MenuUI
528 // 527 //
529 //////////////////////////////////////////////////////////////////////////////// 528 ////////////////////////////////////////////////////////////////////////////////
530 529
531 MenuUI::MenuUI(TabContents* contents) : DOMUI(contents) { 530 MenuUI::MenuUI(TabContents* contents) : DOMUI(contents) {
532 MenuHandler* handler = new MenuHandler(); 531 MenuHandler* handler = new MenuHandler();
533 AddMessageHandler((handler)->Attach(this)); 532 AddMessageHandler((handler)->Attach(this));
534 533
535 contents->profile()->GetChromeURLDataManager()->AddDataSource( 534 BrowserThread::PostTask(
536 CreateDataSource()); 535 BrowserThread::IO, FROM_HERE,
536 NewRunnableMethod(
537 ChromeURLDataManager::GetInstance(),
538 &ChromeURLDataManager::AddDataSource,
539 make_scoped_refptr(CreateDataSource())));
537 } 540 }
538 541
539 MenuUI::MenuUI(TabContents* contents, ChromeURLDataManager::DataSource* source) 542 MenuUI::MenuUI(TabContents* contents, ChromeURLDataManager::DataSource* source)
540 : DOMUI(contents) { 543 : DOMUI(contents) {
541 MenuHandler* handler = new MenuHandler(); 544 MenuHandler* handler = new MenuHandler();
542 AddMessageHandler((handler)->Attach(this)); 545 AddMessageHandler((handler)->Attach(this));
543 546
544 contents->profile()->GetChromeURLDataManager()->AddDataSource(source); 547 BrowserThread::PostTask(
548 BrowserThread::IO, FROM_HERE,
549 NewRunnableMethod(
550 ChromeURLDataManager::GetInstance(),
551 &ChromeURLDataManager::AddDataSource,
552 make_scoped_refptr(source)));
545 } 553 }
546 554
547 void MenuUI::ModelUpdated(const ui::MenuModel* model) { 555 void MenuUI::ModelUpdated(const ui::MenuModel* model) {
548 DictionaryValue json_model; 556 DictionaryValue json_model;
549 ListValue* items = new ListValue(); 557 ListValue* items = new ListValue();
550 json_model.Set("items", items); 558 json_model.Set("items", items);
551 int max_icon_width = 0; 559 int max_icon_width = 0;
552 bool has_accelerator = false; 560 bool has_accelerator = false;
553 for (int index = 0; index < model->GetItemCount(); ++index) { 561 for (int index = 0; index < model->GetItemCount(); ++index) {
554 ui::MenuModel::ItemType type = model->GetTypeAt(index); 562 ui::MenuModel::ItemType type = model->GetTypeAt(index);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 654
647 ChromeURLDataManager::DataSource* MenuUI::CreateDataSource() { 655 ChromeURLDataManager::DataSource* MenuUI::CreateDataSource() {
648 return CreateMenuUIHTMLSource(NULL, 656 return CreateMenuUIHTMLSource(NULL,
649 chrome::kChromeUIMenu, 657 chrome::kChromeUIMenu,
650 "Menu" /* class name */, 658 "Menu" /* class name */,
651 kNoExtraResource, 659 kNoExtraResource,
652 kNoExtraResource); 660 kNoExtraResource);
653 } 661 }
654 662
655 } // namespace chromeos 663 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/dom_ui/login/login_ui.cc ('k') | chrome/browser/chromeos/dom_ui/mobile_setup_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698