OLD | NEW |
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 "chrome/browser/ui/gtk/view_id_util.h" | 5 #include "chrome/browser/ui/gtk/view_id_util.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include <gtk/gtk.h> | 10 #include <gtk/gtk.h> |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 106 |
107 case VIEW_ID_FIND_IN_PAGE: | 107 case VIEW_ID_FIND_IN_PAGE: |
108 return "chrome-find-in-page"; | 108 return "chrome-find-in-page"; |
109 | 109 |
110 case VIEW_ID_DEV_TOOLS_DOCKED: | 110 case VIEW_ID_DEV_TOOLS_DOCKED: |
111 return "chrome-dev-tools-docked"; | 111 return "chrome-dev-tools-docked"; |
112 | 112 |
113 case VIEW_ID_ZOOM_BUTTON: | 113 case VIEW_ID_ZOOM_BUTTON: |
114 return "chrome-zoom-button"; | 114 return "chrome-zoom-button"; |
115 | 115 |
| 116 case VIEW_ID_SCRIPT_BUBBLE: |
| 117 return "chrome-script-bubble-button"; |
| 118 |
116 // These are never hit because the tab container uses the delegate to | 119 // These are never hit because the tab container uses the delegate to |
117 // set its ID. | 120 // set its ID. |
118 case VIEW_ID_TAB_CONTAINER: | 121 case VIEW_ID_TAB_CONTAINER: |
119 default: | 122 default: |
120 NOTREACHED() << "If you added a new VIEW_ID, please provide " | 123 NOTREACHED() << "If you added a new VIEW_ID, please provide " |
121 "a name for the widget."; | 124 "a name for the widget."; |
122 return NULL; | 125 return NULL; |
123 } | 126 } |
124 } | 127 } |
125 | 128 |
126 } // namespace | 129 } // namespace |
127 | 130 |
128 void ViewIDUtil::SetID(GtkWidget* widget, ViewID id) { | 131 void ViewIDUtil::SetID(GtkWidget* widget, ViewID id) { |
129 const char* name = GetNameFromID(id); | 132 const char* name = GetNameFromID(id); |
130 if (name) | 133 if (name) |
131 gtk_widget_set_name(widget, name); | 134 gtk_widget_set_name(widget, name); |
132 g_object_set_data(G_OBJECT(widget), kViewIDString, | 135 g_object_set_data(G_OBJECT(widget), kViewIDString, |
133 reinterpret_cast<void*>(id)); | 136 reinterpret_cast<void*>(id)); |
134 } | 137 } |
135 | 138 |
136 GtkWidget* ViewIDUtil::GetWidget(GtkWidget* root, ViewID id) { | 139 GtkWidget* ViewIDUtil::GetWidget(GtkWidget* root, ViewID id) { |
137 ViewIDSearchStruct search_struct = { id, NULL }; | 140 ViewIDSearchStruct search_struct = { id, NULL }; |
138 SearchForWidgetWithViewID(root, &search_struct); | 141 SearchForWidgetWithViewID(root, &search_struct); |
139 return search_struct.widget; | 142 return search_struct.widget; |
140 } | 143 } |
141 | 144 |
142 void ViewIDUtil::SetDelegateForWidget(GtkWidget* widget, Delegate* delegate) { | 145 void ViewIDUtil::SetDelegateForWidget(GtkWidget* widget, Delegate* delegate) { |
143 g_object_set_data(G_OBJECT(widget), kViewIDOverrideString, delegate); | 146 g_object_set_data(G_OBJECT(widget), kViewIDOverrideString, delegate); |
144 } | 147 } |
OLD | NEW |