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

Side by Side Diff: chrome/browser/tab_contents/render_view_host_delegate_helper.cc

Issue 8342048: Make NotificationService an interface in the content namespace, and switch callers to use it. Mov... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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/tab_contents/render_view_host_delegate_helper.h" 5 #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 18 matching lines...) Expand all
29 #include "content/browser/renderer_host/render_process_host.h" 29 #include "content/browser/renderer_host/render_process_host.h"
30 #include "content/browser/renderer_host/render_widget_fullscreen_host.h" 30 #include "content/browser/renderer_host/render_widget_fullscreen_host.h"
31 #include "content/browser/renderer_host/render_widget_host.h" 31 #include "content/browser/renderer_host/render_widget_host.h"
32 #include "content/browser/renderer_host/render_widget_host_view.h" 32 #include "content/browser/renderer_host/render_widget_host_view.h"
33 #include "content/browser/site_instance.h" 33 #include "content/browser/site_instance.h"
34 #include "content/browser/tab_contents/navigation_details.h" 34 #include "content/browser/tab_contents/navigation_details.h"
35 #include "content/browser/tab_contents/tab_contents.h" 35 #include "content/browser/tab_contents/tab_contents.h"
36 #include "content/browser/tab_contents/tab_contents_delegate.h" 36 #include "content/browser/tab_contents/tab_contents_delegate.h"
37 #include "content/browser/tab_contents/tab_contents_view.h" 37 #include "content/browser/tab_contents/tab_contents_view.h"
38 #include "content/browser/webui/web_ui.h" 38 #include "content/browser/webui/web_ui.h"
39 #include "content/common/notification_service.h" 39 #include "content/public/browser/notification_service.h"
40 #include "content/common/view_messages.h" 40 #include "content/common/view_messages.h"
41 #include "net/base/network_change_notifier.h" 41 #include "net/base/network_change_notifier.h"
42 42
43 namespace { 43 namespace {
44 44
45 // Fills |map| with the per-script font prefs under path |map_name|. 45 // Fills |map| with the per-script font prefs under path |map_name|.
46 void FillFontFamilyMap(const PrefService* prefs, 46 void FillFontFamilyMap(const PrefService* prefs,
47 const char* map_name, 47 const char* map_name,
48 WebPreferences::ScriptFontFamilyMap* map) { 48 WebPreferences::ScriptFontFamilyMap* map) {
49 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) { 49 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) {
50 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i]; 50 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i];
51 std::string pref_name = base::StringPrintf("%s.%s", map_name, script); 51 std::string pref_name = base::StringPrintf("%s.%s", map_name, script);
52 std::string font_family = prefs->GetString(pref_name.c_str()); 52 std::string font_family = prefs->GetString(pref_name.c_str());
53 if (!font_family.empty()) 53 if (!font_family.empty())
54 map->push_back(std::make_pair(script, UTF8ToUTF16(font_family))); 54 map->push_back(std::make_pair(script, UTF8ToUTF16(font_family)));
55 } 55 }
56 } 56 }
57 57
58 } // namespace 58 } // namespace
59 59
60 60
61 RenderViewHostDelegateViewHelper::RenderViewHostDelegateViewHelper() { 61 RenderViewHostDelegateViewHelper::RenderViewHostDelegateViewHelper() {
62 registrar_.Add(this, content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, 62 registrar_.Add(this, content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED,
63 NotificationService::AllSources()); 63 content::NotificationService::AllSources());
64 } 64 }
65 65
66 RenderViewHostDelegateViewHelper::~RenderViewHostDelegateViewHelper() {} 66 RenderViewHostDelegateViewHelper::~RenderViewHostDelegateViewHelper() {}
67 67
68 void RenderViewHostDelegateViewHelper::Observe( 68 void RenderViewHostDelegateViewHelper::Observe(
69 int type, 69 int type,
70 const content::NotificationSource& source, 70 const content::NotificationSource& source,
71 const content::NotificationDetails& details) { 71 const content::NotificationDetails& details) {
72 DCHECK_EQ(type, content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED); 72 DCHECK_EQ(type, content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED);
73 RenderWidgetHost* host = content::Source<RenderWidgetHost>(source).ptr(); 73 RenderWidgetHost* host = content::Source<RenderWidgetHost>(source).ptr();
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 tab_contents, 261 tab_contents,
262 params.window_container_type, 262 params.window_container_type,
263 params.frame_name); 263 params.frame_name);
264 264
265 if (new_contents) { 265 if (new_contents) {
266 content::RetargetingDetails details; 266 content::RetargetingDetails details;
267 details.source_tab_contents = tab_contents; 267 details.source_tab_contents = tab_contents;
268 details.source_frame_id = params.opener_frame_id; 268 details.source_frame_id = params.opener_frame_id;
269 details.target_url = params.target_url; 269 details.target_url = params.target_url;
270 details.target_tab_contents = new_contents; 270 details.target_tab_contents = new_contents;
271 NotificationService::current()->Notify( 271 content::NotificationService::current()->Notify(
272 content::NOTIFICATION_RETARGETING, 272 content::NOTIFICATION_RETARGETING,
273 content::Source<content::BrowserContext>( 273 content::Source<content::BrowserContext>(
274 tab_contents->browser_context()), 274 tab_contents->browser_context()),
275 content::Details<content::RetargetingDetails>(&details)); 275 content::Details<content::RetargetingDetails>(&details));
276 276
277 if (tab_contents->delegate()) 277 if (tab_contents->delegate())
278 tab_contents->delegate()->TabContentsCreated(new_contents); 278 tab_contents->delegate()->TabContentsCreated(new_contents);
279 } else { 279 } else {
280 NotificationService::current()->Notify( 280 content::NotificationService::current()->Notify(
281 content::NOTIFICATION_CREATING_NEW_WINDOW_CANCELLED, 281 content::NOTIFICATION_CREATING_NEW_WINDOW_CANCELLED,
282 content::Source<TabContents>(tab_contents), 282 content::Source<TabContents>(tab_contents),
283 content::Details<const ViewHostMsg_CreateWindow_Params>(&params)); 283 content::Details<const ViewHostMsg_CreateWindow_Params>(&params));
284 } 284 }
285 285
286 return new_contents; 286 return new_contents;
287 } 287 }
288 288
289 TabContents* RenderViewHostDelegateViewHelper::ShowCreatedWindow( 289 TabContents* RenderViewHostDelegateViewHelper::ShowCreatedWindow(
290 TabContents* tab_contents, 290 TabContents* tab_contents,
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 DictionaryValue* inspector_settings = update.Get(); 543 DictionaryValue* inspector_settings = update.Get();
544 inspector_settings->SetWithoutPathExpansion(key, 544 inspector_settings->SetWithoutPathExpansion(key,
545 Value::CreateStringValue(value)); 545 Value::CreateStringValue(value));
546 } 546 }
547 547
548 void RenderViewHostDelegateHelper::ClearInspectorSettings( 548 void RenderViewHostDelegateHelper::ClearInspectorSettings(
549 content::BrowserContext* browser_context) { 549 content::BrowserContext* browser_context) {
550 Profile::FromBrowserContext(browser_context)->GetPrefs()-> 550 Profile::FromBrowserContext(browser_context)->GetPrefs()->
551 ClearPref(prefs::kWebKitInspectorSettings); 551 ClearPref(prefs::kWebKitInspectorSettings);
552 } 552 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/render_view_context_menu.cc ('k') | chrome/browser/tab_contents/thumbnail_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698