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

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

Issue 7096016: Remove JS dialog dependency from content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: now a tc delegate Created 9 years, 6 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/background_contents.h" 5 #include "chrome/browser/tab_contents/background_contents.h"
6 6
7 #include "chrome/browser/background_contents_service.h" 7 #include "chrome/browser/background_contents_service.h"
8 #include "chrome/browser/extensions/extension_message_service.h" 8 #include "chrome/browser/extensions/extension_message_service.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/renderer_preferences_util.h" 10 #include "chrome/browser/renderer_preferences_util.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } 102 }
103 103
104 void BackgroundContents::RunJavaScriptMessage( 104 void BackgroundContents::RunJavaScriptMessage(
105 const RenderViewHost* rvh, 105 const RenderViewHost* rvh,
106 const string16& message, 106 const string16& message,
107 const string16& default_prompt, 107 const string16& default_prompt,
108 const GURL& frame_url, 108 const GURL& frame_url,
109 const int flags, 109 const int flags,
110 IPC::Message* reply_msg, 110 IPC::Message* reply_msg,
111 bool* did_suppress_message) { 111 bool* did_suppress_message) {
112 // TODO(rafaelw): Implement, The JavaScriptModalDialog needs to learn about 112 // TODO(rafaelw): Implement.
113 // BackgroundContents. 113
114 // Since we are suppressing messages, just reply as if the user immediately
115 // pressed "Cancel".
116 OnDialogClosed(reply_msg, false, string16());
117
114 *did_suppress_message = true; 118 *did_suppress_message = true;
115 } 119 }
116 120
117 bool BackgroundContents::PreHandleKeyboardEvent( 121 bool BackgroundContents::PreHandleKeyboardEvent(
118 const NativeWebKeyboardEvent& event, 122 const NativeWebKeyboardEvent& event,
119 bool* is_keyboard_shortcut) { 123 bool* is_keyboard_shortcut) {
120 return false; 124 return false;
121 } 125 }
122 126
123 void BackgroundContents::Observe(NotificationType type, 127 void BackgroundContents::Observe(NotificationType type,
124 const NotificationSource& source, 128 const NotificationSource& source,
125 const NotificationDetails& details) { 129 const NotificationDetails& details) {
126 // TODO(rafaelw): Implement pagegroup ref-counting so that non-persistent 130 // TODO(rafaelw): Implement pagegroup ref-counting so that non-persistent
127 // background pages are closed when the last referencing frame is closed. 131 // background pages are closed when the last referencing frame is closed.
128 switch (type.value) { 132 switch (type.value) {
129 case NotificationType::PROFILE_DESTROYED: 133 case NotificationType::PROFILE_DESTROYED:
130 case NotificationType::APP_TERMINATING: { 134 case NotificationType::APP_TERMINATING: {
131 delete this; 135 delete this;
132 break; 136 break;
133 } 137 }
134 default: 138 default:
135 NOTREACHED() << "Unexpected notification sent."; 139 NOTREACHED() << "Unexpected notification sent.";
136 break; 140 break;
137 } 141 }
138 } 142 }
139 143
140 void BackgroundContents::OnMessageBoxClosed(IPC::Message* reply_msg, 144 void BackgroundContents::OnDialogClosed(IPC::Message* reply_msg,
141 bool success, 145 bool success,
142 const std::wstring& user_input) { 146 const string16& user_input) {
143 render_view_host()->JavaScriptDialogClosed(reply_msg, 147 render_view_host()->JavaScriptDialogClosed(reply_msg,
144 success, 148 success,
145 WideToUTF16Hack(user_input)); 149 user_input);
146 } 150 }
147 151
148 gfx::NativeWindow BackgroundContents::GetMessageBoxRootWindow() { 152 gfx::NativeWindow BackgroundContents::GetDialogRootWindow() {
149 NOTIMPLEMENTED(); 153 NOTIMPLEMENTED();
150 return NULL; 154 return NULL;
151 } 155 }
152 156
153 TabContents* BackgroundContents::AsTabContents() { 157 TabContents* BackgroundContents::AsTabContents() {
154 return NULL; 158 return NULL;
155 } 159 }
156 160
157 ExtensionHost* BackgroundContents::AsExtensionHost() { 161 ExtensionHost* BackgroundContents::AsExtensionHost() {
158 return NULL; 162 return NULL;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 BackgroundContents* 258 BackgroundContents*
255 BackgroundContents::GetBackgroundContentsByID(int render_process_id, 259 BackgroundContents::GetBackgroundContentsByID(int render_process_id,
256 int render_view_id) { 260 int render_view_id) {
257 RenderViewHost* render_view_host = 261 RenderViewHost* render_view_host =
258 RenderViewHost::FromID(render_process_id, render_view_id); 262 RenderViewHost::FromID(render_process_id, render_view_id);
259 if (!render_view_host) 263 if (!render_view_host)
260 return NULL; 264 return NULL;
261 265
262 return render_view_host->delegate()->GetAsBackgroundContents(); 266 return render_view_host->delegate()->GetAsBackgroundContents();
263 } 267 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698