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

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

Issue 11358027: Move constrained web dialog code back to chrome/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cros fix2 Created 8 years, 1 month 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) 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 "ui/web_dialogs/constrained_web_dialog_ui.h" 5 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "content/public/browser/notification_service.h" 14 #include "content/public/browser/notification_service.h"
15 #include "content/public/browser/render_view_host.h" 15 #include "content/public/browser/render_view_host.h"
16 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
17 #include "content/public/browser/web_ui.h" 17 #include "content/public/browser/web_ui.h"
18 #include "ui/web_dialogs/web_dialog_delegate.h" 18 #include "ui/web_dialogs/web_dialog_delegate.h"
19 #include "ui/web_dialogs/web_dialog_ui.h" 19 #include "ui/web_dialogs/web_dialog_ui.h"
20 20
21 using content::RenderViewHost; 21 using content::RenderViewHost;
22 using content::WebContents; 22 using content::WebContents;
23 using content::WebUIMessageHandler; 23 using content::WebUIMessageHandler;
24 24
25 namespace ui {
26
27 namespace { 25 namespace {
28 26
29 const char kConstrainedWebDialogDelegateUserDataKey[] = 27 const char kConstrainedWebDialogDelegateUserDataKey[] =
30 "ConstrainedWebDialogDelegateUserData"; 28 "ConstrainedWebDialogDelegateUserData";
31 29
32 class ConstrainedWebDialogDelegateUserData 30 class ConstrainedWebDialogDelegateUserData
33 : public base::SupportsUserData::Data { 31 : public base::SupportsUserData::Data {
34 public: 32 public:
35 explicit ConstrainedWebDialogDelegateUserData( 33 explicit ConstrainedWebDialogDelegateUserData(
36 ConstrainedWebDialogDelegate* delegate) : delegate_(delegate) {} 34 ConstrainedWebDialogDelegate* delegate) : delegate_(delegate) {}
(...skipping 15 matching lines...) Expand all
52 50
53 ConstrainedWebDialogUI::~ConstrainedWebDialogUI() { 51 ConstrainedWebDialogUI::~ConstrainedWebDialogUI() {
54 } 52 }
55 53
56 void ConstrainedWebDialogUI::RenderViewCreated( 54 void ConstrainedWebDialogUI::RenderViewCreated(
57 RenderViewHost* render_view_host) { 55 RenderViewHost* render_view_host) {
58 ConstrainedWebDialogDelegate* delegate = GetConstrainedDelegate(); 56 ConstrainedWebDialogDelegate* delegate = GetConstrainedDelegate();
59 if (!delegate) 57 if (!delegate)
60 return; 58 return;
61 59
62 WebDialogDelegate* dialog_delegate = delegate->GetWebDialogDelegate(); 60 ui::WebDialogDelegate* dialog_delegate = delegate->GetWebDialogDelegate();
63 std::vector<WebUIMessageHandler*> handlers; 61 std::vector<WebUIMessageHandler*> handlers;
64 dialog_delegate->GetWebUIMessageHandlers(&handlers); 62 dialog_delegate->GetWebUIMessageHandlers(&handlers);
65 render_view_host->SetWebUIProperty("dialogArguments", 63 render_view_host->SetWebUIProperty("dialogArguments",
66 dialog_delegate->GetDialogArgs()); 64 dialog_delegate->GetDialogArgs());
67 for (std::vector<WebUIMessageHandler*>::iterator it = handlers.begin(); 65 for (std::vector<WebUIMessageHandler*>::iterator it = handlers.begin();
68 it != handlers.end(); ++it) { 66 it != handlers.end(); ++it) {
69 web_ui()->AddMessageHandler(*it); 67 web_ui()->AddMessageHandler(*it);
70 } 68 }
71 69
72 // Add a "DialogClose" callback which matches WebDialogUI behavior. 70 // Add a "DialogClose" callback which matches WebDialogUI behavior.
(...skipping 25 matching lines...) Expand all
98 } 96 }
99 97
100 ConstrainedWebDialogDelegate* ConstrainedWebDialogUI::GetConstrainedDelegate() { 98 ConstrainedWebDialogDelegate* ConstrainedWebDialogUI::GetConstrainedDelegate() {
101 ConstrainedWebDialogDelegateUserData* user_data = 99 ConstrainedWebDialogDelegateUserData* user_data =
102 static_cast<ConstrainedWebDialogDelegateUserData*>( 100 static_cast<ConstrainedWebDialogDelegateUserData*>(
103 web_ui()->GetWebContents()-> 101 web_ui()->GetWebContents()->
104 GetUserData(&kConstrainedWebDialogDelegateUserDataKey)); 102 GetUserData(&kConstrainedWebDialogDelegateUserDataKey));
105 103
106 return user_data ? user_data->delegate() : NULL; 104 return user_data ? user_data->delegate() : NULL;
107 } 105 }
108
109 } // namespace ui
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/constrained_web_dialog_ui.h ('k') | chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698